From 63e4b1a6438c22006ea0dee098c9e068378432ab Mon Sep 17 00:00:00 2001 From: Mark Watkins <mark@jedimark.net> Date: Wed, 6 Jun 2018 10:48:31 +1000 Subject: [PATCH] Fix opengl screenshots on windows, remove the last of qprogress and statusbar, and add progressdialog to recompress/recalc --- .../loader_plugins/cms50f37_loader.cpp | 2 - .../loader_plugins/md300w1_loader.cpp | 2 - .../loader_plugins/mseries_loader.cpp | 2 - .../SleepLib/loader_plugins/resmed_loader.cpp | 4 +- .../loader_plugins/weinmann_loader.cpp | 2 - sleepyhead/SleepLib/machine.cpp | 28 +- sleepyhead/SleepLib/machine.h | 13 +- sleepyhead/daily.cpp | 1 - sleepyhead/main.cpp | 2 - sleepyhead/mainwindow.cpp | 285 ++++++------------ sleepyhead/mainwindow.h | 5 - sleepyhead/mainwindow.ui | 25 +- sleepyhead/overview.cpp | 3 +- sleepyhead/reports.cpp | 30 +- 14 files changed, 134 insertions(+), 270 deletions(-) diff --git a/sleepyhead/SleepLib/loader_plugins/cms50f37_loader.cpp b/sleepyhead/SleepLib/loader_plugins/cms50f37_loader.cpp index 5752cb02..3c1dcfde 100644 --- a/sleepyhead/SleepLib/loader_plugins/cms50f37_loader.cpp +++ b/sleepyhead/SleepLib/loader_plugins/cms50f37_loader.cpp @@ -33,8 +33,6 @@ using namespace std; #include "SleepLib/machine.h" #include "SleepLib/session.h" -extern QProgressBar *qprogress; - CMS50F37Loader::CMS50F37Loader() { m_type = MT_OXIMETER; diff --git a/sleepyhead/SleepLib/loader_plugins/md300w1_loader.cpp b/sleepyhead/SleepLib/loader_plugins/md300w1_loader.cpp index aa31c4b4..0631b88a 100644 --- a/sleepyhead/SleepLib/loader_plugins/md300w1_loader.cpp +++ b/sleepyhead/SleepLib/loader_plugins/md300w1_loader.cpp @@ -32,8 +32,6 @@ using namespace std; #include "SleepLib/machine.h" #include "SleepLib/session.h" -extern QProgressBar *qprogress; - MD300W1Loader::MD300W1Loader() { m_type = MT_OXIMETER; diff --git a/sleepyhead/SleepLib/loader_plugins/mseries_loader.cpp b/sleepyhead/SleepLib/loader_plugins/mseries_loader.cpp index 94ae5f75..4f62f814 100644 --- a/sleepyhead/SleepLib/loader_plugins/mseries_loader.cpp +++ b/sleepyhead/SleepLib/loader_plugins/mseries_loader.cpp @@ -10,8 +10,6 @@ #include <QProgressBar> #include "mseries_loader.h" -extern QProgressBar *qprogress; - MSeries::MSeries(Profile *profile, MachineID id) diff --git a/sleepyhead/SleepLib/loader_plugins/resmed_loader.cpp b/sleepyhead/SleepLib/loader_plugins/resmed_loader.cpp index 6fa314af..c9de3e9b 100644 --- a/sleepyhead/SleepLib/loader_plugins/resmed_loader.cpp +++ b/sleepyhead/SleepLib/loader_plugins/resmed_loader.cpp @@ -1135,7 +1135,7 @@ int ResmedLoader::scanFiles(Machine * mach, const QString & datalog_path) EDForder.push_back(EDF_SAD); QHash<EDFType, QStringList>::iterator gi; - qprogress->setMaximum(filesbytype[EDF_PLD].size() + filesbytype[EDF_BRP].size() + filesbytype[EDF_SAD].size()); + emit setProgressMax(filesbytype[EDF_PLD].size() + filesbytype[EDF_BRP].size() + filesbytype[EDF_SAD].size()); cnt = 0; for (int i=0; i<3; i++) { @@ -1146,7 +1146,7 @@ int ResmedLoader::scanFiles(Machine * mach, const QString & datalog_path) int base_size = LIST.size(); for (int f=0; f < base_size; ++f) { if ((cnt % 50) == 0) { - qprogress->setValue(cnt); + emit setProgressValue(cnt); QApplication::processEvents(); } cnt++; diff --git a/sleepyhead/SleepLib/loader_plugins/weinmann_loader.cpp b/sleepyhead/SleepLib/loader_plugins/weinmann_loader.cpp index 677156bc..9516ebce 100644 --- a/sleepyhead/SleepLib/loader_plugins/weinmann_loader.cpp +++ b/sleepyhead/SleepLib/loader_plugins/weinmann_loader.cpp @@ -16,8 +16,6 @@ #include "weinmann_loader.h" -extern QProgressBar *qprogress; - Weinmann::Weinmann(Profile *profile, MachineID id) : CPAP(profile, id) { diff --git a/sleepyhead/SleepLib/machine.cpp b/sleepyhead/SleepLib/machine.cpp index 4fbd309d..6dcbeec6 100644 --- a/sleepyhead/SleepLib/machine.cpp +++ b/sleepyhead/SleepLib/machine.cpp @@ -36,7 +36,6 @@ #include "mainwindow.h" extern MainWindow * mainwin; -extern QProgressBar *qprogress; ////////////////////////////////////////////////////////////////////////////////////////// // Machine Base-Class implmementation @@ -739,13 +738,14 @@ bool Machine::SaveSession(Session *sess) return true; } -void Machine::queSaveList(Session * sess) +/*void Machine::queSaveList(Session * sess) { if (!m_save_threads_running) { // Threads aren't being used.. so run the actual immediately... - int i = (float(m_donetasks) / float(m_totaltasks) * 100.0); - qprogress->setValue(i); - QApplication::processEvents(); + + int i = (float(m_donetasks) / float(m_totaltasks) * 100.0); + //qprogress->setValue(i); + //QApplication::processEvents(); sess->UpdateSummaries(); sess->Store(getDataPath()); @@ -759,7 +759,7 @@ void Machine::queSaveList(Session * sess) m_savelist.append(sess); listMutex.unlock(); } -} +}*/ Session *Machine::popSaveList() { @@ -776,7 +776,7 @@ Session *Machine::popSaveList() return sess; } -// Call any time queing starts +/*// Call any time queing starts void Machine::StartSaveThreads() { m_savelist.clear(); @@ -827,7 +827,7 @@ void Machine::FinishSaveThreads() } delete savelistSem; -} +} */ void SaveThread::run() { @@ -898,14 +898,16 @@ void Machine::runTasks() return; QThreadPool * threadpool = QThreadPool::globalInstance(); - int m_totaltasks=m_tasklist.size(); - int m_currenttask=0; - qprogress->setMaximum(m_totaltasks); + //int m_totaltasks=m_tasklist.size(); + //int m_currenttask=0; + // if (loader()) emit loader()->setProgressMax(m_totaltasks); while (!m_tasklist.isEmpty()) { if (threadpool->tryStart(m_tasklist.at(0))) { m_tasklist.pop_front(); - qprogress->setValue(m_currenttask++); - QApplication::processEvents(); +/* if (loader()) { + emit loader()->setProgressValue(++m_currenttask); + QApplication::processEvents(); + }*/ } } QThreadPool::globalInstance()->waitForDone(-1); diff --git a/sleepyhead/SleepLib/machine.h b/sleepyhead/SleepLib/machine.h index 91595332..94e6ae2e 100644 --- a/sleepyhead/SleepLib/machine.h +++ b/sleepyhead/SleepLib/machine.h @@ -18,7 +18,6 @@ #include <QThread> #include <QMutex> #include <QSemaphore> -#include <QProgressBar> #include <QHash> #include <QVector> @@ -160,19 +159,19 @@ class Machine //! \brief Returns the date of the most recent loaded Session const QDate &LastDay() { return lastday; } - //! \brief Add a new task to the multithreaded save code - void queSaveList(Session * sess); + // //! \brief Add a new task to the multithreaded save code + //void queSaveList(Session * sess); bool hasModifiedSessions(); //! \brief Grab the next task in the multithreaded save code Session *popSaveList(); - //! \brief Start the save threads which handle indexing, file storage and waveform processing - void StartSaveThreads(); + // //! \brief Start the save threads which handle indexing, file storage and waveform processing + //void StartSaveThreads(); - //! \brief Finish the save threads and safely close them - void FinishSaveThreads(); + // //! \brief Finish the save threads and safely close them + //void FinishSaveThreads(); //! \brief The list of sessions that need saving (for multithreaded save code) QList<Session *> m_savelist; diff --git a/sleepyhead/daily.cpp b/sleepyhead/daily.cpp index d5ccc30e..9cc5d139 100644 --- a/sleepyhead/daily.cpp +++ b/sleepyhead/daily.cpp @@ -40,7 +40,6 @@ #include "Graphs/gdailysummary.h" #include "Graphs/MinutesAtPressure.h" -//extern QProgressBar *qprogress; extern MainWindow * mainwin; // This was Sean Stangl's idea.. but I couldn't apply that patch. diff --git a/sleepyhead/main.cpp b/sleepyhead/main.cpp index b7d6279d..032f8f56 100644 --- a/sleepyhead/main.cpp +++ b/sleepyhead/main.cpp @@ -16,7 +16,6 @@ #include "version.h" #include "logger.h" -#include "SleepLib/schema.h" #include "mainwindow.h" #include "SleepLib/profiles.h" #include "translation.h" @@ -264,7 +263,6 @@ retry_directory: CMS50Loader::Register(); CMS50F37Loader::Register(); MD300W1Loader::Register(); - //ZEOLoader::Register(); // Use outside of directory importer.. schema::setOrders(); // could be called in init... diff --git a/sleepyhead/mainwindow.cpp b/sleepyhead/mainwindow.cpp index 74ac723d..db2dbe11 100644 --- a/sleepyhead/mainwindow.cpp +++ b/sleepyhead/mainwindow.cpp @@ -29,6 +29,7 @@ #include <QTextBrowser> #include <QStandardPaths> #include <QDesktopServices> +#include <QScreen> #include <cmath> #include "common_gui.h" @@ -63,10 +64,6 @@ #include <QOpenGLFunctions> #endif -QProgressBar *qprogress; -QLabel *qstatus; -QStatusBar *qstatusbar; - MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) @@ -113,15 +110,6 @@ MainWindow::MainWindow(QWidget *parent) : m_inRecalculation = false; m_restartRequired = false; // Initialize Status Bar objects - qstatusbar = ui->statusbar; - qprogress = new QProgressBar(this); - qprogress->setMaximum(100); - qstatus = new QLabel("", this); - qprogress->hide(); - //ui->statusbar->setMinimumWidth(200); - ui->statusbar->addPermanentWidget(qstatus, 0); - ui->statusbar->addPermanentWidget(qprogress, 1); - QTextCharFormat format = ui->statStartDate->calendarWidget()->weekdayTextFormat(Qt::Saturday); format.setForeground(QBrush(Qt::black, Qt::SolidPattern)); @@ -217,10 +205,10 @@ MainWindow::MainWindow(QWidget *parent) : QString loadingtxt = "<HTML><body style='text-align: center; vertical-align: center'><table width='100%' height='100%'>" "<tr><td align=center>" - "<img src='qrc:/docs/sheep.png' heigh=300px>" - //"<h1>" + tr("Please Wait, Loading...") + "</h1>" + "<img src='qrc:/docs/sheep.png'>" + "<h1>" + tr("Under construction...") + "</h1>" "</td></tr></table></body></HTML>"; - ui->statisticsView->setHtml(loadingtxt); + ui->helpBrowser->setHtml(loadingtxt); on_tabWidget_currentChanged(0); #ifndef REMSTAR_M_SUPPORT @@ -322,8 +310,6 @@ void MainWindow::Notify(QString s, QString title, int ms) #endif systray->showMessage(title, msg, QSystemTrayIcon::Information, ms); - } else { - ui->statusbar->showMessage(s, ms); } } @@ -427,9 +413,6 @@ bool MainWindow::OpenProfile(QString profileName, bool skippassword) prof->removeLock(); } -// qstatus->setText(tr("Loading Data")); -// qprogress->show(); - p_profile = prof; ProgressDialog * progress = new ProgressDialog(this); @@ -524,9 +507,6 @@ bool MainWindow::OpenProfile(QString profileName, bool skippassword) progress->close(); delete progress; - - //qprogress->hide(); - //qstatus->setText(""); return true; } @@ -962,10 +942,6 @@ void MainWindow::on_action_Import_Data_triggered() // QStringList goodlocations; -// waitmsg.setText(tr("Please wait, SleepyHead is importing data...")); -// qprogress->setVisible(true); - -// popup.show(); ProgressDialog * prog = new ProgressDialog(this); prog->setMessage(tr("Processing import list...")); prog->addAbortButton(); @@ -1329,10 +1305,18 @@ void MainWindow::on_action_Screenshot_triggered() void MainWindow::DelayedScreenshot() { // Make sure to scale for high resolution displays (like Retina) - qreal pr = devicePixelRatio(); + // qreal pr = devicePixelRatio(); - QPixmap pixmap=grab(); + QScreen * screen = QApplication::primaryScreen(); + + + int titleBarHeight = -QApplication::style()->pixelMetric(QStyle::PM_TitleBarHeight); +#ifdef Q_OS_WIN + titleBarHeight += 6; +#endif + + QPixmap pixmap = screen->grabWindow(winId(),0,titleBarHeight); /*#if defined(Q_OS_WIN) || defined(Q_OS_LINUX) || defined(Q_OS_HAIKU) // grab the whole screen @@ -1370,10 +1354,6 @@ void MainWindow::on_actionView_Oximetry_triggered() { on_oximetryButton_clicked(); } -void MainWindow::updatestatusBarMessage(const QString &text) -{ - ui->statusbar->showMessage(text, 1000); -} void MainWindow::on_actionPrint_Report_triggered() { @@ -2030,13 +2010,6 @@ void MainWindow::on_actionView_Statistics_triggered() ui->tabWidget->setCurrentWidget(ui->statisticsTab); } -void MainWindow::LinkHovered(const QString &link, const QString &title, const QString &textContent) -{ - Q_UNUSED(title); - Q_UNUSED(textContent); - ui->statusbar->showMessage(link); -} - void MainWindow::on_tabWidget_currentChanged(int index) { Q_UNUSED(index); @@ -2101,181 +2074,111 @@ void MainWindow::MachineUnsupported(Machine * m) void MainWindow::doRecompressEvents() { - if (p_profile->countDays(MT_CPAP, p_profile->FirstDay(), p_profile->LastDay()) == 0) { - return; - } - m_inRecalculation = true; - QDate first = p_profile->FirstDay(); - QDate date = p_profile->LastDay(); - Session *sess; - Day *day; - //FlowParser flowparser; - - mainwin->Notify(tr("Performance will be degraded during these recalculations."), - tr("Recalculating Indices")); - - // For each day in history - int daycount = first.daysTo(date); - int idx = 0; - - qstatus->setText(tr("Re/Decompressing Session Event Data")); - - if (qprogress) { - qprogress->setValue(0); - qprogress->setVisible(true); - qprogress->setMaximum(daycount); - } + if (!p_profile) return; + ProgressDialog progress(this); + progress.setMessage("Recompressing Session Files"); + progress.setProgressMax(p_profile->daylist.size()); + QPixmap icon = QPixmap(":/docs/sheep.png").scaled(64,64); + progress.setPixmap(icon); + progress.open(); bool isopen; + int idx = 0; + for (Day * day : p_profile->daylist) { + for (Session * sess : day->sessions) { + isopen = sess->eventsLoaded(); + // Load the events and summary if they aren't loaded already + sess->LoadSummary(); + sess->OpenEvents(); + sess->SetChanged(true); + sess->machine()->SaveSession(sess); - do { - day = p_profile->GetDay(date, MT_CPAP); - - if (day) { - for (int i = 0; i < day->size(); i++) { - sess = (*day)[i]; - isopen = sess->eventsLoaded(); - - // Load the events if they aren't loaded already - sess->OpenEvents(); - sess->SetChanged(true); - sess->machine()->SaveSession(sess); - - if (!isopen) { - sess->TrashEvents(); - } + if (!isopen) { + sess->TrashEvents(); } } - - date = date.addDays(-1); - qprogress->setValue(idx); + progress.setProgressValue(++idx); QApplication::processEvents(); - idx++; - } while (date >= first); - - qstatus->setText(tr("")); - qprogress->setVisible(false); - m_inRecalculation = false; - - Notify(tr("Session re/decompression are now complete."), tr("Task Completed")); + } + progress.close(); } void MainWindow::doReprocessEvents() { - if (p_profile->countDays(MT_CPAP, p_profile->FirstDay(), p_profile->LastDay()) == 0) { - return; + if (!p_profile) return; + + ProgressDialog progress(this); + progress.setMessage("Recalculating summaries"); + progress.setProgressMax(p_profile->daylist.size()); + QPixmap icon = QPixmap(":/docs/sheep.png").scaled(64,64); + progress.setPixmap(icon); + progress.open(); + + if (daily) { + daily->Unload(); + daily->clearLastDay(); // otherwise Daily will crash + delete daily; + daily = nullptr; + } + if (welcome) { + delete welcome; + welcome = nullptr; + } + if (overview) { + delete overview; + overview = nullptr; } - m_inRecalculation = true; - QDate first = p_profile->FirstDay(); - QDate date = p_profile->LastDay(); - Session *sess; - Day *day; - //FlowParser flowparser; + for (Day * day : p_profile->daylist) { + for (Session * sess : day->sessions) { + bool isopen = sess->eventsLoaded(); - mainwin->Notify(tr("Performance will be degraded during these recalculations."), - tr("Recompressing Session Data")); + // Load the events if they aren't loaded already + sess->LoadSummary(); + sess->OpenEvents(); - // For each day in history - int daycount = first.daysTo(date); - int idx = 0; + // Destroy any current user flags.. + sess->destroyEvent(CPAP_UserFlag1); + sess->destroyEvent(CPAP_UserFlag2); + sess->destroyEvent(CPAP_UserFlag3); - QList<Machine *> machines = p_profile->GetMachines(MT_CPAP); + // AHI flags + sess->destroyEvent(CPAP_AHI); + sess->destroyEvent(CPAP_RDI); + if (sess->machine()->loaderName() != STR_MACH_PRS1) { + sess->destroyEvent(CPAP_LargeLeak); + } else { + sess->destroyEvent(CPAP_Leak); + } - // Disabling multithreaded save as it appears it's causing problems - bool cache_sessions = false; //p_profile->session->cacheSessions(); + sess->SetChanged(true); - if (cache_sessions) { // Use multithreaded save to handle reindexing.. (hogs memory like hell) - qstatus->setText(tr("Loading Event Data")); - } else { - qstatus->setText(tr("Recalculating Summaries")); - } + sess->UpdateSummaries(); + sess->machine()->SaveSession(sess); - if (qprogress) { - qprogress->setValue(0); - qprogress->setVisible(true); - qprogress->setMaximum(daycount); - } - - bool isopen; - - do { - day = p_profile->GetDay(date, MT_CPAP); - - if (day) { - for (int i = 0; i < day->size(); i++) { - sess = (*day)[i]; - isopen = sess->eventsLoaded(); - - // Load the events if they aren't loaded already - sess->OpenEvents(); - - //if (!sess->channelDataExists(CPAP_FlowRate)) continue; - - //QVector<EventList *> & flowlist=sess->eventlist[CPAP_FlowRate]; - - // Destroy any current user flags.. - sess->destroyEvent(CPAP_UserFlag1); - sess->destroyEvent(CPAP_UserFlag2); - sess->destroyEvent(CPAP_UserFlag3); - - // AHI flags - sess->destroyEvent(CPAP_AHI); - sess->destroyEvent(CPAP_RDI); - - if (sess->machine()->loaderName() != STR_MACH_PRS1) { - sess->destroyEvent(CPAP_LargeLeak); - } else { - sess->destroyEvent(CPAP_Leak); - } - - sess->SetChanged(true); - - if (!cache_sessions) { - sess->UpdateSummaries(); - sess->machine()->SaveSession(sess); - - if (!isopen) { - sess->TrashEvents(); - } - } + if (!isopen) { + sess->TrashEvents(); } } - - date = date.addDays(-1); - - qprogress->setValue(++idx); - QApplication::processEvents(); - - } while (date >= first); - - if (cache_sessions) { - qstatus->setText(tr("Recalculating Summaries")); - - for (int i = 0; i < machines.size(); i++) { - machines.at(i)->Save(); - } } + progress.close(); - qstatus->setText(tr("")); - qprogress->setVisible(false); - m_inRecalculation = false; + welcome = new Welcome(ui->tabWidget); + ui->tabWidget->insertTab(1, welcome, tr("Welcome")); - if (m_restartRequired) { - QMessageBox::information(this, tr("Restart Required"), - tr("Recalculations are complete, the application now needs to restart to display the changes."), - QMessageBox::Ok); - RestartApplication(); - return; - } else { - Notify(tr("Recalculations are now complete."), tr("Task Completed")); + daily = new Daily(ui->tabWidget, nullptr); + ui->tabWidget->insertTab(2, daily, STR_TR_Daily); + daily->ReloadGraphs(); - FreeSessions(); - QDate current = daily->getDate(); - daily->LoadDate(current); + overview = new Overview(ui->tabWidget, daily->graphView()); + ui->tabWidget->insertTab(3, overview, STR_TR_Overview); + overview->ReloadGraphs(); + + // Should really create welcome and statistics here, but they need redoing later anyway to kill off webkit + ui->tabWidget->setCurrentIndex(AppSetting->openTabAtStart()); + GenerateStatistics(); + PopulatePurgeMenu(); - if (overview) { overview->ReloadGraphs(); } - } } void MainWindow::on_actionImport_ZEO_Data_triggered() diff --git a/sleepyhead/mainwindow.h b/sleepyhead/mainwindow.h index 4ce8856d..294a3afc 100644 --- a/sleepyhead/mainwindow.h +++ b/sleepyhead/mainwindow.h @@ -223,9 +223,6 @@ class MainWindow : public QMainWindow //! \brief a slot that calls the real Oximetry tab selector void on_actionView_Oximetry_triggered(); - //! \brief Updates the Statusbar message with the QString message contained in Text - void updatestatusBarMessage(const QString &text); - //! \brief Passes the Daily, Overview & Oximetry object to Print Report, based on current tab void on_actionPrint_Report_triggered(); @@ -259,8 +256,6 @@ class MainWindow : public QMainWindow //void on_favouritesList_itemClicked(QListWidgetItem *item); - //! \brief Display Help WebView Link in statusbar. - void LinkHovered(const QString &link, const QString &title, const QString &textContent); void on_tabWidget_currentChanged(int index); void on_filterBookmarks_editingFinished(); diff --git a/sleepyhead/mainwindow.ui b/sleepyhead/mainwindow.ui index f0c9d3cc..148e7cea 100644 --- a/sleepyhead/mainwindow.ui +++ b/sleepyhead/mainwindow.ui @@ -1403,8 +1403,8 @@ QToolBox::tab:selected { <rect> <x>0</x> <y>0</y> - <width>310</width> - <height>676</height> + <width>327</width> + <height>687</height> </rect> </property> <property name="palette"> @@ -1862,7 +1862,7 @@ border: 2px solid #56789a; border-radius: 30px; <x>0</x> <y>0</y> <width>327</width> - <height>667</height> + <height>687</height> </rect> </property> <property name="palette"> @@ -2918,7 +2918,7 @@ p, li { white-space: pre-wrap; } <x>0</x> <y>0</y> <width>327</width> - <height>667</height> + <height>687</height> </rect> </property> <property name="mouseTracking"> @@ -3097,23 +3097,6 @@ p, li { white-space: pre-wrap; } <addaction name="menu_Data"/> <addaction name="menu_Help"/> </widget> - <widget class="QStatusBar" name="statusbar"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="maximumSize"> - <size> - <width>16777215</width> - <height>20</height> - </size> - </property> - <property name="sizeGripEnabled"> - <bool>true</bool> - </property> - </widget> <action name="action_Import_Data"> <property name="text"> <string>&Import Data</string> diff --git a/sleepyhead/overview.cpp b/sleepyhead/overview.cpp index 17eea819..7ec246b2 100644 --- a/sleepyhead/overview.cpp +++ b/sleepyhead/overview.cpp @@ -1,4 +1,4 @@ -/* Overview GUI Implementation +/* Overview GUI Implementation * * Copyright (c) 2011-2018 Mark Watkins <mark@jedimark.net> * @@ -26,7 +26,6 @@ #include "mainwindow.h" extern MainWindow *mainwin; -//extern QProgressBar * qprogress; Overview::Overview(QWidget *parent, gGraphView *shared) : QWidget(parent), diff --git a/sleepyhead/reports.cpp b/sleepyhead/reports.cpp index e44a1c6c..1f2a4d74 100644 --- a/sleepyhead/reports.cpp +++ b/sleepyhead/reports.cpp @@ -10,15 +10,14 @@ #include <QtPrintSupport/qprinter.h> #include <QtPrintSupport/qprintdialog.h> #include <QTextDocument> -#include <QProgressBar> #include <QApplication> #include <cmath> #include "reports.h" #include "mainwindow.h" #include "common_gui.h" +#include "SleepLib/progressdialog.h" -extern QProgressBar *qprogress; extern MainWindow *mainwin; @@ -93,12 +92,14 @@ void Report::PrintReport(gGraphView *gv, QString name, QDate date) return; } + QPainter painter(printer); + + ProgressDialog progress(mainwin); + progress.setMessage(QObject::tr("Printing %1 Report").arg(name)); + QPixmap icon = QPixmap(":/docs/sheep.png").scaled(64,64); + progress.setPixmap(icon); + progress.open(); - mainwin->Notify( - QObject::tr("This make take some time to complete..\nPlease don't touch anything until it's done."), - QObject::tr("Printing %1 Report").arg(name), 20000); - QPainter painter; - painter.begin(printer); GLint gw; gw = 2048; // Rough guess.. No GL_MAX_RENDERBUFFER_SIZE in mingw.. :( @@ -526,11 +527,7 @@ void Report::PrintReport(gGraphView *gv, QString name, QDate date) int pages = ceil(float(graphs.size() + graph_slots) / float(graphs_per_page)); - if (qprogress) { - qprogress->setValue(0); - qprogress->setMaximum(graphs.size()); - qprogress->show(); - } + progress.setProgressMax(graphs.size()); int page = 1; int gcnt = 0; @@ -614,17 +611,14 @@ void Report::PrintReport(gGraphView *gv, QString name, QDate date) gcnt++; - if (qprogress) { - qprogress->setValue(i); - QApplication::processEvents(); - } + progress.setProgressValue(i); + QApplication::processEvents(); } gv->SetXBounds(savest, saveet); - qprogress->hide(); painter.end(); + progress.close(); delete printer; - mainwin->Notify(QObject::tr("SleepyHead has finished sending the job to the printer.")); AppSetting->setLineCursorMode(lineCursorMode); }