Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Introduce a hacky method to restart the application with the new sett…

…ings.
  • Loading branch information...
commit 9877baad0fd61e624c6100121fe89541907ed64c 1 parent de9c048
@wimleers authored
View
10 code/UI/SettingsDialog.cpp
@@ -23,6 +23,7 @@ SettingsDialog::SettingsDialog(QWidget * parent) :
mainLayout->addWidget(buttonBox);
// Connections.
+ connect(this, SIGNAL(settingsChanged()), SLOT(restart()));
connect(this->minSupport, SIGNAL(valueChanged(double)), SLOT(minSupportChanged(double)));
connect(this->minConfidence, SIGNAL(valueChanged(double)), SLOT(minConfidenceChanged(double)));
connect(this->patternTreeSupportErrorMargin, SIGNAL(valueChanged(double)), SLOT(patternTreeSupportErrorMarginChanged(double)));
@@ -95,6 +96,15 @@ void SettingsDialog::buttonSave() {
emit this->settingsChanged();
}
+void SettingsDialog::restart() {
+ // @see main.cpp
+ // exit()ing the application with this return code will simply restart the
+ // application!
+ // FIXME: this is *very* unelegant. Especially since the threads of
+ // MainWindow are not properly deleted.
+ qApp->exit(1000);
+}
+
QWidget * SettingsDialog::createAnalystTab() {
QSettings settings;
View
2  code/UI/SettingsDialog.h
@@ -39,6 +39,8 @@ protected slots:
void buttonCancel();
void buttonSave();
+ void restart();
+
protected:
QWidget * createAnalystTab();
QWidget * createParserTab();
View
21 code/main.cpp
@@ -11,14 +11,21 @@ int main(int argc, char *argv[]) {
// compiler warnings.
Q_UNUSED(cl);
- QApplication app(argc, argv);
+ const int RESTART_CODE = 1000;
+ int r;
- QCoreApplication::setOrganizationName("WimLeers");
- QCoreApplication::setOrganizationDomain("wimleers.com");
- QCoreApplication::setApplicationName("WPO Analytics");
+ do {
+ QApplication app(argc, argv);
- MainWindow * mainWindow = new MainWindow();
- mainWindow->show();
+ QCoreApplication::setOrganizationName("WimLeers");
+ QCoreApplication::setOrganizationDomain("wimleers.com");
+ QCoreApplication::setApplicationName("WPO Analytics");
- return app.exec();
+ MainWindow * mainWindow = new MainWindow();
+ mainWindow->show();
+
+ r = app.exec();
+ } while (r == RESTART_CODE);
+
+ return r;
}
Please sign in to comment.
Something went wrong with that request. Please try again.