Added an option to hibernate the computer ("suspend to disk") instead of shutting it down ("power off").

This commit is contained in:
LoRd_MuldeR 2011-10-22 01:13:28 +02:00
parent 0e6058df9e
commit a98206bd70
22 changed files with 712 additions and 499 deletions

View File

@ -88,7 +88,7 @@
</ClCompile>
<Link>
<AdditionalOptions>"/MANIFESTDEPENDENCY:type=%27win32%27 name=%27Microsoft.Windows.Common-Controls%27 version=%276.0.0.0%27 publicKeyToken=%276595b64144ccf1df%27 language=%27*%27 processorArchitecture=%27*%27" %(AdditionalOptions)</AdditionalOptions>
<AdditionalDependencies>qtmaind.lib;QtCored4.lib;QtGuid4.lib;Winmm.lib;Shlwapi.lib;Wininet.lib;psapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>qtmaind.lib;QtCored4.lib;QtGuid4.lib;Winmm.lib;Shlwapi.lib;Wininet.lib;PowrProf.lib;psapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(QTDIR)\lib;$(QTDIR)\plugins\imageformats;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
@ -141,7 +141,7 @@ copy "$(QTDIR)\plugins\imageformats\q????d4.dll" "$(TargetDir)imageformats\"
</ClCompile>
<Link>
<AdditionalOptions>"/MANIFESTDEPENDENCY:type=%27win32%27 name=%27Microsoft.Windows.Common-Controls%27 version=%276.0.0.0%27 publicKeyToken=%276595b64144ccf1df%27 language=%27*%27 processorArchitecture=%27*%27" %(AdditionalOptions)</AdditionalOptions>
<AdditionalDependencies>qtmain.lib;QtCore4.lib;QtGui4.lib;Winmm.lib;Shlwapi.lib;Wininet.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>qtmain.lib;QtCore4.lib;QtGui4.lib;Winmm.lib;Shlwapi.lib;Wininet.lib;PowrProf.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ShowProgress>LinkVerboseLib</ShowProgress>
<Version>
</Version>
@ -213,7 +213,7 @@ del "$(TargetDir)imageformats\q???d4.dll"
</ClCompile>
<Link>
<AdditionalOptions>"/MANIFESTDEPENDENCY:type=%27win32%27 name=%27Microsoft.Windows.Common-Controls%27 version=%276.0.0.0%27 publicKeyToken=%276595b64144ccf1df%27 language=%27*%27 processorArchitecture=%27*%27" %(AdditionalOptions)</AdditionalOptions>
<AdditionalDependencies>qtmain.lib;QtCore.lib;QtGui.lib;QtSvg.lib;qsvg.lib;qico.lib;Winmm.lib;imm32.lib;ws2_32.lib;Shlwapi.lib;Wininet.lib;EncodePointer.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>qtmain.lib;QtCore.lib;QtGui.lib;QtSvg.lib;qsvg.lib;qico.lib;Winmm.lib;imm32.lib;ws2_32.lib;Shlwapi.lib;Wininet.lib;PowrProf.lib;EncodePointer.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ShowProgress>LinkVerboseLib</ShowProgress>
<AdditionalLibraryDirectories>$(SolutionDir)\etc\Prerequisites\qt4_static\lib;$(SolutionDir)\etc\Prerequisites\qt4_static\plugins\imageformats;$(SolutionDir)\etc\Prerequisites\EncodePointer\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>

File diff suppressed because it is too large Load Diff

View File

@ -1670,6 +1670,26 @@
<source>DEMO VERSION</source>
<translation></translation>
</message>
<message>
<source>Hibernate Computer On Shutdown</source>
<translation>Computer in den Ruhezustand versetzen</translation>
</message>
<message>
<source>Hibernate Computer</source>
<translation>Ruhezustand</translation>
</message>
<message>
<source>Do you really want the computer to be hibernated on shutdown?</source>
<translation>Sind Sie sicher, dass der Computer in den Ruhezustand versetzt werden soll?</translation>
</message>
<message>
<source>LameXP will hibernate the computer on shutdown from now on.</source>
<translation>LameXP wird den Computer fortan in den Ruhezustand versetzen.</translation>
</message>
<message>
<source>LameXP will &lt;i&gt;not&lt;/i&gt; hibernate the computer on shutdown from now on.</source>
<translation>LameXP wird den Computer fortan &lt;i&gt;nicht&lt;/i&gt; in den Ruhezustand versetzen.</translation>
</message>
</context>
<context>
<name>MetaInfo</name>

View File

@ -1669,6 +1669,26 @@
<source>DEMO VERSION</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hibernate Computer On Shutdown</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hibernate Computer</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Do you really want the computer to be hibernated on shutdown?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LameXP will hibernate the computer on shutdown from now on.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LameXP will &lt;i&gt;not&lt;/i&gt; hibernate the computer on shutdown from now on.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MetaInfo</name>

View File

@ -1679,6 +1679,26 @@ Ouvrir le dossier récursivement...</translation>
<source>DEMO VERSION</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hibernate Computer On Shutdown</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hibernate Computer</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Do you really want the computer to be hibernated on shutdown?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LameXP will hibernate the computer on shutdown from now on.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LameXP will &lt;i&gt;not&lt;/i&gt; hibernate the computer on shutdown from now on.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MetaInfo</name>

View File

@ -1670,6 +1670,26 @@
<source>DEMO VERSION</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hibernate Computer On Shutdown</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hibernate Computer</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Do you really want the computer to be hibernated on shutdown?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LameXP will hibernate the computer on shutdown from now on.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LameXP will &lt;i&gt;not&lt;/i&gt; hibernate the computer on shutdown from now on.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MetaInfo</name>

View File

@ -1669,6 +1669,26 @@
<source>DEMO VERSION</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hibernate Computer On Shutdown</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hibernate Computer</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Do you really want the computer to be hibernated on shutdown?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LameXP will hibernate the computer on shutdown from now on.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LameXP will &lt;i&gt;not&lt;/i&gt; hibernate the computer on shutdown from now on.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MetaInfo</name>

File diff suppressed because it is too large Load Diff

View File

@ -1675,6 +1675,26 @@
<source>DEMO VERSION</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hibernate Computer On Shutdown</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hibernate Computer</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Do you really want the computer to be hibernated on shutdown?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LameXP will hibernate the computer on shutdown from now on.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LameXP will &lt;i&gt;not&lt;/i&gt; hibernate the computer on shutdown from now on.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MetaInfo</name>

View File

@ -1670,6 +1670,26 @@
<source>DEMO VERSION</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hibernate Computer On Shutdown</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hibernate Computer</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Do you really want the computer to be hibernated on shutdown?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LameXP will hibernate the computer on shutdown from now on.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LameXP will &lt;i&gt;not&lt;/i&gt; hibernate the computer on shutdown from now on.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MetaInfo</name>

View File

@ -1099,8 +1099,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>604</width>
<height>1524</height>
<width>602</width>
<height>1515</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_22">
@ -3482,6 +3482,7 @@
<addaction name="actionDisableSlowStartupNotifications"/>
<addaction name="actionDisableShellIntegration"/>
<addaction name="separator"/>
<addaction name="actionHibernateComputer"/>
<addaction name="actionCheckForBetaUpdates"/>
</widget>
<addaction name="actionImportCueSheet"/>
@ -3793,6 +3794,14 @@
<string>Disable Slow Startup Notifications</string>
</property>
</action>
<action name="actionHibernateComputer">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Hibernate Computer On Shutdown</string>
</property>
</action>
</widget>
<resources>
<include location="../res/Icons.qrc"/>

Binary file not shown.

View File

@ -30,7 +30,7 @@
#define VER_LAMEXP_MINOR_LO 3
#define VER_LAMEXP_TYPE Beta
#define VER_LAMEXP_PATCH 6
#define VER_LAMEXP_BUILD 750
#define VER_LAMEXP_BUILD 752
///////////////////////////////////////////////////////////////////////////////
// Tools versions

View File

@ -360,12 +360,14 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S
actionDisableShellIntegration->setDisabled(lamexp_portable_mode() && actionDisableShellIntegration->isChecked());
actionCheckForBetaUpdates->setChecked(m_settings->autoUpdateCheckBeta() || lamexp_version_demo());
actionCheckForBetaUpdates->setEnabled(!lamexp_version_demo());
actionHibernateComputer->setChecked(m_settings->hibernateComputer());
connect(actionDisableUpdateReminder, SIGNAL(triggered(bool)), this, SLOT(disableUpdateReminderActionTriggered(bool)));
connect(actionDisableSounds, SIGNAL(triggered(bool)), this, SLOT(disableSoundsActionTriggered(bool)));
connect(actionDisableNeroAacNotifications, SIGNAL(triggered(bool)), this, SLOT(disableNeroAacNotificationsActionTriggered(bool)));
connect(actionDisableSlowStartupNotifications, SIGNAL(triggered(bool)), this, SLOT(disableSlowStartupNotificationsActionTriggered(bool)));
connect(actionDisableShellIntegration, SIGNAL(triggered(bool)), this, SLOT(disableShellIntegrationActionTriggered(bool)));
connect(actionShowDropBoxWidget, SIGNAL(triggered(bool)), this, SLOT(showDropBoxWidgetActionTriggered(bool)));
connect(actionHibernateComputer, SIGNAL(triggered(bool)), this, SLOT(hibernateComputerActionTriggered(bool)));
connect(actionCheckForBetaUpdates, SIGNAL(triggered(bool)), this, SLOT(checkForBetaUpdatesActionTriggered(bool)));
connect(actionImportCueSheet, SIGNAL(triggered(bool)), this, SLOT(importCueSheetActionTriggered(bool)));
@ -1449,9 +1451,9 @@ void MainWindow::disableUpdateReminderActionTriggered(bool checked)
{
if(checked)
{
if(0 == QMessageBox::question(this, tr("Disable Update Reminder"), tr("Do you really want to disable the update reminder?"), tr("Yes"), tr("No"), QString(), 1))
if(0 == QMessageBox::question(this, tr("Disable Update Reminder"), NOBR(tr("Do you really want to disable the update reminder?")), tr("Yes"), tr("No"), QString(), 1))
{
QMessageBox::information(this, tr("Update Reminder"), QString("%1<br>%2").arg(tr("The update reminder has been disabled."), tr("Please remember to check for updates at regular intervals!")));
QMessageBox::information(this, tr("Update Reminder"), QString("%1<br>%2").arg(NOBR(tr("The update reminder has been disabled.")), NOBR(tr("Please remember to check for updates at regular intervals!"))));
m_settings->autoUpdateEnabled(false);
}
else
@ -1461,7 +1463,7 @@ void MainWindow::disableUpdateReminderActionTriggered(bool checked)
}
else
{
QMessageBox::information(this, tr("Update Reminder"), tr("The update reminder has been re-enabled."));
QMessageBox::information(this, tr("Update Reminder"), NOBR(tr("The update reminder has been re-enabled.")));
m_settings->autoUpdateEnabled(true);
}
@ -1475,9 +1477,9 @@ void MainWindow::disableSoundsActionTriggered(bool checked)
{
if(checked)
{
if(0 == QMessageBox::question(this, tr("Disable Sound Effects"), tr("Do you really want to disable all sound effects?"), tr("Yes"), tr("No"), QString(), 1))
if(0 == QMessageBox::question(this, tr("Disable Sound Effects"), NOBR(tr("Do you really want to disable all sound effects?")), tr("Yes"), tr("No"), QString(), 1))
{
QMessageBox::information(this, tr("Sound Effects"), tr("All sound effects have been disabled."));
QMessageBox::information(this, tr("Sound Effects"), NOBR(tr("All sound effects have been disabled.")));
m_settings->soundsEnabled(false);
}
else
@ -1487,7 +1489,7 @@ void MainWindow::disableSoundsActionTriggered(bool checked)
}
else
{
QMessageBox::information(this, tr("Sound Effects"), tr("The sound effects have been re-enabled."));
QMessageBox::information(this, tr("Sound Effects"), NOBR(tr("The sound effects have been re-enabled.")));
m_settings->soundsEnabled(true);
}
@ -1501,9 +1503,9 @@ void MainWindow::disableNeroAacNotificationsActionTriggered(bool checked)
{
if(checked)
{
if(0 == QMessageBox::question(this, tr("Nero AAC Notifications"), tr("Do you really want to disable all Nero AAC Encoder notifications?"), tr("Yes"), tr("No"), QString(), 1))
if(0 == QMessageBox::question(this, tr("Nero AAC Notifications"), NOBR(tr("Do you really want to disable all Nero AAC Encoder notifications?")), tr("Yes"), tr("No"), QString(), 1))
{
QMessageBox::information(this, tr("Nero AAC Notifications"), tr("All Nero AAC Encoder notifications have been disabled."));
QMessageBox::information(this, tr("Nero AAC Notifications"), NOBR(tr("All Nero AAC Encoder notifications have been disabled.")));
m_settings->neroAacNotificationsEnabled(false);
}
else
@ -1513,39 +1515,13 @@ void MainWindow::disableNeroAacNotificationsActionTriggered(bool checked)
}
else
{
QMessageBox::information(this, tr("Nero AAC Notifications"), tr("The Nero AAC Encoder notifications have been re-enabled."));
QMessageBox::information(this, tr("Nero AAC Notifications"), NOBR(tr("The Nero AAC Encoder notifications have been re-enabled.")));
m_settings->neroAacNotificationsEnabled(true);
}
actionDisableNeroAacNotifications->setChecked(!m_settings->neroAacNotificationsEnabled());
}
/*
* Disable WMA Decoder component action
*/
//void MainWindow::disableWmaDecoderNotificationsActionTriggered(bool checked)
//{
// if(checked)
// {
// if(0 == QMessageBox::question(this, tr("WMA Decoder Notifications"), tr("Do you really want to disable all WMA Decoder notifications?"), tr("Yes"), tr("No"), QString(), 1))
// {
// QMessageBox::information(this, tr("WMA Decoder Notifications"), tr("All WMA Decoder notifications have been disabled."));
// m_settings->wmaDecoderNotificationsEnabled(false);
// }
// else
// {
// m_settings->wmaDecoderNotificationsEnabled(true);
// }
// }
// else
// {
// QMessageBox::information(this, tr("WMA Decoder Notifications"), tr("The WMA Decoder notifications have been re-enabled."));
// m_settings->wmaDecoderNotificationsEnabled(true);
// }
//
// actionDisableWmaDecoderNotifications->setChecked(!m_settings->wmaDecoderNotificationsEnabled());
//}
/*
* Disable slow startup action
*/
@ -1553,9 +1529,9 @@ void MainWindow::disableSlowStartupNotificationsActionTriggered(bool checked)
{
if(checked)
{
if(0 == QMessageBox::question(this, tr("Slow Startup Notifications"), tr("Do you really want to disable the slow startup notifications?"), tr("Yes"), tr("No"), QString(), 1))
if(0 == QMessageBox::question(this, tr("Slow Startup Notifications"), NOBR(tr("Do you really want to disable the slow startup notifications?")), tr("Yes"), tr("No"), QString(), 1))
{
QMessageBox::information(this, tr("Slow Startup Notifications"), tr("The slow startup notifications have been disabled."));
QMessageBox::information(this, tr("Slow Startup Notifications"), NOBR(tr("The slow startup notifications have been disabled.")));
m_settings->antivirNotificationsEnabled(false);
}
else
@ -1565,28 +1541,13 @@ void MainWindow::disableSlowStartupNotificationsActionTriggered(bool checked)
}
else
{
QMessageBox::information(this, tr("Slow Startup Notifications"), tr("The slow startup notifications have been re-enabled."));
QMessageBox::information(this, tr("Slow Startup Notifications"), NOBR(tr("The slow startup notifications have been re-enabled.")));
m_settings->antivirNotificationsEnabled(true);
}
actionDisableSlowStartupNotifications->setChecked(!m_settings->antivirNotificationsEnabled());
}
/*
* Download and install WMA Decoder component
*/
//void MainWindow::installWMADecoderActionTriggered(bool checked)
//{
// if(QMessageBox::question(this, tr("Install WMA Decoder"), tr("Do you want to download and install the WMA File Decoder component now?"), tr("Download && Install"), tr("Cancel")) == 0)
// {
// if(installWMADecoder())
// {
// QApplication::quit();
// return;
// }
// }
//}
/*
* Import a Cue Sheet file
*/
@ -1654,9 +1615,9 @@ void MainWindow::checkForBetaUpdatesActionTriggered(bool checked)
if(checked)
{
if(0 == QMessageBox::question(this, tr("Beta Updates"), tr("Do you really want LameXP to check for Beta (pre-release) updates?"), tr("Yes"), tr("No"), QString(), 1))
if(0 == QMessageBox::question(this, tr("Beta Updates"), NOBR(tr("Do you really want LameXP to check for Beta (pre-release) updates?")), tr("Yes"), tr("No"), QString(), 1))
{
if(0 == QMessageBox::information(this, tr("Beta Updates"), tr("LameXP will check for Beta (pre-release) updates from now on."), tr("Check Now"), tr("Discard")))
if(0 == QMessageBox::information(this, tr("Beta Updates"), NOBR(tr("LameXP will check for Beta (pre-release) updates from now on.")), tr("Check Now"), tr("Discard")))
{
checkUpdatesNow = true;
}
@ -1669,7 +1630,7 @@ void MainWindow::checkForBetaUpdatesActionTriggered(bool checked)
}
else
{
QMessageBox::information(this, tr("Beta Updates"), tr("LameXP will <i>not</i> check for Beta (pre-release) updates from now on."));
QMessageBox::information(this, tr("Beta Updates"), NOBR(tr("LameXP will <i>not</i> check for Beta (pre-release) updates from now on.")));
m_settings->autoUpdateCheckBeta(false);
}
@ -1684,6 +1645,32 @@ void MainWindow::checkForBetaUpdatesActionTriggered(bool checked)
}
}
/*
* Hibernate computer action
*/
void MainWindow::hibernateComputerActionTriggered(bool checked)
{
if(checked)
{
if(0 == QMessageBox::question(this, tr("Hibernate Computer"), NOBR(tr("Do you really want the computer to be hibernated on shutdown?")), tr("Yes"), tr("No"), QString(), 1))
{
QMessageBox::information(this, tr("Hibernate Computer"), NOBR(tr("LameXP will hibernate the computer on shutdown from now on.")));
m_settings->hibernateComputer(true);
}
else
{
m_settings->hibernateComputer(false);
}
}
else
{
QMessageBox::information(this, tr("Hibernate Computer"), NOBR(tr("LameXP will <i>not</i> hibernate the computer on shutdown from now on.")));
m_settings->hibernateComputer(false);
}
actionHibernateComputer->setChecked(m_settings->hibernateComputer());
}
/*
* Disable shell integration action
*/
@ -1691,10 +1678,10 @@ void MainWindow::disableShellIntegrationActionTriggered(bool checked)
{
if(checked)
{
if(0 == QMessageBox::question(this, tr("Shell Integration"), tr("Do you really want to disable the LameXP shell integration?"), tr("Yes"), tr("No"), QString(), 1))
if(0 == QMessageBox::question(this, tr("Shell Integration"), NOBR(tr("Do you really want to disable the LameXP shell integration?")), tr("Yes"), tr("No"), QString(), 1))
{
ShellIntegration::remove();
QMessageBox::information(this, tr("Shell Integration"), tr("The LameXP shell integration has been disabled."));
QMessageBox::information(this, tr("Shell Integration"), NOBR(tr("The LameXP shell integration has been disabled.")));
m_settings->shellIntegrationEnabled(false);
}
else
@ -1705,7 +1692,7 @@ void MainWindow::disableShellIntegrationActionTriggered(bool checked)
else
{
ShellIntegration::install();
QMessageBox::information(this, tr("Shell Integration"), tr("The LameXP shell integration has been re-enabled."));
QMessageBox::information(this, tr("Shell Integration"), NOBR(tr("The LameXP shell integration has been re-enabled.")));
m_settings->shellIntegrationEnabled(true);
}

View File

@ -87,6 +87,7 @@ private slots:
void gotoHomeFolderButtonClicked(void);
void gotoMusicFolderButtonClicked(void);
void handleDelayedFiles(void);
void hibernateComputerActionTriggered(bool checked);
void importCueSheetActionTriggered(bool checked);
void initOutputFolderModel(void);
void languageActionActivated(QAction *action);

View File

@ -96,7 +96,7 @@ ProcessingDialog::ProcessingDialog(FileListModel *fileListModel, AudioFileModel
m_systemTray(new QSystemTrayIcon(QIcon(":/icons/cd_go.png"), this)),
m_settings(settings),
m_metaInfo(metaInfo),
m_shutdownFlag(false),
m_shutdownFlag(shutdownFlag_None),
m_diskObserver(NULL)
{
//Init the dialog, from the .ui file
@ -431,7 +431,7 @@ void ProcessingDialog::doneEncoding(void)
{
if(shutdownComputer())
{
m_shutdownFlag = true;
m_shutdownFlag = m_settings->hibernateComputer() ? shutdownFlag_Hibernate : shutdownFlag_TurnPowerOff;
accept();
}
}

View File

@ -35,6 +35,13 @@ class AudioFileModel;
class SettingsModel;
class DiskObserverThread;
enum shutdownFlag_t
{
shutdownFlag_None = 0,
shutdownFlag_TurnPowerOff = 1,
shutdownFlag_Hibernate = 2
};
class ProcessingDialog : public QDialog, private Ui::ProcessingDialog
{
Q_OBJECT
@ -43,7 +50,7 @@ public:
ProcessingDialog(FileListModel *fileListModel, AudioFileModel *metaInfo, SettingsModel *settings, QWidget *parent = 0);
~ProcessingDialog(void);
bool getShutdownFlag(void) { return m_shutdownFlag; }
int getShutdownFlag(void) { return m_shutdownFlag; }
private slots:
void initEncoding(void);
@ -85,6 +92,6 @@ private:
QList<QUuid> m_failedJobs;
bool m_userAborted;
QSystemTrayIcon *m_systemTray;
bool m_shutdownFlag;
int m_shutdownFlag;
DiskObserverThread *m_diskObserver;
};

View File

@ -58,6 +58,7 @@
//COM includes
#include <Objbase.h>
#include <PowrProf.h>
//Debug only includes
#if LAMEXP_DEBUG
@ -1501,7 +1502,7 @@ __int64 lamexp_free_diskspace(const QString &path)
/*
* Shutdown the computer
*/
bool lamexp_shutdown_computer(const QString &message, const unsigned long timeout, const bool forceShutdown)
bool lamexp_shutdown_computer(const QString &message, const unsigned long timeout, const bool forceShutdown, const bool hibernate)
{
HANDLE hToken = NULL;
@ -1516,8 +1517,15 @@ bool lamexp_shutdown_computer(const QString &message, const unsigned long timeou
{
if(AdjustTokenPrivileges(hToken, FALSE, &privileges, NULL, NULL, NULL))
{
if(hibernate)
{
if(SetSuspendState(TRUE, TRUE, TRUE))
{
return true;
}
}
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 InitiateSystemShutdownEx(NULL, const_cast<wchar_t*>(QWCHAR(message)), timeout, forceShutdown ? TRUE : FALSE, FALSE, reason);
}
}
}

View File

@ -103,7 +103,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(int argc = 0, char **argv = NULL);
bool lamexp_portable_mode(void);
bool lamexp_shutdown_computer(const QString &message, const unsigned long timeout = 30, const bool forceShutdown = true);
bool lamexp_shutdown_computer(const QString &message, const unsigned long timeout = 30, const bool forceShutdown = true, const bool hibernate = false);
//Translation support
QStringList lamexp_query_translations(void);

View File

@ -46,8 +46,8 @@
static int lamexp_main(int argc, char* argv[])
{
int iResult = -1;
int iShutdown = shutdownFlag_None;
bool bAccepted = true;
bool bShutdown = false;
//Init console
lamexp_init_console(argc, argv);
@ -145,7 +145,7 @@ static int lamexp_main(int argc, char* argv[])
MainWindow *poMainWindow = new MainWindow(fileListModel, metaInfo, settingsModel);
//Main application loop
while(bAccepted && !bShutdown)
while(bAccepted && (iShutdown <= shutdownFlag_None))
{
//Show main window
poMainWindow->show();
@ -157,7 +157,7 @@ static int lamexp_main(int argc, char* argv[])
{
ProcessingDialog *processingDialog = new ProcessingDialog(fileListModel, metaInfo, settingsModel);
processingDialog->exec();
bShutdown = processingDialog->getShutdownFlag();
iShutdown = processingDialog->getShutdownFlag();
LAMEXP_DELETE(processingDialog);
}
}
@ -172,9 +172,9 @@ static int lamexp_main(int argc, char* argv[])
qDebug("Shutting down, please wait...\n");
//Shotdown computer
if(bShutdown)
if(iShutdown > shutdownFlag_None)
{
if(!lamexp_shutdown_computer(QApplication::applicationFilePath(), 12))
if(!lamexp_shutdown_computer(QApplication::applicationFilePath(), 12, true, (iShutdown == shutdownFlag_Hibernate)))
{
QMessageBox messageBox(QMessageBox::Critical, "LameXP", "Sorry, LameXP was unable to shutdown your computer!", QMessageBox::NoButton, NULL, Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint | Qt::WindowStaysOnTopHint);
}

View File

@ -113,6 +113,7 @@ LAMEXP_MAKE_ID(customParametersAften, "AdvancedOptions/CustomParameters/Aften");
LAMEXP_MAKE_ID(customParametersFLAC, "AdvancedOptions/CustomParameters/FLAC");
LAMEXP_MAKE_ID(renameOutputFilesEnabled, "AdvancedOptions/RenameOutputFiles/Enabled");
LAMEXP_MAKE_ID(renameOutputFilesPattern, "AdvancedOptions/RenameOutputFiles/Pattern");
LAMEXP_MAKE_ID(hibernateComputer, "AdvancedOptions/HibernateComputerOnShutdown");
LAMEXP_MAKE_ID(metaInfoPosition, "MetaInformation/PlaylistPosition");
LAMEXP_MAKE_ID(maximumInstances, "AdvancedOptions/Threading/MaximumInstances");
LAMEXP_MAKE_ID(customTempPath, "AdvancedOptions/TempDirectory/CustomPath");
@ -363,3 +364,4 @@ LAMEXP_MAKE_OPTION_S(customTempPath, QDesktopServices::storageLocation(QDesktopS
LAMEXP_MAKE_OPTION_B(customTempPathEnabled, false);
LAMEXP_MAKE_OPTION_B(slowStartup, false);
LAMEXP_MAKE_OPTION_S(mostRecentInputPath, QDesktopServices::storageLocation(QDesktopServices::MusicLocation));
LAMEXP_MAKE_OPTION_B(hibernateComputer, false);

View File

@ -128,6 +128,7 @@ public:
LAMEXP_MAKE_OPTION_B(customTempPathEnabled);
LAMEXP_MAKE_OPTION_B(slowStartup);
LAMEXP_MAKE_OPTION_S(mostRecentInputPath);
LAMEXP_MAKE_OPTION_B(hibernateComputer);
//Misc
void validate(void);