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)
This commit is contained in:
parent
87e1004f25
commit
e8a208384c
@ -26,6 +26,8 @@
|
|||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QMenuBar>
|
||||||
|
|
||||||
#include "QCMake.h"
|
#include "QCMake.h"
|
||||||
#include "QCMakeCacheView.h"
|
#include "QCMakeCacheView.h"
|
||||||
@ -61,6 +63,7 @@ void QCMakeThread::run()
|
|||||||
}
|
}
|
||||||
|
|
||||||
CMakeSetupDialog::CMakeSetupDialog()
|
CMakeSetupDialog::CMakeSetupDialog()
|
||||||
|
: QuitOnConfigure(true)
|
||||||
{
|
{
|
||||||
// create the GUI
|
// create the GUI
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
@ -83,7 +86,34 @@ CMakeSetupDialog::CMakeSetupDialog()
|
|||||||
this->statusBar()->addPermanentWidget(this->InterruptButton);
|
this->statusBar()->addPermanentWidget(this->InterruptButton);
|
||||||
this->statusBar()->addPermanentWidget(this->ProgressBar);
|
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
|
// start the cmake worker thread
|
||||||
this->CMakeThread = new QCMakeThread(this);
|
this->CMakeThread = new QCMakeThread(this);
|
||||||
@ -110,10 +140,7 @@ void CMakeSetupDialog::initialize()
|
|||||||
this, SLOT(finishGenerate(int)));
|
this, SLOT(finishGenerate(int)));
|
||||||
|
|
||||||
QObject::connect(this->GenerateButton, SIGNAL(clicked(bool)),
|
QObject::connect(this->GenerateButton, SIGNAL(clicked(bool)),
|
||||||
this, SLOT(doOk()));
|
this, SLOT(doGenerate()));
|
||||||
|
|
||||||
QObject::connect(this->CancelButton, SIGNAL(clicked(bool)),
|
|
||||||
this, SLOT(close()));
|
|
||||||
|
|
||||||
QObject::connect(this->BrowseSourceDirectoryButton, SIGNAL(clicked(bool)),
|
QObject::connect(this->BrowseSourceDirectoryButton, SIGNAL(clicked(bool)),
|
||||||
this, SLOT(doSourceBrowse()));
|
this, SLOT(doSourceBrowse()));
|
||||||
@ -148,9 +175,6 @@ void CMakeSetupDialog::initialize()
|
|||||||
SIGNAL(outputMessage(QString)),
|
SIGNAL(outputMessage(QString)),
|
||||||
this->Output, SLOT(append(QString)));
|
this->Output, SLOT(append(QString)));
|
||||||
|
|
||||||
QObject::connect(this->HelpButton, SIGNAL(clicked(bool)),
|
|
||||||
this, SLOT(doHelp()));
|
|
||||||
|
|
||||||
QObject::connect(this->Advanced, SIGNAL(clicked(bool)),
|
QObject::connect(this->Advanced, SIGNAL(clicked(bool)),
|
||||||
this->CacheValues, SLOT(setShowAdvanced(bool)));
|
this->CacheValues, SLOT(setShowAdvanced(bool)));
|
||||||
QObject::connect(this->Search, SIGNAL(textChanged(QString)),
|
QObject::connect(this->Search, SIGNAL(textChanged(QString)),
|
||||||
@ -251,13 +275,13 @@ void CMakeSetupDialog::finishGenerate(int err)
|
|||||||
tr("Error in generation process, project files may be invalid"),
|
tr("Error in generation process, project files may be invalid"),
|
||||||
QMessageBox::Ok);
|
QMessageBox::Ok);
|
||||||
}
|
}
|
||||||
else
|
else if(this->QuitOnConfigure)
|
||||||
{
|
{
|
||||||
QApplication::quit();
|
QApplication::quit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMakeSetupDialog::doOk()
|
void CMakeSetupDialog::doGenerate()
|
||||||
{
|
{
|
||||||
this->InterruptButton->setEnabled(true);
|
this->InterruptButton->setEnabled(true);
|
||||||
this->setEnabledState(false);
|
this->setEnabledState(false);
|
||||||
@ -394,7 +418,6 @@ void CMakeSetupDialog::setEnabledState(bool enabled)
|
|||||||
this->BrowseBinaryDirectoryButton->setEnabled(enabled);
|
this->BrowseBinaryDirectoryButton->setEnabled(enabled);
|
||||||
this->ConfigureButton->setEnabled(enabled);
|
this->ConfigureButton->setEnabled(enabled);
|
||||||
this->GenerateButton->setEnabled(enabled);
|
this->GenerateButton->setEnabled(enabled);
|
||||||
this->CancelButton->setEnabled(enabled);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMakeSetupDialog::promptForGenerator()
|
void CMakeSetupDialog::promptForGenerator()
|
||||||
@ -434,4 +457,41 @@ void CMakeSetupDialog::updateGeneratorLabel(const QString& gen)
|
|||||||
this->Generator->setText(str);
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,8 +39,9 @@ public:
|
|||||||
protected slots:
|
protected slots:
|
||||||
void initialize();
|
void initialize();
|
||||||
void doConfigure();
|
void doConfigure();
|
||||||
void doOk();
|
void doGenerate();
|
||||||
void doHelp();
|
void doHelp();
|
||||||
|
void doAbout();
|
||||||
void doInterrupt();
|
void doInterrupt();
|
||||||
void finishConfigure(int error);
|
void finishConfigure(int error);
|
||||||
void finishGenerate(int error);
|
void finishGenerate(int error);
|
||||||
@ -48,12 +49,15 @@ protected slots:
|
|||||||
|
|
||||||
void doSourceBrowse();
|
void doSourceBrowse();
|
||||||
void doBinaryBrowse();
|
void doBinaryBrowse();
|
||||||
|
void doReloadCache();
|
||||||
|
void doDeleteCache();
|
||||||
void updateSourceDirectory(const QString& dir);
|
void updateSourceDirectory(const QString& dir);
|
||||||
void setBinaryDirectory(const QString& dir);
|
void setBinaryDirectory(const QString& dir);
|
||||||
void showProgress(const QString& msg, float percent);
|
void showProgress(const QString& msg, float percent);
|
||||||
void setEnabledState(bool);
|
void setEnabledState(bool);
|
||||||
void promptForGenerator();
|
void promptForGenerator();
|
||||||
void updateGeneratorLabel(const QString& gen);
|
void updateGeneratorLabel(const QString& gen);
|
||||||
|
void setExitAfterGenerate(bool);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent*);
|
void closeEvent(QCloseEvent*);
|
||||||
@ -61,6 +65,7 @@ protected:
|
|||||||
QCMakeThread* CMakeThread;
|
QCMakeThread* CMakeThread;
|
||||||
QProgressBar* ProgressBar;
|
QProgressBar* ProgressBar;
|
||||||
QToolButton* InterruptButton;
|
QToolButton* InterruptButton;
|
||||||
|
bool QuitOnConfigure;
|
||||||
};
|
};
|
||||||
|
|
||||||
// QCMake instance on a thread
|
// QCMake instance on a thread
|
||||||
|
@ -148,20 +148,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
<item>
|
||||||
<spacer>
|
<spacer>
|
||||||
<property name="orientation" >
|
<property name="orientation" >
|
||||||
|
@ -248,3 +248,27 @@ QStringList QCMake::availableGenerators() const
|
|||||||
return this->AvailableGenerators;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -83,6 +83,10 @@ public slots:
|
|||||||
void setProperties(const QCMakeCachePropertyList&);
|
void setProperties(const QCMakeCachePropertyList&);
|
||||||
/// interrupt the configure or generate process
|
/// interrupt the configure or generate process
|
||||||
void interrupt();
|
void interrupt();
|
||||||
|
/// delete the cache in binary directory
|
||||||
|
void deleteCache();
|
||||||
|
/// reload the cache in binary directory
|
||||||
|
void reloadCache();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// get the list of cache properties
|
/// get the list of cache properties
|
||||||
|
Loading…
x
Reference in New Issue
Block a user