</property>
<item>
<widget class="QLabel" name="label">
+ <property name="toolTip">
+ <string>Select the source video file. This can be an Avisynth script or any type of video file supported by FFmpegSource2 (libavformat).</string>
+ </property>
<property name="text">
<string>Source Media/Avisynth File:</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLineEdit" name="editSource">
+ <property name="toolTip">
+ <string>Select the source video file. This can be an Avisynth script or any type of video file supported by FFmpegSource2 (libavformat).</string>
+ </property>
<property name="readOnly">
<bool>true</bool>
</property>
</property>
<item>
<widget class="QLabel" name="label_2">
+ <property name="toolTip">
+ <string>Select the output H.264/AVC file. This can be a Matroska (MKV,) MPEG-4 Part-14 (MP4) or "raw" H.264 file.</string>
+ </property>
<property name="text">
<string>Output AVC/H.264 File:</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLineEdit" name="editOutput">
+ <property name="toolTip">
+ <string>Select the output H.264/AVC file. This can be a Matroska (MKV,) MPEG-4 Part-14 (MP4) or "raw" H.264 file.</string>
+ </property>
<property name="readOnly">
<bool>true</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="label_9">
+ <property name="toolTip">
+ <string>Here you can load a user-defined template that you have saved before. Use the "Save" button to save your current configuration to a new profile.</string>
+ </property>
<property name="text">
<string>Template:</string>
</property>
<height>0</height>
</size>
</property>
+ <property name="toolTip">
+ <string>Here you can load a user-defined template that you have saved before. Use the "Save" button to save your current configuration to a new profile.</string>
+ </property>
<property name="currentIndex">
<number>-1</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="label_3">
+ <property name="toolTip">
+ <string>Select the x264 rate-control mode. Use 'CRF' mode to hit a specific level of quality or use '2-Pass' mode to hit a specific file size.</string>
+ </property>
<property name="text">
<string>Mode:</string>
</property>
</item>
<item>
<widget class="QComboBox" name="cbxRateControlMode">
+ <property name="toolTip">
+ <string>Select the x264 rate-control mode. Use 'CRF' mode to hit a specific level of quality or use '2-Pass' mode to hit a specific file size.</string>
+ </property>
<property name="currentIndex">
<number>0</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QLabel" name="label_4">
+ <property name="toolTip">
+ <string>Select the quantizer or CRF value. Smaller value means better quality, but bigger file. Higher value means smaller file, but lower quality. A value of '0' triggers lossless mode.</string>
+ </property>
<property name="text">
<string>Quantizer/CRF:</string>
</property>
</item>
<item>
<widget class="QSpinBox" name="spinQuantizer">
+ <property name="toolTip">
+ <string>Select the quantizer or CRF value. Smaller value means better quality, but bigger file. Higher value means smaller file, but lower quality. A value of '0' triggers lossless mode.</string>
+ </property>
<property name="maximum">
<number>52</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QLabel" name="label_5">
+ <property name="toolTip">
+ <string>Select the target average(!) bitrate, in kilobit/sec. Higher value means better quality, but bigger file. Lower value means smaller file, but lower quality.</string>
+ </property>
<property name="text">
<string>Target Bitrate (kbps):</string>
</property>
</item>
<item>
<widget class="QSpinBox" name="spinBitrate">
+ <property name="toolTip">
+ <string>Select the target average(!) bitrate, in kilobit/sec. Higher value means better quality, but bigger file. Lower value means smaller file, but lower quality.</string>
+ </property>
<property name="minimum">
<number>100</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout_11">
<item>
<widget class="QLabel" name="label_6">
+ <property name="toolTip">
+ <string>This option controls the "Speed -vs- Quality" trade-off. Use a slower preset to improve the quality at the same bitrate (file size). Use a faster preset to save encoding time, at the cost of reduced quality.</string>
+ </property>
<property name="text">
<string>Preset:</string>
</property>
</item>
<item>
<widget class="QComboBox" name="cbxPreset">
+ <property name="toolTip">
+ <string>This option controls the "Speed -vs- Quality" trade-off. Use a slower preset to improve the quality at the same bitrate (file size). Use a faster preset to save encoding time, at the cost of reduced quality.</string>
+ </property>
<property name="currentIndex">
<number>5</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
<item>
<widget class="QLabel" name="label_7">
+ <property name="toolTip">
+ <string>This option tweaks x264 for a specific type of source/content. For real-life footage, CGI and most other stuff, use the "Film" option. For anime/cartoon use the "Animation" option.</string>
+ </property>
<property name="text">
<string>Tuning:</string>
</property>
</item>
<item>
<widget class="QComboBox" name="cbxTuning">
+ <property name="toolTip">
+ <string>This option tweaks x264 for a specific type of source/content. For real-life footage, CGI and most other stuff, use the "Film" option. For anime/cartoon use the "Animation" option.</string>
+ </property>
<property name="currentIndex">
<number>1</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
<widget class="QLabel" name="label_8">
+ <property name="toolTip">
+ <string>This option can be used to enforce the restrictions of a specific H.264/AVC Proifle, though it won't force a higher profile than needed. Use "Auto" for an unrestricted encode.</string>
+ </property>
<property name="text">
<string>Profile:</string>
</property>
</item>
<item>
<widget class="QComboBox" name="cbxProfile">
+ <property name="toolTip">
+ <string>This option can be used to enforce the restrictions of a specific H.264/AVC Proifle, though it won't force a higher profile than needed. Use "Auto" for an unrestricted encode.</string>
+ </property>
<property name="currentIndex">
<number>0</number>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_10">
+ <property name="toolTip">
+ <string>All command-line parameters you enter here will be passed to x264 unmodified and unchecked. Some parameters are forbidden, as they are reserved for the GUI.</string>
+ </property>
<property name="text">
<string>Custom x264 Parameters:</string>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
+ <property name="toolTip">
+ <string>Click here to show a detailed list of all command-line options available in your build of x264!</string>
+ </property>
<property name="text">
<string>Show Help Screen</string>
</property>
</item>
<item>
<widget class="QLineEdit" name="editCustomParams">
+ <property name="toolTip">
+ <string>All command-line parameters you enter here will be passed to x264 unmodified and unchecked. Some parameters are forbidden, as they are reserved for the GUI.</string>
+ </property>
<property name="placeholderText">
<string>You can enter custom command-line options here...</string>
</property>
<rect>
<x>0</x>
<y>0</y>
- <width>784</width>
+ <width>800</width>
<height>384</height>
</rect>
</property>
<rect>
<x>0</x>
<y>0</y>
- <width>375</width>
- <height>171</height>
+ <width>378</width>
+ <height>193</height>
</rect>
</property>
<property name="windowTitle">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QGridLayout" name="gridLayout">
- <item row="1" column="1" colspan="2">
+ <item row="2" column="2" colspan="2">
<widget class="QLabel" name="labelJobCount">
<property name="enabled">
<bool>false</bool>
</property>
+ <property name="toolTip">
+ <string>If the specified number of jobs (or even more) is already running, the next one will NOT be launched yet.</string>
+ </property>
<property name="text">
<string>Maximum number of running jobs:</string>
</property>
</widget>
</item>
- <item row="1" column="3">
+ <item row="2" column="4">
<widget class="QSpinBox" name="spinBoxJobCount">
<property name="enabled">
<bool>false</bool>
<height>0</height>
</size>
</property>
+ <property name="toolTip">
+ <string>If the specified number of jobs (or even more) is already running, the next one will NOT be launched yet.</string>
+ </property>
<property name="minimum">
<number>1</number>
</property>
</property>
</widget>
</item>
- <item row="0" column="5" rowspan="2">
+ <item row="2" column="5">
+ <spacer name="horizontalSpacer_4">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>0</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="1" column="1">
+ <widget class="QCheckBox" name="checkRunNextJob">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2" colspan="4">
+ <widget class="QLabel" name="labelRunNextJob">
+ <property name="text">
+ <string>Automatically launch next job when a running job completes</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="6" rowspan="4">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
<property name="sizeHint" stdset="0">
<size>
- <width>1024</width>
+ <width>12</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
- <item row="0" column="0" rowspan="2">
+ <item row="1" column="0" rowspan="4">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</spacer>
</item>
- <item row="1" column="4">
- <spacer name="horizontalSpacer_4">
+ <item row="3" column="1" colspan="5">
+ <spacer name="verticalSpacer">
<property name="orientation">
- <enum>Qt::Horizontal</enum>
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
- <width>0</width>
- <height>20</height>
+ <width>20</width>
+ <height>8</height>
</size>
</property>
</spacer>
</item>
- <item row="0" column="1" colspan="4">
- <widget class="QCheckBox" name="checkRunNextJob">
+ <item row="4" column="1">
+ <widget class="QCheckBox" name="checkShutdownComputer">
<property name="text">
- <string>Automatically launch next job when a running job completes</string>
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="2" colspan="4">
+ <widget class="QLabel" name="labelShutdownComputer">
+ <property name="text">
+ <string>Shutdown computer as soon as the last job has completed</string>
</property>
</widget>
</item>
+ <item row="0" column="1" colspan="5">
+ <spacer name="verticalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>12</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="5" column="1" colspan="5">
+ <spacer name="verticalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>12</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
</layout>
</item>
</layout>
<file>buttons/pause.png</file>
<file>buttons/play.png</file>
<file>buttons/play_big.png</file>
+ <file>buttons/power_off.png</file>
+ <file>buttons/power_on.png</file>
<file>buttons/suspended.png</file>
<file>buttons/trash.png</file>
<file>buttons/world_link.png</file>
}
/*
+ * Shutdown the computer
+ */
+bool x264_shutdown_computer(const QString &message, const unsigned long timeout, const bool forceShutdown)
+{
+ HANDLE hToken = NULL;
+
+ if(OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
+ {
+ TOKEN_PRIVILEGES privileges;
+ memset(&privileges, 0, sizeof(TOKEN_PRIVILEGES));
+ privileges.PrivilegeCount = 1;
+ privileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
+
+ if(LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &privileges.Privileges[0].Luid))
+ {
+ if(AdjustTokenPrivileges(hToken, FALSE, &privileges, NULL, NULL, NULL))
+ {
+ const DWORD reason = SHTDN_REASON_MAJOR_APPLICATION | SHTDN_REASON_FLAG_PLANNED;
+ return InitiateSystemShutdownEx(NULL, const_cast<wchar_t*>(QWCHAR(message)), timeout, forceShutdown ? TRUE : FALSE, FALSE, reason);
+ }
+ }
+ }
+
+ return false;
+}
+
+/*
* Check for debugger (detect routine)
*/
static bool x264_check_for_debugger(void)
void x264_init_console(int argc, char* argv[]);
bool x264_init_qt(int argc, char* argv[]);
x264_cpu_t x264_detect_cpu_features(int argc, char **argv);
+bool x264_shutdown_computer(const QString &message, const unsigned long timeout, const bool forceShutdown);
SIZE_T x264_dbg_private_bytes(void);
void x264_finalization(void);
#include "model_jobList.h"
#include "global.h"
#include "thread_encode.h"
+#include "model_options.h"
#include <QIcon>
#include <QFileInfo>
{
return QModelIndex();
}
-
+
+ QString config = "N/A";
+
+ switch(thread->options()->rcMode())
+ {
+ case OptionsModel::RCMode_CQ:
+ config = QString("CQ@%1").arg(QString::number(thread->options()->quantizer()));
+ break;
+ case OptionsModel::RCMode_CRF:
+ config = QString("CRF@%1").arg(QString::number(thread->options()->quantizer()));
+ break;
+ case OptionsModel::RCMode_2Pass:
+ config = QString("2Pass@%1").arg(QString::number(thread->options()->bitrate()));
+ break;
+ case OptionsModel::RCMode_ABR:
+ config = QString("ABR@%1").arg(QString::number(thread->options()->bitrate()));
+ break;
+ }
+
int n = 2;
- QString jobName = QFileInfo(thread->sourceFileName()).completeBaseName();
+ QString jobName = QString("%1 [%2]").arg(QFileInfo(thread->sourceFileName()).completeBaseName(), config);
forever
{
}
if(!unique)
{
- jobName = QString("%1 (%2)").arg(QFileInfo(thread->sourceFileName()).completeBaseName(), QString::number(n++));
+ jobName = QString("%1 (%2) [%3]").arg(QFileInfo(thread->sourceFileName()).completeBaseName(), QString::number(n++), config);
continue;
}
break;
{ \
log("\nPROCESS ABORTED BY USER !!!"); \
setStatus(JobStatus_Aborted); \
+ if(QFileInfo(indexFile).exists()) QFile::remove(indexFile); \
return; \
} \
else if(!(OK_FLAG)) \
{ \
setStatus(JobStatus_Failed); \
+ if(QFileInfo(indexFile).exists()) QFile::remove(indexFile); \
return; \
} \
}
//Use Avisynth?
const bool usePipe = (QFileInfo(m_sourceFileName).suffix().compare("avs", Qt::CaseInsensitive) == 0);
+ const QString indexFile = QString("%1/%2.ffindex").arg(QDir::tempPath(), m_jobId.toString());
//Checking x264 version
log(tr("\n--- CHECK VERSION ---\n"));
}
log(tr("\n--- PASS 1 ---\n"));
- ok = runEncodingPass(m_x64, usePipe, frames, 1, passLogFile);
+ ok = runEncodingPass(m_x64, usePipe, frames, indexFile, 1, passLogFile);
CHECK_STATUS(m_abort, ok);
log(tr("\n--- PASS 2 ---\n"));
- ok = runEncodingPass(m_x64, usePipe, frames, 2, passLogFile);
+ ok = runEncodingPass(m_x64, usePipe, frames, indexFile, 2, passLogFile);
CHECK_STATUS(m_abort, ok);
}
else
{
log(tr("\n--- ENCODING ---\n"));
- ok = runEncodingPass(m_x64, usePipe, frames);
+ ok = runEncodingPass(m_x64, usePipe, frames, indexFile);
CHECK_STATUS(m_abort, ok);
}
log(tr("\n--- DONE ---\n"));
+ if(QFileInfo(indexFile).exists()) QFile::remove(indexFile);
int timePassed = startTime.secsTo(QDateTime::currentDateTime());
log(tr("Job finished at %1, %2. Process took %3 minutes, %4 seconds.").arg(QDate::currentDate().toString(Qt::ISODate), QTime::currentTime().toString( Qt::ISODate), QString::number(timePassed / 60), QString::number(timePassed % 60)));
setStatus(JobStatus_Completed);
}
-bool EncodeThread::runEncodingPass(bool x64, bool usePipe, unsigned int frames, int pass, const QString &passLogFile)
+bool EncodeThread::runEncodingPass(bool x64, bool usePipe, unsigned int frames, const QString &indexFile, int pass, const QString &passLogFile)
{
QProcess processEncode, processAvisynth;
}
}
- QStringList cmdLine_Encode = buildCommandLine(usePipe, frames, pass, passLogFile);
+ QStringList cmdLine_Encode = buildCommandLine(usePipe, frames, indexFile, pass, passLogFile);
log("Creating x264 process:");
if(!startProcess(processEncode, QString("%1/%2.exe").arg(m_binDir, x64 ? "x264_x64" : "x264"), cmdLine_Encode))
return true;
}
-QStringList EncodeThread::buildCommandLine(bool usePipe, unsigned int frames, int pass, const QString &passLogFile)
+QStringList EncodeThread::buildCommandLine(bool usePipe, unsigned int frames, const QString &indexFile, int pass, const QString &passLogFile)
{
QStringList cmdLine;
}
else
{
- QString indexFile = QString("%1/%2.ffindex").arg(QDir::tempPath(), m_jobId.toString());
cmdLine << "--index" << QDir::toNativeSeparators(indexFile);
cmdLine << QDir::toNativeSeparators(m_sourceFileName);
}
~EncodeThread(void);
QUuid getId(void) { return this->m_jobId; };
- const QString &sourceFileName(void) { return this->m_sourceFileName; };
- const QString &outputFileName(void) { return this->m_outputFileName; };
-
+ const QString &sourceFileName(void) { return this->m_sourceFileName; }
+ const QString &outputFileName(void) { return this->m_outputFileName; }
+ const OptionsModel *options(void) { return m_options; }
+
void pauseJob(void)
{
m_pause = true;
//Encode functions
void encode(void);
- bool runEncodingPass(bool x64, bool usePipe, unsigned int frames, int pass = 0, const QString &passLogFile = QString());
- QStringList buildCommandLine(bool usePipe, unsigned int frames, int pass = 0, const QString &passLogFile = QString());
+ bool runEncodingPass(bool x64, bool usePipe, unsigned int frames, const QString &indexFile, int pass = 0, const QString &passLogFile = QString());
+ QStringList buildCommandLine(bool usePipe, unsigned int frames, const QString &indexFile, int pass = 0, const QString &passLogFile = QString());
unsigned int checkVersionX264(bool x64, bool &modified);
unsigned int checkVersionAvs2yuv(void);
bool checkProperties(unsigned int &frames);
#include "model_options.h"
#include "win_addJob.h"
#include "win_preferences.h"
+#include "resource.h"
#include <QDate>
#include <QTimer>
#include <QDir>
#include <QLibrary>
#include <QProcess>
+#include <QProgressDialog>
-//#include <Shellapi.h>
+#include <Mmsystem.h>
const char *home_url = "http://mulder.brhack.net/";
if(ok) *ok = false;
AddJobDialog *addDialog = new AddJobDialog(this, m_options, m_x64supported);
- addDialog->setRunImmediately(countPendingJobs() < m_preferences.maxRunningJobCount);
+ addDialog->setRunImmediately(countRunningJobs() < (m_preferences.autoRunNextJob ? m_preferences.maxRunningJobCount : 1));
if(!filePath.isEmpty()) addDialog->setSourceFile(filePath);
+
int result = addDialog->exec();
-
if(result == QDialog::Accepted)
{
-
EncodeThread *thrd = new EncodeThread
(
addDialog->sourceFile(),
{
for(int i = topLeft.row(); i <= bottomRight.row(); i++)
{
- EncodeThread::JobStatus status = m_jobList->getJobStatus(m_jobList->index(i, 0, QModelIndex()));
+ EncodeThread::JobStatus status = m_jobList->getJobStatus(m_jobList->index(i, 0, QModelIndex()));
if(i == selected)
{
qDebug("Current job changed status!");
updateButtons(status);
}
- if((status == EncodeThread::JobStatus_Completed || status == EncodeThread::JobStatus_Failed) && m_preferences.autoRunNextJob)
+ if((status == EncodeThread::JobStatus_Completed) || (status == EncodeThread::JobStatus_Failed))
{
- QTimer::singleShot(0, this, SLOT(launchNextJob()));
+ if(m_preferences.autoRunNextJob) QTimer::singleShot(0, this, SLOT(launchNextJob()));
+ if(m_preferences.shutdownComputer) QTimer::singleShot(0, this, SLOT(shutdownComputer()));
}
}
}
forever
{
- int ret = QMessageBox::information(this, tr("About..."), text.replace("-", "−"), tr("About x264"), tr("About Qt"), tr("Close"));
+ int ret = QMessageBox::information(this, tr("About..."), text.replace("-", "−"), tr("About x264"), tr("About Qt"), tr("Close"), 0, 2);
switch(ret)
{
void MainWindow::launchNextJob(void)
{
+ qDebug("launchNextJob(void)");
+
+
const int rows = m_jobList->rowCount(QModelIndex());
- unsigned int running = countRunningJobs();
- if(running >= m_preferences.maxRunningJobCount)
+ if(countRunningJobs() >= m_preferences.maxRunningJobCount)
{
- qWarning("Still have too many jobs running, won't launch next one yet!");
+ qDebug("Still have too many jobs running, won't launch next one yet!");
return;
}
- bool first = true;
- while(running < m_preferences.maxRunningJobCount)
+ int startIdx= jobsView->currentIndex().isValid() ? qBound(0, jobsView->currentIndex().row(), rows-1) : 0;
+
+ for(int i = 0; i < rows; i++)
{
- bool ok = false;
- for(int i = 0; i < rows; i++)
+ int currentIdx = (i + startIdx) % rows;
+ EncodeThread::JobStatus status = m_jobList->getJobStatus(m_jobList->index(currentIdx, 0, QModelIndex()));
+ if(status == EncodeThread::JobStatus_Enqueued)
{
- EncodeThread::JobStatus status = m_jobList->getJobStatus(m_jobList->index(i, 0, QModelIndex()));
- if(status == EncodeThread::JobStatus_Enqueued)
+ if(m_jobList->startJob(m_jobList->index(currentIdx, 0, QModelIndex())))
{
- if(m_jobList->startJob(m_jobList->index(i, 0, QModelIndex())))
- {
- if(first)
- {
- first = false;
- jobsView->selectRow(i);
- }
- running++;
- ok = true;
- qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
- break;
- }
+ jobsView->selectRow(currentIdx);
+ return;
}
}
+ }
- if(!ok)
+ qWarning("No enqueued jobs left!");
+}
+
+void MainWindow::shutdownComputer(void)
+{
+ qDebug("shutdownComputer(void)");
+
+ if(countPendingJobs() > 0)
+ {
+ qDebug("Still have pending jobs, won't shutdown yet!");
+ return;
+ }
+
+ const int iTimeout = 30;
+ const Qt::WindowFlags flags = Qt::WindowStaysOnTopHint | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint | Qt::WindowSystemMenuHint;
+ const QString text = QString("%1%2%1").arg(QString().fill(' ', 18), tr("Warning: Computer will shutdown in %1 seconds..."));
+
+ qWarning("Initiating shutdown sequence!");
+
+ QProgressDialog progressDialog(text.arg(iTimeout), tr("Cancel Shutdown"), 0, iTimeout + 1, this, flags);
+ QPushButton *cancelButton = new QPushButton(tr("Cancel Shutdown"), &progressDialog);
+ cancelButton->setIcon(QIcon(":/buttons/power_on.png"));
+ progressDialog.setModal(true);
+ progressDialog.setAutoClose(false);
+ progressDialog.setAutoReset(false);
+ progressDialog.setWindowIcon(QIcon(":/buttons/power_off.png"));
+ progressDialog.setWindowTitle(windowTitle());
+ progressDialog.setCancelButton(cancelButton);
+ progressDialog.show();
+
+ QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
+ QApplication::setOverrideCursor(Qt::WaitCursor);
+ PlaySound(MAKEINTRESOURCE(IDR_WAVE1), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
+ QApplication::restoreOverrideCursor();
+
+ QTimer timer;
+ timer.setInterval(1000);
+ timer.start();
+
+ QEventLoop eventLoop(this);
+ connect(&timer, SIGNAL(timeout()), &eventLoop, SLOT(quit()));
+ connect(&progressDialog, SIGNAL(canceled()), &eventLoop, SLOT(quit()));
+
+ for(int i = 1; i <= iTimeout; i++)
+ {
+ eventLoop.exec();
+ if(progressDialog.wasCanceled())
{
- qWarning("No enqueued jobs left!");
- break;
+ progressDialog.close();
+ return;
}
+ progressDialog.setValue(i+1);
+ progressDialog.setLabelText(text.arg(iTimeout-i));
+ if(iTimeout-i == 3) progressDialog.setCancelButton(NULL);
+ QApplication::processEvents();
+ PlaySound(MAKEINTRESOURCE((i < iTimeout) ? IDR_WAVE2 : IDR_WAVE3), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
+ }
+
+ qWarning("Shutting down !!!");
+
+ if(x264_shutdown_computer("Simple x264 Launcher: All jobs completed, shutting down!", 10, true))
+ {
+ qApp->closeAllWindows();
}
}
void jobSelected(const QModelIndex & current, const QModelIndex & previous);
void jobChangedData(const QModelIndex &top, const QModelIndex &bottom);
void jobLogExtended(const QModelIndex & parent, int start, int end);
- void launchNextJob(void);
+ void launchNextJob();
void pauseButtonPressed(bool checked);
void showAbout(void);
void showPreferences(void);
void showWebLink(void);
+ void shutdownComputer(void);
void startButtonPressed(void);
void updateLabel(void);
};
#include <QSettings>
#include <QDesktopServices>
+#include <QMouseEvent>
PreferencesDialog::PreferencesDialog(QWidget *parent, Preferences *preferences)
:
{
setupUi(this);
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
- setFixedSize(size());
+ setFixedSize(minimumSize());
- HMENU hMenu = GetSystemMenu((HWND) winId(), FALSE);
- EnableMenuItem(hMenu, SC_CLOSE, MF_BYCOMMAND | MF_GRAYED);
+ labelRunNextJob->installEventFilter(this);
+ labelShutdownComputer->installEventFilter(this);
m_preferences = preferences;
}
void PreferencesDialog::showEvent(QShowEvent *event)
{
+ QDialog::showEvent(event);
+
while(checkRunNextJob->isChecked() != m_preferences->autoRunNextJob)
{
checkRunNextJob->click();
}
-
+ while(checkShutdownComputer->isChecked() != m_preferences->shutdownComputer)
+ {
+ checkShutdownComputer->click();
+ }
spinBoxJobCount->setValue(m_preferences->maxRunningJobCount);
}
+bool PreferencesDialog::eventFilter(QObject *o, QEvent *e)
+{
+ if(o == labelRunNextJob && e->type() == QEvent::MouseButtonRelease)
+ {
+ QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent*>(e);
+ if(mouseEvent)
+ {
+ if(qApp->widgetAt(mouseEvent->globalPos()) == labelRunNextJob)
+ {
+ checkRunNextJob->click();
+ }
+ }
+ }
+ if(o == labelShutdownComputer && e->type() == QEvent::MouseButtonRelease)
+ {
+ QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent*>(e);
+ if(mouseEvent)
+ {
+ if(qApp->widgetAt(mouseEvent->globalPos()) == labelShutdownComputer)
+ {
+ checkShutdownComputer->click();
+ }
+ }
+ }
+ return false;
+}
+
void PreferencesDialog::accept(void)
{
m_preferences->autoRunNextJob = checkRunNextJob->isChecked();
+ m_preferences->shutdownComputer = checkShutdownComputer->isChecked();
m_preferences->maxRunningJobCount = spinBoxJobCount->value();
savePreferences(m_preferences);
settings.beginGroup("preferences");
preferences->autoRunNextJob = settings.value("auto_run_next_job", QVariant(true)).toBool();
preferences->maxRunningJobCount = qBound(1U, settings.value("max_running_job_count", QVariant(1U)).toUInt(), 16U);
+ preferences->shutdownComputer = settings.value("shutdown_computer_on_completion", QVariant(false)).toBool();
}
void PreferencesDialog::savePreferences(Preferences *preferences)
settings.beginGroup("preferences");
settings.setValue("auto_run_next_job", preferences->autoRunNextJob);
+ settings.setValue("shutdown_computer_on_completion", preferences->shutdownComputer);
settings.setValue("max_running_job_count", preferences->maxRunningJobCount);
settings.sync();
}
{
bool autoRunNextJob;
unsigned int maxRunningJobCount;
+ bool shutdownComputer;
}
Preferences;
protected:
virtual void accept(void);
virtual void showEvent(QShowEvent *event);
+ virtual bool eventFilter(QObject *o, QEvent *e);
private:
Preferences *m_preferences;
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(QTDIR)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <AdditionalDependencies>QtMaind.lib;QtCored4.lib;QtGuid4.lib;psapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>QtMaind.lib;QtCored4.lib;QtGuid4.lib;Winmm.lib;psapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(QTDIR)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <AdditionalDependencies>QtMain.lib;QtCore4.lib;QtGui4.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>QtMain.lib;QtCore4.lib;QtGui4.lib;Winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
</Link>
<PreBuildEvent>