From a1e0b85787166ccc6ffc9d5f5e91105916839df6 Mon Sep 17 00:00:00 2001 From: lordmulder Date: Sun, 29 Jan 2012 00:57:47 +0100 Subject: [PATCH] Improved queue support + some GUI redesign. --- gui/win_main.ui | 117 ++++++++++++++++++++++------------ res/icons/movie.ico | Bin 25214 -> 25214 bytes src/model_jobList.cpp | 10 ++- src/thread_encode.cpp | 32 ++++++++-- src/thread_encode.h | 10 +-- src/win_main.cpp | 51 ++++++++++++--- src/win_main.h | 1 + x264_launcher.vcxproj | 13 +++- x264_launcher.vcxproj.filters | 11 ++++ 9 files changed, 182 insertions(+), 63 deletions(-) diff --git a/gui/win_main.ui b/gui/win_main.ui index cc3ea04..5af2cb2 100644 --- a/gui/win_main.ui +++ b/gui/win_main.ui @@ -6,8 +6,8 @@ 0 0 - 640 - 512 + 720 + 640 @@ -15,31 +15,14 @@ - - - - 0 - - - Qt::AlignCenter - - - - - - - QFrame::HLine - - - QFrame::Sunken - - - Qt::Vertical + + 8 + false @@ -69,28 +52,72 @@ false - - - - Lucida Console - + + + Job Details + + + 2 + + + + + 0 + + + Qt::AlignCenter + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 3 + + + + + + + + + Lucida Console + + + + QAbstractItemView::NoSelection + + + QAbstractItemView::SelectRows + + + + + + + + 75 + true + + + + true + + + + - - - - - 75 - true - - - - true - - - @@ -182,7 +209,7 @@ 0 0 - 640 + 720 21 @@ -220,6 +247,14 @@ + + buttonAddJob + buttonStartJob + buttonAbortJob + jobsView + logView + editDetails + diff --git a/res/icons/movie.ico b/res/icons/movie.ico index 88400e35c29d52a32517d87c9545d1297688df0f..f4e7e12477fee6e2b609253021c0ad66d53a6b98 100644 GIT binary patch delta 151 zcmex&gz?`I#(D+@Mg~p>0|NmD1_l;}3^oRaX+V~O0)+p9iGkrCP)tAo!q;GAV0gyK z08|fD#K6I@f{%fLj~k>O%I9EU*d_^558-F9GBCs`!PF}-tWafOIHnF$59IRz73TRu KHEituoCp9IniKK> delta 151 zcmex&gz?`I#(D+@Mg~p>0|Nmd&BBnu#=tO*fq_9m0m6U5#K7J=DPs4_4dQ-`Ss@_B#?^L(Ki JHg(tr("Progress")); break; case 3: - return QVariant::fromValue(tr("Progress Details")); + return QVariant::fromValue(tr("Details")); break; default: return QVariant(); @@ -115,6 +115,12 @@ QVariant JobListModel::data(const QModelIndex &index, int role) const case EncodeThread::JobStatus_Running: return QVariant::fromValue(tr("Running...")); break; + case EncodeThread::JobStatus_Running_Pass1: + return QVariant::fromValue(tr("Running... (Pass 1)")); + break; + case EncodeThread::JobStatus_Running_Pass2: + return QVariant::fromValue(tr("Running... (Pass 2)")); + break; case EncodeThread::JobStatus_Completed: return QVariant::fromValue(tr("Completed.")); break; @@ -160,6 +166,8 @@ QVariant JobListModel::data(const QModelIndex &index, int role) const return QIcon(":/buttons/find.png"); break; case EncodeThread::JobStatus_Running: + case EncodeThread::JobStatus_Running_Pass1: + case EncodeThread::JobStatus_Running_Pass2: return QIcon(":/buttons/play.png"); break; case EncodeThread::JobStatus_Completed: diff --git a/src/thread_encode.cpp b/src/thread_encode.cpp index fe9e3b1..40cdef8 100644 --- a/src/thread_encode.cpp +++ b/src/thread_encode.cpp @@ -57,21 +57,21 @@ void EncodeThread::encode(void) { Sleep(1500); - for(int i = 0; i <= 100; i++) + for(int i = 0; i <= 100; i += 5) { emit progressChanged(m_jobId, i); - emit statusChanged(m_jobId, (i % 2) ? JobStatus_Indexing : JobStatus_Running); + emit statusChanged(m_jobId, (i % 2) ? JobStatus_Indexing : JobStatus_Running_Pass1); emit messageLogged(m_jobId, QUuid::createUuid().toString()); - for(int i = 0; i < 5; i++) + for(int j = 0; j < 3; j++) { emit detailsChanged(m_jobId, QUuid::createUuid().toString()); - Sleep(200); + Sleep(120); } if(m_abort) { - Sleep(1500); + Sleep(500); emit statusChanged(m_jobId, JobStatus_Aborted); return; } @@ -79,5 +79,27 @@ void EncodeThread::encode(void) Sleep(1500); + for(int i = 0; i <= 100; i += 5) + { + emit progressChanged(m_jobId, i); + emit statusChanged(m_jobId, (i % 2) ? JobStatus_Indexing : JobStatus_Running_Pass2); + emit messageLogged(m_jobId, QUuid::createUuid().toString()); + + for(int j = 0; j < 3; j++) + { + emit detailsChanged(m_jobId, QUuid::createUuid().toString()); + Sleep(120); + } + + if(m_abort) + { + Sleep(500); + emit statusChanged(m_jobId, JobStatus_Aborted); + return; + } + } + + Sleep(250); + emit statusChanged(m_jobId, JobStatus_Completed); } diff --git a/src/thread_encode.h b/src/thread_encode.h index 80276f5..9072a7b 100644 --- a/src/thread_encode.h +++ b/src/thread_encode.h @@ -35,10 +35,12 @@ public: JobStatus_Starting = 1, JobStatus_Indexing = 2, JobStatus_Running = 3, - JobStatus_Completed = 4, - JobStatus_Failed = 5, - JobStatus_Aborting = 6, - JobStatus_Aborted = 7 + JobStatus_Running_Pass1 = 4, + JobStatus_Running_Pass2 = 5, + JobStatus_Completed = 6, + JobStatus_Failed = 7, + JobStatus_Aborting = 8, + JobStatus_Aborted = 9 }; EncodeThread(void); diff --git a/src/win_main.cpp b/src/win_main.cpp index be97e86..2d6697e 100644 --- a/src/win_main.cpp +++ b/src/win_main.cpp @@ -86,7 +86,7 @@ void MainWindow::addButtonPressed(void) { EncodeThread *thrd = new EncodeThread(); QModelIndex newIndex = m_jobList->insertJob(thrd); - jobsView->selectionModel()->setCurrentIndex(newIndex, QItemSelectionModel::ClearAndSelect); + jobsView->selectRow(newIndex.row()); } void MainWindow::startButtonPressed(void) @@ -98,6 +98,7 @@ void MainWindow::abortButtonPressed(void) { m_jobList->abortJob(jobsView->currentIndex()); } + void MainWindow::jobSelected(const QModelIndex & current, const QModelIndex & previous) { qDebug("Job selected: %d", current.row()); @@ -124,11 +125,15 @@ void MainWindow::jobChangedData(const QModelIndex &topLeft, const QModelIndex & { for(int i = topLeft.row(); i <= bottomRight.row(); i++) { + EncodeThread::JobStatus status = m_jobList->getJobStatus(m_jobList->index(i, 0, QModelIndex())); if(i == selected) { qDebug("Current job changed status!"); - updateButtons(m_jobList->getJobStatus(m_jobList->index(i, 0, QModelIndex()))); - break; + updateButtons(status); + } + if(status == EncodeThread::JobStatus_Completed) + { + QTimer::singleShot(0, this, SLOT(launchNextJob())); } } } @@ -166,15 +171,42 @@ void MainWindow::showAbout(void) QString text; const char *url = "http://mulder.brhack.net/"; - text += QString().sprintf("Simple x264 Launcher v%u.%02u − use 64−Bit x264 with 32−Bit Avisynth
", x264_version_major(), x264_version_minor()); - text += QString().sprintf("Copyright (c) 2004−%04d LoRd_MuldeR <mulder2@gmx.de>. Some rights reserved.
", qMax(x264_version_date().year(),QDate::currentDate().year())); - text += QString().sprintf("Built on %s at %s with %s for Win−%s.

", x264_version_date().toString(Qt::ISODate).toLatin1().constData(), x264_version_time(), x264_version_compiler(), x264_version_arch()); + text += QString().sprintf("
Simple x264 Launcher v%u.%02u - use 64-Bit x264 with 32-Bit Avisynth
", x264_version_major(), x264_version_minor()); + text += QString().sprintf("Copyright (c) 2004-%04d LoRd_MuldeR <mulder2@gmx.de>. Some rights reserved.
", qMax(x264_version_date().year(),QDate::currentDate().year())); + text += QString().sprintf("Built on %s at %s with %s for Win-%s.

", x264_version_date().toString(Qt::ISODate).toLatin1().constData(), x264_version_time(), x264_version_compiler(), x264_version_arch()); text += QString().sprintf("This program is free software: you can redistribute it and/or modify
"); text += QString().sprintf("it under the terms of the GNU General Public License <http://www.gnu.org/>.
"); text += QString().sprintf("Note that this program is distributed with ABSOLUTELY NO WARRANTY.

"); - text += QString().sprintf("Please check the web−site at %s for updates !!!
", url, url); + text += QString().sprintf("Please check the web-site at %s for updates !!!
", url, url); - QMessageBox::information(this, tr("About..."), text); + QMessageBox::information(this, tr("About..."), text.replace("-", "−")); +} + +void MainWindow::launchNextJob(void) +{ + const int rows = m_jobList->rowCount(QModelIndex()); + + for(int i = 0; i < rows; i++) + { + EncodeThread::JobStatus status = m_jobList->getJobStatus(m_jobList->index(i, 0, QModelIndex())); + if(status == EncodeThread::JobStatus_Running || status == EncodeThread::JobStatus_Running_Pass1 || status == EncodeThread::JobStatus_Running_Pass2) + { + qWarning("Still have a job running, won't launch next yet!"); + return; + } + } + + for(int i = 0; i < rows; i++) + { + EncodeThread::JobStatus status = m_jobList->getJobStatus(m_jobList->index(i, 0, QModelIndex())); + if(status == EncodeThread::JobStatus_Enqueued) + { + m_jobList->startJob(m_jobList->index(i, 0, QModelIndex())); + return; + } + } + + qWarning("No enqueued jobs left!"); } /////////////////////////////////////////////////////////////////////////////// @@ -206,5 +238,6 @@ void MainWindow::updateButtons(EncodeThread::JobStatus status) qDebug("MainWindow::updateButtons(void)"); buttonStartJob->setEnabled(status == EncodeThread::JobStatus_Enqueued); - buttonAbortJob->setEnabled(status == EncodeThread::JobStatus_Indexing || status == EncodeThread::JobStatus_Running); + buttonAbortJob->setEnabled(status == EncodeThread::JobStatus_Indexing || status == EncodeThread::JobStatus_Running || + status == EncodeThread::JobStatus_Running_Pass1 || status == EncodeThread::JobStatus_Running_Pass2 ); } diff --git a/src/win_main.h b/src/win_main.h index d6b3b0c..1ce1d05 100644 --- a/src/win_main.h +++ b/src/win_main.h @@ -50,4 +50,5 @@ private slots: void jobChangedData(const QModelIndex &top, const QModelIndex &bottom); void jobLogExtended(const QModelIndex & parent, int start, int end); void showAbout(void); + void launchNextJob(void); }; diff --git a/x264_launcher.vcxproj b/x264_launcher.vcxproj index 22e2992..aeb86c0 100644 --- a/x264_launcher.vcxproj +++ b/x264_launcher.vcxproj @@ -66,8 +66,7 @@ Level3 - - + NotUsing Full true true @@ -80,14 +79,17 @@ NotSet Fast false + true + false Windows - true + false true true $(QTDIR)\lib;%(AdditionalLibraryDirectories) QtMain.lib;QtCore4.lib;QtGui4.lib;%(AdditionalDependencies) + UseLinkTimeCodeGeneration @@ -111,6 +113,7 @@ $(SolutionDir)tmp\qrc\qrc_%(Filename).cpp;%(Outputs) Designer + @@ -121,6 +124,7 @@ $(SolutionDir)tmp\moc\moc_%(Filename).cpp;%(Outputs) $(SolutionDir)tmp\moc\moc_%(Filename).cpp;%(Outputs) + "$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\moc\moc_%(Filename).cpp" "%(FullPath)" @@ -162,6 +166,9 @@ + + + diff --git a/x264_launcher.vcxproj.filters b/x264_launcher.vcxproj.filters index 6ae9124..521d599 100644 --- a/x264_launcher.vcxproj.filters +++ b/x264_launcher.vcxproj.filters @@ -22,6 +22,9 @@ + + Resource Files + @@ -33,6 +36,9 @@ Header Files + + Header Files + @@ -89,4 +95,9 @@ Header Files + + + Resource Files + + \ No newline at end of file