diff options
author | Clinton Stimpson <clinton@elemtech.com> | 2007-11-07 02:27:45 (GMT) |
---|---|---|
committer | Clinton Stimpson <clinton@elemtech.com> | 2007-11-07 02:27:45 (GMT) |
commit | 7294b272939c768f641ea9bfcf5f65b0fb2b3a3f (patch) | |
tree | 8bccbc4518377088b11ce44706e9aeb91ceee374 | |
parent | 1e91100599d88ba12dd7a91db17e47d8d9110914 (diff) | |
download | CMake-7294b272939c768f641ea9bfcf5f65b0fb2b3a3f.zip CMake-7294b272939c768f641ea9bfcf5f65b0fb2b3a3f.tar.gz CMake-7294b272939c768f641ea9bfcf5f65b0fb2b3a3f.tar.bz2 |
BUG: Put back read/write of original WhereBuild* settings.
ENH: Make public a couple functions to support command line args.
Try removing exit after generate to see if others like it.
COMP: Fix warnings.
-rw-r--r-- | Source/QtDialog/CMakeSetupDialog.cxx | 85 | ||||
-rw-r--r-- | Source/QtDialog/CMakeSetupDialog.h | 7 |
2 files changed, 69 insertions, 23 deletions
diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index 6703256..385d2e3 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -107,7 +107,7 @@ CMakeSetupDialog::CMakeSetupDialog() this->GenerateAction = ToolsMenu->addAction(tr("&Generate")); QObject::connect(this->GenerateAction, SIGNAL(triggered(bool)), this, SLOT(doGenerate())); - + /* QMenu* OptionsMenu = this->menuBar()->addMenu(tr("&Options")); QAction* a = OptionsMenu->addAction(tr("Exit after Generation")); a->setCheckable(true); @@ -115,9 +115,10 @@ CMakeSetupDialog::CMakeSetupDialog() a->setChecked(this->ExitAfterGenerate); QObject::connect(a, SIGNAL(triggered(bool)), this, SLOT(setExitAfterGenerate(bool))); + */ QMenu* HelpMenu = this->menuBar()->addMenu(tr("&Help")); - a = HelpMenu->addAction(tr("About")); + QAction* a = HelpMenu->addAction(tr("About")); QObject::connect(a, SIGNAL(triggered(bool)), this, SLOT(doAbout())); a = HelpMenu->addAction(tr("Help")); @@ -205,9 +206,7 @@ void CMakeSetupDialog::initialize() this, SLOT(cacheModelDirty())); // get the saved binary directories - QSettings settings; - settings.beginGroup("Settings/StartPath"); - QStringList buildPaths = settings.value("WhereBuild").toStringList(); + QStringList buildPaths = this->loadBuildPaths(); this->BinaryDirectory->addItems(buildPaths); } @@ -288,17 +287,19 @@ void CMakeSetupDialog::finishGenerate(int err) this->setEnabledState(true); this->setGenerateEnabled(true); this->ProgressBar->reset(); - this->statusBar()->showMessage(tr("Generate Done"), 2000); + this->statusBar()->showMessage(tr("Generate Done")); if(err != 0) { QMessageBox::critical(this, tr("Error"), tr("Error in generation process, project files may be invalid"), QMessageBox::Ok); } + /* else if(this->ExitAfterGenerate) { QApplication::quit(); } + */ } void CMakeSetupDialog::doGenerate() @@ -381,7 +382,7 @@ void CMakeSetupDialog::doSourceBrowse() tr("Enter Path to Source"), this->SourceDirectory->text()); if(!dir.isEmpty()) { - this->SourceDirectory->setText(dir); + this->setSourceDirectory(dir); } } @@ -389,7 +390,7 @@ void CMakeSetupDialog::updateSourceDirectory(const QString& dir) { if(this->SourceDirectory->text() != dir) { - this->SourceDirectory->setText(dir); + this->setSourceDirectory(dir); } } @@ -412,6 +413,11 @@ void CMakeSetupDialog::setBinaryDirectory(const QString& dir) "setBinaryDirectory", Qt::QueuedConnection, Q_ARG(QString, dir)); } +void CMakeSetupDialog::setSourceDirectory(const QString& dir) +{ + this->SourceDirectory->setText(dir); +} + void CMakeSetupDialog::showProgress(const QString& msg, float percent) { this->statusBar()->showMessage(msg); @@ -530,9 +536,11 @@ void CMakeSetupDialog::doAbout() void CMakeSetupDialog::setExitAfterGenerate(bool b) { this->ExitAfterGenerate = b; + /* QSettings settings; settings.beginGroup("Settings/StartPath"); settings.setValue("ExitAfterGenerate", b); + */ } void CMakeSetupDialog::cacheModelDirty() @@ -553,10 +561,8 @@ void CMakeSetupDialog::addBinaryPath(const QString& path) { QString cleanpath = QDir::cleanPath(path); - QSettings settings; - settings.beginGroup("Settings/StartPath"); - QStringList buildPaths = settings.value("WhereBuild").toStringList(); - buildPaths.removeAll(cleanpath); + // update UI + this->BinaryDirectory->blockSignals(true); int idx = this->BinaryDirectory->findText(cleanpath); if(idx != -1) { @@ -564,18 +570,19 @@ void CMakeSetupDialog::addBinaryPath(const QString& path) } this->BinaryDirectory->insertItem(0, cleanpath); this->BinaryDirectory->setCurrentIndex(0); + this->BinaryDirectory->blockSignals(false); + + // save to registry + QStringList buildPaths = this->loadBuildPaths(); + buildPaths.removeAll(cleanpath); buildPaths.prepend(cleanpath); - while(buildPaths.count() > 10) - { - buildPaths.removeLast(); - } - settings.setValue("WhereBuild", buildPaths); + this->saveBuildPaths(buildPaths); } void CMakeSetupDialog::dragEnterEvent(QDragEnterEvent* e) { - const QMimeData* data = e->mimeData(); - QList<QUrl> urls = data->urls(); + const QMimeData* dat = e->mimeData(); + QList<QUrl> urls = dat->urls(); QString file = urls.count() ? urls[0].toLocalFile() : QString(); if(!file.isEmpty() && (file.endsWith("CMakeCache.txt", Qt::CaseInsensitive) || @@ -591,8 +598,8 @@ void CMakeSetupDialog::dragEnterEvent(QDragEnterEvent* e) void CMakeSetupDialog::dropEvent(QDropEvent* e) { - const QMimeData* data = e->mimeData(); - QList<QUrl> urls = data->urls(); + const QMimeData* dat = e->mimeData(); + QList<QUrl> urls = dat->urls(); QString file = urls.count() ? urls[0].toLocalFile() : QString(); if(file.endsWith("CMakeCache.txt", Qt::CaseInsensitive)) { @@ -602,8 +609,42 @@ void CMakeSetupDialog::dropEvent(QDropEvent* e) else if(file.endsWith("CMakeLists.txt", Qt::CaseInsensitive)) { QFileInfo info(file); - this->SourceDirectory->setText(info.absolutePath()); + this->setSourceDirectory(info.absolutePath()); this->setBinaryDirectory(info.absolutePath()); } } +QStringList CMakeSetupDialog::loadBuildPaths() +{ + QSettings settings; + settings.beginGroup("Settings/StartPath"); + + QStringList buildPaths; + for(int i=0; i<10; i++) + { + QString p = settings.value(QString("WhereBuild%1").arg(i)).toString(); + if(!p.isEmpty()) + { + buildPaths.append(p); + } + } + return buildPaths; +} + +void CMakeSetupDialog::saveBuildPaths(const QStringList& paths) +{ + QSettings settings; + settings.beginGroup("Settings/StartPath"); + + int num = paths.count(); + if(num > 10) + { + num = 10; + } + + for(int i=0; i<num; i++) + { + settings.setValue(QString("WhereBuild%1").arg(i), paths[i]); + } +} + diff --git a/Source/QtDialog/CMakeSetupDialog.h b/Source/QtDialog/CMakeSetupDialog.h index 250be16..0010e1d 100644 --- a/Source/QtDialog/CMakeSetupDialog.h +++ b/Source/QtDialog/CMakeSetupDialog.h @@ -36,6 +36,10 @@ public: CMakeSetupDialog(); ~CMakeSetupDialog(); +public slots: + void setBinaryDirectory(const QString& dir); + void setSourceDirectory(const QString& dir); + protected slots: void initialize(); void doConfigure(); @@ -52,7 +56,6 @@ protected slots: void doReloadCache(); void doDeleteCache(); void updateSourceDirectory(const QString& dir); - void setBinaryDirectory(const QString& dir); void showProgress(const QString& msg, float percent); void setEnabledState(bool); void promptForGenerator(); @@ -61,6 +64,8 @@ protected slots: void cacheModelDirty(); void setGenerateEnabled(bool); void addBinaryPath(const QString&); + QStringList loadBuildPaths(); + void saveBuildPaths(const QStringList&); protected: void closeEvent(QCloseEvent*); |