Added an option to shutdown the computer as soon as all files are completed.
This commit is contained in:
parent
cd319fdf5a
commit
108c167767
@ -111,6 +111,7 @@ IDR_WAVE_ERROR WAVE "res\\sounds\\error.wav"
|
||||
IDR_WAVE_ABORTED WAVE "res\\sounds\\aborted.wav"
|
||||
IDR_WAVE_WHAMMY WAVE "res\\sounds\\whammy.wav"
|
||||
IDR_WAVE_WOOHOO WAVE "res\\sounds\\woohoo.wav"
|
||||
IDR_WAVE_SHUTDOWN WAVE "res\\sounds\\shutdown.wav"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
@ -157,6 +157,7 @@
|
||||
AdditionalOptions=""/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'""
|
||||
AdditionalDependencies="qtmain.lib QtCore4.lib QtGui4.lib Winmm.lib Shlwapi.lib"
|
||||
ShowProgress="2"
|
||||
Version=""
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories=""$(QTDIR)\lib";"$(QTDIR)\plugins\imageformats""
|
||||
GenerateDebugInformation="false"
|
||||
@ -254,7 +255,6 @@
|
||||
AdditionalOptions=""/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'""
|
||||
AdditionalDependencies="qtmain.lib QtCore.lib QtGui.lib QtSvg.lib qsvg.lib qico.lib Winmm.lib imm32.lib ws2_32.lib Shlwapi.lib"
|
||||
ShowProgress="2"
|
||||
Version=""
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories=""$(SolutionDir)\etc\Prerequisites\qt4_static\lib";"$(SolutionDir)\etc\Prerequisites\qt4_static\plugins\imageformats""
|
||||
IgnoreDefaultLibraryNames=""
|
||||
|
@ -10,6 +10,7 @@
|
||||
<a name="4.01">Changes between v4.00 and v4.01:</a><br><ul>
|
||||
<li>Added an option to manually specify the number of parallel instances
|
||||
<li>Added an option to select a user-defined TEMP directory
|
||||
<li>Added an option to shutdown the computer as soon as all files are completed
|
||||
<li>Updated Qt runtime libraries to v4.7.2
|
||||
<li>Updated LAME encoder to v3.99.0.14 (2011-02-28), compiled with ICL 12.0.2
|
||||
<li>Updated Vorbis encoder to v2.87 using aoTuV Beta-6.02 (2011-02-28), compiled with ICL 11.1 and MSVC 9.0
|
||||
|
@ -317,8 +317,7 @@ LameXP setup/update program on a platform that is NOT supported, such as Windows
|
||||
Millennium Edition or Windows NT 4.0. There is nothing you can do about that, except for updating to a less<br>
|
||||
antiquated OS. Running an outdated/unsupported OS is a severe security risk anyway!<br>
|
||||
<br>
|
||||
Remark: Executable files compiled with Microsoft Visual Studio 2005 (or later) won't load on Windows 9x.<br>
|
||||
<br><br>
|
||||
Remark: Executable files compiled with Microsoft Visual Studio 2005 (or later) won't load on Windows 9x.<br><br>
|
||||
|
||||
<br><br>
|
||||
|
||||
|
@ -1456,6 +1456,10 @@
|
||||
<source>Initializing, please wait...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Shutdown the computer as soon as all files have been converted</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Abort</source>
|
||||
<translation type="unfinished"></translation>
|
||||
@ -1544,6 +1548,14 @@
|
||||
<source>The playlist file could not be created:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Warning: Computer will shutdown in %1 seconds...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Cancel Shutdown</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ProgressModel</name>
|
||||
|
@ -1545,6 +1545,18 @@
|
||||
<source>Browse Output File Location</source>
|
||||
<translation>Ausgabedatei suchen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Shutdown the computer as soon as all files have been converted</source>
|
||||
<translation>Computer herunterfahren sobald alle Dateien fertiggestellt sind</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Warning: Computer will shutdown in %1 seconds...</source>
|
||||
<translation>Achtung: Computer wird in %1 Sekunden heruntergefahren...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Cancel Shutdown</source>
|
||||
<translation>Herunterfahren abbrechen</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ProgressModel</name>
|
||||
|
@ -1544,6 +1544,18 @@
|
||||
<source>Browse Output File Location</source>
|
||||
<translation>Navegar hasta la ubicación del archivo de salida</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Shutdown the computer as soon as all files have been converted</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Warning: Computer will shutdown in %1 seconds...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Cancel Shutdown</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ProgressModel</name>
|
||||
|
@ -1553,6 +1553,18 @@ Sélection automatique (par défaut)</translation>
|
||||
<source>Browse Output File Location</source>
|
||||
<translation>Rechercher l'emplacement du fichier de sortie</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Shutdown the computer as soon as all files have been converted</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Warning: Computer will shutdown in %1 seconds...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Cancel Shutdown</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ProgressModel</name>
|
||||
|
@ -1545,6 +1545,18 @@
|
||||
<source>Browse Output File Location</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Shutdown the computer as soon as all files have been converted</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Warning: Computer will shutdown in %1 seconds...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Cancel Shutdown</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ProgressModel</name>
|
||||
|
@ -1548,6 +1548,18 @@
|
||||
<source>The playlist file could not be created:</source>
|
||||
<translation type="unfinished">Плэйлист неможет быть создан:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Shutdown the computer as soon as all files have been converted</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Warning: Computer will shutdown in %1 seconds...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Cancel Shutdown</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ProgressModel</name>
|
||||
|
@ -1544,6 +1544,18 @@
|
||||
<source>Browse Output File Location</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Shutdown the computer as soon as all files have been converted</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Warning: Computer will shutdown in %1 seconds...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Cancel Shutdown</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ProgressModel</name>
|
||||
|
@ -301,6 +301,23 @@
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_shutdownComputer">
|
||||
<property name="text">
|
||||
<string>Shutdown the computer as soon as all files have been converted</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::HLine</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_horizontal">
|
||||
<item>
|
||||
@ -452,6 +469,10 @@
|
||||
<include location="../res/Images.qrc"/>
|
||||
<include location="../res/Icons.qrc"/>
|
||||
<include location="../res/Images.qrc"/>
|
||||
<include location="../res/Icons.qrc"/>
|
||||
<include location="../res/Images.qrc"/>
|
||||
<include location="../res/Icons.qrc"/>
|
||||
<include location="../res/Images.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
|
@ -50,6 +50,7 @@
|
||||
<file>icons/house.png</file>
|
||||
<file>icons/hourglass.png</file>
|
||||
<file>icons/information.png</file>
|
||||
<file>icons/lightning.png</file>
|
||||
<file>icons/media_play.png</file>
|
||||
<file>icons/money_dollar.png</file>
|
||||
<file>icons/monitor.png</file>
|
||||
|
Binary file not shown.
BIN
res/sounds/shutdown.wav
Normal file
BIN
res/sounds/shutdown.wav
Normal file
Binary file not shown.
@ -25,8 +25,8 @@
|
||||
#define VER_LAMEXP_MAJOR 4
|
||||
#define VER_LAMEXP_MINOR_HI 0
|
||||
#define VER_LAMEXP_MINOR_LO 1
|
||||
#define VER_LAMEXP_BUILD 367
|
||||
#define VER_LAMEXP_SUFFIX Beta-8
|
||||
#define VER_LAMEXP_BUILD 372
|
||||
#define VER_LAMEXP_SUFFIX Beta-9
|
||||
|
||||
/*
|
||||
* Tools versions
|
||||
|
@ -53,6 +53,7 @@
|
||||
#include <QMenu>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QProcess>
|
||||
#include <QProgressDialog>
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
@ -90,7 +91,8 @@ ProcessingDialog::ProcessingDialog(FileListModel *fileListModel, AudioFileModel
|
||||
QDialog(parent),
|
||||
m_systemTray(new QSystemTrayIcon(QIcon(":/icons/cd_go.png"), this)),
|
||||
m_settings(settings),
|
||||
m_metaInfo(metaInfo)
|
||||
m_metaInfo(metaInfo),
|
||||
m_shutdownFlag(false)
|
||||
{
|
||||
//Init the dialog, from the .ui file
|
||||
setupUi(this);
|
||||
@ -269,6 +271,8 @@ void ProcessingDialog::initEncoding(void)
|
||||
button_closeDialog->setEnabled(false);
|
||||
button_AbortProcess->setEnabled(true);
|
||||
progressBar->setRange(0, m_pendingJobs.count());
|
||||
checkBox_shutdownComputer->setEnabled(true);
|
||||
checkBox_shutdownComputer->setChecked(false);
|
||||
|
||||
WinSevenTaskbar::initTaskbar();
|
||||
WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarNormalState);
|
||||
@ -387,6 +391,7 @@ void ProcessingDialog::doneEncoding(void)
|
||||
setCloseButtonEnabled(true);
|
||||
button_closeDialog->setEnabled(true);
|
||||
button_AbortProcess->setEnabled(false);
|
||||
checkBox_shutdownComputer->setEnabled(false);
|
||||
|
||||
view_log->scrollToBottom();
|
||||
m_progressIndicator->stop();
|
||||
@ -394,6 +399,12 @@ void ProcessingDialog::doneEncoding(void)
|
||||
WinSevenTaskbar::setTaskbarProgress(this, progressBar->value(), progressBar->maximum());
|
||||
|
||||
QApplication::restoreOverrideCursor();
|
||||
|
||||
if(!m_userAborted && checkBox_shutdownComputer->isChecked())
|
||||
{
|
||||
qWarning("Initiating shutdown sequence!");
|
||||
shutdownComputer();
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessingDialog::processFinished(const QUuid &jobId, const QString &outFileName, bool success)
|
||||
@ -699,3 +710,51 @@ void ProcessingDialog::systemTrayActivated(QSystemTrayIcon::ActivationReason rea
|
||||
SetForegroundWindow(this->winId());
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessingDialog::shutdownComputer(void)
|
||||
{
|
||||
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..."));
|
||||
|
||||
QProgressDialog progressDialog(text.arg(iTimeout), tr("Cancel Shutdown"), 0, iTimeout + 1, this, flags);
|
||||
progressDialog.setModal(true);
|
||||
progressDialog.setAutoClose(false);
|
||||
progressDialog.setAutoReset(false);
|
||||
progressDialog.setWindowIcon(QIcon(":/icons/lightning.png"));
|
||||
progressDialog.show();
|
||||
|
||||
QApplication::processEvents();
|
||||
|
||||
if(m_settings->soundsEnabled())
|
||||
{
|
||||
PlaySound(MAKEINTRESOURCE(IDR_WAVE_SHUTDOWN), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
|
||||
}
|
||||
|
||||
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()) break;
|
||||
progressDialog.setValue(i+1);
|
||||
progressDialog.setLabelText(text.arg(iTimeout-i));
|
||||
if(iTimeout-i == 3) progressDialog.setCancelButtonText(QString());
|
||||
QApplication::processEvents();
|
||||
Beep(4000, (i < iTimeout) ? 100 : 1000);
|
||||
}
|
||||
|
||||
if(!progressDialog.wasCanceled())
|
||||
{
|
||||
m_shutdownFlag = true;
|
||||
accept();
|
||||
}
|
||||
|
||||
progressDialog.close();
|
||||
}
|
||||
|
@ -41,6 +41,8 @@ class ProcessingDialog : public QDialog, private Ui::ProcessingDialog
|
||||
public:
|
||||
ProcessingDialog(FileListModel *fileListModel, AudioFileModel *metaInfo, SettingsModel *settings, QWidget *parent = 0);
|
||||
~ProcessingDialog(void);
|
||||
|
||||
bool getShutdownFlag(void) { return m_shutdownFlag; }
|
||||
|
||||
private slots:
|
||||
void initEncoding(void);
|
||||
@ -64,6 +66,7 @@ private:
|
||||
void startNextJob(void);
|
||||
AudioFileModel updateMetaInfo(const AudioFileModel &audioFile);
|
||||
void writePlayList(void);
|
||||
void shutdownComputer(void);
|
||||
|
||||
QList<AudioFileModel> m_pendingJobs;
|
||||
SettingsModel *m_settings;
|
||||
@ -80,4 +83,5 @@ private:
|
||||
QList<QUuid> m_failedJobs;
|
||||
bool m_userAborted;
|
||||
QSystemTrayIcon *m_systemTray;
|
||||
bool m_shutdownFlag;
|
||||
};
|
||||
|
@ -690,6 +690,18 @@ bool lamexp_init_qt(int argc, char* argv[])
|
||||
}
|
||||
}
|
||||
|
||||
//Update console icon, if a console is attached
|
||||
if(g_lamexp_console_attached)
|
||||
{
|
||||
typedef DWORD (__stdcall *SetConsoleIconFun)(HICON);
|
||||
QLibrary kernel32("kernel32.dll");
|
||||
SetConsoleIconFun SetConsoleIconPtr = (SetConsoleIconFun) kernel32.resolve("SetConsoleIcon");
|
||||
if(SetConsoleIconPtr)
|
||||
{
|
||||
SetConsoleIconPtr(QIcon(":/icons/sound.png").pixmap(16, 16).toWinHICON());
|
||||
}
|
||||
}
|
||||
|
||||
//Done
|
||||
qt_initialized = true;
|
||||
return true;
|
||||
@ -1306,6 +1318,30 @@ __int64 lamexp_free_diskspace(const QString &path)
|
||||
}
|
||||
}
|
||||
|
||||
bool lamexp_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, FALSE, reason);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Finalization function (final clean-up)
|
||||
*/
|
||||
|
@ -94,6 +94,7 @@ void lamexp_ipc_read(unsigned int *command, char* message, size_t buffSize);
|
||||
void lamexp_ipc_send(unsigned int command, const char* message);
|
||||
lamexp_cpu_t lamexp_detect_cpu_features(void);
|
||||
bool lamexp_portable_mode(void);
|
||||
bool lamexp_shutdown_computer(const QString &message, const unsigned long timeout = 30, const bool forceShutdown = true);
|
||||
|
||||
//Translation support
|
||||
QStringList lamexp_query_translations(void);
|
||||
|
13
src/Main.cpp
13
src/Main.cpp
@ -47,6 +47,7 @@ int lamexp_main(int argc, char* argv[])
|
||||
{
|
||||
int iResult = -1;
|
||||
bool bAccepted = true;
|
||||
bool bShutdown = false;
|
||||
|
||||
//Init console
|
||||
lamexp_init_console(argc, argv);
|
||||
@ -132,7 +133,7 @@ int lamexp_main(int argc, char* argv[])
|
||||
MainWindow *poMainWindow = new MainWindow(fileListModel, metaInfo, settingsModel);
|
||||
|
||||
//Main application loop
|
||||
while(bAccepted)
|
||||
while(bAccepted && !bShutdown)
|
||||
{
|
||||
//Show main window
|
||||
poMainWindow->show();
|
||||
@ -144,6 +145,7 @@ int lamexp_main(int argc, char* argv[])
|
||||
{
|
||||
ProcessingDialog *processingDialog = new ProcessingDialog(fileListModel, metaInfo, settingsModel);
|
||||
processingDialog->exec();
|
||||
bShutdown = processingDialog->getShutdownFlag();
|
||||
LAMEXP_DELETE(processingDialog);
|
||||
}
|
||||
}
|
||||
@ -157,6 +159,15 @@ int lamexp_main(int argc, char* argv[])
|
||||
//Final clean-up
|
||||
qDebug("Shutting down, please wait...\n");
|
||||
|
||||
//Shotdown computer
|
||||
if(bShutdown)
|
||||
{
|
||||
if(!lamexp_shutdown_computer("LameXP planned computer shutdown!", 12))
|
||||
{
|
||||
QMessageBox messageBox(QMessageBox::Critical, "LameXP", "Sorry, LameXP was unable to shutdown your computer!", QMessageBox::NoButton, NULL, Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint | Qt::WindowStaysOnTopHint);
|
||||
}
|
||||
}
|
||||
|
||||
//Terminate
|
||||
return iResult;
|
||||
}
|
||||
|
@ -32,6 +32,7 @@
|
||||
#define IDR_WAVE_ABORTED 669
|
||||
#define IDR_WAVE_WHAMMY 670
|
||||
#define IDR_WAVE_WOOHOO 671
|
||||
#define IDR_WAVE_SHUTDOWN 672
|
||||
|
||||
/*
|
||||
* Next default values for new objects
|
||||
|
Loading…
Reference in New Issue
Block a user