From 01bafb43ad4e7fa242732977c3d01e4db266851e Mon Sep 17 00:00:00 2001 From: Guido Tack Date: Sat, 17 Oct 2015 14:31:42 +1100 Subject: [PATCH 1/3] Better handling of running processes (only disable the Run and Compile actions, but leave everything else enabled) --- MiniZincIDE/mainwindow.cpp | 73 ++++++++++++++++++++------------------ MiniZincIDE/mainwindow.h | 2 ++ 2 files changed, 40 insertions(+), 35 deletions(-) diff --git a/MiniZincIDE/mainwindow.cpp b/MiniZincIDE/mainwindow.cpp index 4c9e78b..2661a4b 100755 --- a/MiniZincIDE/mainwindow.cpp +++ b/MiniZincIDE/mainwindow.cpp @@ -546,7 +546,8 @@ MainWindow::MainWindow(const QString& project) : tmpDir(NULL), saveBeforeRunning(false), project(ui), - outputBuffer(NULL) + outputBuffer(NULL), + processRunning(false) { init(project); } @@ -560,7 +561,8 @@ MainWindow::MainWindow(const QStringList& files) : tmpDir(NULL), saveBeforeRunning(false), project(ui), - outputBuffer(NULL) + outputBuffer(NULL), + processRunning(false) { init(QString()); for (int i=0; isetEnabled(true); + ui->actionRun->setEnabled(false); + fakeCompileAction->setEnabled(true); + ui->actionCompile->setEnabled(false); + fakeStopAction->setEnabled(false); + ui->actionStop->setEnabled(true); + ui->actionSubmit_to_Coursera->setEnabled(false); + } else { + bool isMzn = false; + bool isFzn = false; + if (curEditor) { + isMzn = QFileInfo(curEditor->filepath).completeSuffix()=="mzn"; + isFzn = QFileInfo(curEditor->filepath).completeSuffix()=="fzn"; + } + fakeRunAction->setEnabled(! (isMzn || isFzn)); + ui->actionRun->setEnabled(isMzn || isFzn); + fakeCompileAction->setEnabled(!isMzn); + ui->actionCompile->setEnabled(isMzn); + fakeStopAction->setEnabled(true); + ui->actionStop->setEnabled(false); + ui->actionSubmit_to_Coursera->setEnabled(true); + } +} + void MainWindow::onActionProjectOpen_triggered() { activateFileInProject(projectSelectedIndex); @@ -1245,12 +1276,7 @@ void MainWindow::tabChange(int tab) { ui->actionSelect_All->setEnabled(true); ui->actionUndo->setEnabled(curEditor->document()->isUndoAvailable()); ui->actionRedo->setEnabled(curEditor->document()->isRedoAvailable()); - bool isMzn = QFileInfo(curEditor->filepath).completeSuffix()=="mzn"; - bool isFzn = QFileInfo(curEditor->filepath).completeSuffix()=="fzn"; - fakeRunAction->setEnabled(! (isMzn || isFzn)); - ui->actionRun->setEnabled(isMzn || isFzn); - fakeCompileAction->setEnabled(!isMzn); - ui->actionCompile->setEnabled(isMzn); + updateUiProcessRunning(processRunning); findDialog->setEditor(curEditor); ui->actionFind->setEnabled(true); @@ -1491,15 +1517,7 @@ void MainWindow::on_actionRun_triggered() } if (curEditor->document()->isModified()) return; - fakeRunAction->setEnabled(true); - ui->actionRun->setEnabled(false); - fakeCompileAction->setEnabled(true); - ui->actionCompile->setEnabled(false); - fakeStopAction->setEnabled(false); - ui->actionStop->setEnabled(true); - ui->configuration->setEnabled(false); - ui->tabWidget->setEnabled(false); - ui->actionSubmit_to_Coursera->setEnabled(false); + updateUiProcessRunning(true); on_actionSplit_triggered(); IDE::instance()->stats.modelsRun++; if (curEditor->filepath.endsWith(".fzn")) { @@ -1773,6 +1791,7 @@ bool MainWindow::runWithOutput(const QString &modelFile, const QString &dataFile outputBuffer = &outstream; compileOnly = false; project.timeLimit(timeout, true); + updateUiProcessRunning(true); on_actionSplit_triggered(); compileAndRun(modelFilePath,"",dataFilePath); return true; @@ -1799,15 +1818,7 @@ void MainWindow::pipeOutput() void MainWindow::procFinished(int, bool showTime) { readOutput(); - fakeRunAction->setEnabled(false); - ui->actionRun->setEnabled(true); - fakeCompileAction->setEnabled(false); - ui->actionCompile->setEnabled(true); - fakeStopAction->setEnabled(true); - ui->actionStop->setEnabled(false); - ui->configuration->setEnabled(true); - ui->tabWidget->setEnabled(true); - ui->actionSubmit_to_Coursera->setEnabled(true); + updateUiProcessRunning(false); timer->stop(); QString elapsedTime = setElapsedTime(); ui->statusbar->showMessage("Ready."); @@ -2151,15 +2162,7 @@ void MainWindow::on_actionCompile_triggered() } if (curEditor->document()->isModified()) return; - fakeRunAction->setEnabled(true); - ui->actionRun->setEnabled(false); - fakeCompileAction->setEnabled(true); - ui->actionCompile->setEnabled(false); - fakeStopAction->setEnabled(false); - ui->actionStop->setEnabled(true); - ui->configuration->setEnabled(false); - ui->tabWidget->setEnabled(false); - ui->actionSubmit_to_Coursera->setEnabled(false); + updateUiProcessRunning(true); compileOnly = true; checkArgs(curEditor->filepath); diff --git a/MiniZincIDE/mainwindow.h b/MiniZincIDE/mainwindow.h index 49d1e5a..7ba1d91 100644 --- a/MiniZincIDE/mainwindow.h +++ b/MiniZincIDE/mainwindow.h @@ -340,6 +340,7 @@ private slots: QAction* minimizeAction; QTextStream* outputBuffer; CourseraSubmission* courseraSubmission; + bool processRunning; void createEditor(const QString& path, bool openAsModified, bool isNewFile, bool readOnly=false); QStringList parseConf(bool compileOnly, bool useDataFile); @@ -355,6 +356,7 @@ private slots: void updateRecentProjects(const QString& p); void updateRecentFiles(const QString& p); void addFileToProject(bool dznOnly); + void updateUiProcessRunning(bool pr); public: void addOutput(const QString& s, bool html=true); void openProject(const QString& fileName); From 2e10caf5c565433347f6b5913e71d9fcfd4535c7 Mon Sep 17 00:00:00 2001 From: Guido Tack Date: Sat, 17 Oct 2015 18:16:33 +1100 Subject: [PATCH 2/3] Keep one setting for the editor font (previously each window had its own settings, which leads to strange results when the same file is open in more than one window) --- MiniZincIDE/mainwindow.cpp | 22 +++++++++++++++++----- MiniZincIDE/mainwindow.h | 1 + 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/MiniZincIDE/mainwindow.cpp b/MiniZincIDE/mainwindow.cpp index 2661a4b..e07ee65 100755 --- a/MiniZincIDE/mainwindow.cpp +++ b/MiniZincIDE/mainwindow.cpp @@ -360,6 +360,18 @@ void IDE::setLastPath(const QString& path) { settings.endGroup(); } +void IDE::setEditorFont(QFont font) +{ + QSettings settings; + settings.beginGroup("MainWindow"); + settings.setValue("editorFont", font); + settings.endGroup(); + for (QSet::iterator it = IDE::instance()->mainWindows.begin(); + it != IDE::instance()->mainWindows.end(); ++it) { + (*it)->setEditorFont(font); + } +} + void IDE::openFile() { QString fileName = QFileDialog::getOpenFileName(NULL, tr("Open File"), getLastPath(), "MiniZinc Files (*.mzn *.dzn *.fzn *.mzp)"); @@ -695,7 +707,7 @@ void MainWindow::init(const QString& projectFile) } settings.endGroup(); - setEditorFont(editorFont); + IDE::instance()->setEditorFont(editorFont); Solver g12fd("G12 fd","flatzinc","-Gg12_fd","",true,false); bool hadg12fd = false; @@ -2195,19 +2207,19 @@ void MainWindow::setEditorFont(QFont font) void MainWindow::on_actionBigger_font_triggered() { editorFont.setPointSize(editorFont.pointSize()+1); - setEditorFont(editorFont); + IDE::instance()->setEditorFont(editorFont); } void MainWindow::on_actionSmaller_font_triggered() { editorFont.setPointSize(std::max(5, editorFont.pointSize()-1)); - setEditorFont(editorFont); + IDE::instance()->setEditorFont(editorFont); } void MainWindow::on_actionDefault_font_size_triggered() { editorFont.setPointSize(13); - setEditorFont(editorFont); + IDE::instance()->setEditorFont(editorFont); } void MainWindow::on_actionAbout_MiniZinc_IDE_triggered() @@ -2323,7 +2335,7 @@ void MainWindow::on_actionSelect_font_triggered() QFont newFont = QFontDialog::getFont(&ok,editorFont,this); if (ok) { editorFont = newFont; - setEditorFont(editorFont); + IDE::instance()->setEditorFont(editorFont); } } diff --git a/MiniZincIDE/mainwindow.h b/MiniZincIDE/mainwindow.h index 7ba1d91..24eb0b0 100644 --- a/MiniZincIDE/mainwindow.h +++ b/MiniZincIDE/mainwindow.h @@ -103,6 +103,7 @@ class IDE : public QApplication { static IDE* instance(void); QString getLastPath(void); void setLastPath(const QString& path); + void setEditorFont(QFont font); protected: bool event(QEvent *); protected slots: From 3f973de9938e6d359c36d0290b06a21cfd34965a Mon Sep 17 00:00:00 2001 From: Guido Tack Date: Sat, 17 Oct 2015 18:19:03 +1100 Subject: [PATCH 3/3] Change log and bump version --- MiniZincIDE/CHANGES | 5 +++++ MiniZincIDE/MiniZincIDE.pro | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/MiniZincIDE/CHANGES b/MiniZincIDE/CHANGES index 2dde1a3..e6da3b1 100644 --- a/MiniZincIDE/CHANGES +++ b/MiniZincIDE/CHANGES @@ -1,3 +1,8 @@ +? + v2.0.8 + - Only disable the run and compile actions when a solving process is currently + running (keep editor and rest of the user interface enabled). + - Keep editor font setting synchronised across different IDE windows. 2015-10-06 v2.0.7 - Changed version number scheme to coincide with MiniZinc version. diff --git a/MiniZincIDE/MiniZincIDE.pro b/MiniZincIDE/MiniZincIDE.pro index f9455e7..b1485d5 100644 --- a/MiniZincIDE/MiniZincIDE.pro +++ b/MiniZincIDE/MiniZincIDE.pro @@ -11,7 +11,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = MiniZincIDE TEMPLATE = app -VERSION = 2.0.7 +VERSION = 2.0.8 DEFINES += MINIZINC_IDE_VERSION=\\\"$$VERSION\\\" bundled {