diff --git a/app/dialog/progress/progress.cpp b/app/dialog/progress/progress.cpp index f1f860f57..011980cb9 100644 --- a/app/dialog/progress/progress.cpp +++ b/app/dialog/progress/progress.cpp @@ -68,18 +68,14 @@ void ProgressDialog::showEvent(QShowEvent *e) elapsed_timer_lbl_->Start(); -#ifdef Q_OS_WINDOWS - Core::instance()->main_window()->SetTaskbarButtonState(TBPF_NORMAL); -#endif + Core::instance()->main_window()->SetApplicationProgressStatus(MainWindow::kProgressShow); } void ProgressDialog::closeEvent(QCloseEvent *e) { QDialog::closeEvent(e); -#ifdef Q_OS_WINDOWS - Core::instance()->main_window()->SetTaskbarButtonState(TBPF_NOPROGRESS); -#endif + Core::instance()->main_window()->SetApplicationProgressStatus(MainWindow::kProgressNone); } void ProgressDialog::SetProgress(double value) @@ -89,16 +85,12 @@ void ProgressDialog::SetProgress(double value) bar_->setValue(percent); elapsed_timer_lbl_->SetProgress(value); -#ifdef Q_OS_WINDOWS - Core::instance()->main_window()->SetTaskbarButtonProgress(percent, 100); -#endif + Core::instance()->main_window()->SetApplicationProgressValue(percent); } void ProgressDialog::ShowErrorMessage(const QString &title, const QString &message) { -#ifdef Q_OS_WINDOWS - Core::instance()->main_window()->SetTaskbarButtonState(TBPF_ERROR); -#endif + Core::instance()->main_window()->SetApplicationProgressStatus(MainWindow::kProgressError); QMessageBox b(this); b.setIcon(QMessageBox::Critical); diff --git a/app/window/mainwindow/mainwindow.cpp b/app/window/mainwindow/mainwindow.cpp index 049fa20d8..31239436d 100644 --- a/app/window/mainwindow/mainwindow.cpp +++ b/app/window/mainwindow/mainwindow.cpp @@ -191,22 +191,6 @@ bool MainWindow::IsSequenceOpen(Sequence *sequence) const return false; } -#ifdef Q_OS_WINDOWS -void MainWindow::SetTaskbarButtonState(TBPFLAG flags) -{ - if (taskbar_interface_) { - taskbar_interface_->SetProgressState(reinterpret_cast(this->winId()), flags); - } -} - -void MainWindow::SetTaskbarButtonProgress(int value, int max) -{ - if (taskbar_interface_) { - taskbar_interface_->SetProgressValue(reinterpret_cast(this->winId()), value, max); - } -} -#endif - void MainWindow::FolderOpen(Project* p, Item *i, bool floating) { ProjectPanel* panel = PanelManager::instance()->CreatePanel(this); @@ -356,6 +340,37 @@ void MainWindow::ProjectClose(Project *p) } } +void MainWindow::SetApplicationProgressStatus(ProgressStatus status) +{ +#if defined(Q_OS_WINDOWS) + if (taskbar_interface_) { + switch (status) { + case kProgressShow: + taskbar_interface_->SetProgressState(reinterpret_cast(this->winId()), TBPF_NORMAL); + break; + case kProgressNone: + taskbar_interface_->SetProgressState(reinterpret_cast(this->winId()), TBPF_NOPROGRESS); + break; + case kProgressError: + taskbar_interface_->SetProgressState(reinterpret_cast(this->winId()), TBPF_ERROR); + break; + } + } + +#elif defined(Q_OS_MAC) +#endif +} + +void MainWindow::SetApplicationProgressValue(int value) +{ +#if defined(Q_OS_WINDOWS) + if (taskbar_interface_) { + taskbar_interface_->SetProgressValue(reinterpret_cast(this->winId()), value, 100); + } +#elif defined(Q_OS_MAC) +#endif +} + void MainWindow::closeEvent(QCloseEvent *e) { // Try to close all projects (this will return false if the user chooses not to close) diff --git a/app/window/mainwindow/mainwindow.h b/app/window/mainwindow/mainwindow.h index 362b88ca4..21a6d561c 100644 --- a/app/window/mainwindow/mainwindow.h +++ b/app/window/mainwindow/mainwindow.h @@ -70,11 +70,26 @@ public: CurvePanel* AppendCurvePanel(); -#ifdef Q_OS_WINDOWS - void SetTaskbarButtonState(TBPFLAG flags); + enum ProgressStatus { + kProgressNone, + kProgressShow, + kProgressError + }; - void SetTaskbarButtonProgress(int value, int max); -#endif + /** + * @brief Where applicable, show progress on an operating system level + * + * * For Windows, this is shown as progress in the taskbar. + * * For macOS, this is shown as progress in the dock. + */ + void SetApplicationProgressStatus(ProgressStatus status); + + /** + * @brief If SetApplicationProgressStatus is set to kShowProgress, set the value with this + * + * Expects a percentage (0-100 inclusive). + */ + void SetApplicationProgressValue(int value); public slots: void ProjectOpen(Project *p);