ui: made os integration more universal
ProgressDialog doesn't have to worry about the platform anymore, now MainWindow will determine what to do or whether to ignore certain progress indicator functions.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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<HWND>(this->winId()), flags);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::SetTaskbarButtonProgress(int value, int max)
|
||||
{
|
||||
if (taskbar_interface_) {
|
||||
taskbar_interface_->SetProgressValue(reinterpret_cast<HWND>(this->winId()), value, max);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void MainWindow::FolderOpen(Project* p, Item *i, bool floating)
|
||||
{
|
||||
ProjectPanel* panel = PanelManager::instance()->CreatePanel<ProjectPanel>(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<HWND>(this->winId()), TBPF_NORMAL);
|
||||
break;
|
||||
case kProgressNone:
|
||||
taskbar_interface_->SetProgressState(reinterpret_cast<HWND>(this->winId()), TBPF_NOPROGRESS);
|
||||
break;
|
||||
case kProgressError:
|
||||
taskbar_interface_->SetProgressState(reinterpret_cast<HWND>(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<HWND>(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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user