diff --git a/src/plugins/projectexplorer/project.cpp b/src/plugins/projectexplorer/project.cpp index 459f8114acffba566e841da0c17031f4564e3da7..cc18fbcfd36de3f58c00201c93215be52468f840 100644 --- a/src/plugins/projectexplorer/project.cpp +++ b/src/plugins/projectexplorer/project.cpp @@ -506,17 +506,17 @@ void Project::setDisplayNameFor(const QString &buildConfiguration, const QString emit buildConfigurationDisplayNameChanged(buildConfiguration); } -QByteArray Project::predefinedMacros(const QString &fileName) const +QByteArray Project::predefinedMacros(const QString &) const { return QByteArray(); } -QStringList Project::includePaths(const QString &fileName) const +QStringList Project::includePaths(const QString &) const { return QStringList(); } -QStringList Project::frameworkPaths(const QString &fileName) const +QStringList Project::frameworkPaths(const QString &) const { return QStringList(); } diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index ebb6a1000a790436ff1fef914b95340d099547d6..4dbf49d75612e28a4c9a9ce659ea4d71871283fb 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -56,6 +56,7 @@ #include "session.h" #include "sessiondialog.h" #include "buildparserfactory.h" +#include "projectexplorersettingspage.h" #include <coreplugin/basemode.h> #include <coreplugin/coreconstants.h> @@ -233,6 +234,9 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er addAutoReleasedObject(new GccParserFactory); addAutoReleasedObject(new MsvcParserFactory); + // Settings page + addAutoReleasedObject(new ProjectExplorerSettingsPage); + // context menus Core::ActionContainer *msessionContextMenu = am->createMenu(Constants::M_SESSIONCONTEXT); @@ -619,7 +623,6 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er } // < -- Creator 1.0 compatibility code - // TODO restore recentProjects if (QSettings *s = core->settings()) { const QStringList fileNames = s->value("ProjectExplorer/RecentProjects/FileNames").toStringList(); const QStringList displayNames = s->value("ProjectExplorer/RecentProjects/DisplayNames").toStringList(); @@ -631,7 +634,10 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er } } - + if (QSettings *s = core->settings()) { + m_projectExplorerSettings.buildBeforeRun = s->value("ProjectExplorer/Settings/BuildBeforeRun", true).toBool(); + m_projectExplorerSettings.saveBeforeBuild = s->value("ProjectExplorer/Settings/SaveBeforeBuild", false).toBool(); + } connect(m_sessionManagerAction, SIGNAL(triggered()), this, SLOT(showSessionManager())); connect(m_newAction, SIGNAL(triggered()), this, SLOT(newProject())); @@ -856,6 +862,9 @@ void ProjectExplorerPlugin::savePersistentSettings() s->setValue("ProjectExplorer/RecentProjects/FileNames", fileNames); s->setValue("ProjectExplorer/RecentProjects/DisplayNames", displayNames); + + s->setValue("ProjectExplorer/Settings/BuildBeforeRun", m_projectExplorerSettings.buildBeforeRun); + s->setValue("ProjectExplorer/Settings/SaveBeforeBuild", m_projectExplorerSettings.saveBeforeBuild); } } @@ -1110,6 +1119,36 @@ void ProjectExplorerPlugin::buildStateChanged(Project * pro) updateActions(); } +void ProjectExplorerPlugin::executeRunConfiguration(QSharedPointer<RunConfiguration> runConfiguration, const QString &runMode) +{ + IRunConfigurationRunner *runner = findRunner(runConfiguration, runMode); + if (runner) { + emit aboutToExecuteProject(runConfiguration->project()); + + RunControl *control = runner->run(runConfiguration, runMode); + m_outputPane->createNewOutputWindow(control); + if (runMode == ProjectExplorer::Constants::RUNMODE) + m_outputPane->popup(false); + m_outputPane->showTabFor(control); + + connect(control, SIGNAL(addToOutputWindow(RunControl *, const QString &)), + this, SLOT(addToApplicationOutputWindow(RunControl *, const QString &))); + connect(control, SIGNAL(addToOutputWindowInline(RunControl *, const QString &)), + this, SLOT(addToApplicationOutputWindowInline(RunControl *, const QString &))); + connect(control, SIGNAL(error(RunControl *, const QString &)), + this, SLOT(addErrorToApplicationOutputWindow(RunControl *, const QString &))); + connect(control, SIGNAL(finished()), + this, SLOT(runControlFinished())); + + if (runMode == ProjectExplorer::Constants::DEBUGMODE) + m_debuggingRunControl = control; + + control->start(); + updateRunAction(); + } + +} + void ProjectExplorerPlugin::buildQueueFinished(bool success) { if (debug) @@ -1118,38 +1157,13 @@ void ProjectExplorerPlugin::buildQueueFinished(bool success) updateActions(); if (success && m_delayedRunConfiguration) { - IRunConfigurationRunner *runner = findRunner(m_delayedRunConfiguration, m_runMode); - if (runner) { - emit aboutToExecuteProject(m_delayedRunConfiguration->project()); - - RunControl *control = runner->run(m_delayedRunConfiguration, m_runMode); - m_outputPane->createNewOutputWindow(control); - if (m_runMode == ProjectExplorer::Constants::RUNMODE) - m_outputPane->popup(false); - m_outputPane->showTabFor(control); - - connect(control, SIGNAL(addToOutputWindow(RunControl *, const QString &)), - this, SLOT(addToApplicationOutputWindow(RunControl *, const QString &))); - connect(control, SIGNAL(addToOutputWindowInline(RunControl *, const QString &)), - this, SLOT(addToApplicationOutputWindowInline(RunControl *, const QString &))); - connect(control, SIGNAL(error(RunControl *, const QString &)), - this, SLOT(addErrorToApplicationOutputWindow(RunControl *, const QString &))); - connect(control, SIGNAL(finished()), - this, SLOT(runControlFinished())); - - if (m_runMode == ProjectExplorer::Constants::DEBUGMODE) - m_debuggingRunControl = control; - - control->start(); - updateRunAction(); - } + executeRunConfiguration(m_delayedRunConfiguration, m_runMode); + m_delayedRunConfiguration = QSharedPointer<RunConfiguration>(0); + m_runMode = QString::null; } else { if (m_buildManager->tasksAvailable()) m_buildManager->showTaskWindow(); } - - m_delayedRunConfiguration = QSharedPointer<RunConfiguration>(0); - m_runMode = QString::null; } void ProjectExplorerPlugin::updateTaskActions() @@ -1306,10 +1320,14 @@ bool ProjectExplorerPlugin::saveModifiedFiles(const QList<Project *> & projects) } if (!filesToSave.isEmpty()) { - bool cancelled; - Core::ICore::instance()->fileManager()->saveModifiedFiles(filesToSave, &cancelled); - if (cancelled) { - return false; + if (m_projectExplorerSettings.saveBeforeBuild) { + Core::ICore::instance()->fileManager()->saveModifiedFilesSilently(filesToSave); + } else { + bool cancelled = false; + Core::ICore::instance()->fileManager()->saveModifiedFiles(filesToSave, &cancelled); + if (cancelled) { + return false; + } } } return true; @@ -1408,12 +1426,16 @@ void ProjectExplorerPlugin::runProjectImpl(Project *pro) if (!pro) return; - if (saveModifiedFiles(QList<Project *>() << pro)) { - m_runMode = ProjectExplorer::Constants::RUNMODE; + if (m_projectExplorerSettings.buildBeforeRun) { + if (saveModifiedFiles(QList<Project *>() << pro)) { + m_runMode = ProjectExplorer::Constants::RUNMODE; + m_delayedRunConfiguration = pro->activeRunConfiguration(); - m_delayedRunConfiguration = pro->activeRunConfiguration(); - //NBS TODO make the build project step take into account project dependencies - m_buildManager->buildProject(pro, pro->activeBuildConfiguration()); + //NBS TODO make the build project step take into account project dependencies + m_buildManager->buildProject(pro, pro->activeBuildConfiguration()); + } + } else { + executeRunConfiguration(pro->activeRunConfiguration(), ProjectExplorer::Constants::RUNMODE); } } @@ -1905,4 +1927,15 @@ void ProjectExplorerPlugin::setSession(QAction *action) m_session->loadSession(session); } + +void ProjectExplorerPlugin::setProjectExplorerSettings(const Internal::ProjectExplorerSettings &pes) +{ + m_projectExplorerSettings = pes; +} + +Internal::ProjectExplorerSettings ProjectExplorerPlugin::projectExplorerSettings() const +{ + return m_projectExplorerSettings; +} + Q_EXPORT_PLUGIN(ProjectExplorerPlugin) diff --git a/src/plugins/projectexplorer/projectexplorer.h b/src/plugins/projectexplorer/projectexplorer.h index 987cb323fb69019c81080ca26ac68bbaf8cc8643..6beca9504f98bd21ed0ada55a9d48963c577991a 100644 --- a/src/plugins/projectexplorer/projectexplorer.h +++ b/src/plugins/projectexplorer/projectexplorer.h @@ -71,6 +71,12 @@ class OutputPane; class ProjectWindow; class ProjectFileFactory; +struct ProjectExplorerSettings +{ + bool buildBeforeRun; + bool saveBeforeBuild; +}; + } // namespace Internal class PROJECTEXPLORER_EXPORT ProjectExplorerPlugin @@ -109,6 +115,9 @@ public: void extensionsInitialized(); void shutdown(); + void setProjectExplorerSettings(const Internal::ProjectExplorerSettings &pes); + Internal::ProjectExplorerSettings projectExplorerSettings() const; + signals: void aboutToShowContextMenu(ProjectExplorer::Project *project, ProjectExplorer::Node *node); @@ -186,6 +195,7 @@ private slots: private: void runProjectImpl(Project *pro); + void executeRunConfiguration(QSharedPointer<RunConfiguration>, const QString &mode); void setCurrent(Project *project, QString filePath, Node *node); QStringList allFilesWithDependencies(Project *pro); @@ -259,6 +269,7 @@ private: RunControl *m_debuggingRunControl; QString m_runMode; QString m_projectFilterString; + Internal::ProjectExplorerSettings m_projectExplorerSettings; }; namespace Internal { diff --git a/src/plugins/projectexplorer/projectexplorer.pro b/src/plugins/projectexplorer/projectexplorer.pro index e6a04cf83d9c551f11a90e19512a8fb8886ffe25..170a54387ea16f8408c1ff67247501469b770e84 100644 --- a/src/plugins/projectexplorer/projectexplorer.pro +++ b/src/plugins/projectexplorer/projectexplorer.pro @@ -59,8 +59,9 @@ HEADERS += projectexplorer.h \ gccparser.h \ msvcparser.h \ filewatcher.h \ - debugginghelper.h\ - abstractmakestep.h + debugginghelper.h \ + abstractmakestep.h \ + projectexplorersettingspage.h SOURCES += projectexplorer.cpp \ projectwindow.cpp \ buildmanager.cpp \ @@ -109,7 +110,8 @@ SOURCES += projectexplorer.cpp \ msvcparser.cpp \ filewatcher.cpp \ debugginghelper.cpp \ - abstractmakestep.cpp + abstractmakestep.cpp \ + projectexplorersettingspage.cpp FORMS += dependenciespanel.ui \ buildsettingspropertiespage.ui \ processstep.ui \ @@ -118,7 +120,8 @@ FORMS += dependenciespanel.ui \ sessiondialog.ui \ projectwizardpage.ui \ buildstepspage.ui \ - removefiledialog.ui + removefiledialog.ui \ + projectexplorersettingspage.ui win32 { SOURCES += applicationlauncher_win.cpp \ winguiprocess.cpp diff --git a/src/plugins/projectexplorer/projectexplorerconstants.h b/src/plugins/projectexplorer/projectexplorerconstants.h index 10c56b8deaa91a3699b5a213a63ba9cbdc707411..351f333a27e5b0dda1b3368c85baa96aa833187e 100644 --- a/src/plugins/projectexplorer/projectexplorerconstants.h +++ b/src/plugins/projectexplorer/projectexplorerconstants.h @@ -176,6 +176,11 @@ const char * const RESOURCE_MIMETYPE = "application/vnd.nokia.xml.qt.resource"; // build parsers const char * const BUILD_PARSER_MSVC = "BuildParser.MSVC"; const char * const BUILD_PARSER_GCC = "BuildParser.Gcc"; + +// settings page +const char * const PROJECTEXPLORER_CATEGORY = "ProjectExplorer"; +const char * const PROJECTEXPLORER_PAGE = "ProjectExplorer.ProjectExplorer"; + } // namespace Constants } // namespace ProjectExplorer