From cce3c991cc961a49ced3da38f22d05d885ad1bee Mon Sep 17 00:00:00 2001 From: Robert Jonsson Date: Fri, 5 Apr 2013 19:01:32 +0000 Subject: save and titles --- muse2/ChangeLog | 7 + muse2/muse/app.cpp | 52 ++++++- muse2/muse/app.h | 5 + muse2/muse/conf.cpp | 3 + muse2/muse/gconfig.cpp | 3 +- muse2/muse/gconfig.h | 1 + muse2/muse/song.h | 1 + muse2/muse/undo.cpp | 6 +- muse2/muse/widgets/genset.cpp | 2 + muse2/muse/widgets/gensetbase.ui | 305 ++++++++++++++++++++------------------- 10 files changed, 229 insertions(+), 156 deletions(-) diff --git a/muse2/ChangeLog b/muse2/ChangeLog index 1990ff37..d5d44367 100644 --- a/muse2/ChangeLog +++ b/muse2/ChangeLog @@ -1,3 +1,10 @@ +05.04.2013: + - Change window title when there are unsaved changes (rj) + - Add auto-save feature, when enabled tries to save after 5 minutes + when there has been changes, unless transport is running (rj) +04.04.2013: + - Added pitch control to SimpleDrums, first version (rj) + - Fixed Ctrl+arrows in the arranger so the track list is scrolled (rj) 29.03.2013: - MusE 2.1.2 released! (rj) 28.03.2013: diff --git a/muse2/muse/app.cpp b/muse2/muse/app.cpp index ae0f19c4..fb93bef5 100644 --- a/muse2/muse/app.cpp +++ b/muse2/muse/app.cpp @@ -327,6 +327,7 @@ MusE::MusE() : QMainWindow() editInstrument = 0; //routingPopupMenu = 0; progress = 0; + saveIncrement = 0; activeTopWin = NULL; currentMenuSharingTopwin = NULL; waitingForTopwin = NULL; @@ -345,7 +346,12 @@ MusE::MusE() : QMainWindow() MusEGlobal::heartBeatTimer->setObjectName("timer"); connect(MusEGlobal::heartBeatTimer, SIGNAL(timeout()), MusEGlobal::song, SLOT(beat())); connect(this, SIGNAL(activeTopWinChanged(MusEGui::TopWin*)), SLOT(activeTopWinChangedSlot(MusEGui::TopWin*))); + connect(MusEGlobal::song, SIGNAL(sigDirty()), this, SLOT(setDirty())); new MusECore::TrackDrummapUpdater(this); // no need for keeping the reference, the thing autoconnects on its own. + + saveTimer = new QTimer(this); + connect(saveTimer, SIGNAL(timeout()), this, SLOT(saveTimerSlot())); + saveTimer->start( 10 * 1000 ); // every minute #ifdef ENABLE_PYTHON //--------------------------------------------------- @@ -970,6 +976,16 @@ void MusE::setHeartBeat() MusEGlobal::heartBeatTimer->start(1000/MusEGlobal::config.guiRefresh); } +//--------------------------------------------------------- +// setDirty +//--------------------------------------------------------- + +void MusE::setDirty() + { + MusEGlobal::song->dirty = true; + setWindowTitle(projectTitle(project.absoluteFilePath()) + " "); + } + //--------------------------------------------------- // loadDefaultSong // if no songname entered on command line: @@ -1215,7 +1231,7 @@ void MusE::loadProjectFile1(const QString& name, bool songTemplate, bool doReadM } if (!songTemplate) { addProject(project.absoluteFilePath()); - setWindowTitle(QString("MusE: Song: ") + MusEGui::projectTitleFromFilename(project.absoluteFilePath())); + setWindowTitle(projectTitle(project.absoluteFilePath())); } MusEGlobal::song->dirty = false; progress->setValue(30); @@ -1321,7 +1337,7 @@ void MusE::setUntitledProject() MusEGlobal::museProject = MusEGlobal::museProjectInitPath; QDir::setCurrent(QDir::homePath()); project.setFile(name); - setWindowTitle(tr("MusE: Song: %1").arg(MusEGui::projectTitleFromFilename(name))); + setWindowTitle(projectTitle(name)); writeTopwinState=true; } @@ -1426,6 +1442,8 @@ bool MusE::save(const QString& name, bool overwriteWarn, bool writeTopwins) else { popenFlag? pclose(f) : fclose(f); MusEGlobal::song->dirty = false; + setWindowTitle(projectTitle(project.absoluteFilePath())); + saveIncrement = 0; return true; } } @@ -1732,7 +1750,7 @@ bool MusE::saveAs() ok = save(name, true, writeTopwinState); if (ok) { project.setFile(name); - setWindowTitle(tr("MusE: Song: %1").arg(MusEGui::projectTitleFromFilename(name))); + setWindowTitle(projectTitle(project.absoluteFilePath())); addProject(name); } else @@ -3694,6 +3712,11 @@ void MusE::tileSubWindows() } } +QString MusE::projectTitle(QString name) +{ + return tr("MusE: Song: ") + MusEGui::projectTitleFromFilename(name); +} + QString MusE::projectTitle() const { return MusEGui::projectTitleFromFilename(project.fileName()); @@ -3709,4 +3732,27 @@ QString MusE::projectExtension() const return MusEGui::projectExtensionFromFilename(project.fileName()); } +void MusE::saveTimerSlot() +{ + if (MusEGlobal::config.autoSave == false || + MusEGlobal::museProject == MusEGlobal::museProjectInitPath || + MusEGlobal::song->dirty == false) + { + //printf("conditions not met, ignore %d %d\n", MusEGlobal::config.autoSave, MusEGlobal::song->dirty); + return; + } + saveIncrement++; + if (saveIncrement > 4) { + // printf("five minutes passed %d %d\n", MusEGlobal::config.autoSave, MusEGlobal::song->dirty); + // time to see if we are allowed to save, if so. Do + if (MusEGlobal::audio->isPlaying() == false) { + printf("Performing autosave\n"); + save(project.filePath(), false, writeTopwinState); + } else + { + //printf("isPlaying, can't save\n"); + } + } +} + } //namespace MusEGui diff --git a/muse2/muse/app.h b/muse2/muse/app.h index 5cd15792..5d17f096 100644 --- a/muse2/muse/app.h +++ b/muse2/muse/app.h @@ -236,16 +236,20 @@ class MusE : public QMainWindow void writeGlobalConfiguration(int level, MusECore::Xml&) const; void writeConfiguration(int level, MusECore::Xml&) const; void updateConfiguration(); + QString projectTitle(QString name); QSignalMapper *midiPluginSignalMapper; QSignalMapper *followSignalMapper; QSignalMapper *windowsMapper; + QTimer *saveTimer; + int saveIncrement; signals: void configChanged(); void activeTopWinChanged(MusEGui::TopWin*); private slots: + void saveTimerSlot(); void loadProject(); bool save(); void configGlobalSettings(); @@ -318,6 +322,7 @@ class MusE : public QMainWindow void arrangeSubWindowsRows(); void arrangeSubWindowsColumns(); void tileSubWindows(); + void setDirty(); public slots: bool saveAs(); diff --git a/muse2/muse/conf.cpp b/muse2/muse/conf.cpp index 3e7927bd..56d648ad 100644 --- a/muse2/muse/conf.cpp +++ b/muse2/muse/conf.cpp @@ -619,6 +619,8 @@ void readConfiguration(Xml& xml, bool doReadMidiPortConfig, bool doReadGlobalCon else if (tag == "theme") MusEGlobal::config.style = xml.parse1(); + else if (tag == "autoSave") + MusEGlobal::config.autoSave = xml.parseInt(); else if (tag == "styleSheetFile") MusEGlobal::config.styleSheetFile = xml.parse1(); else if (tag == "useOldStyleStopShortCut") @@ -1338,6 +1340,7 @@ void MusE::writeGlobalConfiguration(int level, MusECore::Xml& xml) const xml.intTag(level, "midiFilterCtrl4", MusEGlobal::midiFilterCtrl4); xml.strTag(level, "theme", MusEGlobal::config.style); + xml.intTag(level, "autoSave", MusEGlobal::config.autoSave); xml.strTag(level, "styleSheetFile", MusEGlobal::config.styleSheetFile); xml.strTag(level, "externalWavEditor", MusEGlobal::config.externalWavEditor); xml.intTag(level, "useOldStyleStopShortCut", MusEGlobal::config.useOldStyleStopShortCut); diff --git a/muse2/muse/gconfig.cpp b/muse2/muse/gconfig.cpp index 07c32561..4df94aeb 100644 --- a/muse2/muse/gconfig.cpp +++ b/muse2/muse/gconfig.cpp @@ -225,7 +225,8 @@ GlobalConfigValues config = { MusEGlobal::PREFER_NEW, // drumTrackPreference true, // smartFocus 20, // trackHeight - true // borderlessMouse + true, // borderlessMouse + true // autoSave }; } // namespace MusEGlobal diff --git a/muse2/muse/gconfig.h b/muse2/muse/gconfig.h index 08990f03..d1fd0ff4 100644 --- a/muse2/muse/gconfig.h +++ b/muse2/muse/gconfig.h @@ -231,6 +231,7 @@ struct GlobalConfigValues { bool smartFocus; int trackHeight; bool borderlessMouse; + bool autoSave; }; diff --git a/muse2/muse/song.h b/muse2/muse/song.h index 63256af3..b9ab5dd5 100644 --- a/muse2/muse/song.h +++ b/muse2/muse/song.h @@ -431,6 +431,7 @@ class Song : public QObject { void midiNote(int pitch, int velo); void controllerChanged(MusECore::Track*, int); void newPartsCreated(const std::map< MusECore::Part*, std::set >&); + void sigDirty(); }; } // namespace MusECore diff --git a/muse2/muse/undo.cpp b/muse2/muse/undo.cpp index 65ca04bf..fc6fc1d8 100644 --- a/muse2/muse/undo.cpp +++ b/muse2/muse/undo.cpp @@ -684,7 +684,7 @@ void Song::addUndo(UndoOp i) return; } undoList->back().push_back(i); - dirty = true; + emit sigDirty(); } //--------------------------------------------------------- @@ -812,7 +812,7 @@ void Song::doUndo3() } redoList->push_back(u); // put item on redo list undoList->pop_back(); - dirty = true; + emit sigDirty(); } //--------------------------------------------------------- @@ -935,7 +935,7 @@ void Song::doRedo3() } undoList->push_back(u); // put item on undo list redoList->pop_back(); - dirty = true; + emit sigDirty(); } diff --git a/muse2/muse/widgets/genset.cpp b/muse2/muse/widgets/genset.cpp index 52be3d8a..3641706c 100644 --- a/muse2/muse/widgets/genset.cpp +++ b/muse2/muse/widgets/genset.cpp @@ -153,6 +153,7 @@ void GlobalSettingsConfig::updateSettings() } } + autoSaveCheckBox->setChecked(MusEGlobal::config.autoSave); warnIfBadTimingCheckBox->setChecked(MusEGlobal::config.warnIfBadTiming); midiSendInit->setChecked(MusEGlobal::config.midiSendInit); midiWarnInitPending->setChecked(MusEGlobal::config.warnInitPending); @@ -331,6 +332,7 @@ void GlobalSettingsConfig::apply() MusEGlobal::config.mixer2.geometry.setWidth(mixer2W->value()); MusEGlobal::config.mixer2.geometry.setHeight(mixer2H->value()); + MusEGlobal::config.autoSave = autoSaveCheckBox->isChecked(); MusEGlobal::config.showSplashScreen = showSplash->isChecked(); MusEGlobal::config.showDidYouKnow = showDidYouKnow->isChecked(); MusEGlobal::config.externalWavEditor = externalWavEditorSelect->text(); diff --git a/muse2/muse/widgets/gensetbase.ui b/muse2/muse/widgets/gensetbase.ui index 8b1cc28d..f6bcb0c4 100644 --- a/muse2/muse/widgets/gensetbase.ui +++ b/muse2/muse/widgets/gensetbase.ui @@ -30,39 +30,133 @@ Application - - + + - Project directory + Start Muse - - - 6 - - - - - Projects: - - - false - - - - - - - - - - ... - - + + + + + + + + + + + + Choose start song or template + + + ... + + + + + + + Reset to default + + + ... + + + + + + + + + Start song + + + + + + start with last song + + + true + + + + + + + + 0 + 0 + + + + start with template + + + false + + + + + + + start with song + + + + + + + + + + On Launch + + + + + + show splash screen + + + + + + + show "Did you know?" dialog + + + + + + + + + + Start template or song: + + + false + + + + + + + Read MIDI Ports configuration from file, + or else automatically configure + + + Read MIDI Ports configuration + + + + - + @@ -445,132 +539,45 @@ - - + + - Start Muse + Project directory - - - - - - - - - - - - Choose start song or template - - - ... - - - - - - - Reset to default - - - ... - - - - - - - - - Start song - - - - - - start with last song - - - true - - - - - - - - 0 - 0 - - - - start with template - - - false - - - - - - - start with song - - - - - - - - - - On Launch - - - - - - show splash screen - - - - - - - show "Did you know?" dialog - - - - - - - - - - Start template or song: - - - false - - - - - - - Read MIDI Ports configuration from file, - or else automatically configure - - - Read MIDI Ports configuration - - - - + + + 6 + + + + + Projects: + + + false + + + + + + + + + + ... + + + + + + Auto save (every 5 minutes if not playing/recording) + + + @@ -1754,8 +1761,8 @@ Disable to use an alternate standard 0 0 - 96 - 26 + 500 + 460 -- cgit v1.2.3