diff options
| author | Robert Jonsson <spamatica@gmail.com> | 2013-04-05 19:01:32 +0000 | 
|---|---|---|
| committer | Robert Jonsson <spamatica@gmail.com> | 2013-04-05 19:01:32 +0000 | 
| commit | cce3c991cc961a49ced3da38f22d05d885ad1bee (patch) | |
| tree | ef0b222e5be625e6b0c2d8296a1d5f605fcf24f7 /muse2/muse | |
| parent | d930cf81c2cbcc65b373442a2aed3e631d331314 (diff) | |
save and titles
Diffstat (limited to 'muse2/muse')
| -rw-r--r-- | muse2/muse/app.cpp | 52 | ||||
| -rw-r--r-- | muse2/muse/app.h | 5 | ||||
| -rw-r--r-- | muse2/muse/conf.cpp | 3 | ||||
| -rw-r--r-- | muse2/muse/gconfig.cpp | 3 | ||||
| -rw-r--r-- | muse2/muse/gconfig.h | 1 | ||||
| -rw-r--r-- | muse2/muse/song.h | 1 | ||||
| -rw-r--r-- | muse2/muse/undo.cpp | 6 | ||||
| -rw-r--r-- | muse2/muse/widgets/genset.cpp | 2 | ||||
| -rw-r--r-- | muse2/muse/widgets/gensetbase.ui | 305 | 
9 files changed, 222 insertions, 156 deletions
| 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()) + " <unsaved changes>"); +      } +  //---------------------------------------------------  //  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<MusECore::Part*> >&); +      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 @@         <string>Application</string>        </attribute>        <layout class="QGridLayout"> -       <item row="0" column="0"> -        <widget class="QGroupBox" name="projDirGroupBox"> +       <item row="2" column="0"> +        <widget class="QGroupBox" name="groupBox3">           <property name="title"> -          <string>Project directory</string> +          <string>Start Muse</string>           </property> -         <layout class="QHBoxLayout" name="qhboxProjDir"> -          <property name="spacing"> -           <number>6</number> -          </property> -          <item> -           <widget class="QLabel" name="textLabel_ProjDir"> -            <property name="text"> -             <string>Projects:</string> -            </property> -            <property name="wordWrap"> -             <bool>false</bool> -            </property> -           </widget> -          </item> -          <item> -           <widget class="QLineEdit" name="projDirEntry"/> -          </item> -          <item> -           <widget class="QToolButton" name="projDirOpenToolButton"> -            <property name="text"> -             <string>...</string> -            </property> -           </widget> +         <layout class="QGridLayout"> +          <item row="0" column="0"> +           <layout class="QGridLayout" name="gridLayout11"> +            <item row="3" column="0" colspan="2"> +             <layout class="QHBoxLayout" name="qhboxStartSong"> +              <item> +               <widget class="QLineEdit" name="startSongEntry"/> +              </item> +              <item> +               <widget class="QToolButton" name="startSongFileOpenToolButton"> +                <property name="toolTip"> +                 <string>Choose start song or template</string> +                </property> +                <property name="text"> +                 <string>...</string> +                </property> +               </widget> +              </item> +              <item> +               <widget class="QToolButton" name="startSongResetToolButton"> +                <property name="toolTip"> +                 <string>Reset to default</string> +                </property> +                <property name="text"> +                 <string>...</string> +                </property> +               </widget> +              </item> +             </layout> +            </item> +            <item row="1" column="0" colspan="2"> +             <widget class="QGroupBox" name="startSongBox"> +              <property name="title"> +               <string>Start song</string> +              </property> +              <layout class="QHBoxLayout" name="hLayout_1"> +               <item> +                <widget class="QRadioButton" name="startLastButton"> +                 <property name="text"> +                  <string>start with last song</string> +                 </property> +                 <property name="checked"> +                  <bool>true</bool> +                 </property> +                </widget> +               </item> +               <item> +                <widget class="QRadioButton" name="startEmptyButton"> +                 <property name="sizePolicy"> +                  <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> +                   <horstretch>0</horstretch> +                   <verstretch>0</verstretch> +                  </sizepolicy> +                 </property> +                 <property name="text"> +                  <string>start with template</string> +                 </property> +                 <property name="checked"> +                  <bool>false</bool> +                 </property> +                </widget> +               </item> +               <item> +                <widget class="QRadioButton" name="startSongButton"> +                 <property name="text"> +                  <string>start with song</string> +                 </property> +                </widget> +               </item> +              </layout> +             </widget> +            </item> +            <item row="0" column="0" colspan="2"> +             <widget class="QGroupBox" name="startUpBox"> +              <property name="title"> +               <string>On Launch</string> +              </property> +              <layout class="QHBoxLayout" name="hLayout_2"> +               <item> +                <widget class="QCheckBox" name="showSplash"> +                 <property name="text"> +                  <string>show splash screen</string> +                 </property> +                </widget> +               </item> +               <item> +                <widget class="QCheckBox" name="showDidYouKnow"> +                 <property name="text"> +                  <string>show "Did you know?" dialog</string> +                 </property> +                </widget> +               </item> +              </layout> +             </widget> +            </item> +            <item row="2" column="0"> +             <widget class="QLabel" name="textLabel1_2"> +              <property name="text"> +               <string>Start template or song:</string> +              </property> +              <property name="wordWrap"> +               <bool>false</bool> +              </property> +             </widget> +            </item> +            <item row="2" column="1"> +             <widget class="QCheckBox" name="readMidiConfigFromSongCheckBox"> +              <property name="toolTip"> +               <string>Read MIDI Ports configuration from file,  + or else automatically configure</string> +              </property> +              <property name="text"> +               <string>Read MIDI Ports configuration</string> +              </property> +             </widget> +            </item> +           </layout>            </item>           </layout>          </widget>         </item> -       <item row="2" column="0"> +       <item row="3" column="0">          <widget class="QGroupBox" name="groupBox4">           <property name="sizePolicy">            <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> @@ -445,132 +539,45 @@           </layout>          </widget>         </item> -       <item row="1" column="0"> -        <widget class="QGroupBox" name="groupBox3"> +       <item row="0" column="0"> +        <widget class="QGroupBox" name="projDirGroupBox">           <property name="title"> -          <string>Start Muse</string> +          <string>Project directory</string>           </property> -         <layout class="QGridLayout"> -          <item row="0" column="0"> -           <layout class="QGridLayout" name="gridLayout11"> -            <item row="3" column="0" colspan="2"> -             <layout class="QHBoxLayout" name="qhboxStartSong"> -              <item> -               <widget class="QLineEdit" name="startSongEntry"/> -              </item> -              <item> -               <widget class="QToolButton" name="startSongFileOpenToolButton"> -                <property name="toolTip"> -                 <string>Choose start song or template</string> -                </property> -                <property name="text"> -                 <string>...</string> -                </property> -               </widget> -              </item> -              <item> -               <widget class="QToolButton" name="startSongResetToolButton"> -                <property name="toolTip"> -                 <string>Reset to default</string> -                </property> -                <property name="text"> -                 <string>...</string> -                </property> -               </widget> -              </item> -             </layout> -            </item> -            <item row="1" column="0" colspan="2"> -             <widget class="QGroupBox" name="startSongBox"> -              <property name="title"> -               <string>Start song</string> -              </property> -              <layout class="QHBoxLayout" name="hLayout_1"> -               <item> -                <widget class="QRadioButton" name="startLastButton"> -                 <property name="text"> -                  <string>start with last song</string> -                 </property> -                 <property name="checked"> -                  <bool>true</bool> -                 </property> -                </widget> -               </item> -               <item> -                <widget class="QRadioButton" name="startEmptyButton"> -                 <property name="sizePolicy"> -                  <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> -                   <horstretch>0</horstretch> -                   <verstretch>0</verstretch> -                  </sizepolicy> -                 </property> -                 <property name="text"> -                  <string>start with template</string> -                 </property> -                 <property name="checked"> -                  <bool>false</bool> -                 </property> -                </widget> -               </item> -               <item> -                <widget class="QRadioButton" name="startSongButton"> -                 <property name="text"> -                  <string>start with song</string> -                 </property> -                </widget> -               </item> -              </layout> -             </widget> -            </item> -            <item row="0" column="0" colspan="2"> -             <widget class="QGroupBox" name="startUpBox"> -              <property name="title"> -               <string>On Launch</string> -              </property> -              <layout class="QHBoxLayout" name="hLayout_2"> -               <item> -                <widget class="QCheckBox" name="showSplash"> -                 <property name="text"> -                  <string>show splash screen</string> -                 </property> -                </widget> -               </item> -               <item> -                <widget class="QCheckBox" name="showDidYouKnow"> -                 <property name="text"> -                  <string>show "Did you know?" dialog</string> -                 </property> -                </widget> -               </item> -              </layout> -             </widget> -            </item> -            <item row="2" column="0"> -             <widget class="QLabel" name="textLabel1_2"> -              <property name="text"> -               <string>Start template or song:</string> -              </property> -              <property name="wordWrap"> -               <bool>false</bool> -              </property> -             </widget> -            </item> -            <item row="2" column="1"> -             <widget class="QCheckBox" name="readMidiConfigFromSongCheckBox"> -              <property name="toolTip"> -               <string>Read MIDI Ports configuration from file,  - or else automatically configure</string> -              </property> -              <property name="text"> -               <string>Read MIDI Ports configuration</string> -              </property> -             </widget> -            </item> -           </layout> +         <layout class="QHBoxLayout" name="qhboxProjDir"> +          <property name="spacing"> +           <number>6</number> +          </property> +          <item> +           <widget class="QLabel" name="textLabel_ProjDir"> +            <property name="text"> +             <string>Projects:</string> +            </property> +            <property name="wordWrap"> +             <bool>false</bool> +            </property> +           </widget> +          </item> +          <item> +           <widget class="QLineEdit" name="projDirEntry"/> +          </item> +          <item> +           <widget class="QToolButton" name="projDirOpenToolButton"> +            <property name="text"> +             <string>...</string> +            </property> +           </widget>            </item>           </layout>          </widget>         </item> +       <item row="1" column="0"> +        <widget class="QCheckBox" name="autoSaveCheckBox"> +         <property name="text"> +          <string>Auto save (every 5 minutes if not playing/recording)</string> +         </property> +        </widget> +       </item>        </layout>       </widget>       <widget class="QWidget" name="tab"> @@ -1754,8 +1761,8 @@ Disable to use an alternate standard                <rect>                 <x>0</x>                 <y>0</y> -               <width>96</width> -               <height>26</height> +               <width>500</width> +               <height>460</height>                </rect>               </property>               <layout class="QHBoxLayout" name="horizontalLayout_3"> | 
