From 2864478b001688d3563ade9fe27e7af5834afca3 Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Thu, 23 Dec 2021 19:14:25 +0100 Subject: [PATCH] Improved loading of icon files. --- src/Dialog_Processing.cpp | 18 +++++++------ src/Dialog_Processing.h | 4 +++ src/Dialog_Update.cpp | 51 ++++++++++++++++++++---------------- src/Dialog_Update.h | 9 +++++++ src/Dialog_WorkingBanner.cpp | 7 +++-- src/Dialog_WorkingBanner.h | 1 + 6 files changed, 56 insertions(+), 34 deletions(-) diff --git a/src/Dialog_Processing.cpp b/src/Dialog_Processing.cpp index 9dbeb3c4..0e633fcd 100644 --- a/src/Dialog_Processing.cpp +++ b/src/Dialog_Processing.cpp @@ -193,6 +193,12 @@ ProcessingDialog::ProcessingDialog(FileListModel *const fileListModel, const Aud ui->label_headerWorking->setMovie(m_progressIndicator.data()); ui->progressBar->setValue(0); + //Load overlay icons + m_iconRunning.reset(new QIcon(":/icons/control_play_blue.png")); + m_iconError.reset (new QIcon(":/icons/error.png")); + m_iconWarning.reset(new QIcon(":/icons/exclamation.png")); + m_iconSuccess.reset(new QIcon(":/icons/accept.png")); + //Init progress model m_progressModel.reset(new ProgressModel()); ui->view_log->setModel(m_progressModel.data()); @@ -491,10 +497,9 @@ void ProcessingDialog::initEncoding(void) ui->checkBox_shutdownComputer->setEnabled(true); ui->checkBox_shutdownComputer->setChecked(false); - QIcon defaultIcon(":/icons/control_play_blue.png"); m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_NORMAL); m_taskbar->setTaskbarProgress(0, m_pendingJobs.count()); - m_taskbar->setOverlayIcon(&defaultIcon); + m_taskbar->setOverlayIcon(m_iconRunning.data()); if(!m_diskObserver) { @@ -693,10 +698,9 @@ void ProcessingDialog::doneEncoding(void) if(m_userAborted) { - QIcon errorIcon(":/icons/error.png"); CHANGE_BACKGROUND_COLOR(ui->frame_header, QColor("#FFFFE0")); m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_ERROR); - m_taskbar->setOverlayIcon(&errorIcon); + m_taskbar->setOverlayIcon(m_iconError.data()); SET_PROGRESS_TEXT((m_succeededJobs.count() > 0) ? tr("Process was aborted by the user after %n file(s)!", "", m_succeededJobs.count()) : tr("Process was aborted prematurely by the user!")); m_systemTray->showMessage(tr("LameXP - Aborted"), tr("Process was aborted by the user."), QSystemTrayIcon::Warning); m_systemTray->setIcon(QIcon(":/icons/cd_delete.png")); @@ -713,10 +717,9 @@ void ProcessingDialog::doneEncoding(void) if(m_failedJobs.count() > 0) { - QIcon warningIcon(":/icons/exclamation.png"); CHANGE_BACKGROUND_COLOR(ui->frame_header, QColor("#FFF0F0")); m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_ERROR); - m_taskbar->setOverlayIcon(&warningIcon); + m_taskbar->setOverlayIcon(m_iconWarning.data()); if(m_skippedJobs.count() > 0) { SET_PROGRESS_TEXT(tr("Error: %1 of %n file(s) failed (%2). Double-click failed items for detailed information!", "", m_failedJobs.count() + m_succeededJobs.count() + m_skippedJobs.count()).arg(QString::number(m_failedJobs.count()), tr("%n file(s) skipped", "", m_skippedJobs.count()))); @@ -732,10 +735,9 @@ void ProcessingDialog::doneEncoding(void) } else { - QIcon successIcon(":/icons/accept.png"); CHANGE_BACKGROUND_COLOR(ui->frame_header, QColor("#F0FFF0")); m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_NORMAL); - m_taskbar->setOverlayIcon(&successIcon); + m_taskbar->setOverlayIcon(m_iconSuccess.data()); if(m_skippedJobs.count() > 0) { SET_PROGRESS_TEXT(tr("All files completed successfully. Skipped %n file(s).", "", m_skippedJobs.count())); diff --git a/src/Dialog_Processing.h b/src/Dialog_Processing.h index 0541b943..d789673d 100644 --- a/src/Dialog_Processing.h +++ b/src/Dialog_Processing.h @@ -146,6 +146,10 @@ private: QScopedPointer m_defaultColor; QScopedPointer m_fileExts; QScopedPointer m_taskbar; + QScopedPointer m_iconRunning; + QScopedPointer m_iconError; + QScopedPointer m_iconWarning; + QScopedPointer m_iconSuccess; static bool isFastSeekingDevice(const QString &path); static quint32 cores2instances(const quint32 &cores); diff --git a/src/Dialog_Update.cpp b/src/Dialog_Update.cpp index 1cbac08c..85351d53 100644 --- a/src/Dialog_Update.cpp +++ b/src/Dialog_Update.cpp @@ -55,7 +55,7 @@ #define SHOW_HINT(TEXT, ICON) do \ { \ ui->hintLabel->setText((TEXT)); \ - ui->hintIcon->setPixmap(QIcon((ICON)).pixmap(16,16)); \ + ui->hintIcon->setPixmap((ICON)->pixmap(16,16)); \ ui->hintIcon->show(); \ ui->hintLabel->show(); \ } \ @@ -63,9 +63,8 @@ while(0) #define UPDATE_TASKBAR(STATE, ICON) do \ { \ - QIcon _icon((ICON)); \ m_taskbar->setTaskbarState((STATE)); \ - m_taskbar->setOverlayIcon(&_icon); \ + m_taskbar->setOverlayIcon((ICON).data()); \ } \ while(0) @@ -100,6 +99,16 @@ UpdateDialog::UpdateDialog(const SettingsModel *const settings, QWidget *parent) //Disable "X" button MUtils::GUI::enable_close_button(this, false); + //Load the icons + m_iconTransmitting.reset (new QIcon(":/icons/transmit_blue.png")); + m_iconFailure.reset (new QIcon(":/icons/exclamation.png")); + m_iconUpdateAvailable.reset(new QIcon(":/icons/shield_exclamation.png")); + m_iconNoUpdates.reset (new QIcon(":/icons/shield_green.png")); + m_iconNewVersionOlder.reset(new QIcon(":/icons/shield_blue.png")); + m_iconVersionError.reset (new QIcon(":/icons/shield_error.png")); + m_iconNetworkError.reset (new QIcon(":/icons/network_error.png")); + m_iconServerError.reset (new QIcon(":/icons/server_error.png")); + //Init animation m_animator.reset(new QMovie(":/images/Loading3.gif")); ui->labelAnimationCenter->setMovie(m_animator.data()); @@ -259,9 +268,8 @@ void UpdateDialog::checkForUpdates(void) } } - QIcon defaultIcon(":/icons/transmit_blue.png"); m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_NORMAL); - m_taskbar->setOverlayIcon(&defaultIcon); + m_taskbar->setOverlayIcon(m_iconTransmitting.data()); ui->progressBar->setValue(0); ui->installButton->setEnabled(false); @@ -296,38 +304,38 @@ void UpdateDialog::threadStatusChanged(const int status) break; case MUtils::UpdateChecker::UpdateStatus_CompletedUpdateAvailable: ui->statusLabel->setText(tr("A new version of LameXP is available!")); - SHOW_HINT(tr("We highly recommend all users to install this update as soon as possible."), ":/icons/shield_exclamation.png"); - UPDATE_TASKBAR(MUtils::Taskbar7::TASKBAR_STATE_NORMAL, ":/icons/shield_exclamation.png"); + SHOW_HINT(tr("We highly recommend all users to install this update as soon as possible."), m_iconUpdateAvailable); + UPDATE_TASKBAR(MUtils::Taskbar7::TASKBAR_STATE_NORMAL, m_iconUpdateAvailable); break; case MUtils::UpdateChecker::UpdateStatus_CompletedNoUpdates: ui->statusLabel->setText(tr("No new updates available at this time.")); - SHOW_HINT(tr("Your version of LameXP is still up-to-date. Please check for updates regularly!"), ":/icons/shield_green.png"); - UPDATE_TASKBAR(MUtils::Taskbar7::TASKBAR_STATE_NORMAL, ":/icons/shield_green.png"); + SHOW_HINT(tr("Your version of LameXP is still up-to-date. Please check for updates regularly!"), m_iconNoUpdates); + UPDATE_TASKBAR(MUtils::Taskbar7::TASKBAR_STATE_NORMAL, m_iconNoUpdates); break; case MUtils::UpdateChecker::UpdateStatus_CompletedNewVersionOlder: ui->statusLabel->setText(tr("Your version appears to be newer than the latest release.")); - SHOW_HINT(tr("This usually indicates your are currently using a pre-release version of LameXP."), ":/icons/shield_blue.png"); - UPDATE_TASKBAR(MUtils::Taskbar7::TASKBAR_STATE_NORMAL, ":/icons/shield_error.png"); + SHOW_HINT(tr("This usually indicates your are currently using a pre-release version of LameXP."), m_iconNewVersionOlder); + UPDATE_TASKBAR(MUtils::Taskbar7::TASKBAR_STATE_NORMAL, m_iconVersionError); break; case MUtils::UpdateChecker::UpdateStatus_ErrorNoConnection: ui->statusLabel->setText(tr("It appears that the computer currently is offline!")); - SHOW_HINT(tr("Please make sure your computer is connected to the internet and try again."), ":/icons/network_error.png"); - UPDATE_TASKBAR(MUtils::Taskbar7::TASKBAR_STATE_NORMAL, ":/icons/exclamation.png"); + SHOW_HINT(tr("Please make sure your computer is connected to the internet and try again."), m_iconNetworkError); + UPDATE_TASKBAR(MUtils::Taskbar7::TASKBAR_STATE_NORMAL, m_iconFailure); break; case MUtils::UpdateChecker::UpdateStatus_ErrorConnectionTestFailed: ui->statusLabel->setText(tr("Network connectivity test has failed!")); - SHOW_HINT(tr("Please make sure your computer is connected to the internet and try again."), ":/icons/network_error.png"); - UPDATE_TASKBAR(MUtils::Taskbar7::TASKBAR_STATE_NORMAL, ":/icons/exclamation.png"); + SHOW_HINT(tr("Please make sure your computer is connected to the internet and try again."), m_iconNetworkError); + UPDATE_TASKBAR(MUtils::Taskbar7::TASKBAR_STATE_NORMAL, m_iconFailure); break; case MUtils::UpdateChecker::UpdateStatus_ErrorFetchUpdateInfo: ui->statusLabel->setText(tr("Failed to fetch update information from server!")); - SHOW_HINT(tr("Sorry, the update server might be busy at this time. Plase try again later."), ":/icons/server_error.png"); - UPDATE_TASKBAR(MUtils::Taskbar7::TASKBAR_STATE_NORMAL, ":/icons/exclamation.png"); + SHOW_HINT(tr("Sorry, the update server might be busy at this time. Plase try again later."), m_iconNetworkError); + UPDATE_TASKBAR(MUtils::Taskbar7::TASKBAR_STATE_NORMAL, m_iconFailure); break; case MUtils::UpdateChecker::UpdateStatus_CancelledByUser: ui->statusLabel->setText(tr("Update check has been cancelled!")); - SHOW_HINT(tr("The update check has been cancelled by the user. Please try again later."), ":/icons/server_error.png"); - UPDATE_TASKBAR(MUtils::Taskbar7::TASKBAR_STATE_NORMAL, ":/icons/exclamation.png"); + SHOW_HINT(tr("The update check has been cancelled by the user. Please try again later."), m_iconServerError); + UPDATE_TASKBAR(MUtils::Taskbar7::TASKBAR_STATE_NORMAL, m_iconFailure); break; default: qWarning("Unknown status %d !!!", int(status)); @@ -422,7 +430,7 @@ void UpdateDialog::applyUpdate(void) args << QString("/AppTitle=LameXP (Build #%1)").arg(QString::number(updateInfo->getBuildNo())); QApplication::setOverrideCursor(Qt::WaitCursor); - UPDATE_TASKBAR(MUtils::Taskbar7::TASKBAR_STATE_INTERMEDIATE, ":/icons/transmit_blue.png"); + UPDATE_TASKBAR(MUtils::Taskbar7::TASKBAR_STATE_INTERMEDIATE, m_iconTransmitting); process.start(m_binaryUpdater, args); bool updateStarted = process.waitForStarted(); @@ -451,10 +459,9 @@ void UpdateDialog::applyUpdate(void) } else { - QIcon warningIcon(":/icons/exclamation.png"); ui->statusLabel->setText(tr("Update failed. Please try again or download manually!")); m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_ERROR); - m_taskbar->setOverlayIcon(&warningIcon); + m_taskbar->setOverlayIcon(m_iconFailure.data()); m_taskbar->setTaskbarProgress(100, 100); } } diff --git a/src/Dialog_Update.h b/src/Dialog_Update.h index 24d54492..125e77da 100644 --- a/src/Dialog_Update.h +++ b/src/Dialog_Update.h @@ -87,6 +87,15 @@ private: QScopedPointer m_logFile; QScopedPointer m_animator; + QScopedPointer m_iconTransmitting; + QScopedPointer m_iconFailure; + QScopedPointer m_iconUpdateAvailable; + QScopedPointer m_iconNoUpdates; + QScopedPointer m_iconNewVersionOlder; + QScopedPointer m_iconVersionError; + QScopedPointer m_iconNetworkError; + QScopedPointer m_iconServerError; + unsigned long m_updaterProcess; bool m_success; diff --git a/src/Dialog_WorkingBanner.cpp b/src/Dialog_WorkingBanner.cpp index 75b2fb3d..fb8ff4de 100644 --- a/src/Dialog_WorkingBanner.cpp +++ b/src/Dialog_WorkingBanner.cpp @@ -85,6 +85,7 @@ WorkingBanner::WorkingBanner(QWidget *parent) : QDialog(parent, Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint), ui(new Ui::WorkingBanner()), + m_iconHourglass(new QIcon(":/icons/hourglass.png")), m_taskbar(new MUtils::Taskbar7(parent)), m_metrics(NULL), m_working(NULL), m_style(NULL) { @@ -162,8 +163,7 @@ void WorkingBanner::show(const QString &text, QThread *thread) connect(thread, SIGNAL(terminated()), loop, SLOT(quit())); //Set taskbar state - QIcon waitingIcon(":/icons/hourglass.png"); - m_taskbar->setOverlayIcon(&waitingIcon); + m_taskbar->setOverlayIcon(m_iconHourglass.data()); m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_INTERMEDIATE); //Start the thread @@ -198,8 +198,7 @@ void WorkingBanner::show(const QString &text, QEventLoop *loop) this->show(text); //Set taskbar state - QIcon waitingIcon(":/icons/hourglass.png"); - m_taskbar->setOverlayIcon(&waitingIcon); + m_taskbar->setOverlayIcon(m_iconHourglass.data()); m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_INTERMEDIATE); //Update cursor diff --git a/src/Dialog_WorkingBanner.h b/src/Dialog_WorkingBanner.h index cb1bb32b..07f2b4e8 100644 --- a/src/Dialog_WorkingBanner.h +++ b/src/Dialog_WorkingBanner.h @@ -79,4 +79,5 @@ protected: QScopedPointer m_metrics; QScopedPointer m_style; + QScopedPointer m_iconHourglass; };