diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 6fbb3cc32b8c022989a69bff2e656b58728eab85..af4beb1ecbcaec158899412a6738f82b5d3b48f0 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -198,6 +198,8 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er m_versionManager = new QtVersionManager(); addAutoReleasedObject(m_versionManager); + addAutoReleasedObject(new QtOptionsPage()); + addAutoReleasedObject(new CoreListenerCheckingForRunningBuild(m_buildManager)); m_outputPane = new OutputPane; diff --git a/src/plugins/projectexplorer/qtversionmanager.cpp b/src/plugins/projectexplorer/qtversionmanager.cpp index 67a8ffbb6581a6a0b344aa965b1d6d03081cde82..acaa49e359b465163712fe40c17243a86431d802 100644 --- a/src/plugins/projectexplorer/qtversionmanager.cpp +++ b/src/plugins/projectexplorer/qtversionmanager.cpp @@ -115,7 +115,7 @@ QtVersionManager::~QtVersionManager() m_emptyVersion = 0; } -QtVersionManager::QtVersionManager *instance() +QtVersionManager *QtVersionManager::instance() { return ProjectExplorerPlugin::instance()->qtVersionManager(); } @@ -147,32 +147,6 @@ int QtVersionManager::getUniqueId() return m_idcount++; } -QString QtVersionManager::id() const -{ - return QLatin1String(Constants::QTVERSION_PAGE); -} - -QString QtVersionManager::trName() const -{ - return tr(Constants::QTVERSION_PAGE); -} - -QString QtVersionManager::category() const -{ - return Constants::QT_CATEGORY; -} - -QString QtVersionManager::trCategory() const -{ - return tr(Constants::QT_CATEGORY); -} - -QWidget *QtVersionManager::createPage(QWidget *parent) -{ - m_widget = new QtDirWidget(parent, m_versions, m_defaultVersion); - return m_widget; -} - void QtVersionManager::updateUniqueIdToIndexMap() { m_uniqueIdToIndex.clear(); @@ -180,40 +154,6 @@ void QtVersionManager::updateUniqueIdToIndexMap() m_uniqueIdToIndex.insert(m_versions.at(i)->uniqueId(), i); } -void QtVersionManager::apply() -{ - m_widget->finish(); - QList<QtVersion*> newVersions = m_widget->versions(); - bool versionPathsChanged = m_versions.size() != newVersions.size(); - if (!versionPathsChanged) { - for (int i = 0; i < m_versions.size(); ++i) { - if (m_versions.at(i)->path() != newVersions.at(i)->path()) { - versionPathsChanged = true; - break; - } - } - } - qDeleteAll(m_versions); - m_versions.clear(); - foreach(QtVersion *version, m_widget->versions()) - m_versions.append(new QtVersion(*version)); - if (versionPathsChanged) - updateDocumentation(); - updateUniqueIdToIndexMap(); - - bool emitDefaultChanged = false; - if (m_defaultVersion != m_widget->defaultVersion()) { - m_defaultVersion = m_widget->defaultVersion(); - emitDefaultChanged = true; - } - - emit qtVersionsChanged(); - if (emitDefaultChanged) - emit defaultQtVersionChanged(); - - writeVersionsIntoSettings(); -} - void QtVersionManager::writeVersionsIntoSettings() { QSettings *s = Core::ICore::instance()->settings(); @@ -383,10 +323,91 @@ QtVersion *QtVersionManager::currentQtVersion() const return m_emptyVersion; } +void QtVersionManager::setNewQtVersions(QList<QtVersion *> newVersions, int newDefaultVersion) +{ + bool versionPathsChanged = m_versions.size() != newVersions.size(); + if (!versionPathsChanged) { + for (int i = 0; i < m_versions.size(); ++i) { + if (m_versions.at(i)->path() != newVersions.at(i)->path()) { + versionPathsChanged = true; + break; + } + } + } + qDeleteAll(m_versions); + m_versions.clear(); + foreach(QtVersion *version, newVersions) + m_versions.append(new QtVersion(*version)); + if (versionPathsChanged) + updateDocumentation(); + updateUniqueIdToIndexMap(); + + bool emitDefaultChanged = false; + if (m_defaultVersion != newDefaultVersion) { + m_defaultVersion = newDefaultVersion; + emitDefaultChanged = true; + } + + emit qtVersionsChanged(); + if (emitDefaultChanged) + emit defaultQtVersionChanged(); + + writeVersionsIntoSettings(); +} + +/// +// QtOptionsPage +/// + +QtOptionsPage::QtOptionsPage() +{ + +} + +QtOptionsPage::~QtOptionsPage() +{ + +} + +QString QtOptionsPage::id() const +{ + return QLatin1String(Constants::QTVERSION_PAGE); +} + +QString QtOptionsPage::trName() const +{ + return tr(Constants::QTVERSION_PAGE); +} + +QString QtOptionsPage::category() const +{ + return Constants::QT_CATEGORY; +} + +QString QtOptionsPage::trCategory() const +{ + return tr(Constants::QT_CATEGORY); +} + +QWidget *QtOptionsPage::createPage(QWidget *parent) +{ + QtVersionManager *vm = QtVersionManager::instance(); + m_widget = new QtDirWidget(parent, vm->versions(), vm->currentQtVersion()); + return m_widget; +} + +void QtOptionsPage::apply() +{ + m_widget->finish(); + + QtVersionManager *vm = QtVersionManager::instance(); + vm->setNewQtVersions(m_widget->versions(), m_widget->defaultVersion()); +} + //----------------------------------------------------- -QtDirWidget::QtDirWidget(QWidget *parent, QList<QtVersion *> versions, int defaultVersion) +QtDirWidget::QtDirWidget(QWidget *parent, QList<QtVersion *> versions, QtVersion *defaultVersion) : QWidget(parent) - , m_defaultVersion(defaultVersion) + , m_defaultVersion(versions.indexOf(defaultVersion)) , m_specifyNameString(tr("<specify a name>")) , m_specifyPathString(tr("<specify a path>")) { diff --git a/src/plugins/projectexplorer/qtversionmanager.h b/src/plugins/projectexplorer/qtversionmanager.h index 1721719c1a2f84fd871f092f8d4c619f5cbd5347..c1db4c5a2b2ff7969df9074d7cb05f9d8afb0e0d 100644 --- a/src/plugins/projectexplorer/qtversionmanager.h +++ b/src/plugins/projectexplorer/qtversionmanager.h @@ -135,7 +135,7 @@ class QtDirWidget : public QWidget { Q_OBJECT public: - QtDirWidget(QWidget *parent, QList<QtVersion *> versions, int defaultVersion); + QtDirWidget(QWidget *parent, QList<QtVersion *> versions, QtVersion *defaultVersion); ~QtDirWidget(); QList<QtVersion *> versions() const; int defaultVersion() const; @@ -168,45 +168,33 @@ private slots: void showDebuggingBuildLog(); }; -class PROJECTEXPLORER_EXPORT QtVersionManager : public Core::IOptionsPage +class PROJECTEXPLORER_EXPORT QtVersionManager : public QObject { Q_OBJECT public: + static QtVersionManager *instance(); QtVersionManager(); ~QtVersionManager(); - - static QtVersionManager *instance(); - - QString id() const; - QString trName() const; - QString category() const; - QString trCategory() const; - - QWidget *createPage(QWidget *parent); - void apply(); - void finish() { } - void writeVersionsIntoSettings(); QList<QtVersion *> versions() const; QtVersion * version(int id) const; QtVersion * currentQtVersion() const; - // internal int getUniqueId(); QtVersion::QmakeBuildConfig scanMakefileForQmakeConfig(const QString &directory, QtVersion::QmakeBuildConfig defaultBuildConfig); QString findQtVersionFromMakefile(const QString &directory); QtVersion *qtVersionForDirectory(const QString &directory); - // Used by the projectloadwizard void addVersion(QtVersion *version); - + // returns something like qmake4, qmake, qmake-qt4 or whatever distributions have chosen (used by QtVersion) static QStringList possibleQMakeCommands(); // return true if the qmake at qmakePath is qt4 (used by QtVersion) static QString qtVersionForQMake(const QString &qmakePath); + void setNewQtVersions(QList<QtVersion *> newVersions, int newDefaultVersion); signals: void defaultQtVersionChanged(); void qtVersionsChanged(); @@ -218,14 +206,29 @@ private: static int indexOfVersionInList(const QtVersion * const version, const QList<QtVersion *> &list); void updateUniqueIdToIndexMap(); - QtDirWidget *m_widget; - QtVersion *m_emptyVersion; int m_defaultVersion; QList<QtVersion *> m_versions; QMap<int, int> m_uniqueIdToIndex; int m_idcount; }; + +class PROJECTEXPLORER_EXPORT QtOptionsPage : public Core::IOptionsPage +{ + Q_OBJECT +public: + QtOptionsPage(); + ~QtOptionsPage(); + QString id() const; + QString trName() const; + QString category() const; + QString trCategory() const; + QWidget *createPage(QWidget *parent); + void apply(); + void finish() { } +private: + QtDirWidget *m_widget; +}; } // namespace ProjectExplorer #endif // QTVERSIONMANAGER_H