Minimize main window into the notification area ("systray"), when trying to close the program while we still have running jobs.
This commit is contained in:
parent
eacfe15342
commit
fff0cc76ef
@ -81,7 +81,7 @@ void PreferencesModel::initPreferences(PreferencesModel *preferences)
|
|||||||
INIT_VALUE(NoUpdateReminder, false);
|
INIT_VALUE(NoUpdateReminder, false);
|
||||||
INIT_VALUE(AbortOnTimeout, true );
|
INIT_VALUE(AbortOnTimeout, true );
|
||||||
INIT_VALUE(SkipVersionTest, false);
|
INIT_VALUE(SkipVersionTest, false);
|
||||||
|
INIT_VALUE(NoSystrayWarning, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferencesModel::loadPreferences(PreferencesModel *preferences)
|
void PreferencesModel::loadPreferences(PreferencesModel *preferences)
|
||||||
@ -101,6 +101,7 @@ void PreferencesModel::loadPreferences(PreferencesModel *preferences)
|
|||||||
LOAD_VALUE_B(EnableSounds );
|
LOAD_VALUE_B(EnableSounds );
|
||||||
LOAD_VALUE_B(DisableWarnings );
|
LOAD_VALUE_B(DisableWarnings );
|
||||||
LOAD_VALUE_B(NoUpdateReminder );
|
LOAD_VALUE_B(NoUpdateReminder );
|
||||||
|
LOAD_VALUE_B(NoSystrayWarning );
|
||||||
|
|
||||||
//Validation
|
//Validation
|
||||||
preferences->setProcessPriority(qBound(-2, preferences->getProcessPriority(), 2));
|
preferences->setProcessPriority(qBound(-2, preferences->getProcessPriority(), 2));
|
||||||
@ -123,6 +124,7 @@ void PreferencesModel::savePreferences(PreferencesModel *preferences)
|
|||||||
STORE_VALUE(EnableSounds );
|
STORE_VALUE(EnableSounds );
|
||||||
STORE_VALUE(DisableWarnings );
|
STORE_VALUE(DisableWarnings );
|
||||||
STORE_VALUE(NoUpdateReminder );
|
STORE_VALUE(NoUpdateReminder );
|
||||||
|
STORE_VALUE(NoSystrayWarning );
|
||||||
|
|
||||||
settings.sync();
|
settings.sync();
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,7 @@ public:
|
|||||||
PREFERENCES_MAKE_B(NoUpdateReminder)
|
PREFERENCES_MAKE_B(NoUpdateReminder)
|
||||||
PREFERENCES_MAKE_B(AbortOnTimeout)
|
PREFERENCES_MAKE_B(AbortOnTimeout)
|
||||||
PREFERENCES_MAKE_B(SkipVersionTest)
|
PREFERENCES_MAKE_B(SkipVersionTest)
|
||||||
|
PREFERENCES_MAKE_B(NoSystrayWarning)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void initPreferences(PreferencesModel *preferences);
|
static void initPreferences(PreferencesModel *preferences);
|
||||||
|
@ -57,6 +57,7 @@
|
|||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
#include <QSystemTrayIcon>
|
||||||
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
@ -94,6 +95,7 @@ MainWindow::MainWindow(const x264_cpu_t *const cpuFeatures, IPC *ipc)
|
|||||||
m_preferences(NULL),
|
m_preferences(NULL),
|
||||||
m_recentlyUsed(NULL),
|
m_recentlyUsed(NULL),
|
||||||
m_status(STATUS_PRE_INIT),
|
m_status(STATUS_PRE_INIT),
|
||||||
|
m_sysTray(new QSystemTrayIcon(this)),
|
||||||
ui(new Ui::MainWindow())
|
ui(new Ui::MainWindow())
|
||||||
{
|
{
|
||||||
//Init the dialog, from the .ui file
|
//Init the dialog, from the .ui file
|
||||||
@ -228,6 +230,11 @@ MainWindow::MainWindow(const x264_cpu_t *const cpuFeatures, IPC *ipc)
|
|||||||
connect(ui->splitter, SIGNAL(splitterMoved(int, int)), this, SLOT(updateLabelPos()));
|
connect(ui->splitter, SIGNAL(splitterMoved(int, int)), this, SLOT(updateLabelPos()));
|
||||||
updateLabelPos();
|
updateLabelPos();
|
||||||
|
|
||||||
|
//Init system tray icon
|
||||||
|
m_sysTray->setToolTip(this->windowTitle());
|
||||||
|
m_sysTray->setIcon(this->windowIcon());
|
||||||
|
connect(m_sysTray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(sysTrayActived()));
|
||||||
|
|
||||||
//Create corner widget
|
//Create corner widget
|
||||||
QLabel *checkUp = new QLabel(ui->menubar);
|
QLabel *checkUp = new QLabel(ui->menubar);
|
||||||
checkUp->setText(QString("<nobr><img src=\":/buttons/exclamation_small.png\"> <b style=\"color:darkred\">%1</b> </nobr>").arg(tr("Check for Updates")));
|
checkUp->setText(QString("<nobr><img src=\":/buttons/exclamation_small.png\"> <b style=\"color:darkred\">%1</b> </nobr>").arg(tr("Check for Updates")));
|
||||||
@ -275,6 +282,7 @@ MainWindow::~MainWindow(void)
|
|||||||
VapourSynthCheckThread::unload();
|
VapourSynthCheckThread::unload();
|
||||||
AvisynthCheckThread::unload();
|
AvisynthCheckThread::unload();
|
||||||
|
|
||||||
|
delete m_sysTray;
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -424,7 +432,12 @@ void MainWindow::moveButtonPressed(void)
|
|||||||
*/
|
*/
|
||||||
void MainWindow::pauseButtonPressed(bool checked)
|
void MainWindow::pauseButtonPressed(bool checked)
|
||||||
{
|
{
|
||||||
ENSURE_APP_IS_IDLE();
|
if(m_status != STATUS_IDLE)
|
||||||
|
{
|
||||||
|
x264_beep(x264_beep_warning);
|
||||||
|
qWarning("Cannot perfrom this action at this time!");
|
||||||
|
ui->buttonPauseJob->setChecked(!checked);
|
||||||
|
}
|
||||||
|
|
||||||
if(checked)
|
if(checked)
|
||||||
{
|
{
|
||||||
@ -1097,6 +1110,11 @@ void MainWindow::handleCommand(const int &command, const QStringList &args, cons
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if((!isVisible()) || m_sysTray->isVisible())
|
||||||
|
{
|
||||||
|
sysTrayActived();
|
||||||
|
}
|
||||||
|
|
||||||
x264_bring_to_front(this);
|
x264_bring_to_front(this);
|
||||||
|
|
||||||
#ifdef IPC_LOGGING
|
#ifdef IPC_LOGGING
|
||||||
@ -1231,6 +1249,16 @@ void MainWindow::jobListKeyPressed(const int &tag)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* System tray was activated
|
||||||
|
*/
|
||||||
|
void MainWindow::sysTrayActived(void)
|
||||||
|
{
|
||||||
|
m_sysTray->hide();
|
||||||
|
showNormal();
|
||||||
|
x264_bring_to_front(this);
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Event functions
|
// Event functions
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@ -1266,9 +1294,18 @@ void MainWindow::closeEvent(QCloseEvent *e)
|
|||||||
if(countRunningJobs() > 0)
|
if(countRunningJobs() > 0)
|
||||||
{
|
{
|
||||||
e->ignore();
|
e->ignore();
|
||||||
m_status = STATUS_BLOCKED;
|
if(!m_preferences->getNoSystrayWarning())
|
||||||
QMessageBox::warning(this, tr("Jobs Are Running"), tr("Sorry, can not exit while there still are running jobs!"));
|
{
|
||||||
m_status = STATUS_IDLE;
|
m_status = STATUS_BLOCKED;
|
||||||
|
if(QMessageBox::warning(this, tr("Jobs Are Running"), tr("<nobr>You still have running jobs, application will be minimized to notification area!<nobr>"), tr("OK"), tr("Don't Show Again")) == 1)
|
||||||
|
{
|
||||||
|
m_preferences->setNoSystrayWarning(true);
|
||||||
|
PreferencesModel::savePreferences(m_preferences);
|
||||||
|
}
|
||||||
|
m_status = STATUS_IDLE;
|
||||||
|
}
|
||||||
|
hide();
|
||||||
|
m_sysTray->show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ class RecentlyUsed;
|
|||||||
class InputEventFilter;
|
class InputEventFilter;
|
||||||
class QModelIndex;
|
class QModelIndex;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
|
class QSystemTrayIcon;
|
||||||
enum JobStatus;
|
enum JobStatus;
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
@ -75,6 +76,7 @@ private:
|
|||||||
QLabel *m_label;
|
QLabel *m_label;
|
||||||
|
|
||||||
IPC *const m_ipc;
|
IPC *const m_ipc;
|
||||||
|
QSystemTrayIcon *const m_sysTray;
|
||||||
|
|
||||||
InputEventFilter *m_inputFilter_jobList;
|
InputEventFilter *m_inputFilter_jobList;
|
||||||
InputEventFilter *m_inputFilter_version;
|
InputEventFilter *m_inputFilter_version;
|
||||||
@ -125,6 +127,7 @@ private slots:
|
|||||||
void showWebLink(void);
|
void showWebLink(void);
|
||||||
void shutdownComputer(void);
|
void shutdownComputer(void);
|
||||||
void startButtonPressed(void);
|
void startButtonPressed(void);
|
||||||
|
void sysTrayActived(void);
|
||||||
void updateLabelPos(void);
|
void updateLabelPos(void);
|
||||||
void versionLabelMouseClicked(const int &tag);
|
void versionLabelMouseClicked(const int &tag);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user