diff options
author | Tobias Hunger <tobias.hunger@nokia.com> | 2010-09-14 11:37:54 +0200 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@nokia.com> | 2010-09-14 17:26:49 +0200 |
commit | 563c542a2f8fda500c9205298a781b2b0297da4d (patch) | |
tree | 1c429b24c063729732b62aba3a1b3a0ba5c6bebd /src | |
parent | b85597da6f120c339a6c6d47611992e44fe4b1bc (diff) | |
download | qt-creator-563c542a2f8fda500c9205298a781b2b0297da4d.tar.gz |
Add option to restore last session at startup
* Add an option to the session manager to restore the last
session on startup of creator.
* Align close button on session manager dialog with the other
buttons.
* Clean up handling of session restoration in the ProjectExplorer:
Move all the relevant code into determineSessionToRestoreAtStartup,
since most was there already.
Task-number: QTCREATORBUG-2324
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/projectexplorer/projectexplorer.cpp | 28 | ||||
-rw-r--r-- | src/plugins/projectexplorer/projectexplorersettings.h | 14 | ||||
-rw-r--r-- | src/plugins/projectexplorer/sessiondialog.cpp | 11 | ||||
-rw-r--r-- | src/plugins/projectexplorer/sessiondialog.h | 3 | ||||
-rw-r--r-- | src/plugins/projectexplorer/sessiondialog.ui | 40 |
5 files changed, 75 insertions, 21 deletions
diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index c8afcd8599..5286ec0383 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -260,9 +260,6 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er d->m_session = new SessionManager(this); - if (arguments.contains("-lastsession")) - d->m_sessionToRestoreAtStartup = d->m_session->lastSession(); - connect(d->m_session, SIGNAL(projectAdded(ProjectExplorer::Project *)), this, SIGNAL(fileListChanged())); connect(d->m_session, SIGNAL(aboutToRemoveProject(ProjectExplorer::Project *)), @@ -799,6 +796,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er d->m_projectExplorerSettings.cleanOldAppOutput = s->value("ProjectExplorer/Settings/CleanOldAppOutput", false).toBool(); d->m_projectExplorerSettings.wrapAppOutput = s->value("ProjectExplorer/Settings/WrapAppOutput", true).toBool(); d->m_projectExplorerSettings.useJom = s->value("ProjectExplorer/Settings/UseJom", true).toBool(); + d->m_projectExplorerSettings.autorestoreLastSession = s->value("ProjectExplorer/Settings/AutoRestoreLastSession", false).toBool(); d->m_projectExplorerSettings.environmentId = QUuid(s->value("ProjectExplorer/Settings/EnvironmentId").toString()); if (d->m_projectExplorerSettings.environmentId.isNull()) d->m_projectExplorerSettings.environmentId = QUuid::createUuid(); @@ -994,7 +992,9 @@ void ProjectExplorerPlugin::showSessionManager() d->m_session->save(); } SessionDialog sessionDialog(d->m_session); + sessionDialog.setAutoLoadSession(d->m_projectExplorerSettings.autorestoreLastSession); sessionDialog.exec(); + d->m_projectExplorerSettings.autorestoreLastSession = sessionDialog.autoLoadSession(); updateActions(); @@ -1053,6 +1053,7 @@ void ProjectExplorerPlugin::savePersistentSettings() s->setValue("ProjectExplorer/Settings/CleanOldAppOutput", d->m_projectExplorerSettings.cleanOldAppOutput); s->setValue("ProjectExplorer/Settings/WrapAppOutput", d->m_projectExplorerSettings.wrapAppOutput); s->setValue("ProjectExplorer/Settings/UseJom", d->m_projectExplorerSettings.useJom); + s->setValue("ProjectExplorer/Settings/AutoRestoreLastSession", d->m_projectExplorerSettings.autorestoreLastSession); s->setValue("ProjectExplorer/Settings/EnvironmentId", d->m_projectExplorerSettings.environmentId.toString()); } } @@ -1187,15 +1188,20 @@ void ProjectExplorerPlugin::currentModeChanged(Core::IMode *mode, Core::IMode *o void ProjectExplorerPlugin::determineSessionToRestoreAtStartup() { - QStringList sessions = d->m_session->sessions(); - // We have command line arguments, try to find a session in them QStringList arguments = ExtensionSystem::PluginManager::instance()->arguments(); - // Default to no session loading - foreach (const QString &arg, arguments) { - if (sessions.contains(arg)) { - // Session argument - d->m_sessionToRestoreAtStartup = arg; - break; + if (arguments.contains("-lastsession") + || d->m_projectExplorerSettings.autorestoreLastSession) { + d->m_sessionToRestoreAtStartup = d->m_session->lastSession(); + } else { + QStringList sessions = d->m_session->sessions(); + // We have command line arguments, try to find a session in them + // Default to no session loading + foreach (const QString &arg, arguments) { + if (sessions.contains(arg)) { + // Session argument + d->m_sessionToRestoreAtStartup = arg; + break; + } } } diff --git a/src/plugins/projectexplorer/projectexplorersettings.h b/src/plugins/projectexplorer/projectexplorersettings.h index 26b50a31e7..cff8b534dc 100644 --- a/src/plugins/projectexplorer/projectexplorersettings.h +++ b/src/plugins/projectexplorer/projectexplorersettings.h @@ -37,9 +37,12 @@ namespace Internal { struct ProjectExplorerSettings { - ProjectExplorerSettings() : buildBeforeDeploy(true), deployBeforeRun(true), - saveBeforeBuild(false), showCompilerOutput(false), - cleanOldAppOutput(false), wrapAppOutput(true), useJom(true) {} + ProjectExplorerSettings() : + buildBeforeDeploy(true), deployBeforeRun(true), + saveBeforeBuild(false), showCompilerOutput(false), + cleanOldAppOutput(false), wrapAppOutput(true), useJom(true), + autorestoreLastSession(false) + { } bool buildBeforeDeploy; bool deployBeforeRun; @@ -48,6 +51,8 @@ struct ProjectExplorerSettings bool cleanOldAppOutput; bool wrapAppOutput; bool useJom; + bool autorestoreLastSession; // This option is set in the Session Manager! + // Add a UUid which is used to identify the development environment. // This is used to warn the user when he is trying to open a .user file that was created // somewhere else (which might lead to unexpected results). @@ -62,7 +67,8 @@ inline bool operator==(const ProjectExplorerSettings &p1, const ProjectExplorerS && p1.showCompilerOutput == p2.showCompilerOutput && p1.cleanOldAppOutput == p2.cleanOldAppOutput && p1.wrapAppOutput == p2.wrapAppOutput - && p1.useJom == p2.useJom; + && p1.useJom == p2.useJom + && p1.autorestoreLastSession == p2.autorestoreLastSession; } diff --git a/src/plugins/projectexplorer/sessiondialog.cpp b/src/plugins/projectexplorer/sessiondialog.cpp index 0590447c3a..fa5405cec1 100644 --- a/src/plugins/projectexplorer/sessiondialog.cpp +++ b/src/plugins/projectexplorer/sessiondialog.cpp @@ -149,6 +149,17 @@ SessionDialog::SessionDialog(SessionManager *sessionManager) markItems(); } +void SessionDialog::setAutoLoadSession(bool check) +{ + m_ui.autoLoadCheckBox->setChecked(check ? Qt::Checked : Qt::Unchecked); +} + +bool SessionDialog::autoLoadSession() const +{ + return m_ui.autoLoadCheckBox->checkState() == Qt::Checked; +} + + void SessionDialog::addItems(bool setDefaultSession) { QStringList sessions = m_sessionManager->sessions(); diff --git a/src/plugins/projectexplorer/sessiondialog.h b/src/plugins/projectexplorer/sessiondialog.h index 06f116d67b..afba5842e3 100644 --- a/src/plugins/projectexplorer/sessiondialog.h +++ b/src/plugins/projectexplorer/sessiondialog.h @@ -47,6 +47,9 @@ class SessionDialog : public QDialog public: SessionDialog(SessionManager *sessionManager); + void setAutoLoadSession(bool); + bool autoLoadSession() const; + private slots: void createNew(); void clone(); diff --git a/src/plugins/projectexplorer/sessiondialog.ui b/src/plugins/projectexplorer/sessiondialog.ui index 98895f94d3..e86331da8c 100644 --- a/src/plugins/projectexplorer/sessiondialog.ui +++ b/src/plugins/projectexplorer/sessiondialog.ui @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>370</width> - <height>260</height> + <width>373</width> + <height>282</height> </rect> </property> <property name="windowTitle"> @@ -17,8 +17,14 @@ <item row="0" column="0"> <widget class="QListWidget" name="sessionList"/> </item> - <item row="0" column="1"> + <item row="0" column="1" rowspan="2"> <layout class="QVBoxLayout" name="verticalLayout"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> <item> <widget class="QPushButton" name="btCreateNew"> <property name="text"> @@ -65,21 +71,31 @@ <property name="sizeHint" stdset="0"> <size> <width>85</width> - <height>13</height> + <height>48</height> </size> </property> </spacer> </item> </layout> </item> - <item row="1" column="0" colspan="2"> + <item row="1" column="0"> + <widget class="QCheckBox" name="autoLoadCheckBox"> + <property name="toolTip"> + <string>Automatically restore the last session when Qt Creator is started.</string> + </property> + <property name="text"> + <string>Restore last session on startup</string> + </property> + </widget> + </item> + <item row="2" column="0" colspan="2"> <widget class="Line" name="line"> <property name="orientation"> <enum>Qt::Horizontal</enum> </property> </widget> </item> - <item row="2" column="0" rowspan="2"> + <item row="3" column="0"> <widget class="QLabel" name="whatsASessionLabel"> <property name="text"> <string><a href="qthelp://com.nokia.qtcreator/doc/creator-project-managing-sessions.html">What is a Session?</a></string> @@ -88,9 +104,21 @@ </item> <item row="3" column="1"> <widget class="QDialogButtonBox" name="buttonBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> <property name="standardButtons"> <set>QDialogButtonBox::Close</set> </property> + <property name="centerButtons"> + <bool>true</bool> + </property> </widget> </item> </layout> |