summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClinton Stimpson <clinton@elemtech.com>2007-11-06 06:16:11 (GMT)
committerClinton Stimpson <clinton@elemtech.com>2007-11-06 06:16:11 (GMT)
commite8a208384c77455d51c398132ff487df86a66f89 (patch)
tree89a8753a54708b4ecbe0cf43b3b77d5589b6951b
parent87e1004f25702d5d21385cd5f616963c67f89b9e (diff)
downloadCMake-e8a208384c77455d51c398132ff487df86a66f89.zip
CMake-e8a208384c77455d51c398132ff487df86a66f89.tar.gz
CMake-e8a208384c77455d51c398132ff487df86a66f89.tar.bz2
ENH: Add menus in menu bar.
Add reload & delete cache options. Add option to quit after generation step (not yet remembered between sessions). Add Help -> About Remove Help button (in menu now) Remove Cancel button (File -> Exit and the Window 'X' button exist)
-rw-r--r--Source/QtDialog/CMakeSetupDialog.cxx82
-rw-r--r--Source/QtDialog/CMakeSetupDialog.h7
-rw-r--r--Source/QtDialog/CMakeSetupDialog.ui14
-rw-r--r--Source/QtDialog/QCMake.cxx24
-rw-r--r--Source/QtDialog/QCMake.h4
5 files changed, 105 insertions, 26 deletions
diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx
index 79e8d33..5db3992 100644
--- a/Source/QtDialog/CMakeSetupDialog.cxx
+++ b/Source/QtDialog/CMakeSetupDialog.cxx
@@ -26,6 +26,8 @@
#include <QCloseEvent>
#include <QCoreApplication>
#include <QSettings>
+#include <QMenu>
+#include <QMenuBar>
#include "QCMake.h"
#include "QCMakeCacheView.h"
@@ -61,6 +63,7 @@ void QCMakeThread::run()
}
CMakeSetupDialog::CMakeSetupDialog()
+ : QuitOnConfigure(true)
{
// create the GUI
QSettings settings;
@@ -83,7 +86,34 @@ CMakeSetupDialog::CMakeSetupDialog()
this->statusBar()->addPermanentWidget(this->InterruptButton);
this->statusBar()->addPermanentWidget(this->ProgressBar);
-
+ QMenu* FileMenu = this->menuBar()->addMenu(tr("&File"));
+ QAction* a = FileMenu->addAction(tr("&Reload Cache"));
+ QObject::connect(a, SIGNAL(triggered(bool)), this, SLOT(doReloadCache()));
+ a = FileMenu->addAction(tr("&Delete Cache"));
+ QObject::connect(a, SIGNAL(triggered(bool)), this, SLOT(doDeleteCache()));
+ a = FileMenu->addAction(tr("&Exit"));
+ QObject::connect(a, SIGNAL(triggered(bool)), this, SLOT(close()));
+ a = FileMenu->addAction(tr("Exit after Generation"));
+ a->setCheckable(true);
+ a->setChecked(true); // TODO read from registry
+ QObject::connect(a, SIGNAL(triggered(bool)),
+ this, SLOT(setExitAfterGenerate(bool)));
+ a = FileMenu->addSeparator();
+ // TODO: recent list
+
+ QMenu* ToolsMenu = this->menuBar()->addMenu(tr("&Tools"));
+ a = ToolsMenu->addAction(tr("&Configure"));
+ QObject::connect(a, SIGNAL(triggered(bool)), this, SLOT(doConfigure()));
+ a = ToolsMenu->addAction(tr("&Generate"));
+ QObject::connect(a, SIGNAL(triggered(bool)), this, SLOT(doGenerate()));
+
+ QMenu* HelpMenu = this->menuBar()->addMenu(tr("&Help"));
+ a = HelpMenu->addAction(tr("About"));
+ QObject::connect(a, SIGNAL(triggered(bool)),
+ this, SLOT(doAbout()));
+ a = HelpMenu->addAction(tr("Help"));
+ QObject::connect(a, SIGNAL(triggered(bool)),
+ this, SLOT(doHelp()));
// start the cmake worker thread
this->CMakeThread = new QCMakeThread(this);
@@ -110,10 +140,7 @@ void CMakeSetupDialog::initialize()
this, SLOT(finishGenerate(int)));
QObject::connect(this->GenerateButton, SIGNAL(clicked(bool)),
- this, SLOT(doOk()));
-
- QObject::connect(this->CancelButton, SIGNAL(clicked(bool)),
- this, SLOT(close()));
+ this, SLOT(doGenerate()));
QObject::connect(this->BrowseSourceDirectoryButton, SIGNAL(clicked(bool)),
this, SLOT(doSourceBrowse()));
@@ -147,9 +174,6 @@ void CMakeSetupDialog::initialize()
QObject::connect(this->CMakeThread->cmakeInstance(),
SIGNAL(outputMessage(QString)),
this->Output, SLOT(append(QString)));
-
- QObject::connect(this->HelpButton, SIGNAL(clicked(bool)),
- this, SLOT(doHelp()));
QObject::connect(this->Advanced, SIGNAL(clicked(bool)),
this->CacheValues, SLOT(setShowAdvanced(bool)));
@@ -251,13 +275,13 @@ void CMakeSetupDialog::finishGenerate(int err)
tr("Error in generation process, project files may be invalid"),
QMessageBox::Ok);
}
- else
+ else if(this->QuitOnConfigure)
{
QApplication::quit();
}
}
-void CMakeSetupDialog::doOk()
+void CMakeSetupDialog::doGenerate()
{
this->InterruptButton->setEnabled(true);
this->setEnabledState(false);
@@ -394,7 +418,6 @@ void CMakeSetupDialog::setEnabledState(bool enabled)
this->BrowseBinaryDirectoryButton->setEnabled(enabled);
this->ConfigureButton->setEnabled(enabled);
this->GenerateButton->setEnabled(enabled);
- this->CancelButton->setEnabled(enabled);
}
void CMakeSetupDialog::promptForGenerator()
@@ -434,4 +457,41 @@ void CMakeSetupDialog::updateGeneratorLabel(const QString& gen)
this->Generator->setText(str);
}
+void CMakeSetupDialog::doReloadCache()
+{
+ QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(),
+ "reloadCache", Qt::QueuedConnection);
+}
+
+void CMakeSetupDialog::doDeleteCache()
+{
+ QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(),
+ "deleteCache", Qt::QueuedConnection);
+}
+
+void CMakeSetupDialog::doAbout()
+{
+ QString msg = "CMakeSetup\nwww.cmake.org";
+
+ QDialog dialog;
+ dialog.setWindowTitle(tr("About CMakeSetup"));
+ QVBoxLayout* l = new QVBoxLayout(&dialog);
+ QLabel* lab = new QLabel(&dialog);
+ l->addWidget(lab);
+ lab->setText(msg);
+ lab->setWordWrap(true);
+ QDialogButtonBox* btns = new QDialogButtonBox(QDialogButtonBox::Ok,
+ Qt::Horizontal, &dialog);
+ QObject::connect(btns, SIGNAL(accepted()), &dialog, SLOT(accept()));
+ l->addWidget(btns);
+ dialog.exec();
+}
+
+void CMakeSetupDialog::setExitAfterGenerate(bool b)
+{
+ this->QuitOnConfigure = b;
+ // TODO
+ // save to registry
+}
+
diff --git a/Source/QtDialog/CMakeSetupDialog.h b/Source/QtDialog/CMakeSetupDialog.h
index db69981..f436481 100644
--- a/Source/QtDialog/CMakeSetupDialog.h
+++ b/Source/QtDialog/CMakeSetupDialog.h
@@ -39,8 +39,9 @@ public:
protected slots:
void initialize();
void doConfigure();
- void doOk();
+ void doGenerate();
void doHelp();
+ void doAbout();
void doInterrupt();
void finishConfigure(int error);
void finishGenerate(int error);
@@ -48,12 +49,15 @@ protected slots:
void doSourceBrowse();
void doBinaryBrowse();
+ 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();
void updateGeneratorLabel(const QString& gen);
+ void setExitAfterGenerate(bool);
protected:
void closeEvent(QCloseEvent*);
@@ -61,6 +65,7 @@ protected:
QCMakeThread* CMakeThread;
QProgressBar* ProgressBar;
QToolButton* InterruptButton;
+ bool QuitOnConfigure;
};
// QCMake instance on a thread
diff --git a/Source/QtDialog/CMakeSetupDialog.ui b/Source/QtDialog/CMakeSetupDialog.ui
index 49dbf10..9447ef3 100644
--- a/Source/QtDialog/CMakeSetupDialog.ui
+++ b/Source/QtDialog/CMakeSetupDialog.ui
@@ -149,20 +149,6 @@
</widget>
</item>
<item>
- <widget class="QPushButton" name="CancelButton" >
- <property name="text" >
- <string>Cancel</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="HelpButton" >
- <property name="text" >
- <string>Help</string>
- </property>
- </widget>
- </item>
- <item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx
index 367f6b3..0fa7441 100644
--- a/Source/QtDialog/QCMake.cxx
+++ b/Source/QtDialog/QCMake.cxx
@@ -248,3 +248,27 @@ QStringList QCMake::availableGenerators() const
return this->AvailableGenerators;
}
+void QCMake::deleteCache()
+{
+ // delete cache
+ this->CMakeInstance->GetCacheManager()->DeleteCache(this->BinaryDirectory.toAscii().data());
+ // reload to make our cache empty
+ this->CMakeInstance->GetCacheManager()->LoadCache(this->BinaryDirectory.toAscii().data());
+ // emit no generator and no properties
+ this->setGenerator(QString());
+ QCMakeCachePropertyList props = this->properties();
+ emit this->propertiesChanged(props);
+}
+
+void QCMake::reloadCache()
+{
+ // emit that the cache was cleaned out
+ QCMakeCachePropertyList props;
+ emit this->propertiesChanged(props);
+ // reload
+ this->CMakeInstance->GetCacheManager()->LoadCache(this->BinaryDirectory.toAscii().data());
+ // emit new cache properties
+ props = this->properties();
+ emit this->propertiesChanged(props);
+}
+
diff --git a/Source/QtDialog/QCMake.h b/Source/QtDialog/QCMake.h
index d28a917..0aeb8bc9 100644
--- a/Source/QtDialog/QCMake.h
+++ b/Source/QtDialog/QCMake.h
@@ -83,6 +83,10 @@ public slots:
void setProperties(const QCMakeCachePropertyList&);
/// interrupt the configure or generate process
void interrupt();
+ /// delete the cache in binary directory
+ void deleteCache();
+ /// reload the cache in binary directory
+ void reloadCache();
public:
/// get the list of cache properties