Improved loading of icon files.

This commit is contained in:
LoRd_MuldeR 2021-12-23 19:14:25 +01:00
parent 2fc7989934
commit 2864478b00
6 changed files with 56 additions and 34 deletions

View File

@ -193,6 +193,12 @@ ProcessingDialog::ProcessingDialog(FileListModel *const fileListModel, const Aud
ui->label_headerWorking->setMovie(m_progressIndicator.data()); ui->label_headerWorking->setMovie(m_progressIndicator.data());
ui->progressBar->setValue(0); 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 //Init progress model
m_progressModel.reset(new ProgressModel()); m_progressModel.reset(new ProgressModel());
ui->view_log->setModel(m_progressModel.data()); ui->view_log->setModel(m_progressModel.data());
@ -491,10 +497,9 @@ void ProcessingDialog::initEncoding(void)
ui->checkBox_shutdownComputer->setEnabled(true); ui->checkBox_shutdownComputer->setEnabled(true);
ui->checkBox_shutdownComputer->setChecked(false); ui->checkBox_shutdownComputer->setChecked(false);
QIcon defaultIcon(":/icons/control_play_blue.png");
m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_NORMAL); m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_NORMAL);
m_taskbar->setTaskbarProgress(0, m_pendingJobs.count()); m_taskbar->setTaskbarProgress(0, m_pendingJobs.count());
m_taskbar->setOverlayIcon(&defaultIcon); m_taskbar->setOverlayIcon(m_iconRunning.data());
if(!m_diskObserver) if(!m_diskObserver)
{ {
@ -693,10 +698,9 @@ void ProcessingDialog::doneEncoding(void)
if(m_userAborted) if(m_userAborted)
{ {
QIcon errorIcon(":/icons/error.png");
CHANGE_BACKGROUND_COLOR(ui->frame_header, QColor("#FFFFE0")); CHANGE_BACKGROUND_COLOR(ui->frame_header, QColor("#FFFFE0"));
m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_ERROR); 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!")); 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->showMessage(tr("LameXP - Aborted"), tr("Process was aborted by the user."), QSystemTrayIcon::Warning);
m_systemTray->setIcon(QIcon(":/icons/cd_delete.png")); m_systemTray->setIcon(QIcon(":/icons/cd_delete.png"));
@ -713,10 +717,9 @@ void ProcessingDialog::doneEncoding(void)
if(m_failedJobs.count() > 0) if(m_failedJobs.count() > 0)
{ {
QIcon warningIcon(":/icons/exclamation.png");
CHANGE_BACKGROUND_COLOR(ui->frame_header, QColor("#FFF0F0")); CHANGE_BACKGROUND_COLOR(ui->frame_header, QColor("#FFF0F0"));
m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_ERROR); m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_ERROR);
m_taskbar->setOverlayIcon(&warningIcon); m_taskbar->setOverlayIcon(m_iconWarning.data());
if(m_skippedJobs.count() > 0) 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()))); 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 else
{ {
QIcon successIcon(":/icons/accept.png");
CHANGE_BACKGROUND_COLOR(ui->frame_header, QColor("#F0FFF0")); CHANGE_BACKGROUND_COLOR(ui->frame_header, QColor("#F0FFF0"));
m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_NORMAL); m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_NORMAL);
m_taskbar->setOverlayIcon(&successIcon); m_taskbar->setOverlayIcon(m_iconSuccess.data());
if(m_skippedJobs.count() > 0) if(m_skippedJobs.count() > 0)
{ {
SET_PROGRESS_TEXT(tr("All files completed successfully. Skipped %n file(s).", "", m_skippedJobs.count())); SET_PROGRESS_TEXT(tr("All files completed successfully. Skipped %n file(s).", "", m_skippedJobs.count()));

View File

@ -146,6 +146,10 @@ private:
QScopedPointer<QColor> m_defaultColor; QScopedPointer<QColor> m_defaultColor;
QScopedPointer<FileExtsModel> m_fileExts; QScopedPointer<FileExtsModel> m_fileExts;
QScopedPointer<MUtils::Taskbar7> m_taskbar; QScopedPointer<MUtils::Taskbar7> m_taskbar;
QScopedPointer<QIcon> m_iconRunning;
QScopedPointer<QIcon> m_iconError;
QScopedPointer<QIcon> m_iconWarning;
QScopedPointer<QIcon> m_iconSuccess;
static bool isFastSeekingDevice(const QString &path); static bool isFastSeekingDevice(const QString &path);
static quint32 cores2instances(const quint32 &cores); static quint32 cores2instances(const quint32 &cores);

View File

@ -55,7 +55,7 @@
#define SHOW_HINT(TEXT, ICON) do \ #define SHOW_HINT(TEXT, ICON) do \
{ \ { \
ui->hintLabel->setText((TEXT)); \ ui->hintLabel->setText((TEXT)); \
ui->hintIcon->setPixmap(QIcon((ICON)).pixmap(16,16)); \ ui->hintIcon->setPixmap((ICON)->pixmap(16,16)); \
ui->hintIcon->show(); \ ui->hintIcon->show(); \
ui->hintLabel->show(); \ ui->hintLabel->show(); \
} \ } \
@ -63,9 +63,8 @@ while(0)
#define UPDATE_TASKBAR(STATE, ICON) do \ #define UPDATE_TASKBAR(STATE, ICON) do \
{ \ { \
QIcon _icon((ICON)); \
m_taskbar->setTaskbarState((STATE)); \ m_taskbar->setTaskbarState((STATE)); \
m_taskbar->setOverlayIcon(&_icon); \ m_taskbar->setOverlayIcon((ICON).data()); \
} \ } \
while(0) while(0)
@ -100,6 +99,16 @@ UpdateDialog::UpdateDialog(const SettingsModel *const settings, QWidget *parent)
//Disable "X" button //Disable "X" button
MUtils::GUI::enable_close_button(this, false); 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 //Init animation
m_animator.reset(new QMovie(":/images/Loading3.gif")); m_animator.reset(new QMovie(":/images/Loading3.gif"));
ui->labelAnimationCenter->setMovie(m_animator.data()); 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->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_NORMAL);
m_taskbar->setOverlayIcon(&defaultIcon); m_taskbar->setOverlayIcon(m_iconTransmitting.data());
ui->progressBar->setValue(0); ui->progressBar->setValue(0);
ui->installButton->setEnabled(false); ui->installButton->setEnabled(false);
@ -296,38 +304,38 @@ void UpdateDialog::threadStatusChanged(const int status)
break; break;
case MUtils::UpdateChecker::UpdateStatus_CompletedUpdateAvailable: case MUtils::UpdateChecker::UpdateStatus_CompletedUpdateAvailable:
ui->statusLabel->setText(tr("A new version of LameXP is available!")); 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"); 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, ":/icons/shield_exclamation.png"); UPDATE_TASKBAR(MUtils::Taskbar7::TASKBAR_STATE_NORMAL, m_iconUpdateAvailable);
break; break;
case MUtils::UpdateChecker::UpdateStatus_CompletedNoUpdates: case MUtils::UpdateChecker::UpdateStatus_CompletedNoUpdates:
ui->statusLabel->setText(tr("No new updates available at this time.")); 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"); 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, ":/icons/shield_green.png"); UPDATE_TASKBAR(MUtils::Taskbar7::TASKBAR_STATE_NORMAL, m_iconNoUpdates);
break; break;
case MUtils::UpdateChecker::UpdateStatus_CompletedNewVersionOlder: case MUtils::UpdateChecker::UpdateStatus_CompletedNewVersionOlder:
ui->statusLabel->setText(tr("Your version appears to be newer than the latest release.")); 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"); 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, ":/icons/shield_error.png"); UPDATE_TASKBAR(MUtils::Taskbar7::TASKBAR_STATE_NORMAL, m_iconVersionError);
break; break;
case MUtils::UpdateChecker::UpdateStatus_ErrorNoConnection: case MUtils::UpdateChecker::UpdateStatus_ErrorNoConnection:
ui->statusLabel->setText(tr("It appears that the computer currently is offline!")); 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"); 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, ":/icons/exclamation.png"); UPDATE_TASKBAR(MUtils::Taskbar7::TASKBAR_STATE_NORMAL, m_iconFailure);
break; break;
case MUtils::UpdateChecker::UpdateStatus_ErrorConnectionTestFailed: case MUtils::UpdateChecker::UpdateStatus_ErrorConnectionTestFailed:
ui->statusLabel->setText(tr("Network connectivity test has failed!")); 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"); 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, ":/icons/exclamation.png"); UPDATE_TASKBAR(MUtils::Taskbar7::TASKBAR_STATE_NORMAL, m_iconFailure);
break; break;
case MUtils::UpdateChecker::UpdateStatus_ErrorFetchUpdateInfo: case MUtils::UpdateChecker::UpdateStatus_ErrorFetchUpdateInfo:
ui->statusLabel->setText(tr("Failed to fetch update information from server!")); 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"); 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, ":/icons/exclamation.png"); UPDATE_TASKBAR(MUtils::Taskbar7::TASKBAR_STATE_NORMAL, m_iconFailure);
break; break;
case MUtils::UpdateChecker::UpdateStatus_CancelledByUser: case MUtils::UpdateChecker::UpdateStatus_CancelledByUser:
ui->statusLabel->setText(tr("Update check has been cancelled!")); 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"); 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, ":/icons/exclamation.png"); UPDATE_TASKBAR(MUtils::Taskbar7::TASKBAR_STATE_NORMAL, m_iconFailure);
break; break;
default: default:
qWarning("Unknown status %d !!!", int(status)); 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())); args << QString("/AppTitle=LameXP (Build #%1)").arg(QString::number(updateInfo->getBuildNo()));
QApplication::setOverrideCursor(Qt::WaitCursor); 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); process.start(m_binaryUpdater, args);
bool updateStarted = process.waitForStarted(); bool updateStarted = process.waitForStarted();
@ -451,10 +459,9 @@ void UpdateDialog::applyUpdate(void)
} }
else else
{ {
QIcon warningIcon(":/icons/exclamation.png");
ui->statusLabel->setText(tr("Update failed. Please try again or download manually!")); ui->statusLabel->setText(tr("Update failed. Please try again or download manually!"));
m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_ERROR); m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_ERROR);
m_taskbar->setOverlayIcon(&warningIcon); m_taskbar->setOverlayIcon(m_iconFailure.data());
m_taskbar->setTaskbarProgress(100, 100); m_taskbar->setTaskbarProgress(100, 100);
} }
} }

View File

@ -87,6 +87,15 @@ private:
QScopedPointer<QStringList> m_logFile; QScopedPointer<QStringList> m_logFile;
QScopedPointer<QMovie> m_animator; QScopedPointer<QMovie> m_animator;
QScopedPointer<QIcon> m_iconTransmitting;
QScopedPointer<QIcon> m_iconFailure;
QScopedPointer<QIcon> m_iconUpdateAvailable;
QScopedPointer<QIcon> m_iconNoUpdates;
QScopedPointer<QIcon> m_iconNewVersionOlder;
QScopedPointer<QIcon> m_iconVersionError;
QScopedPointer<QIcon> m_iconNetworkError;
QScopedPointer<QIcon> m_iconServerError;
unsigned long m_updaterProcess; unsigned long m_updaterProcess;
bool m_success; bool m_success;

View File

@ -85,6 +85,7 @@ WorkingBanner::WorkingBanner(QWidget *parent)
: :
QDialog(parent, Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint), QDialog(parent, Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint),
ui(new Ui::WorkingBanner()), ui(new Ui::WorkingBanner()),
m_iconHourglass(new QIcon(":/icons/hourglass.png")),
m_taskbar(new MUtils::Taskbar7(parent)), m_taskbar(new MUtils::Taskbar7(parent)),
m_metrics(NULL), m_working(NULL), m_style(NULL) 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())); connect(thread, SIGNAL(terminated()), loop, SLOT(quit()));
//Set taskbar state //Set taskbar state
QIcon waitingIcon(":/icons/hourglass.png"); m_taskbar->setOverlayIcon(m_iconHourglass.data());
m_taskbar->setOverlayIcon(&waitingIcon);
m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_INTERMEDIATE); m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_INTERMEDIATE);
//Start the thread //Start the thread
@ -198,8 +198,7 @@ void WorkingBanner::show(const QString &text, QEventLoop *loop)
this->show(text); this->show(text);
//Set taskbar state //Set taskbar state
QIcon waitingIcon(":/icons/hourglass.png"); m_taskbar->setOverlayIcon(m_iconHourglass.data());
m_taskbar->setOverlayIcon(&waitingIcon);
m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_INTERMEDIATE); m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_INTERMEDIATE);
//Update cursor //Update cursor

View File

@ -79,4 +79,5 @@ protected:
QScopedPointer<QFontMetrics> m_metrics; QScopedPointer<QFontMetrics> m_metrics;
QScopedPointer<QStyle> m_style; QScopedPointer<QStyle> m_style;
QScopedPointer<QIcon> m_iconHourglass;
}; };