Skip to content

Commit

Permalink
change jacksession file handling. untitled song will saved into a jac…
Browse files Browse the repository at this point in the history
…ksession without qmessage box question. remove white spaces from song-file names if they saved in a jack session.

git-svn-id: http://svn.assembla.com/svn/hydrogen/trunk@2482 3b3fb362-3133-0410-aa15-cf69e0a59cb7
  • Loading branch information
wolkstein committed Apr 2, 2012
1 parent e788a0c commit 64bb85b
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 74 deletions.
3 changes: 1 addition & 2 deletions data/hydrogen.default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
<patternModePlaysSelected>true</patternModePlaysSelected>
<useLash>false</useLash>
<useTimeLine>false</useTimeLine>
<maxBars>400</maxBars>
<JackSessionUseSessionDir>true</JackSessionUseSessionDir>
<maxBars>400</maxBars>
<showDevelWarning>true</showDevelWarning>
<hearNewNotes>true</hearNewNotes>
<recordEvents>false</recordEvents>
Expand Down
7 changes: 0 additions & 7 deletions src/core/include/hydrogen/Preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -586,12 +586,6 @@ class Preferences : public H2Core::Object
jackSessionApplicationPath = path;
}

bool getJackSessionUseSessionDir(){
return m_bjackSessionUseSessionDir;
}
void setJackSessionUseSessionDir( bool val ){
m_bjackSessionUseSessionDir = val;
}
#endif

bool getUseTimelineBpm(){
Expand Down Expand Up @@ -658,7 +652,6 @@ class Preferences : public H2Core::Object
#ifdef H2CORE_HAVE_JACKSESSION
QString jackSessionUUID;
QString jackSessionApplicationPath;
bool m_bjackSessionUseSessionDir;
#endif
bool waitingForSessionHandler;
bool __useTimelineBpm;
Expand Down
32 changes: 12 additions & 20 deletions src/core/src/IO/jack_output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -758,32 +758,26 @@ void JackOutput::jack_session_callback_impl(jack_session_event_t *event)
enum session_events{
SAVE_SESSION,
SAVE_AND_QUIT,
SAVE_TEMPLATE,
SAVE_SESSION_NEW_FILE
SAVE_TEMPLATE
};

jack_session_event_t *ev = (jack_session_event_t *) event;

/* Valid Song is needed */
if(Hydrogen::get_instance()->getSong()->get_filename().isEmpty()){
EventQueue::get_instance()->push_event(EVENT_JACK_SESSION, SAVE_SESSION_NEW_FILE);
jack_session_reply(client, ev );
jack_session_event_free (ev);
return;
Hydrogen::get_instance()->getSong()->set_filename("Untitled_Song");
}

QString songfilename;
if(Preferences::get_instance()->getJackSessionUseSessionDir()){
QString jackSessionDirectory = (QString)ev->session_dir;
QStringList list1 = Hydrogen::get_instance()->getSong()->get_filename().split("/");
QString realFillename = list1[list1.size()-1];
Hydrogen::get_instance()->getSong()->set_filename(jackSessionDirectory + realFillename);
songfilename = "\"${SESSION_DIR}\"" + realFillename;
}else
{
songfilename = Hydrogen::get_instance()->getSong()->get_filename();
if(Hydrogen::get_instance()->getSong()->get_filename().contains(" ")){
QStringList removeWhiteSpaces = Hydrogen::get_instance()->getSong()->get_filename().split(" ");
Hydrogen::get_instance()->getSong()->set_filename( removeWhiteSpaces.join("_") );
}

QString songfilename;
QString jackSessionDirectory = (QString)ev->session_dir;
QStringList list1 = Hydrogen::get_instance()->getSong()->get_filename().split("/");
QString realFillename = list1[list1.size()-1];
Hydrogen::get_instance()->getSong()->set_filename(jackSessionDirectory + realFillename);
songfilename = "\"${SESSION_DIR}\"" + realFillename;

QString retval = QString(Preferences::get_instance()->getJackSessionApplicationPath() + " -s" + songfilename + " --jacksessionid " + ev->client_uuid);
const char * filename = retval.toAscii().data();
Expand All @@ -792,10 +786,8 @@ void JackOutput::jack_session_callback_impl(jack_session_event_t *event)
EventQueue::get_instance()->push_event(EVENT_JACK_SESSION, SAVE_SESSION);
}
if (ev->type == JackSessionSaveAndQuit) {
if(Preferences::get_instance()->getJackSessionUseSessionDir()){
EventQueue::get_instance()->push_event(EVENT_JACK_SESSION, SAVE_SESSION);
}
EventQueue::get_instance()->push_event(EVENT_JACK_SESSION, SAVE_AND_QUIT);
EventQueue::get_instance()->push_event(EVENT_JACK_SESSION, SAVE_AND_QUIT);
}

ev->command_line = strdup (filename);
Expand Down
12 changes: 0 additions & 12 deletions src/core/src/preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ Preferences::Preferences()
m_brestartLash = false;
m_bsetLash = false;

#ifdef H2CORE_HAVE_JACKSESSION
m_bjackSessionUseSessionDir = false;
#endif

//init pre delete default
m_nRecPreDelete = 0;
m_nRecPostDelete = 0;
Expand Down Expand Up @@ -409,10 +405,6 @@ void Preferences::loadPreferences( bool bGlobal )

hearNewNotes = LocalFileMng::readXmlBool( rootNode, "hearNewNotes", hearNewNotes );
quantizeEvents = LocalFileMng::readXmlBool( rootNode, "quantizeEvents", quantizeEvents );

#ifdef H2CORE_HAVE_JACKSESSION
m_bjackSessionUseSessionDir = LocalFileMng::readXmlBool( rootNode, "JackSessionUseSessionDir", m_bjackSessionUseSessionDir );
#endif

//rubberband
if( readPrefFileforotherplaces ){
Expand Down Expand Up @@ -763,10 +755,6 @@ void Preferences::savePreferences()
LocalFileMng::writeXmlString( rootNode, "preDelete", QString("%1").arg(m_nRecPreDelete) );
LocalFileMng::writeXmlString( rootNode, "postDelete", QString("%1").arg(m_nRecPostDelete) );

#ifdef H2CORE_HAVE_JACKSESSION
LocalFileMng::writeXmlString( rootNode, "JackSessionUseSessionDir", m_bjackSessionUseSessionDir ? "true": "false" );
#endif

//show development version warning
LocalFileMng::writeXmlString( rootNode, "showDevelWarning", m_bShowDevelWarning ? "true": "false" );

Expand Down
13 changes: 5 additions & 8 deletions src/gui/src/MainForm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ void MainForm::action_file_save_as()
fd->selectFile( defaultFilename );

QString filename;
if (fd->exec() == QDialog::Accepted) {
if (fd->exec() == QDialog::Accepted) {
filename = fd->selectedFiles().first();
}

Expand All @@ -510,10 +510,10 @@ void MainForm::action_file_save()
Song *song = Hydrogen::get_instance()->getSong();
QString filename = song->get_filename();

if ( filename.isEmpty() ) {
// just in case!
return action_file_save_as();
}
if ( filename.isEmpty() ) {
// just in case!
return action_file_save_as();
}

bool saved = false;
saved = song->save( filename );
Expand Down Expand Up @@ -1468,9 +1468,6 @@ void MainForm::jacksessionEvent( int nEvent )
case 1:
action_file_exit();
break;
case 3:
action_file_save();
QMessageBox::information( this, "Hydrogen", trUtf8( "Sorry, the Hydrogen-Songfile is not saved properly in this Jack-Session! You have to repeat the \"Save-Session\" procedure from your Jack-Session-Manager.") );
}

}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/src/MainForm.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public slots:
void action_file_new();
void action_file_open();
void action_file_openDemo();
void action_file_save();
void action_file_save();
void action_file_save_as();
void action_file_openPattern();
void action_file_export_pattern_as();
Expand Down
11 changes: 0 additions & 11 deletions src/gui/src/PreferencesDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,6 @@ PreferencesDialog::PreferencesDialog(QWidget* parent)
rubberbandLineEdit->hide();
#endif

#ifdef H2CORE_HAVE_JACKSESSION
useJackSessinStoreFiles->setVisible(true);
useJackSessinStoreFiles->setChecked(pPref->getJackSessionUseSessionDir());
#else
useJackSessinStoreFiles->setVisible(false);
#endif

m_bNeedDriverRestart = false;
connect(m_pMidiDriverComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT( onMidiDriverComboBoxIndexChanged(int) ));
}
Expand Down Expand Up @@ -421,10 +414,6 @@ void PreferencesDialog::on_okBtn_clicked()
//path to rubberband
pPref-> m_rubberBandCLIexecutable = rubberbandLineEdit->text();

#ifdef H2CORE_HAVE_JACKSESSION
pPref->setJackSessionUseSessionDir(useJackSessinStoreFiles->isChecked());
#endif

//check preferences
if ( pPref->m_brestartLash == true ){
pPref->m_bsetLash = true ;
Expand Down
13 changes: 0 additions & 13 deletions src/gui/src/UI/PreferencesDialog_UI.ui
Original file line number Diff line number Diff line change
Expand Up @@ -330,19 +330,6 @@
<string>Alt+R</string>
</property>
</widget>
<widget class="QCheckBox" name="useJackSessinStoreFiles">
<property name="geometry">
<rect>
<x>10</x>
<y>100</y>
<width>511</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>Save song files in Jack Session Directory (default on)</string>
</property>
</widget>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
Expand Down

0 comments on commit 64bb85b

Please sign in to comment.