Skip to content

Commit

Permalink
Merge branch 'release/2.0.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
guidotack committed Oct 19, 2015
2 parents 01d4917 + 3f973de commit 308d9ec
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 41 deletions.
5 changes: 5 additions & 0 deletions MiniZincIDE/CHANGES
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion MiniZincIDE/MiniZincIDE.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
95 changes: 55 additions & 40 deletions MiniZincIDE/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<MainWindow*>::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)");
Expand Down Expand Up @@ -546,7 +558,8 @@ MainWindow::MainWindow(const QString& project) :
tmpDir(NULL),
saveBeforeRunning(false),
project(ui),
outputBuffer(NULL)
outputBuffer(NULL),
processRunning(false)
{
init(project);
}
Expand All @@ -560,7 +573,8 @@ MainWindow::MainWindow(const QStringList& files) :
tmpDir(NULL),
saveBeforeRunning(false),
project(ui),
outputBuffer(NULL)
outputBuffer(NULL),
processRunning(false)
{
init(QString());
for (int i=0; i<files.size(); i++)
Expand Down Expand Up @@ -693,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;
Expand Down Expand Up @@ -879,6 +893,35 @@ void MainWindow::addFileToProject(bool dznOnly)
setupDznMenu();
}

void MainWindow::updateUiProcessRunning(bool pr)
{
processRunning = pr;

if (processRunning) {
fakeRunAction->setEnabled(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);
Expand Down Expand Up @@ -1245,12 +1288,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);
Expand Down Expand Up @@ -1491,15 +1529,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")) {
Expand Down Expand Up @@ -1773,6 +1803,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;
Expand All @@ -1799,15 +1830,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.");
Expand Down Expand Up @@ -2151,15 +2174,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);
Expand Down Expand Up @@ -2192,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()
Expand Down Expand Up @@ -2320,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);
}
}

Expand Down
3 changes: 3 additions & 0 deletions MiniZincIDE/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -340,6 +341,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);
Expand All @@ -355,6 +357,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);
Expand Down

0 comments on commit 308d9ec

Please sign in to comment.