///////////////////////////////////////////////////////////////////////////////
// LameXP - Audio Encoder Front-End
-// Copyright (C) 2004-2013 LoRd_MuldeR <MuldeR2@GMX.de>
+// Copyright (C) 2004-2015 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
// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
+// (at your option) any later version, but always including the *additional*
+// restrictions defined in the "License.txt" file.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
#include "Dialog_Processing.h"
//UIC includes
-#include "../tmp/UIC_ProcessingDialog.h"
+#include "UIC_ProcessingDialog.h"
+//Internal
#include "Global.h"
-#include "Resource.h"
#include "Model_FileList.h"
#include "Model_Progress.h"
#include "Model_Settings.h"
+#include "Model_FileExts.h"
#include "Thread_Process.h"
#include "Thread_CPUObserver.h"
#include "Thread_RAMObserver.h"
#include "Filter_Normalize.h"
#include "Filter_Resample.h"
#include "Filter_ToneAdjust.h"
-#include "WinSevenTaskbar.h"
+//MUtils
+#include <MUtils/Global.h>
+#include <MUtils/OSSupport.h>
+#include <MUtils/GUI.h>
+#include <MUtils/CPUFeatures.h>
+#include <MUtils/Sound.h>
+#include <MUtils/Taskbar7.h>
+
+//Qt
#include <QApplication>
#include <QRect>
#include <QDesktopWidget>
#include <QProgressDialog>
#include <QResizeEvent>
#include <QTime>
+#include <QElapsedTimer>
#include <QThreadPool>
#include <math.h>
#include <float.h>
+#include <stdint.h>
////////////////////////////////////////////////////////////
//Maximum number of parallel instances
-#define MAX_INSTANCES 16U
+#define MAX_INSTANCES 32U
//Function to calculate the number of instances
static int cores2instances(int cores);
} \
while(0)
+#define PLAY_SOUND_OPTIONAL(NAME, ASYNC) do \
+{ \
+ if(m_settings->soundsEnabled()) MUtils::Sound::play_sound((NAME), (ASYNC)); \
+} \
+while(0)
+
#define IS_VBR(RC_MODE) ((RC_MODE) == SettingsModel::VBRMode)
////////////////////////////////////////////////////////////
// Constructor
////////////////////////////////////////////////////////////
-ProcessingDialog::ProcessingDialog(FileListModel *fileListModel, const AudioFileModel_MetaInfo *metaInfo, SettingsModel *settings, QWidget *parent)
+ProcessingDialog::ProcessingDialog(FileListModel *const fileListModel, const AudioFileModel_MetaInfo *const metaInfo, const SettingsModel *const settings, QWidget *const parent)
:
QDialog(parent),
ui(new Ui::ProcessingDialog),
m_systemTray(new QSystemTrayIcon(QIcon(":/icons/cd_go.png"), this)),
+ m_taskbar(new MUtils::Taskbar7(this)),
m_settings(settings),
m_metaInfo(metaInfo),
- m_shutdownFlag(shutdownFlag_None),
- m_threadPool(NULL),
- m_diskObserver(NULL),
- m_cpuObserver(NULL),
- m_ramObserver(NULL),
+ m_shutdownFlag(SHUTDOWN_FLAG_NONE),
m_progressViewFilter(-1),
+ m_initThreads(0),
+ m_defaultColor(new QColor()),
m_firstShow(true)
{
//Init the dialog, from the .ui file
ui->setupUi(this);
setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint);
+ //Update the window icon
+ MUtils::GUI::set_window_icon(this, lamexp_app_icon(), true);
+
//Update header icon
ui->label_headerIcon->setPixmap(lamexp_app_icon().pixmap(ui->label_headerIcon->size()));
connect(ui->button_AbortProcess, SIGNAL(clicked()), this, SLOT(abortEncoding()));
//Init progress indicator
- m_progressIndicator = new QMovie(":/images/Working.gif");
+ m_progressIndicator.reset(new QMovie(":/images/Working.gif"));
m_progressIndicator->setCacheMode(QMovie::CacheAll);
- m_progressIndicator->setSpeed(50);
- ui->label_headerWorking->setMovie(m_progressIndicator);
+ ui->label_headerWorking->setMovie(m_progressIndicator.data());
ui->progressBar->setValue(0);
//Init progress model
- m_progressModel = new ProgressModel();
- ui->view_log->setModel(m_progressModel);
+ m_progressModel.reset(new ProgressModel());
+ ui->view_log->setModel(m_progressModel.data());
ui->view_log->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
ui->view_log->verticalHeader()->hide();
ui->view_log->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
ui->view_log->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
ui->view_log->viewport()->installEventFilter(this);
- connect(m_progressModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(progressModelChanged()));
- connect(m_progressModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)), this, SLOT(progressModelChanged()));
- connect(m_progressModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(progressModelChanged()));
- connect(m_progressModel, SIGNAL(modelReset()), this, SLOT(progressModelChanged()));
+ connect(m_progressModel.data(), SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(progressModelChanged()));
+ connect(m_progressModel.data(), SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)), this, SLOT(progressModelChanged()));
+ connect(m_progressModel.data(), SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(progressModelChanged()));
+ connect(m_progressModel.data(), SIGNAL(modelReset()), this, SLOT(progressModelChanged()));
connect(ui->view_log, SIGNAL(activated(QModelIndex)), this, SLOT(logViewDoubleClicked(QModelIndex)));
connect(ui->view_log->horizontalHeader(), SIGNAL(sectionResized(int,int,int)), this, SLOT(logViewSectionSizeChanged(int,int,int)));
//Create context menu
- m_contextMenu = new QMenu();
- QAction *contextMenuDetailsAction = m_contextMenu->addAction(QIcon(":/icons/zoom.png"), tr("Show details for selected job"));
+ m_contextMenu.reset(new QMenu());
+ QAction *contextMenuDetailsAction = m_contextMenu->addAction(QIcon(":/icons/zoom.png"), tr("Show details for selected job"));
QAction *contextMenuShowFileAction = m_contextMenu->addAction(QIcon(":/icons/folder_go.png"), tr("Browse Output File Location"));
m_contextMenu->addSeparator();
//Create "filter" context menu
- m_progressViewFilterGroup = new QActionGroup(this);
+ m_progressViewFilterGroup.reset(new QActionGroup(this));
QAction *contextMenuFilterAction[5] = {NULL, NULL, NULL, NULL, NULL};
if(QMenu *filterMenu = m_contextMenu->addMenu(QIcon(":/icons/filter.png"), tr("Filter Log Items")))
{
}
//Create info label
- if(m_filterInfoLabel = new QLabel(ui->view_log))
- {
- m_filterInfoLabel->setFrameShape(QFrame::NoFrame);
- m_filterInfoLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
- m_filterInfoLabel->setUserData(0, new IntUserData(-1));
- SET_FONT_BOLD(m_filterInfoLabel, true);
- SET_TEXT_COLOR(m_filterInfoLabel, Qt::darkGray);
- m_filterInfoLabel->setContextMenuPolicy(Qt::CustomContextMenu);
- connect(m_filterInfoLabel, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuTriggered(QPoint)));
- m_filterInfoLabel->hide();
- }
- if(m_filterInfoLabelIcon = new QLabel(ui->view_log))
- {
- m_filterInfoLabelIcon->setFrameShape(QFrame::NoFrame);
- m_filterInfoLabelIcon->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
- m_filterInfoLabelIcon->setContextMenuPolicy(Qt::CustomContextMenu);
- const QIcon &ico = m_progressModel->getIcon(ProgressModel::JobState(-1));
- m_filterInfoLabelIcon->setPixmap(ico.pixmap(16, 16));
- connect(m_filterInfoLabelIcon, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuTriggered(QPoint)));
- m_filterInfoLabelIcon->hide();
- }
+ m_filterInfoLabel.reset(new QLabel(ui->view_log));
+ m_filterInfoLabel->setFrameShape(QFrame::NoFrame);
+ m_filterInfoLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
+ m_filterInfoLabel->setUserData(0, new IntUserData(-1));
+ SET_FONT_BOLD(m_filterInfoLabel, true);
+ SET_TEXT_COLOR(m_filterInfoLabel, Qt::darkGray);
+ m_filterInfoLabel->setContextMenuPolicy(Qt::CustomContextMenu);
+ connect(m_filterInfoLabel.data(), SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuTriggered(QPoint)));
+ m_filterInfoLabel->hide();
+
+ m_filterInfoLabelIcon .reset(new QLabel(ui->view_log));
+ m_filterInfoLabelIcon->setFrameShape(QFrame::NoFrame);
+ m_filterInfoLabelIcon->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
+ m_filterInfoLabelIcon->setContextMenuPolicy(Qt::CustomContextMenu);
+ const QIcon &ico = m_progressModel->getIcon(ProgressModel::JobState(-1));
+ m_filterInfoLabelIcon->setPixmap(ico.pixmap(16, 16));
+ connect(m_filterInfoLabelIcon.data(), SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuTriggered(QPoint)));
+ m_filterInfoLabelIcon->hide();
//Connect context menu
ui->view_log->setContextMenuPolicy(Qt::CustomContextMenu);
}
SET_FONT_BOLD(contextMenuDetailsAction, true);
+ //Setup file extensions
+ if(!m_settings->renameFiles_fileExtension().isEmpty())
+ {
+ m_fileExts.reset(new FileExtsModel());
+ m_fileExts->importItems(m_settings->renameFiles_fileExtension());
+ }
+
//Enque jobs
if(fileListModel)
{
ui->label_headerStatus->setText(QString("<b>%1</b><br>%2").arg(tr("Encoding Files"), tr("Your files are being encoded, please be patient...")));
//Enable system tray icon
- connect(m_systemTray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(systemTrayActivated(QSystemTrayIcon::ActivationReason)));
+ connect(m_systemTray.data(), SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(systemTrayActivated(QSystemTrayIcon::ActivationReason)));
//Init other vars
m_runningThreads = 0;
m_skippedJobs.clear();
m_userAborted = false;
m_forcedAbort = false;
- m_timerStart = 0I64;
}
////////////////////////////////////////////////////////////
{
ui->view_log->setModel(NULL);
- if(m_progressIndicator)
+ if(!m_progressIndicator.isNull())
{
m_progressIndicator->stop();
}
- if(m_diskObserver)
+ if(!m_diskObserver.isNull())
{
m_diskObserver->stop();
if(!m_diskObserver->wait(15000))
m_diskObserver->wait();
}
}
- if(m_cpuObserver)
+
+ if(!m_cpuObserver.isNull())
{
m_cpuObserver->stop();
if(!m_cpuObserver->wait(15000))
m_cpuObserver->wait();
}
}
- if(m_ramObserver)
+
+ if(!m_ramObserver.isNull())
{
m_ramObserver->stop();
if(!m_ramObserver->wait(15000))
}
}
- if(m_threadPool)
+ if(!m_threadPool.isNull())
{
if(!m_threadPool->waitForDone(100))
{
}
}
- LAMEXP_DELETE(m_progressIndicator);
- LAMEXP_DELETE(m_systemTray);
- LAMEXP_DELETE(m_diskObserver);
- LAMEXP_DELETE(m_cpuObserver);
- LAMEXP_DELETE(m_ramObserver);
- LAMEXP_DELETE(m_progressViewFilterGroup);
- LAMEXP_DELETE(m_filterInfoLabel);
- LAMEXP_DELETE(m_filterInfoLabelIcon);
- LAMEXP_DELETE(m_contextMenu);
- LAMEXP_DELETE(m_progressModel);
- LAMEXP_DELETE(m_threadPool);
-
- WinSevenTaskbar::setOverlayIcon(this, NULL);
- WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarNoState);
-
- LAMEXP_DELETE(ui);
+ m_taskbar->setOverlayIcon(NULL);
+ m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_NONE);
+
+ MUTILS_DELETE(ui);
}
////////////////////////////////////////////////////////////
if(m_firstShow)
{
static const char *NA = " N/A";
-
- lamexp_enable_close_button(this, false);
+
+ MUtils::GUI::enable_close_button(this, false);
ui->button_closeDialog->setEnabled(false);
ui->button_AbortProcess->setEnabled(false);
+ m_progressIndicator->start();
m_systemTray->setVisible(true);
- lamexp_change_process_priority(1);
-
+ MUtils::OS::change_process_priority(1);
+
ui->label_cpu->setText(NA);
ui->label_disk->setText(NA);
ui->label_ram->setText(NA);
- QTimer::singleShot(1000, this, SLOT(initEncoding()));
+ QTimer::singleShot(500, this, SLOT(initEncoding()));
m_firstShow = false;
}
bool ProcessingDialog::eventFilter(QObject *obj, QEvent *event)
{
- static QColor defaultColor = QColor();
-
if(obj == ui->label_versionInfo)
{
if(event->type() == QEvent::Enter)
{
QPalette palette = ui->label_versionInfo->palette();
- defaultColor = palette.color(QPalette::Normal, QPalette::WindowText);
+ *m_defaultColor = palette.color(QPalette::Normal, QPalette::WindowText);
palette.setColor(QPalette::Normal, QPalette::WindowText, Qt::red);
ui->label_versionInfo->setPalette(palette);
}
else if(event->type() == QEvent::Leave)
{
QPalette palette = ui->label_versionInfo->palette();
- palette.setColor(QPalette::Normal, QPalette::WindowText, defaultColor);
+ palette.setColor(QPalette::Normal, QPalette::WindowText, *m_defaultColor);
ui->label_versionInfo->setPalette(palette);
}
else if(event->type() == QEvent::MouseButtonPress)
{
switch(e->type())
{
- case lamexp_event_queryendsession:
+ case MUtils::GUI::USER_EVENT_QUERYENDSESSION:
qWarning("System is shutting down, preparing to abort...");
if(!m_userAborted) abortEncoding(true);
return true;
- case lamexp_event_endsession:
+ case MUtils::GUI::USER_EVENT_ENDSESSION:
qWarning("System is shutting down, encoding will be aborted now...");
if(isVisible())
{
}
}
-bool ProcessingDialog::winEvent(MSG *message, long *result)
-{
- return WinSevenTaskbar::handleWinEvent(message, result);
-}
-
////////////////////////////////////////////////////////////
// SLOTS
////////////////////////////////////////////////////////////
CHANGE_BACKGROUND_COLOR(ui->frame_header, QColor(Qt::white));
SET_PROGRESS_TEXT(tr("Encoding files, please wait..."));
- m_progressIndicator->start();
ui->button_closeDialog->setEnabled(false);
ui->button_AbortProcess->setEnabled(true);
ui->checkBox_shutdownComputer->setEnabled(true);
ui->checkBox_shutdownComputer->setChecked(false);
- WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarNormalState);
- WinSevenTaskbar::setTaskbarProgress(this, 0, m_pendingJobs.count());
- WinSevenTaskbar::setOverlayIcon(this, &QIcon(":/icons/control_play_blue.png"));
+ m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_NORMAL);
+ m_taskbar->setTaskbarProgress(0, m_pendingJobs.count());
+ m_taskbar->setOverlayIcon(&QIcon(":/icons/control_play_blue.png"));
if(!m_diskObserver)
{
- m_diskObserver = new DiskObserverThread(m_settings->customTempPathEnabled() ? m_settings->customTempPath() : lamexp_temp_folder2());
- connect(m_diskObserver, SIGNAL(messageLogged(QString,int)), m_progressModel, SLOT(addSystemMessage(QString,int)), Qt::QueuedConnection);
- connect(m_diskObserver, SIGNAL(freeSpaceChanged(quint64)), this, SLOT(diskUsageHasChanged(quint64)), Qt::QueuedConnection);
+ m_diskObserver.reset(new DiskObserverThread(m_settings->customTempPathEnabled() ? m_settings->customTempPath() : MUtils::temp_folder()));
+ connect(m_diskObserver.data(), SIGNAL(messageLogged(QString,int)), m_progressModel.data(), SLOT(addSystemMessage(QString,int)), Qt::QueuedConnection);
+ connect(m_diskObserver.data(), SIGNAL(freeSpaceChanged(quint64)), this, SLOT(diskUsageHasChanged(quint64)), Qt::QueuedConnection);
m_diskObserver->start();
}
if(!m_cpuObserver)
{
- m_cpuObserver = new CPUObserverThread();
- connect(m_cpuObserver, SIGNAL(currentUsageChanged(double)), this, SLOT(cpuUsageHasChanged(double)), Qt::QueuedConnection);
+ m_cpuObserver.reset(new CPUObserverThread());
+ connect(m_cpuObserver.data(), SIGNAL(currentUsageChanged(double)), this, SLOT(cpuUsageHasChanged(double)), Qt::QueuedConnection);
m_cpuObserver->start();
}
if(!m_ramObserver)
{
- m_ramObserver = new RAMObserverThread();
- connect(m_ramObserver, SIGNAL(currentUsageChanged(double)), this, SLOT(ramUsageHasChanged(double)), Qt::QueuedConnection);
+ m_ramObserver.reset(new RAMObserverThread());
+ connect(m_ramObserver.data(), SIGNAL(currentUsageChanged(double)), this, SLOT(ramUsageHasChanged(double)), Qt::QueuedConnection);
m_ramObserver->start();
}
- if(!m_threadPool)
+ if(m_threadPool.isNull())
{
unsigned int maximumInstances = qBound(0U, m_settings->maximumInstances(), MAX_INSTANCES);
if(maximumInstances < 1)
{
- lamexp_cpu_t cpuFeatures = lamexp_detect_cpu_features(lamexp_arguments());
- maximumInstances = cores2instances(qBound(1, cpuFeatures.count, 64));
+ const MUtils::CPUFetaures::cpu_info_t cpuFeatures = MUtils::CPUFetaures::detect();
+ maximumInstances = cores2instances(qBound(1U, cpuFeatures.count, 64U));
}
maximumInstances = qBound(1U, maximumInstances, static_cast<unsigned int>(m_pendingJobs.count()));
m_progressModel->addSystemMessage(tr("Multi-threading enabled: Running %1 instances in parallel!").arg(QString::number(maximumInstances)));
}
- m_threadPool = new QThreadPool();
+ m_threadPool.reset(new QThreadPool());
m_threadPool->setMaxThreadCount(maximumInstances);
}
- for(int i = 0; i < m_threadPool->maxThreadCount(); i++)
+ m_initThreads = m_threadPool->maxThreadCount();
+ QTimer::singleShot(100, this, SLOT(initNextJob()));
+
+ m_totalTime.reset(new QElapsedTimer());
+ m_totalTime->start();
+}
+
+void ProcessingDialog::initNextJob(void)
+{
+ if((m_initThreads > 0) && (!m_userAborted))
{
startNextJob();
- qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
- QThread::yieldCurrentThread();
+ if(--m_initThreads > 0)
+ {
+ QTimer::singleShot(32, this, SLOT(initNextJob()));
+ }
}
-
- m_timerStart = lamexp_perfcounter_value();
}
void ProcessingDialog::startNextJob(void)
(
currentFile,
(m_settings->outputToSourceDir() ? QFileInfo(currentFile.filePath()).absolutePath() : m_settings->outputDir()),
- (m_settings->customTempPathEnabled() ? m_settings->customTempPath() : lamexp_temp_folder2()),
+ (m_settings->customTempPathEnabled() ? m_settings->customTempPath() : MUtils::temp_folder()),
encoder,
m_settings->prependRelativeSourcePath() && (!m_settings->outputToSourceDir())
);
}
if(m_settings->normalizationFilterEnabled())
{
- thread->addFilter(new NormalizeFilter(m_settings->normalizationFilterMaxVolume(), m_settings->normalizationFilterEQMode()));
+ thread->addFilter(new NormalizeFilter(m_settings->normalizationFilterMaxVolume(), m_settings->normalizationFilterDynamic(), m_settings->normalizationFilterCoupled(), m_settings->normalizationFilterSize()));
+ }
+ if(m_settings->renameFiles_renameEnabled() && (!m_settings->renameFiles_renamePattern().simplified().isEmpty()))
+ {
+ thread->setRenamePattern(m_settings->renameFiles_renamePattern());
+ }
+ if(m_settings->renameFiles_regExpEnabled() && (!m_settings->renameFiles_regExpSearch().trimmed().isEmpty()) && (!m_settings->renameFiles_regExpReplace().simplified().isEmpty()))
+ {
+ thread->setRenameRegExp(m_settings->renameFiles_regExpSearch(), m_settings->renameFiles_regExpReplace());
}
- if(m_settings->renameOutputFilesEnabled() && (!m_settings->renameOutputFilesPattern().simplified().isEmpty()))
+ if(!m_fileExts.isNull())
{
- thread->setRenamePattern(m_settings->renameOutputFilesPattern());
+ thread->setRenameFileExt(m_fileExts->apply(QString::fromUtf8(EncoderRegistry::getEncoderInfo(m_settings->compressionEncoder())->extension())));
}
if(m_settings->overwriteMode() != SettingsModel::Overwrite_KeepBoth)
{
thread->setOverwriteMode((m_settings->overwriteMode() == SettingsModel::Overwrite_SkipFile), (m_settings->overwriteMode() == SettingsModel::Overwrite_Replaces));
}
+ if (m_settings->keepOriginalDataTime())
+ {
+ thread->setKeepDateTime(m_settings->keepOriginalDataTime());
+ }
m_allJobs.append(thread->getId());
//Connect thread signals
connect(thread, SIGNAL(processFinished()), this, SLOT(doneEncoding()), Qt::QueuedConnection);
- connect(thread, SIGNAL(processStateInitialized(QUuid,QString,QString,int)), m_progressModel, SLOT(addJob(QUuid,QString,QString,int)), Qt::QueuedConnection);
- connect(thread, SIGNAL(processStateChanged(QUuid,QString,int)), m_progressModel, SLOT(updateJob(QUuid,QString,int)), Qt::QueuedConnection);
+ connect(thread, SIGNAL(processStateInitialized(QUuid,QString,QString,int)), m_progressModel.data(), SLOT(addJob(QUuid,QString,QString,int)), Qt::QueuedConnection);
+ connect(thread, SIGNAL(processStateChanged(QUuid,QString,int)), m_progressModel.data(), SLOT(updateJob(QUuid,QString,int)), Qt::QueuedConnection);
connect(thread, SIGNAL(processStateFinished(QUuid,QString,int)), this, SLOT(processFinished(QUuid,QString,int)), Qt::QueuedConnection);
- connect(thread, SIGNAL(processMessageLogged(QUuid,QString)), m_progressModel, SLOT(appendToLog(QUuid,QString)), Qt::QueuedConnection);
+ connect(thread, SIGNAL(processMessageLogged(QUuid,QString)), m_progressModel.data(), SLOT(appendToLog(QUuid,QString)), Qt::QueuedConnection);
connect(this, SIGNAL(abortRunningTasks()), thread, SLOT(abort()), Qt::DirectConnection);
//Initialize thread object
qFatal("Fatal Error: Thread initialization has failed!");
}
- //Update GUI
- qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
-
//Give it a go!
- if(!thread->start(m_threadPool))
+ if(!thread->start(m_threadPool.data()))
{
qWarning("Job failed to start or file was skipped!");
}
if(!m_userAborted)
{
SET_PROGRESS_TEXT(tr("Encoding: %n file(s) of %1 completed so far, please wait...", "", ui->progressBar->value()).arg(QString::number(ui->progressBar->maximum())));
- WinSevenTaskbar::setTaskbarProgress(this, ui->progressBar->value(), ui->progressBar->maximum());
+ m_taskbar->setTaskbarProgress(ui->progressBar->value(), ui->progressBar->maximum());
}
if((!m_pendingJobs.isEmpty()) && (!m_userAborted))
if(m_userAborted)
{
- CHANGE_BACKGROUND_COLOR(ui->frame_header, QColor("#FFF3BA"));
- WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarErrorState);
- WinSevenTaskbar::setOverlayIcon(this, &QIcon(":/icons/error.png"));
+ CHANGE_BACKGROUND_COLOR(ui->frame_header, QColor("#FFFFE0"));
+ m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_ERROR);
+ m_taskbar->setOverlayIcon(&QIcon(":/icons/error.png"));
SET_PROGRESS_TEXT((m_succeededJobs.count() > 0) ? tr("Process was aborted by the user after %n file(s)!", "", m_succeededJobs.count()) : tr("Process was aborted prematurely by the user!"));
m_systemTray->showMessage(tr("LameXP - Aborted"), tr("Process was aborted by the user."), QSystemTrayIcon::Warning);
m_systemTray->setIcon(QIcon(":/icons/cd_delete.png"));
qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
- if(m_settings->soundsEnabled() && (!m_forcedAbort))
- {
- lamexp_play_sound(IDR_WAVE_ABORTED, false);
- }
+ if(!m_forcedAbort) PLAY_SOUND_OPTIONAL("aborted", false);
}
else
{
- const __int64 counter = lamexp_perfcounter_value();
- const __int64 frequency = lamexp_perfcounter_frequ();
- if((counter >= 0I64) && (frequency >= 0))
+ if((!m_totalTime.isNull()) && m_totalTime->isValid())
{
- if((m_timerStart >= 0I64) && (m_timerStart < counter))
- {
- double timeElapsed = static_cast<double>(counter - m_timerStart) / static_cast<double>(frequency);
- m_progressModel->addSystemMessage(tr("Process finished after %1.").arg(time2text(timeElapsed)), ProgressModel::SysMsg_Performance);
- }
+ m_progressModel->addSystemMessage(tr("Process finished after %1.").arg(time2text(m_totalTime->elapsed())), ProgressModel::SysMsg_Performance);
+ m_totalTime->invalidate();
}
if(m_failedJobs.count() > 0)
{
- CHANGE_BACKGROUND_COLOR(ui->frame_header, QColor("#FFBABA"));
- WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarErrorState);
- WinSevenTaskbar::setOverlayIcon(this, &QIcon(":/icons/exclamation.png"));
+ CHANGE_BACKGROUND_COLOR(ui->frame_header, QColor("#FFF0F0"));
+ m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_ERROR);
+ m_taskbar->setOverlayIcon(&QIcon(":/icons/exclamation.png"));
if(m_skippedJobs.count() > 0)
{
SET_PROGRESS_TEXT(tr("Error: %1 of %n file(s) failed (%2). Double-click failed items for detailed information!", "", m_failedJobs.count() + m_succeededJobs.count() + m_skippedJobs.count()).arg(QString::number(m_failedJobs.count()), tr("%n file(s) skipped", "", m_skippedJobs.count())));
m_systemTray->showMessage(tr("LameXP - Error"), tr("At least one file has failed!"), QSystemTrayIcon::Critical);
m_systemTray->setIcon(QIcon(":/icons/cd_delete.png"));
qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
- if(m_settings->soundsEnabled()) lamexp_play_sound(IDR_WAVE_ERROR, false);
+ PLAY_SOUND_OPTIONAL("error", false);
}
else
{
- CHANGE_BACKGROUND_COLOR(ui->frame_header, QColor("#E0FFE2"));
- WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarNormalState);
- WinSevenTaskbar::setOverlayIcon(this, &QIcon(":/icons/accept.png"));
+ CHANGE_BACKGROUND_COLOR(ui->frame_header, QColor("#F0FFF0"));
+ m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_NORMAL);
+ m_taskbar->setOverlayIcon(&QIcon(":/icons/accept.png"));
if(m_skippedJobs.count() > 0)
{
SET_PROGRESS_TEXT(tr("All files completed successfully. Skipped %n file(s).", "", m_skippedJobs.count()));
m_systemTray->showMessage(tr("LameXP - Done"), tr("All files completed successfully."), QSystemTrayIcon::Information);
m_systemTray->setIcon(QIcon(":/icons/cd_add.png"));
qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
- if(m_settings->soundsEnabled()) lamexp_play_sound(IDR_WAVE_SUCCESS, false);
+ PLAY_SOUND_OPTIONAL("success", false);
}
}
- lamexp_enable_close_button(this, true);
+ MUtils::GUI::enable_close_button(this, true);
ui->button_closeDialog->setEnabled(true);
ui->button_AbortProcess->setEnabled(false);
ui->checkBox_shutdownComputer->setEnabled(false);
ui->view_log->scrollToBottom();
m_progressIndicator->stop();
ui->progressBar->setValue(ui->progressBar->maximum());
- WinSevenTaskbar::setTaskbarProgress(this, ui->progressBar->value(), ui->progressBar->maximum());
+ m_taskbar->setTaskbarProgress(ui->progressBar->value(), ui->progressBar->maximum());
QApplication::restoreOverrideCursor();
{
if(shutdownComputer())
{
- m_shutdownFlag = m_settings->hibernateComputer() ? shutdownFlag_Hibernate : shutdownFlag_TurnPowerOff;
+ m_shutdownFlag = m_settings->hibernateComputer() ? SHUTDOWN_FLAG_HIBERNATE : SHUTDOWN_FLAG_POWER_OFF;
accept();
}
}
LogViewDialog *logView = new LogViewDialog(this);
logView->setWindowTitle(QString("LameXP - [%1]").arg(m_progressModel->data(index, Qt::DisplayRole).toString()));
logView->exec(logFile);
- LAMEXP_DELETE(logView);
+ MUTILS_DELETE(logView);
}
else
{
}
else
{
- lamexp_beep(lamexp_beep_warning);
+ MUtils::Sound::beep(MUtils::Sound::BEEP_WRN);
}
}
if(filePath.isEmpty())
{
- lamexp_beep(lamexp_beep_warning);
+ MUtils::Sound::beep(MUtils::Sound::BEEP_WRN);
return;
}
{
QString systemRootPath;
- QDir systemRoot(lamexp_known_folder(lamexp_folder_systemfolder));
+ QDir systemRoot(MUtils::OS::known_folder(MUtils::OS::FOLDER_SYSTEMFOLDER));
if(systemRoot.exists() && systemRoot.cdUp())
{
systemRootPath = systemRoot.canonicalPath();
else
{
qWarning("File not found: %s", filePath.toLatin1().constData());
- lamexp_beep(lamexp_beep_error);
+ MUtils::Sound::beep(MUtils::Sound::BEEP_ERR);
}
}
}
//Clean playlist name
- playListName = lamexp_clean_filename(playListName);
+ playListName = MUtils::clean_file_name(playListName);
//Create list of audio files
for(int i = 0; i < m_allJobs.count(); i++)
//Do we need an UTF-8 playlist?
for(int i = 0; i < list.count(); i++)
{
- if(wcscmp(QWCHAR(QString::fromLatin1(list.at(i).toLatin1().constData())), QWCHAR(list.at(i))))
+ if(wcscmp(MUTILS_WCHR(QString::fromLatin1(list.at(i).toLatin1().constData())), MUTILS_WCHR(list.at(i))))
{
useUtf8 = true;
break;
playList.write("#EXTM3U\r\n");
while(!list.isEmpty())
{
- playList.write(useUtf8 ? QUTF8(list.takeFirst()) : list.takeFirst().toLatin1().constData());
+ playList.write(useUtf8 ? MUTILS_UTF8(list.takeFirst()) : list.takeFirst().toLatin1().constData());
playList.write("\r\n");
}
playList.close();
{
if(reason == QSystemTrayIcon::DoubleClick)
{
- lamexp_bring_to_front(this);
+ MUtils::GUI::bring_to_front(this);
}
}
qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
- if(m_settings->soundsEnabled())
- {
- QApplication::setOverrideCursor(Qt::WaitCursor);
- lamexp_play_sound(IDR_WAVE_SHUTDOWN, false);
- QApplication::restoreOverrideCursor();
- }
+ QApplication::setOverrideCursor(Qt::WaitCursor);
+ PLAY_SOUND_OPTIONAL("shutdown", false);
+ QApplication::restoreOverrideCursor();
QTimer timer;
timer.setInterval(1000);
progressDialog.setLabelText(text.arg(iTimeout-i));
if(iTimeout-i == 3) progressDialog.setCancelButton(NULL);
qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
- lamexp_play_sound(((i < iTimeout) ? IDR_WAVE_BEEP : IDR_WAVE_BEEP_LONG), false);
+ PLAY_SOUND_OPTIONAL(((i < iTimeout) ? "beep" : "beep2"), false);
}
progressDialog.close();
return true;
}
-QString ProcessingDialog::time2text(const double timeVal) const
+QString ProcessingDialog::time2text(const qint64 &msec) const
{
- double intPart = 0;
- double frcPart = modf(timeVal, &intPart);
-
- QTime time = QTime().addSecs(qRound(intPart)).addMSecs(qRound(frcPart * 1000.0));
+ const qint64 MILLISECONDS_PER_DAY = 86399999; //24x60x60x1000 - 1
+ const QTime time = QTime().addMSecs(qMin(msec, MILLISECONDS_PER_DAY));
QString a, b;
if(time.hour() > 0)
{
- a = tr("%n hour(s)", "", time.hour());
+ a = tr("%n hour(s)", "", time.hour());
b = tr("%n minute(s)", "", time.minute());
}
else if(time.minute() > 0)
}
else
{
- a = tr("%n second(s)", "", time.second());
+ a = tr("%n second(s)", "", time.second());
b = tr("%n millisecond(s)", "", time.msec());
}