Use custom Wave files instead of Beep(), as the Beep() function doesn't work reliably on all platforms.

This commit is contained in:
LoRd_MuldeR 2011-03-18 12:37:18 +01:00
parent 108c167767
commit f60515ca50
8 changed files with 24 additions and 14 deletions

View File

@ -112,6 +112,8 @@ 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"
IDR_WAVE_BEEP WAVE "res\\sounds\\beep.wav"
IDR_WAVE_BEEP_LONG WAVE "res\\sounds\\beep2.wav"
/////////////////////////////////////////////////////////////////////////////
//

BIN
res/sounds/beep.wav Normal file

Binary file not shown.

BIN
res/sounds/beep2.wav Normal file

Binary file not shown.

View File

@ -25,7 +25,7 @@
#define VER_LAMEXP_MAJOR 4
#define VER_LAMEXP_MINOR_HI 0
#define VER_LAMEXP_MINOR_LO 1
#define VER_LAMEXP_BUILD 372
#define VER_LAMEXP_BUILD 373
#define VER_LAMEXP_SUFFIX Beta-9
/*

View File

@ -402,8 +402,11 @@ void ProcessingDialog::doneEncoding(void)
if(!m_userAborted && checkBox_shutdownComputer->isChecked())
{
qWarning("Initiating shutdown sequence!");
shutdownComputer();
if(shutdownComputer())
{
m_shutdownFlag = true;
accept();
}
}
}
@ -711,12 +714,14 @@ void ProcessingDialog::systemTrayActivated(QSystemTrayIcon::ActivationReason rea
}
}
void ProcessingDialog::shutdownComputer(void)
bool 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..."));
qWarning("Initiating shutdown sequence!");
QProgressDialog progressDialog(text.arg(iTimeout), tr("Cancel Shutdown"), 0, iTimeout + 1, this, flags);
progressDialog.setModal(true);
progressDialog.setAutoClose(false);
@ -728,7 +733,9 @@ void ProcessingDialog::shutdownComputer(void)
if(m_settings->soundsEnabled())
{
QApplication::setOverrideCursor(Qt::WaitCursor);
PlaySound(MAKEINTRESOURCE(IDR_WAVE_SHUTDOWN), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
QApplication::restoreOverrideCursor();
}
QTimer timer;
@ -742,19 +749,18 @@ void ProcessingDialog::shutdownComputer(void)
for(int i = 1; i <= iTimeout; i++)
{
eventLoop.exec();
if(progressDialog.wasCanceled()) break;
if(progressDialog.wasCanceled())
{
progressDialog.close();
return false;
}
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();
PlaySound(MAKEINTRESOURCE((i < iTimeout) ? IDR_WAVE_BEEP : IDR_WAVE_BEEP_LONG), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
}
progressDialog.close();
return true;
}

View File

@ -66,7 +66,7 @@ private:
void startNextJob(void);
AudioFileModel updateMetaInfo(const AudioFileModel &audioFile);
void writePlayList(void);
void shutdownComputer(void);
bool shutdownComputer(void);
QList<AudioFileModel> m_pendingJobs;
SettingsModel *m_settings;

View File

@ -162,7 +162,7 @@ int lamexp_main(int argc, char* argv[])
//Shotdown computer
if(bShutdown)
{
if(!lamexp_shutdown_computer("LameXP planned computer shutdown!", 12))
if(!lamexp_shutdown_computer(QApplication::applicationFilePath(), 12))
{
QMessageBox messageBox(QMessageBox::Critical, "LameXP", "Sorry, LameXP was unable to shutdown your computer!", QMessageBox::NoButton, NULL, Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint | Qt::WindowStaysOnTopHint);
}

View File

@ -33,6 +33,8 @@
#define IDR_WAVE_WHAMMY 670
#define IDR_WAVE_WOOHOO 671
#define IDR_WAVE_SHUTDOWN 672
#define IDR_WAVE_BEEP 673
#define IDR_WAVE_BEEP_LONG 674
/*
* Next default values for new objects