From 62aa72d28309de69c9d9abc5d37f3b72118289ff Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Sun, 4 May 2014 16:59:06 +0200 Subject: [PATCH] Implemented menubar corner widget. --- res/Icons.qrc | 1 + res/icons/exclamation_small.png | Bin 0 -> 415 bytes src/Config.h | 2 +- src/Dialog_MainWindow.cpp | 91 +++++++++++++++++++++++--------- src/Dialog_MainWindow.h | 2 + src/Dialog_Processing.cpp | 8 +-- src/Dialog_Processing.h | 1 + 7 files changed, 76 insertions(+), 29 deletions(-) create mode 100644 res/icons/exclamation_small.png diff --git a/res/Icons.qrc b/res/Icons.qrc index 7a6f69ad..caf3d709 100644 --- a/res/Icons.qrc +++ b/res/Icons.qrc @@ -50,6 +50,7 @@ icons/drive_link.png icons/drive_network.png icons/exclamation.png + icons/exclamation_small.png icons/error.png icons/error_big.png icons/feed.png diff --git a/res/icons/exclamation_small.png b/res/icons/exclamation_small.png new file mode 100644 index 0000000000000000000000000000000000000000..ba672fc3eb4806e5e1f4c1c02018fa4fde44431c GIT binary patch literal 415 zcmV;Q0bu@#P) zf*30cQwV~sA7FnLVk4r3zhP}-VWCYxxDW6Hti(dAAR^HOY!oqCiQMj8p8FP$aIB5K z<*~Cf^O$8>K}7gZm2z;j?T*;z)q~egi?|v8HYoDMe6SL_SX*yUvlWkP?sz1~bPRd-5ue2Hn`N37w+&#c+7M zVE9Z)kPu*vJ(}7mBu;w6s2UQoBtfdL*cw z^m^*2+N12NIwfj9+{#xGx3;=xpm&%IJOrHP%002ov JPDHLkV1k0xvpN6( literal 0 HcmV?d00001 diff --git a/src/Config.h b/src/Config.h index 68310ec1..bb899c23 100644 --- a/src/Config.h +++ b/src/Config.h @@ -35,7 +35,7 @@ #define VER_LAMEXP_MINOR_LO 0 #define VER_LAMEXP_TYPE Beta #define VER_LAMEXP_PATCH 1 -#define VER_LAMEXP_BUILD 1542 +#define VER_LAMEXP_BUILD 1543 #define VER_LAMEXP_CONFG 1528 /////////////////////////////////////////////////////////////////////////////// diff --git a/src/Dialog_MainWindow.cpp b/src/Dialog_MainWindow.cpp index d82b385d..c3be8a1d 100644 --- a/src/Dialog_MainWindow.cpp +++ b/src/Dialog_MainWindow.cpp @@ -198,6 +198,15 @@ while(0) } \ while(0) +#define SHOW_CORNER_WIDGET(FLAG) do \ +{ \ + if(QWidget *cornerWidget = ui->menubar->cornerWidget()) \ + { \ + cornerWidget->setVisible((FLAG)); \ + } \ +} \ +while(0) + #define LINK(URL) QString("%2").arg(URL).arg(QString(URL).replace("-", "−")) #define FSLINK(PATH) QString("%2").arg(PATH).arg(QString(PATH).replace("-", "−")) #define CENTER_CURRENT_OUTPUT_FOLDER_DELAYED QTimer::singleShot(125, this, SLOT(centerOutputFolderModel())) @@ -238,7 +247,7 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel_MetaInfo *me //Enabled main buttons connect(ui->buttonAbout, SIGNAL(clicked()), this, SLOT(aboutButtonClicked())); connect(ui->buttonStart, SIGNAL(clicked()), this, SLOT(encodeButtonClicked())); - connect(ui->buttonQuit, SIGNAL(clicked()), this, SLOT(closeButtonClicked())); + connect(ui->buttonQuit, SIGNAL(clicked()), this, SLOT(closeButtonClicked())); //Setup tab widget ui->tabWidget->setCurrentIndex(0); @@ -247,6 +256,17 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel_MetaInfo *me //Add system menu lamexp_append_sysmenu(this, IDM_ABOUTBOX, "About..."); + //Setup corner widget + QLabel *cornerWidget = new QLabel(ui->menubar); + m_evenFilterCornerWidget = new CustomEventFilter; + cornerWidget->setText(QString(" %1   ").arg(tr("Check for Updates"))); + cornerWidget->setFixedHeight(ui->menubar->height()); + cornerWidget->setCursor(QCursor(Qt::PointingHandCursor)); + cornerWidget->hide(); + cornerWidget->installEventFilter(m_evenFilterCornerWidget); + connect(m_evenFilterCornerWidget, SIGNAL(eventOccurred(QWidget*, QEvent*)), this, SLOT(cornerWidgetEventOccurred(QWidget*, QEvent*))); + ui->menubar->setCornerWidget(cornerWidget); + //-------------------------------- // Setup "Source" tab //-------------------------------- @@ -268,23 +288,24 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel_MetaInfo *me m_exportCsvContextAction = m_sourceFilesContextMenu->addAction(QIcon(":/icons/table_save.png"), "N/A"); m_importCsvContextAction = m_sourceFilesContextMenu->addAction(QIcon(":/icons/folder_table.png"), "N/A"); SET_FONT_BOLD(m_showDetailsContextAction, true); - connect(ui->buttonAddFiles, SIGNAL(clicked()), this, SLOT(addFilesButtonClicked())); - connect(ui->buttonRemoveFile, SIGNAL(clicked()), this, SLOT(removeFileButtonClicked())); - connect(ui->buttonClearFiles, SIGNAL(clicked()), this, SLOT(clearFilesButtonClicked())); - connect(ui->buttonFileUp, SIGNAL(clicked()), this, SLOT(fileUpButtonClicked())); - connect(ui->buttonFileDown, SIGNAL(clicked()), this, SLOT(fileDownButtonClicked())); - connect(ui->buttonShowDetails, SIGNAL(clicked()), this, SLOT(showDetailsButtonClicked())); - connect(m_fileListModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(sourceModelChanged())); - connect(m_fileListModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(sourceModelChanged())); - connect(m_fileListModel, SIGNAL(modelReset()), this, SLOT(sourceModelChanged())); - connect(ui->sourceFileView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(sourceFilesContextMenu(QPoint))); - connect(ui->sourceFileView->verticalScrollBar(), SIGNAL(sliderMoved(int)), this, SLOT(sourceFilesScrollbarMoved(int))); - connect(ui->sourceFileView->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(sourceFilesScrollbarMoved(int))); - connect(m_showDetailsContextAction, SIGNAL(triggered(bool)), this, SLOT(showDetailsButtonClicked())); - connect(m_previewContextAction, SIGNAL(triggered(bool)), this, SLOT(previewContextActionTriggered())); - connect(m_findFileContextAction, SIGNAL(triggered(bool)), this, SLOT(findFileContextActionTriggered())); - connect(m_exportCsvContextAction, SIGNAL(triggered(bool)), this, SLOT(exportCsvContextActionTriggered())); - connect(m_importCsvContextAction, SIGNAL(triggered(bool)), this, SLOT(importCsvContextActionTriggered())); + + connect(ui->buttonAddFiles, SIGNAL(clicked()), this, SLOT(addFilesButtonClicked())); + connect(ui->buttonRemoveFile, SIGNAL(clicked()), this, SLOT(removeFileButtonClicked())); + connect(ui->buttonClearFiles, SIGNAL(clicked()), this, SLOT(clearFilesButtonClicked())); + connect(ui->buttonFileUp, SIGNAL(clicked()), this, SLOT(fileUpButtonClicked())); + connect(ui->buttonFileDown, SIGNAL(clicked()), this, SLOT(fileDownButtonClicked())); + connect(ui->buttonShowDetails, SIGNAL(clicked()), this, SLOT(showDetailsButtonClicked())); + connect(m_fileListModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(sourceModelChanged())); + connect(m_fileListModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(sourceModelChanged())); + connect(m_fileListModel, SIGNAL(modelReset()), this, SLOT(sourceModelChanged())); + connect(ui->sourceFileView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(sourceFilesContextMenu(QPoint))); + connect(ui->sourceFileView->verticalScrollBar(), SIGNAL(sliderMoved(int)), this, SLOT(sourceFilesScrollbarMoved(int))); + connect(ui->sourceFileView->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(sourceFilesScrollbarMoved(int))); + connect(m_showDetailsContextAction, SIGNAL(triggered(bool)), this, SLOT(showDetailsButtonClicked())); + connect(m_previewContextAction, SIGNAL(triggered(bool)), this, SLOT(previewContextActionTriggered())); + connect(m_findFileContextAction, SIGNAL(triggered(bool)), this, SLOT(findFileContextActionTriggered())); + connect(m_exportCsvContextAction, SIGNAL(triggered(bool)), this, SLOT(exportCsvContextActionTriggered())); + connect(m_importCsvContextAction, SIGNAL(triggered(bool)), this, SLOT(importCsvContextActionTriggered())); //-------------------------------- // Setup "Output" tab @@ -714,6 +735,7 @@ MainWindow::~MainWindow(void) LAMEXP_DELETE(m_outputFolderFavoritesMenu); LAMEXP_DELETE(m_outputFolderContextMenu); LAMEXP_DELETE(m_dropBox); + LAMEXP_DELETE(m_evenFilterCornerWidget); LAMEXP_DELETE(m_evenFilterCustumParamsHelp); LAMEXP_DELETE(m_evenFilterOutputFolderMouse); LAMEXP_DELETE(m_evenFilterOutputFolderView); @@ -864,6 +886,7 @@ bool MainWindow::checkForUpdates(void) if(updateDialog->getSuccess()) { + SHOW_CORNER_WIDGET(false); m_settings->autoUpdateLastCheck(QDate::currentDate().toString(Qt::ISODate)); bReadyToInstall = updateDialog->updateReadyToInstall(); } @@ -1331,6 +1354,7 @@ void MainWindow::windowShown(void) if(lamexp_current_date_safe() >= lamexp_version_date().addYears(1)) { qWarning("Binary is more than a year old, time to update!"); + SHOW_CORNER_WIDGET(true); int ret = QMessageBox::warning(this, tr("Urgent Update"), NOBR(tr("Your version of LameXP is more than a year old. Time for an update!")), tr("Check for Updates"), tr("Exit Program"), tr("Ignore")); switch(ret) { @@ -1351,17 +1375,21 @@ void MainWindow::windowShown(void) break; } } - else if(m_settings->autoUpdateEnabled()) + else { QDate lastUpdateCheck = QDate::fromString(m_settings->autoUpdateLastCheck(), Qt::ISODate); - if(!firstRun && (!lastUpdateCheck.isValid() || lamexp_current_date_safe() >= lastUpdateCheck.addDays(14))) + if((!firstRun) && ((!lastUpdateCheck.isValid()) || (lamexp_current_date_safe() >= lastUpdateCheck.addDays(14)))) { - if(QMessageBox::information(this, tr("Update Reminder"), NOBR(lastUpdateCheck.isValid() ? tr("Your last update check was more than 14 days ago. Check for updates now?") : tr("Your did not check for LameXP updates yet. Check for updates now?")), tr("Check for Updates"), tr("Postpone")) == 0) + SHOW_CORNER_WIDGET(true); + if(m_settings->autoUpdateEnabled()) { - if(checkForUpdates()) + if(QMessageBox::information(this, tr("Update Reminder"), NOBR(lastUpdateCheck.isValid() ? tr("Your last update check was more than 14 days ago. Check for updates now?") : tr("Your did not check for LameXP updates yet. Check for updates now?")), tr("Check for Updates"), tr("Postpone")) == 0) { - QApplication::quit(); - return; + if(checkForUpdates()) + { + QApplication::quit(); + return; + } } } } @@ -1727,6 +1755,21 @@ void MainWindow::tabActionActivated(QAction *action) } } +// ========================================================= +// Menubar slots +// ========================================================= + +/* + * Handle corner widget Event + */ +void MainWindow::cornerWidgetEventOccurred(QWidget *sender, QEvent *event) +{ + if(event->type() == QEvent::MouseButtonPress) + { + QTimer::singleShot(0, this, SLOT(checkUpdatesActionActivated())); + } +} + // ========================================================= // View menu slots // ========================================================= diff --git a/src/Dialog_MainWindow.h b/src/Dialog_MainWindow.h index 8c88cfaf..21cd77d4 100644 --- a/src/Dialog_MainWindow.h +++ b/src/Dialog_MainWindow.h @@ -85,6 +85,7 @@ private slots: void clearMetaButtonClicked(void); void closeButtonClicked(void); void compressionTabEventOccurred(QWidget*, QEvent*); + void cornerWidgetEventOccurred(QWidget *sender, QEvent *event); void customParamsChanged(void); void customParamsHelpRequested(QWidget *obj, QEvent *event); void customTempFolderChanged(const QString &text); @@ -231,6 +232,7 @@ private: QButtonGroup *m_modeButtonGroup; QButtonGroup *m_overwriteButtonGroup; + CustomEventFilter *m_evenFilterCornerWidget; CustomEventFilter *m_evenFilterCustumParamsHelp; CustomEventFilter *m_evenFilterOutputFolderMouse; CustomEventFilter *m_evenFilterOutputFolderView; diff --git a/src/Dialog_Processing.cpp b/src/Dialog_Processing.cpp index eeea81c2..0fdfd81c 100644 --- a/src/Dialog_Processing.cpp +++ b/src/Dialog_Processing.cpp @@ -152,6 +152,7 @@ ProcessingDialog::ProcessingDialog(FileListModel *fileListModel, const AudioFile m_ramObserver(NULL), m_progressViewFilter(-1), m_initThreads(0), + m_defaultColor(new QColor()), m_firstShow(true) { //Init the dialog, from the .ui file @@ -348,6 +349,7 @@ ProcessingDialog::~ProcessingDialog(void) LAMEXP_DELETE(m_contextMenu); LAMEXP_DELETE(m_progressModel); LAMEXP_DELETE(m_threadPool); + LAMEXP_DELETE(m_defaultColor); WinSevenTaskbar::setOverlayIcon(this, NULL); WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarNoState); @@ -407,21 +409,19 @@ void ProcessingDialog::closeEvent(QCloseEvent *event) bool ProcessingDialog::eventFilter(QObject *obj, QEvent *event) { - static QColor defaultColor = QColor(); - if(obj == ui->label_versionInfo) { if(event->type() == QEvent::Enter) { QPalette palette = ui->label_versionInfo->palette(); - defaultColor = palette.color(QPalette::Normal, QPalette::WindowText); + *m_defaultColor = palette.color(QPalette::Normal, QPalette::WindowText); palette.setColor(QPalette::Normal, QPalette::WindowText, Qt::red); ui->label_versionInfo->setPalette(palette); } else if(event->type() == QEvent::Leave) { QPalette palette = ui->label_versionInfo->palette(); - palette.setColor(QPalette::Normal, QPalette::WindowText, defaultColor); + palette.setColor(QPalette::Normal, QPalette::WindowText, *m_defaultColor); ui->label_versionInfo->setPalette(palette); } else if(event->type() == QEvent::MouseButtonPress) diff --git a/src/Dialog_Processing.h b/src/Dialog_Processing.h index ff93baaa..4f0281b9 100644 --- a/src/Dialog_Processing.h +++ b/src/Dialog_Processing.h @@ -136,4 +136,5 @@ private: DiskObserverThread *m_diskObserver; qint64 m_timerStart; int m_progressViewFilter; + QColor *m_defaultColor; };