///////////////////////////////////////////////////////////////////////////////
// LameXP - Audio Encoder Front-End
-// Copyright (C) 2004-2011 LoRd_MuldeR <MuldeR2@GMX.de>
+// Copyright (C) 2004-2012 LoRd_MuldeR <MuldeR2@GMX.de>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
m_shutdownFlag(shutdownFlag_None),
m_diskObserver(NULL),
m_cpuObserver(NULL),
- m_ramObserver(NULL)
+ m_ramObserver(NULL),
+ m_firstShow(true)
{
//Init the dialog, from the .ui file
setupUi(this);
setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint);
+ //Update header icon
+ label_headerIcon->setPixmap(lamexp_app_icon().pixmap(label_headerIcon->size()));
+
//Setup version info
label_versionInfo->setText(QString().sprintf("v%d.%02d %s (Build %d)", lamexp_version_major(), lamexp_version_minor(), lamexp_version_release(), lamexp_version_build()));
label_versionInfo->installEventFilter(this);
m_succeededJobs.clear();
m_failedJobs.clear();
m_userAborted = false;
+ m_forcedAbort = false;
m_timerStart = 0I64;
}
void ProcessingDialog::showEvent(QShowEvent *event)
{
- static const char *NA = " N/A";
+ QDialog::showEvent(event);
- setCloseButtonEnabled(false);
- button_closeDialog->setEnabled(false);
- button_AbortProcess->setEnabled(false);
- m_systemTray->setVisible(true);
-
- if(!SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS))
+ if(m_firstShow)
{
- SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
- }
+ static const char *NA = " N/A";
+
+ setCloseButtonEnabled(false);
+ button_closeDialog->setEnabled(false);
+ button_AbortProcess->setEnabled(false);
+ m_systemTray->setVisible(true);
+
+ if(!SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS))
+ {
+ SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
+ }
- label_cpu->setText(NA);
- label_disk->setText(NA);
- label_ram->setText(NA);
+ label_cpu->setText(NA);
+ label_disk->setText(NA);
+ label_ram->setText(NA);
- QTimer::singleShot(1000, this, SLOT(initEncoding()));
+ QTimer::singleShot(1000, this, SLOT(initEncoding()));
+ m_firstShow = false;
+ }
}
void ProcessingDialog::closeEvent(QCloseEvent *event)
return false;
}
+bool ProcessingDialog::event(QEvent *e)
+{
+ switch(e->type())
+ {
+ case lamexp_event_queryendsession:
+ qWarning("System is shutting down, preparing to abort...");
+ if(!m_userAborted) abortEncoding(true);
+ return true;
+ case lamexp_event_endsession:
+ qWarning("System is shutting down, encoding will be aborted now...");
+ if(isVisible())
+ {
+ while(!close())
+ {
+ if(!m_userAborted) abortEncoding(true);
+ QApplication::processEvents(QEventLoop::WaitForMoreEvents & QEventLoop::ExcludeUserInputEvents);
+ }
+ }
+ m_pendingJobs.clear();
+ return true;
+ default:
+ return QDialog::event(e);
+ }
+}
+
bool ProcessingDialog::winEvent(MSG *message, long *result)
{
return WinSevenTaskbar::handleWinEvent(message, result);
void ProcessingDialog::initEncoding(void)
{
+ qDebug("Initializing encoding process...");
+
m_runningThreads = 0;
m_currentFile = 0;
m_allJobs.clear();
m_succeededJobs.clear();
m_failedJobs.clear();
m_userAborted = false;
+ m_forcedAbort = false;
m_playList.clear();
CHANGE_BACKGROUND_COLOR(frame_header, QColor(Qt::white));
unsigned int maximumInstances = qBound(0U, m_settings->maximumInstances(), MAX_INSTANCES);
if(maximumInstances < 1)
{
- lamexp_cpu_t cpuFeatures = lamexp_detect_cpu_features();
+ lamexp_cpu_t cpuFeatures = lamexp_detect_cpu_features(lamexp_arguments());
maximumInstances = cores2instances(qBound(1, cpuFeatures.count, 64));
}
}
}
-void ProcessingDialog::abortEncoding(void)
+void ProcessingDialog::abortEncoding(bool force)
{
m_userAborted = true;
+ if(force) m_forcedAbort = true;
button_AbortProcess->setEnabled(false);
-
SET_PROGRESS_TEXT(tr("Aborted! Waiting for running jobs to terminate..."));
for(int i = 0; i < m_threadList.count(); i++)
m_systemTray->showMessage(tr("LameXP - Aborted"), tr("Process was aborted by the user."), QSystemTrayIcon::Warning);
m_systemTray->setIcon(QIcon(":/icons/cd_delete.png"));
QApplication::processEvents();
- if(m_settings->soundsEnabled()) PlaySound(MAKEINTRESOURCE(IDR_WAVE_ABORTED), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
+ if(m_settings->soundsEnabled() && !m_forcedAbort)
+ {
+ PlaySound(MAKEINTRESOURCE(IDR_WAVE_ABORTED), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
+ }
}
else
{
}
else
{
- MessageBeep(MB_ICONWARNING);
+ QMessageBox::information(this, windowTitle(), m_progressModel->data(m_progressModel->index(index.row(), 0)).toString());
}
}
else
{
if(reason == QSystemTrayIcon::DoubleClick)
{
- SetForegroundWindow(this->winId());
+ SetForegroundWindow(reinterpret_cast<HWND>(this->winId()));
}
}