OSDN Git Service

Added option to delete jobs from the list + also added option to browse the output...
authorlordmulder <mulder2@gmx.de>
Thu, 2 Feb 2012 21:53:40 +0000 (22:53 +0100)
committerlordmulder <mulder2@gmx.de>
Thu, 2 Feb 2012 21:53:40 +0000 (22:53 +0100)
15 files changed:
gui/win_addJob.ui
gui/win_main.ui
res/buttons/folder_magnify.png [new file with mode: 0644]
res/buttons/trash.png [new file with mode: 0644]
res/resources.qrc
src/global.cpp
src/global.h
src/model_jobList.cpp
src/model_jobList.h
src/thread_encode.cpp
src/thread_encode.h
src/version.h
src/win_addJob.cpp
src/win_main.cpp
src/win_main.h

index b34df7a..280af40 100644 (file)
   <tabstop>buttonBrowseSource</tabstop>
   <tabstop>editOutput</tabstop>
   <tabstop>buttonBrowseOutput</tabstop>
+  <tabstop>cbxTemplate</tabstop>
+  <tabstop>buttonSaveTemplate</tabstop>
+  <tabstop>buttonDeleteTemplate</tabstop>
   <tabstop>cbxRateControlMode</tabstop>
   <tabstop>spinQuantizer</tabstop>
   <tabstop>spinBitrate</tabstop>
   <tabstop>cbxPreset</tabstop>
   <tabstop>cbxTuning</tabstop>
   <tabstop>cbxProfile</tabstop>
+  <tabstop>editCustomParams</tabstop>
   <tabstop>checkBoxRun</tabstop>
   <tabstop>buttonAccept</tabstop>
   <tabstop>buttonCancel</tabstop>
    <slot>accept()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>587</x>
-     <y>406</y>
+     <x>495</x>
+     <y>558</y>
     </hint>
     <hint type="destinationlabel">
      <x>397</x>
    <slot>reject()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>721</x>
-     <y>406</y>
+     <x>629</x>
+     <y>558</y>
     </hint>
     <hint type="destinationlabel">
      <x>397</x>
index 55a527a..6f01f2c 100644 (file)
@@ -30,6 +30,9 @@
        <bool>false</bool>
       </property>
       <widget class="QTableView" name="jobsView">
+       <property name="focusPolicy">
+        <enum>Qt::StrongFocus</enum>
+       </property>
        <property name="contextMenuPolicy">
         <enum>Qt::ActionsContextMenu</enum>
        </property>
     <addaction name="actionJob_Start"/>
     <addaction name="actionJob_Pause"/>
     <addaction name="actionJob_Abort"/>
+    <addaction name="actionJob_Browse"/>
+    <addaction name="actionJob_Delete"/>
    </widget>
    <addaction name="menuFile"/>
    <addaction name="menuJob"/>
     <string>Preferences</string>
    </property>
   </action>
+  <action name="actionJob_Delete">
+   <property name="enabled">
+    <bool>false</bool>
+   </property>
+   <property name="icon">
+    <iconset resource="../res/resources.qrc">
+     <normaloff>:/buttons/trash.png</normaloff>:/buttons/trash.png</iconset>
+   </property>
+   <property name="text">
+    <string>Delete Job</string>
+   </property>
+  </action>
+  <action name="actionJob_Browse">
+   <property name="enabled">
+    <bool>false</bool>
+   </property>
+   <property name="icon">
+    <iconset resource="../res/resources.qrc">
+     <normaloff>:/buttons/folder_magnify.png</normaloff>:/buttons/folder_magnify.png</iconset>
+   </property>
+   <property name="text">
+    <string>Explore Job</string>
+   </property>
+  </action>
  </widget>
  <tabstops>
   <tabstop>buttonAddJob</tabstop>
diff --git a/res/buttons/folder_magnify.png b/res/buttons/folder_magnify.png
new file mode 100644 (file)
index 0000000..0a3e798
Binary files /dev/null and b/res/buttons/folder_magnify.png differ
diff --git a/res/buttons/trash.png b/res/buttons/trash.png
new file mode 100644 (file)
index 0000000..745665e
Binary files /dev/null and b/res/buttons/trash.png differ
index 67e9230..9c2b219 100644 (file)
@@ -16,6 +16,7 @@
     <file>buttons/error.png</file>
     <file>buttons/exclamation.png</file>
     <file>buttons/find.png</file>
+    <file>buttons/folder_magnify.png</file>
     <file>buttons/hourglass.png</file>
     <file>buttons/information.png</file>
     <file>buttons/lightning.png</file>
@@ -24,6 +25,7 @@
     <file>buttons/play.png</file>
     <file>buttons/play_big.png</file>
     <file>buttons/suspended.png</file>
+    <file>buttons/trash.png</file>
     <file>buttons/world_link.png</file>
     <file>buttons/wrench.png</file>
     <file>images/x264.png</file>
index f101cc7..6d2c7dd 100644 (file)
@@ -264,7 +264,7 @@ void x264_message_handler(QtMsgType type, const char *msg)
  */
 void x264_init_console(int argc, char* argv[])
 {
-       bool enableConsole = true; //x264_version_demo();
+       bool enableConsole = x264_is_prerelease();
 
        if(_environ)
        {
@@ -407,6 +407,11 @@ const char *x264_version_time(void)
        return g_x264_version.ver_time;
 }
 
+bool x264_is_prerelease(void)
+{
+       return (VER_x264_PRE_RELEASE);
+}
+
 /*
  * Detect CPU features
  */
index 06389cf..cf1ac03 100644 (file)
@@ -95,6 +95,7 @@ void x264_message_handler(QtMsgType type, const char *msg);
 unsigned int x264_version_major(void);
 unsigned int x264_version_minor(void);
 const QDate &x264_version_date(void);
+bool x264_is_prerelease(void);
 const char *x264_version_time(void);
 const char *x264_version_compiler(void);
 const char *x264_version_arch(void);
index 9f3e9e2..21a6247 100644 (file)
@@ -337,6 +337,40 @@ bool JobListModel::abortJob(const QModelIndex &index)
        return false;
 }
 
+bool JobListModel::deleteJob(const QModelIndex &index)
+{
+       if(index.isValid() && index.row() >= 0 && index.row() < m_jobs.count())
+       {
+               QUuid id = m_jobs.at(index.row());
+               if(m_status.value(id) == EncodeThread::JobStatus_Completed || m_status.value(id) == EncodeThread::JobStatus_Failed ||
+                       m_status.value(id) == EncodeThread::JobStatus_Aborted || m_status.value(id) == EncodeThread::JobStatus_Enqueued)
+               {
+                       int idx = index.row();
+                       QUuid id = m_jobs.at(idx);
+                       EncodeThread *thread = m_threads.value(id, NULL);
+                       LogFileModel *logFile = m_logFile.value(id, NULL);
+                       if((thread == NULL) || (!thread->isRunning()))
+                       {
+                               
+                               beginRemoveRows(QModelIndex(), idx, idx);
+                               m_jobs.removeAt(index.row());
+                               m_name.remove(id);
+                               m_threads.remove(id);
+                               m_status.remove(id);
+                               m_progress.remove(id);
+                               m_logFile.remove(id);
+                               m_details.remove(id);
+                               endRemoveRows();
+                               X264_DELETE(thread);
+                               X264_DELETE(logFile);
+                               return true;
+                       }
+               }
+       }
+
+       return false;
+}
+
 LogFileModel *JobListModel::getLogFile(const QModelIndex &index)
 {
        if(index.isValid() && index.row() >= 0 && index.row() < m_jobs.count())
@@ -347,6 +381,19 @@ LogFileModel *JobListModel::getLogFile(const QModelIndex &index)
        return NULL;
 }
 
+const QString &JobListModel::getJobOutputFile(const QModelIndex &index)
+{
+       static QString nullStr;
+       
+       if(index.isValid() && index.row() >= 0 && index.row() < m_jobs.count())
+       {
+               EncodeThread *thread = m_threads.value(m_jobs.at(index.row()));
+               return (thread != NULL) ? thread->outputFileName() : nullStr;
+       }
+
+       return nullStr;
+}
+
 EncodeThread::JobStatus JobListModel::getJobStatus(const QModelIndex &index)
 {
        if(index.isValid() && index.row() >= 0 && index.row() < m_jobs.count())
index b3463a8..c9c0457 100644 (file)
@@ -49,7 +49,9 @@ public:
        bool pauseJob(const QModelIndex &index);
        bool resumeJob(const QModelIndex &index);
        bool abortJob(const QModelIndex &index);
+       bool deleteJob(const QModelIndex &index);
        LogFileModel *getLogFile(const QModelIndex &index);
+       const QString &getJobOutputFile(const QModelIndex &index);
        EncodeThread::JobStatus getJobStatus(const QModelIndex &index);
        unsigned int getJobProgress(const QModelIndex &index);
        QModelIndex getJobIndexById(const QUuid &id);
index 3f6f4f7..6ec86cf 100644 (file)
 #include <QDir>
 #include <QProcess>
 #include <QMutex>
-#include <QLibrary>
-
-/*
- * Win32 API definitions
- */
-typedef HANDLE (WINAPI *CreateJobObjectFun)(__in_opt LPSECURITY_ATTRIBUTES lpJobAttributes, __in_opt LPCSTR lpName);
-typedef BOOL (WINAPI *SetInformationJobObjectFun)(__in HANDLE hJob, __in JOBOBJECTINFOCLASS JobObjectInformationClass, __in_bcount(cbJobObjectInformationLength) LPVOID lpJobObjectInformation, __in DWORD cbJobObjectInformationLength);
-typedef BOOL (WINAPI *AssignProcessToJobObjectFun)(__in HANDLE hJob, __in HANDLE hProcess);
 
 /*
  * Static vars
@@ -116,7 +108,7 @@ void EncodeThread::run(void)
 
        if(m_handle_jobObject)
        {
-               CloseHandle(m_handle_jobObject);
+               TerminateJobObject(m_handle_jobObject, 42);
                m_handle_jobObject = NULL;
        }
 }
@@ -898,46 +890,26 @@ void EncodeThread::setDetails(const QString &text)
 
 bool EncodeThread::startProcess(QProcess &process, const QString &program, const QStringList &args, bool mergeChannels)
 {
-       static AssignProcessToJobObjectFun AssignProcessToJobObjectPtr = NULL;
-       static CreateJobObjectFun CreateJobObjectPtr = NULL;
-       static SetInformationJobObjectFun SetInformationJobObjectPtr = NULL;
-       
        QMutexLocker lock(&m_mutex_startProcess);
        log(commandline2string(program, args) + "\n");
 
        //Create a new job object, if not done yet
        if(!m_handle_jobObject)
        {
-               if(!CreateJobObjectPtr || !SetInformationJobObjectPtr)
+               m_handle_jobObject = CreateJobObject(NULL, NULL);
+               if(m_handle_jobObject == INVALID_HANDLE_VALUE)
                {
-                       QLibrary Kernel32Lib("kernel32.dll");
-                       CreateJobObjectPtr = (CreateJobObjectFun) Kernel32Lib.resolve("CreateJobObjectA");
-                       SetInformationJobObjectPtr = (SetInformationJobObjectFun) Kernel32Lib.resolve("SetInformationJobObject");
+                       m_handle_jobObject = NULL;
                }
-               if(CreateJobObjectPtr && SetInformationJobObjectPtr)
+               if(m_handle_jobObject)
                {
-                       m_handle_jobObject = CreateJobObjectPtr(NULL, NULL);
-                       if(m_handle_jobObject == INVALID_HANDLE_VALUE)
-                       {
-                               m_handle_jobObject = NULL;
-                       }
-                       if(m_handle_jobObject)
-                       {
-                               JOBOBJECT_EXTENDED_LIMIT_INFORMATION jobExtendedLimitInfo;
-                               memset(&jobExtendedLimitInfo, 0, sizeof(JOBOBJECT_EXTENDED_LIMIT_INFORMATION));
-                               jobExtendedLimitInfo.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE | JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION;
-                               SetInformationJobObjectPtr(m_handle_jobObject, JobObjectExtendedLimitInformation, &jobExtendedLimitInfo, sizeof(JOBOBJECT_EXTENDED_LIMIT_INFORMATION));
-                       }
+                       JOBOBJECT_EXTENDED_LIMIT_INFORMATION jobExtendedLimitInfo;
+                       memset(&jobExtendedLimitInfo, 0, sizeof(JOBOBJECT_EXTENDED_LIMIT_INFORMATION));
+                       jobExtendedLimitInfo.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE | JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION;
+                       SetInformationJobObject(m_handle_jobObject, JobObjectExtendedLimitInformation, &jobExtendedLimitInfo, sizeof(JOBOBJECT_EXTENDED_LIMIT_INFORMATION));
                }
        }
 
-       //Initialize AssignProcessToJobObject function
-       if(!AssignProcessToJobObjectPtr)
-       {
-               QLibrary Kernel32Lib("kernel32.dll");
-               AssignProcessToJobObjectPtr = (AssignProcessToJobObjectFun) Kernel32Lib.resolve("AssignProcessToJobObject");
-       }
-       
        if(mergeChannels)
        {
                process.setProcessChannelMode(QProcess::MergedChannels);
@@ -953,13 +925,14 @@ bool EncodeThread::startProcess(QProcess &process, const QString &program, const
        
        if(process.waitForStarted())
        {
-               if(AssignProcessToJobObjectPtr)
+               Q_PID pid = process.pid();
+               AssignProcessToJobObject(m_handle_jobObject, process.pid()->hProcess);
+               if(pid != NULL)
                {
-                       AssignProcessToJobObjectPtr(m_handle_jobObject, process.pid()->hProcess);
-               }
-               if(!SetPriorityClass(process.pid()->hProcess, BELOW_NORMAL_PRIORITY_CLASS))
-               {
-                       SetPriorityClass(process.pid()->hProcess, IDLE_PRIORITY_CLASS);
+                       if(!SetPriorityClass(process.pid()->hProcess, BELOW_NORMAL_PRIORITY_CLASS))
+                       {
+                               SetPriorityClass(process.pid()->hProcess, IDLE_PRIORITY_CLASS);
+                       }
                }
                
                lock.unlock();
index fcace26..3526947 100644 (file)
@@ -49,7 +49,8 @@ public:
                JobStatus_Paused = 9,
                JobStatus_Resuming = 10,
                JobStatus_Aborting = 11,
-               JobStatus_Aborted = 12
+               JobStatus_Aborted = 12,
+               JobStatus_Undefined = 666
        };
        
        EncodeThread(const QString &sourceFileName, const QString &outputFileName, const OptionsModel *options, const QString &binDir, bool x64);
index ced0944..5e4e864 100644 (file)
@@ -25,3 +25,5 @@
 #define VER_X264_MINIMUM_REV (2146)
 #define VER_X264_CURRENT_API (120)
 #define VER_x264_AVS2YUV_VER (242)
+
+#define VER_x264_PRE_RELEASE (0)
index ce720a2..734c3f4 100644 (file)
@@ -212,6 +212,7 @@ void AddJobDialog::showEvent(QShowEvent *event)
        if(!editSource->text().isEmpty())
        {
                generateOutputFileName(QDir::fromNativeSeparators(editSource->text()));
+               buttonAccept->setFocus();
        }
 }
 
index 2aae904..35751b9 100644 (file)
 #include <QUrl>
 #include <QDir>
 #include <QLibrary>
+#include <QProcess>
 
-const char *home_url = "http://mulder.brhack.net/";
+//#include <Shellapi.h>
 
-#define PRE_RELEASE (0)
+const char *home_url = "http://mulder.brhack.net/";
 
 #define SET_FONT_BOLD(WIDGET,BOLD) { QFont _font = WIDGET->font(); _font.setBold(BOLD); WIDGET->setFont(_font); }
 #define SET_TEXT_COLOR(WIDGET,COLOR) { QPalette _palette = WIDGET->palette(); _palette.setColor(QPalette::WindowText, (COLOR)); _palette.setColor(QPalette::Text, (COLOR)); WIDGET->setPalette(_palette); }
@@ -68,7 +69,7 @@ MainWindow::MainWindow(bool x64supported)
        labelBuildDate->setText(tr("Built on %1 at %2").arg(x264_version_date().toString(Qt::ISODate), QString::fromLatin1(x264_version_time())));
        labelBuildDate->installEventFilter(this);
        setWindowTitle(QString("%1 (%2 Mode)").arg(windowTitle(), m_x64supported ? "64-Bit" : "32-Bit"));
-       if(PRE_RELEASE) setWindowTitle(QString("%1 | PRE-RELEASE VERSION").arg(windowTitle()));
+       if(x264_is_prerelease()) setWindowTitle(QString("%1 | PRE-RELEASE VERSION").arg(windowTitle()));
 
 
        //Create model
@@ -88,6 +89,7 @@ MainWindow::MainWindow(bool x64supported)
 
        //Create context menu
        QAction *actionClipboard = new QAction(QIcon(":/buttons/page_paste.png"), tr("Copy to Clipboard"), logView);
+       actionClipboard->setEnabled(false);
        logView->addAction(actionClipboard);
        connect(actionClipboard, SIGNAL(triggered(bool)), this, SLOT(copyLogToClipboard(bool)));
        jobsView->addActions(menuJob->actions());
@@ -97,6 +99,8 @@ MainWindow::MainWindow(bool x64supported)
        connect(buttonStartJob, SIGNAL(clicked()), this, SLOT(startButtonPressed()));
        connect(buttonAbortJob, SIGNAL(clicked()), this, SLOT(abortButtonPressed()));
        connect(buttonPauseJob, SIGNAL(toggled(bool)), this, SLOT(pauseButtonPressed(bool)));
+       connect(actionJob_Delete, SIGNAL(triggered()), this, SLOT(deleteButtonPressed()));
+       connect(actionJob_Browse, SIGNAL(triggered()), this, SLOT(browseButtonPressed()));
 
        //Enable menu
        connect(actionAbout, SIGNAL(triggered()), this, SLOT(showAbout()));
@@ -172,11 +176,11 @@ void MainWindow::addButtonPressed(const QString &filePath, bool *ok)
                                m_jobList->startJob(newIndex);
                        }
 
-                       m_label->setVisible(false);
                        if(ok) *ok = true;
                }
        }
 
+       m_label->setVisible(m_jobList->rowCount(QModelIndex()) == 0);
        X264_DELETE(addDialog);
 }
 
@@ -190,6 +194,25 @@ void MainWindow::abortButtonPressed(void)
        m_jobList->abortJob(jobsView->currentIndex());
 }
 
+void MainWindow::deleteButtonPressed(void)
+{
+       m_jobList->deleteJob(jobsView->currentIndex());
+       m_label->setVisible(m_jobList->rowCount(QModelIndex()) == 0);
+}
+
+void MainWindow::browseButtonPressed(void)
+{
+       QString outputFile = m_jobList->getJobOutputFile(jobsView->currentIndex());
+       if((!outputFile.isEmpty()) && QFileInfo(outputFile).exists() && QFileInfo(outputFile).isFile())
+       {
+               QProcess::startDetached(QString::fromLatin1("explorer.exe"), QStringList() << QString::fromLatin1("/select,") << QDir::toNativeSeparators(outputFile), QFileInfo(outputFile).path());
+       }
+       else
+       {
+               QMessageBox::warning(this, tr("Not Found"), tr("Sorry, the output file could not be found!"));
+       }
+}
+
 void MainWindow::pauseButtonPressed(bool checked)
 {
        if(checked)
@@ -211,13 +234,25 @@ void MainWindow::jobSelected(const QModelIndex & current, const QModelIndex & pr
                disconnect(logView->model(), SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(jobLogExtended(QModelIndex, int, int)));
        }
        
-       logView->setModel(m_jobList->getLogFile(current));
-       connect(logView->model(), SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(jobLogExtended(QModelIndex, int, int)));
-       QTimer::singleShot(0, logView, SLOT(scrollToBottom()));
+       if(current.isValid())
+       {
+               logView->setModel(m_jobList->getLogFile(current));
+               connect(logView->model(), SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(jobLogExtended(QModelIndex, int, int)));
+               logView->actions().first()->setEnabled(true);
+               QTimer::singleShot(0, logView, SLOT(scrollToBottom()));
        
-       progressBar->setValue(m_jobList->getJobProgress(current));
-       editDetails->setText(m_jobList->data(m_jobList->index(current.row(), 3, QModelIndex()), Qt::DisplayRole).toString());
-       updateButtons(m_jobList->getJobStatus(current));
+               progressBar->setValue(m_jobList->getJobProgress(current));
+               editDetails->setText(m_jobList->data(m_jobList->index(current.row(), 3, QModelIndex()), Qt::DisplayRole).toString());
+               updateButtons(m_jobList->getJobStatus(current));
+       }
+       else
+       {
+               logView->setModel(NULL);
+               logView->actions().first()->setEnabled(false);
+               progressBar->setValue(0);
+               editDetails->clear();
+               updateButtons(EncodeThread::JobStatus_Undefined);
+       }
 
        progressBar->repaint();
 }
@@ -292,10 +327,10 @@ void MainWindow::showAbout(void)
                case 0:
                        {
                                QString text2;
-                               text2 += tr("<nobr><tt>x264, the best H.264/AVC encoder. Copyright (c) 2003-2011 x264 project.<br>");
+                               text2 += tr("<nobr><tt>x264 - the best H.264/AVC encoder. Copyright (c) 2003-2012 x264 project.<br>");
                                text2 += tr("Free software library for encoding video streams into the H.264/MPEG-4 AVC format.<br>");
                                text2 += tr("Released under the terms of the GNU General Public License.<br><br>");
-                               text2 += tr("Please visit <a href=\"http://x264licensing.com/\">http://x264licensing.com/</a> for obtaining a <u>commercial</u> x264 license!<br></tt></nobr>");
+                               text2 += tr("Please visit <a href=\"%1\">%1</a> for obtaining a <u>commercial</u> x264 license!<br></tt></nobr>").arg("http://x264licensing.com/");
                                QMessageBox::information(this, tr("About x264"), text2.replace("-", "&minus;"), tr("Close"));
                        }
                        break;
@@ -384,7 +419,7 @@ void MainWindow::init(void)
        }
 
        //Pre-release popup
-       if(PRE_RELEASE)
+       if(x264_is_prerelease())
        {
                qsrand(time(NULL)); int rnd = qrand() % 3;
                int val = QMessageBox::information(this, tr("Pre-Release Version"), tr("Note: This is a pre-release version. Please do NOT use for production!<br>Click the button #%1 in order to continue...<br><br>(There will be no such message box in the final version of this application)").arg(QString::number(rnd + 1)), tr("(1)"), tr("(2)"), tr("(3)"), qrand() % 3);
@@ -456,13 +491,35 @@ void MainWindow::showEvent(QShowEvent *e)
 
 void MainWindow::closeEvent(QCloseEvent *e)
 {
-       if(havePendingJobs())
+       if(haveRunningJobs())
        {
                e->ignore();
-               MessageBeep(MB_ICONWARNING);
+               QMessageBox::warning(this, tr("Jobs Are Running"), tr("Sorry, can not exit while there still are running jobs!"));
                return;
        }
+       
+       if(havePendingJobs())
+       {
+               int ret = QMessageBox::question(this, tr("Jobs Are Pending"), tr("Do you really want to quit and discard the pending jobs?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
+               if(ret != QMessageBox::Yes)
+               {
+                       e->ignore();
+                       return;
+               }
+       }
+
+       while(m_jobList->rowCount(QModelIndex()) > 0)
+       {
+               qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
+               if(!m_jobList->deleteJob(m_jobList->index(0, 0, QModelIndex())))
+               {
+                       e->ignore();
+                       QMessageBox::warning(this, tr("Failed To Exit"), tr("Sorry, at least one job could not be deleted!"));
+                       return;
+               }
+       }
 
+       qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
        QMainWindow::closeEvent(e);
 }
 
@@ -529,6 +586,7 @@ void MainWindow::dropEvent(QDropEvent *event)
 // Private functions
 ///////////////////////////////////////////////////////////////////////////////
 
+/*Jobs that are not completed (or failed, or aborted) yet*/
 bool MainWindow::havePendingJobs(void)
 {
        const int rows = m_jobList->rowCount(QModelIndex());
@@ -545,6 +603,23 @@ bool MainWindow::havePendingJobs(void)
        return false;
 }
 
+/*Jobs that are still active, i.e. not terminated or enqueued*/
+bool MainWindow::haveRunningJobs(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_Completed && status != EncodeThread::JobStatus_Aborted && status != EncodeThread::JobStatus_Failed && status != EncodeThread::JobStatus_Enqueued)
+               {
+                       return true;
+               }
+       }
+
+       return false;
+}
+
 void MainWindow::updateButtons(EncodeThread::JobStatus status)
 {
        qDebug("MainWindow::updateButtons(void)");
@@ -554,6 +629,9 @@ void MainWindow::updateButtons(EncodeThread::JobStatus status)
        buttonPauseJob->setEnabled(status == EncodeThread::JobStatus_Indexing || status == EncodeThread::JobStatus_Running || status == EncodeThread::JobStatus_Paused || status == EncodeThread::JobStatus_Running_Pass1 || status == EncodeThread::JobStatus_Running_Pass2);
        buttonPauseJob->setChecked(status == EncodeThread::JobStatus_Paused || status == EncodeThread::JobStatus_Pausing);
 
+       actionJob_Delete->setEnabled(status == EncodeThread::JobStatus_Completed || status == EncodeThread::JobStatus_Aborted || status == EncodeThread::JobStatus_Failed || status == EncodeThread::JobStatus_Enqueued);
+       actionJob_Browse->setEnabled(status == EncodeThread::JobStatus_Completed);
+
        actionJob_Start->setEnabled(buttonStartJob->isEnabled());
        actionJob_Abort->setEnabled(buttonAbortJob->isEnabled());
        actionJob_Pause->setEnabled(buttonPauseJob->isEnabled());
index 60ce292..b1c19f8 100644 (file)
@@ -57,10 +57,13 @@ private:
        
        void updateButtons(EncodeThread::JobStatus status);
        bool havePendingJobs(void);
+       bool haveRunningJobs(void);
 
 private slots:
        void addButtonPressed(const QString &filePath = QString(), bool *ok = NULL);
        void abortButtonPressed(void);
+       void browseButtonPressed(void);
+       void deleteButtonPressed(void);
        void copyLogToClipboard(bool checked);
        void init(void);
        void jobSelected(const QModelIndex & current, const QModelIndex & previous);