GProgressDialog Mac QT 5.3.1 fixups

.. being more careful with modality and mainwindow
This commit is contained in:
Mark Liversedge
2014-06-30 18:03:44 +01:00
parent cb8a7edec3
commit 97aac8ea3e
5 changed files with 11 additions and 6 deletions

View File

@@ -18,16 +18,16 @@
#include "GProgressDialog.h"
GProgressDialog::GProgressDialog(QString title, int min, int max, QWidget *parent) :
GProgressDialog::GProgressDialog(QString title, int min, int max, bool modal, QWidget *parent) :
// sheet on mac and no window manager chrome
QDialog(parent, Qt::Sheet | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint),
QDialog(modal ? parent : NULL, Qt::Sheet | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint),
// defaults
title(title), min(min), max(max)
{
// only block mainwindow
setWindowModality(Qt::WindowModal); // only block mainwindow
if (modal) setWindowModality(Qt::WindowModal); // only block mainwindow
// zap me when closed and make me see through
setAttribute(Qt::WA_DeleteOnClose, true);

View File

@@ -35,7 +35,7 @@ class GProgressDialog : public QDialog
public:
// no frame, translucent, no button, no parent - always modal with chrome heading
GProgressDialog(QString title, int min, int max, QWidget *parent = NULL);
GProgressDialog(QString title, int min, int max, bool modal, QWidget *parent = NULL);
// set value, which in turn repaints the progress at the bottom
void setValue(int x);

View File

@@ -109,6 +109,7 @@ MainWindow::MainWindow(const QDir &home)
*--------------------------------------------------------------------*/
setAttribute(Qt::WA_DeleteOnClose);
mainwindows.append(this); // add us to the list of open windows
init = false;
#ifdef Q_OS_MAC
head = NULL; // early resize event causes a crash
#endif
@@ -713,6 +714,8 @@ MainWindow::MainWindow(const QDir &home)
// catch config changes
connect(context, SIGNAL(configChanged()), this, SLOT(configChanged()));
configChanged();
init = true;
}
/*----------------------------------------------------------------------

View File

@@ -66,6 +66,7 @@ class MainWindow : public QMainWindow
~MainWindow(); // temp to zap db - will move to tab //
void byebye() { close(); } // go bye bye for a restart
bool init; // if constructor has completed set to true
protected:

View File

@@ -165,7 +165,7 @@ void MetricAggregator::refreshMetrics(QDateTime forceAfterThisDate)
// create the dialog if we need to show progress for long running uodate
long elapsedtime = elapsed.elapsed();
if ((!forceAfterThisDate.isNull() || first || elapsedtime > 6000) && bar == NULL) {
bar = new GProgressDialog(title, 0, filenames.count()); // not owned by mainwindow
bar = new GProgressDialog(title, 0, filenames.count(), context->mainWindow->init, context->mainWindow);
bar->show(); // lets hide until elapsed time is > 6 seconds
// lets make sure it goes to the center!
@@ -516,7 +516,8 @@ MetricAggregator::refreshCPModelMetrics(bool bg)
// progress for the model parameters
GProgressDialog *bar = NULL;
if (!bg) {
bar = new GProgressDialog(tr("Update Model Estimates"), 1, (lastYear*12 + lastMonth) - (year*12 + month));
bar = new GProgressDialog(tr("Update Model Estimates"), 1, (lastYear*12 + lastMonth) - (year*12 + month),
context->mainWindow->init, context->mainWindow);
bar->setValue(1);
bar->show(); // lets hide until elapsed time is > 6 seconds
QApplication::processEvents();