From d9e775b4b836beb19f35def67d060a43dab230e4 Mon Sep 17 00:00:00 2001 From: lordmulder Date: Wed, 2 Feb 2011 22:56:45 +0100 Subject: [PATCH] Show notification in progress window, if multi-threading is activated. --- etc/Translation/Blank.ts | 4 ++++ etc/Translation/LameXP_DE.ts | 4 ++++ etc/Translation/LameXP_ES.ts | 4 ++++ etc/Translation/LameXP_FR.ts | 4 ++++ etc/Translation/LameXP_IT.ts | 4 ++++ res/localization/LameXP_DE.qm | Bin 50505 -> 50724 bytes src/Config.h | 2 +- src/Dialog_Processing.cpp | 24 +++++++++++++++++++----- src/Model_Progress.cpp | 30 ++++++++++++++++++++++++++++-- src/Model_Progress.h | 5 ++++- 10 files changed, 72 insertions(+), 9 deletions(-) diff --git a/etc/Translation/Blank.ts b/etc/Translation/Blank.ts index a3d583e0..eb31a961 100644 --- a/etc/Translation/Blank.ts +++ b/etc/Translation/Blank.ts @@ -1408,6 +1408,10 @@ Encoding files, please wait... + + Multi-threading enabled: Running %1 instances in parallel! + + Aborted! Waiting for running jobs to terminate... diff --git a/etc/Translation/LameXP_DE.ts b/etc/Translation/LameXP_DE.ts index 63c6e070..63b6389e 100644 --- a/etc/Translation/LameXP_DE.ts +++ b/etc/Translation/LameXP_DE.ts @@ -1469,6 +1469,10 @@ Process was aborted prematurely by the user! Der Vorgang wurde vom Benutzer abgebrochen! + + Multi-threading enabled: Running %1 instances in parallel! + Multithreading aktiviert: Führe %1 Instanzen parallel aus! + ProgressModel diff --git a/etc/Translation/LameXP_ES.ts b/etc/Translation/LameXP_ES.ts index 48f4f60c..c1bbb895 100644 --- a/etc/Translation/LameXP_ES.ts +++ b/etc/Translation/LameXP_ES.ts @@ -1469,6 +1469,10 @@ Process was aborted prematurely by the user! ¡El proceso fue cancelado prematuramente por el usuario! + + Multi-threading enabled: Running %1 instances in parallel! + + ProgressModel diff --git a/etc/Translation/LameXP_FR.ts b/etc/Translation/LameXP_FR.ts index 1f757d89..5709a676 100644 --- a/etc/Translation/LameXP_FR.ts +++ b/etc/Translation/LameXP_FR.ts @@ -1471,6 +1471,10 @@ Votre dossier TEMP est situé ici: Process was aborted prematurely by the user! Le processus a été abandonné prématurément par l'utilisateur ! + + Multi-threading enabled: Running %1 instances in parallel! + + ProgressModel diff --git a/etc/Translation/LameXP_IT.ts b/etc/Translation/LameXP_IT.ts index 13bf33fc..c5272c8b 100644 --- a/etc/Translation/LameXP_IT.ts +++ b/etc/Translation/LameXP_IT.ts @@ -1469,6 +1469,10 @@ Process was aborted prematurely by the user! + + Multi-threading enabled: Running %1 instances in parallel! + + ProgressModel diff --git a/res/localization/LameXP_DE.qm b/res/localization/LameXP_DE.qm index 8ad4871fdd4369d1807e4521d8f43642270b06a8..4e15fc7851488cb8e126c65cd909bd3dad3a144c 100644 GIT binary patch delta 584 zcmXX@ZAepL6n^gK<~Ev6VSzuq3zqa@VX%HIEG#slW@s@+L~wIAck6c9CqlVCeoQKA zYrM@`P(R8ob8Y38m5>FIh?N9U5Jbp=Kq}~05s}s##o^&O=Q+>$an6}J!wsM1&Nn!g z0@wts?g4}iz`0kHcLIAZ0o_y^9ZtJa%-8f(lj9w>`;P$^J@8B=sM7-9%u}G(58v}F zP)QPjN!khrnTE+`VBKZLexeGLzLOl|WlMErfmzRvzaTEwYs%-i#`q#o_(C#lim4JO z=UsNk%X{Mkz~(3axO9rw8oPkKZ~1U64Lo>5u5fv_z>yAqh#h@N-t%i$d=si$g23_} z!l&X-V4z=E+#LdPZ6Zg?fITEyUta}o^ph5$%T!(?o-EQ0Z-%J zviD}mWX%Eg=GKbSq%-V&1Id`1>*lS2Y%SnCWL16B^gz$Zthv)(X}8Wjq-$A@TIZvu zfsT|4Onk1aw6y1%qVOOF4N<5R0feDIhM!hC`XG_e#`@!KNa)0`|6K`Av{Gdobwucl zO!)|%(y11tRhUAfp-@OPk5QMyNS_Xo!tIG^QMDx+2rIH*)%zqxm-lOm-!1jTbp5a3 dY?V|!5|#B{B|hgwKhVH~^(UUJW3< z0EP|>RspqNfofx$-S=8OEZrNFK>d;UzQYS_aPkY&e6E0O;wYcJrDHMQk|~{*w*fh?rHkMV(A_BuqytIs zWbJSQn4Ti5WLH<}aH9Mgo??pjH;`4)3=BVSa4EFbRS>4p>T8)|K1*Yrn(qkFC@Py_sLVO z*=Jn9a{Zr{OCM#5HP6>o6^pk`K DEcJ!m diff --git a/src/Config.h b/src/Config.h index 184f63ee..e80f383d 100644 --- a/src/Config.h +++ b/src/Config.h @@ -25,7 +25,7 @@ #define VER_LAMEXP_MAJOR 4 #define VER_LAMEXP_MINOR_HI 0 #define VER_LAMEXP_MINOR_LO 0 -#define VER_LAMEXP_BUILD 289 +#define VER_LAMEXP_BUILD 290 #define VER_LAMEXP_SUFFIX Beta-3 /* diff --git a/src/Dialog_Processing.cpp b/src/Dialog_Processing.cpp index bb225d03..8037c709 100644 --- a/src/Dialog_Processing.cpp +++ b/src/Dialog_Processing.cpp @@ -259,8 +259,14 @@ void ProcessingDialog::initEncoding(void) WinSevenTaskbar::setOverlayIcon(this, &QIcon(":/icons/control_play_blue.png")); lamexp_cpu_t cpuFeatures = lamexp_detect_cpu_features(); + int parallelThreadCount = max(min(min(cpuFeatures.count, m_pendingJobs.count()), 4), 1); - for(int i = 0; i < min(max(cpuFeatures.count, 1), 4); i++) + if(parallelThreadCount > 1) + { + m_progressModel->addSystemMessage(tr("Multi-threading enabled: Running %1 instances in parallel!").arg(QString::number(parallelThreadCount))); + } + + for(int i = 0; i < parallelThreadCount; i++) { startNextJob(); } @@ -391,10 +397,18 @@ void ProcessingDialog::logViewDoubleClicked(const QModelIndex &index) if(m_runningThreads == 0) { const QStringList &logFile = m_progressModel->getLogFile(index); - LogViewDialog *logView = new LogViewDialog(this); - logView->setWindowTitle(QString("LameXP - [%1]").arg(m_progressModel->data(index, Qt::DisplayRole).toString())); - logView->exec(logFile); - LAMEXP_DELETE(logView); + + if(!logFile.isEmpty()) + { + LogViewDialog *logView = new LogViewDialog(this); + logView->setWindowTitle(QString("LameXP - [%1]").arg(m_progressModel->data(index, Qt::DisplayRole).toString())); + logView->exec(logFile); + LAMEXP_DELETE(logView); + } + else + { + MessageBeep(MB_ICONWARNING); + } } else { diff --git a/src/Model_Progress.cpp b/src/Model_Progress.cpp index f24a4521..58233c18 100644 --- a/src/Model_Progress.cpp +++ b/src/Model_Progress.cpp @@ -23,11 +23,13 @@ #include -ProgressModel::ProgressModel(void) : +ProgressModel::ProgressModel(void) +: m_iconRunning(":/icons/media_play.png"), m_iconPaused(":/icons/control_pause_blue.png"), m_iconComplete(":/icons/tick.png"), - m_iconFailed(":/icons/exclamation.png") + m_iconFailed(":/icons/exclamation.png"), + m_iconSystem(":/icons/computer.png") { } @@ -77,6 +79,9 @@ QVariant ProgressModel::data(const QModelIndex &index, int role) const case JobComplete: return m_iconComplete; break; + case JobSystem: + return m_iconSystem; + break; default: return m_iconFailed; break; @@ -171,3 +176,24 @@ const QStringList &ProgressModel::getLogFile(const QModelIndex &index) return *(reinterpret_cast(NULL)); } + +void ProgressModel::addSystemMessage(const QString &text) +{ + const QUuid &jobId = QUuid::createUuid(); + + if(m_jobList.contains(jobId)) + { + return; + } + + int newIndex = m_jobList.count(); + beginInsertRows(QModelIndex(), newIndex, newIndex); + + m_jobList.append(jobId); + m_jobName.insert(jobId, text); + m_jobStatus.insert(jobId, QString()); + m_jobState.insert(jobId, JobSystem); + m_jobLogFile.insert(jobId, QStringList()); + + endInsertRows(); +} diff --git a/src/Model_Progress.h b/src/Model_Progress.h index a8128435..4afd251b 100644 --- a/src/Model_Progress.h +++ b/src/Model_Progress.h @@ -43,7 +43,8 @@ public: JobRunning = 0, JobPaused = 1, JobComplete = 2, - JobFailed = 3 + JobFailed = 3, + JobSystem = 4 }; //Model functions @@ -59,6 +60,7 @@ public slots: void addJob(const QUuid &jobId, const QString &jobName, const QString &jobInitialStatus = QString("Initializing..."), int jobInitialState = JobRunning); void updateJob(const QUuid &jobId, const QString &newStatus, int newState); void appendToLog(const QUuid &jobId, const QString &line); + void addSystemMessage(const QString &text); private: QList m_jobList; @@ -71,4 +73,5 @@ private: const QIcon m_iconPaused; const QIcon m_iconComplete; const QIcon m_iconFailed; + const QIcon m_iconSystem; };