diff --git a/LameXP.rc b/LameXP.rc
index 9adcef2e..2b6612dd 100644
--- a/LameXP.rc
+++ b/LameXP.rc
@@ -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"
/////////////////////////////////////////////////////////////////////////////
//
diff --git a/LameXP.vcproj b/LameXP.vcproj
index ef0c66f8..7fdf474d 100644
--- a/LameXP.vcproj
+++ b/LameXP.vcproj
@@ -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=""
diff --git a/doc/Changelog.html b/doc/Changelog.html
index 0d3f6f37..81b1e4e6 100644
--- a/doc/Changelog.html
+++ b/doc/Changelog.html
@@ -10,6 +10,7 @@
Changes between v4.00 and v4.01:
Added an option to manually specify the number of parallel instances
Added an option to select a user-defined TEMP directory
+ Added an option to shutdown the computer as soon as all files are completed
Updated Qt runtime libraries to v4.7.2
Updated LAME encoder to v3.99.0.14 (2011-02-28), compiled with ICL 12.0.2
Updated Vorbis encoder to v2.87 using aoTuV Beta-6.02 (2011-02-28), compiled with ICL 11.1 and MSVC 9.0
diff --git a/doc/FAQ.html b/doc/FAQ.html
index 2bd4cc15..5611e305 100644
--- a/doc/FAQ.html
+++ b/doc/FAQ.html
@@ -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
antiquated OS. Running an outdated/unsupported OS is a severe security risk anyway!
-Remark: Executable files compiled with Microsoft Visual Studio 2005 (or later) won't load on Windows 9x.
-
+Remark: Executable files compiled with Microsoft Visual Studio 2005 (or later) won't load on Windows 9x.
diff --git a/etc/Translation/Blank.ts b/etc/Translation/Blank.ts
index 1b811633..401a901e 100644
--- a/etc/Translation/Blank.ts
+++ b/etc/Translation/Blank.ts
@@ -1456,6 +1456,10 @@
Initializing, please wait...
+
+ Shutdown the computer as soon as all files have been converted
+
+
Abort
@@ -1544,6 +1548,14 @@
The playlist file could not be created:
+
+ Warning: Computer will shutdown in %1 seconds...
+
+
+
+ Cancel Shutdown
+
+
ProgressModel
diff --git a/etc/Translation/LameXP_DE.ts b/etc/Translation/LameXP_DE.ts
index 53b761f5..92dc3324 100644
--- a/etc/Translation/LameXP_DE.ts
+++ b/etc/Translation/LameXP_DE.ts
@@ -1545,6 +1545,18 @@
Browse Output File Location
Ausgabedatei suchen
+
+ Shutdown the computer as soon as all files have been converted
+ Computer herunterfahren sobald alle Dateien fertiggestellt sind
+
+
+ Warning: Computer will shutdown in %1 seconds...
+ Achtung: Computer wird in %1 Sekunden heruntergefahren...
+
+
+ Cancel Shutdown
+ Herunterfahren abbrechen
+
ProgressModel
diff --git a/etc/Translation/LameXP_ES.ts b/etc/Translation/LameXP_ES.ts
index ed9fab1d..8967be72 100644
--- a/etc/Translation/LameXP_ES.ts
+++ b/etc/Translation/LameXP_ES.ts
@@ -1544,6 +1544,18 @@
Browse Output File Location
Navegar hasta la ubicación del archivo de salida
+
+ Shutdown the computer as soon as all files have been converted
+
+
+
+ Warning: Computer will shutdown in %1 seconds...
+
+
+
+ Cancel Shutdown
+
+
ProgressModel
diff --git a/etc/Translation/LameXP_FR.ts b/etc/Translation/LameXP_FR.ts
index 6e14050c..88a205f2 100644
--- a/etc/Translation/LameXP_FR.ts
+++ b/etc/Translation/LameXP_FR.ts
@@ -1553,6 +1553,18 @@ Sélection automatique (par défaut)
Browse Output File Location
Rechercher l'emplacement du fichier de sortie
+
+ Shutdown the computer as soon as all files have been converted
+
+
+
+ Warning: Computer will shutdown in %1 seconds...
+
+
+
+ Cancel Shutdown
+
+
ProgressModel
diff --git a/etc/Translation/LameXP_IT.ts b/etc/Translation/LameXP_IT.ts
index 6a3293a9..37ab152b 100644
--- a/etc/Translation/LameXP_IT.ts
+++ b/etc/Translation/LameXP_IT.ts
@@ -1545,6 +1545,18 @@
Browse Output File Location
+
+ Shutdown the computer as soon as all files have been converted
+
+
+
+ Warning: Computer will shutdown in %1 seconds...
+
+
+
+ Cancel Shutdown
+
+
ProgressModel
diff --git a/etc/Translation/LameXP_RU.ts b/etc/Translation/LameXP_RU.ts
index 6b9d7a62..13df0478 100644
--- a/etc/Translation/LameXP_RU.ts
+++ b/etc/Translation/LameXP_RU.ts
@@ -1548,6 +1548,18 @@
The playlist file could not be created:
Плэйлист неможет быть создан:
+
+ Shutdown the computer as soon as all files have been converted
+
+
+
+ Warning: Computer will shutdown in %1 seconds...
+
+
+
+ Cancel Shutdown
+
+
ProgressModel
diff --git a/etc/Translation/LameXP_UK.ts b/etc/Translation/LameXP_UK.ts
index a7c49741..113fd944 100644
--- a/etc/Translation/LameXP_UK.ts
+++ b/etc/Translation/LameXP_UK.ts
@@ -1544,6 +1544,18 @@
Browse Output File Location
+
+ Shutdown the computer as soon as all files have been converted
+
+
+
+ Warning: Computer will shutdown in %1 seconds...
+
+
+
+ Cancel Shutdown
+
+
ProgressModel
diff --git a/gui/ProcessingDialog.ui b/gui/ProcessingDialog.ui
index 1f37b2f9..5225d7f5 100644
--- a/gui/ProcessingDialog.ui
+++ b/gui/ProcessingDialog.ui
@@ -301,6 +301,23 @@
+ -
+
+
+ Shutdown the computer as soon as all files have been converted
+
+
+
+ -
+
+
+ QFrame::HLine
+
+
+ QFrame::Sunken
+
+
+
-
-
@@ -452,6 +469,10 @@
+
+
+
+
diff --git a/res/Icons.qrc b/res/Icons.qrc
index ffa71e41..1d4e07f5 100644
--- a/res/Icons.qrc
+++ b/res/Icons.qrc
@@ -50,6 +50,7 @@
icons/house.png
icons/hourglass.png
icons/information.png
+ icons/lightning.png
icons/media_play.png
icons/money_dollar.png
icons/monitor.png
diff --git a/res/localization/LameXP_DE.qm b/res/localization/LameXP_DE.qm
index fb86f812..97b6dec2 100644
Binary files a/res/localization/LameXP_DE.qm and b/res/localization/LameXP_DE.qm differ
diff --git a/res/sounds/shutdown.wav b/res/sounds/shutdown.wav
new file mode 100644
index 00000000..ec64b4a3
Binary files /dev/null and b/res/sounds/shutdown.wav differ
diff --git a/src/Config.h b/src/Config.h
index 458b479e..e39bc953 100644
--- a/src/Config.h
+++ b/src/Config.h
@@ -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
diff --git a/src/Dialog_Processing.cpp b/src/Dialog_Processing.cpp
index 9524dd67..e4dd2b05 100644
--- a/src/Dialog_Processing.cpp
+++ b/src/Dialog_Processing.cpp
@@ -53,6 +53,7 @@
#include
#include
#include
+#include
#include
@@ -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();
+}
diff --git a/src/Dialog_Processing.h b/src/Dialog_Processing.h
index 8a16052b..96647b93 100644
--- a/src/Dialog_Processing.h
+++ b/src/Dialog_Processing.h
@@ -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 m_pendingJobs;
SettingsModel *m_settings;
@@ -80,4 +83,5 @@ private:
QList m_failedJobs;
bool m_userAborted;
QSystemTrayIcon *m_systemTray;
+ bool m_shutdownFlag;
};
diff --git a/src/Global.cpp b/src/Global.cpp
index 06710c12..98119d8c 100644
--- a/src/Global.cpp
+++ b/src/Global.cpp
@@ -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(QWCHAR(message)), timeout, forceShutdown, FALSE, reason);
+ }
+ }
+ }
+
+ return false;
+}
+
/*
* Finalization function (final clean-up)
*/
diff --git a/src/Global.h b/src/Global.h
index 99ba52a7..cb3784e1 100644
--- a/src/Global.h
+++ b/src/Global.h
@@ -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);
diff --git a/src/Main.cpp b/src/Main.cpp
index 3c8b63ea..060de100 100644
--- a/src/Main.cpp
+++ b/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;
}
diff --git a/src/Resource.h b/src/Resource.h
index a2379d9d..0572fac9 100644
--- a/src/Resource.h
+++ b/src/Resource.h
@@ -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