OSDN Git Service

Changed behavior of launchNextJob() to launch the *first* pending job on the list...
authorlordmulder <mulder2@gmx.de>
Sun, 20 Apr 2014 17:40:59 +0000 (19:40 +0200)
committerlordmulder <mulder2@gmx.de>
Sun, 20 Apr 2014 17:40:59 +0000 (19:40 +0200)
src/version.h
src/win_main.cpp
src/win_updater.cpp
src/win_updater.h

index 359bec5..bb93ad9 100644 (file)
@@ -26,7 +26,7 @@
 #define VER_X264_MAJOR 2
 #define VER_X264_MINOR 3
 #define VER_X264_PATCH 7
-#define VER_X264_BUILD 844
+#define VER_X264_BUILD 846
 
 #define VER_X264_PORTABLE_EDITION (0)
 
index 02c7874..2140db7 100644 (file)
@@ -60,9 +60,9 @@
 
 #include <ctime>
 
-const char *home_url = "http://muldersoft.com/";
-const char *update_url = "https://github.com/lordmulder/Simple-x264-Launcher/releases/latest";
-const char *tpl_last = "<LAST_USED>";
+static const char *home_url = "http://muldersoft.com/";
+static const char *update_url = "https://github.com/lordmulder/Simple-x264-Launcher/releases/latest";
+static const char *tpl_last = "<LAST_USED>";
 
 #define SET_FONT_BOLD(WIDGET,BOLD) do { QFont _font = WIDGET->font(); _font.setBold(BOLD); WIDGET->setFont(_font); } while(0)
 #define SET_TEXT_COLOR(WIDGET,COLOR) do { QPalette _palette = WIDGET->palette(); _palette.setColor(QPalette::WindowText, (COLOR)); _palette.setColor(QPalette::Text, (COLOR)); WIDGET->setPalette(_palette); } while(0)
@@ -499,7 +499,6 @@ void MainWindow::jobChangedData(const QModelIndex &topLeft, const  QModelIndex &
                        if((status == JobStatus_Completed) || (status == JobStatus_Failed))
                        {
                                if(m_preferences->getAutoRunNextJob()) QTimer::singleShot(0, this, SLOT(launchNextJob()));
-                               if(m_preferences->getShutdownComputer()) QTimer::singleShot(0, this, SLOT(shutdownComputer()));
                                if(m_preferences->getSaveLogFiles()) saveLogFile(m_jobList->index(i, 1, QModelIndex()));
                        }
                }
@@ -593,9 +592,7 @@ void MainWindow::showPreferences(void)
  */
 void MainWindow::launchNextJob(void)
 {
-       qDebug("launchNextJob(void)");
-       
-       const int rows = m_jobList->rowCount(QModelIndex());
+       qDebug("Launching next job...");
 
        if(countRunningJobs() >= m_preferences->getMaxRunningJobCount())
        {
@@ -603,23 +600,27 @@ void MainWindow::launchNextJob(void)
                return;
        }
 
-       int startIdx= ui->jobsView->currentIndex().isValid() ? qBound(0, ui->jobsView->currentIndex().row(), rows-1) : 0;
+       const int rows = m_jobList->rowCount(QModelIndex());
 
        for(int i = 0; i < rows; i++)
        {
-               int currentIdx = (i + startIdx) % rows;
-               JobStatus status = m_jobList->getJobStatus(m_jobList->index(currentIdx, 0, QModelIndex()));
-               if(status == JobStatus_Enqueued)
+               const QModelIndex currentIndex = m_jobList->index(i, 0, QModelIndex());
+               if(m_jobList->getJobStatus(currentIndex) == JobStatus_Enqueued)
                {
-                       if(m_jobList->startJob(m_jobList->index(currentIdx, 0, QModelIndex())))
+                       if(m_jobList->startJob(currentIndex))
                        {
-                               ui->jobsView->selectRow(currentIdx);
+                               ui->jobsView->selectRow(currentIndex.row());
                                return;
                        }
                }
        }
                
-       qWarning("No enqueued jobs left!");
+       qWarning("No enqueued jobs left to be started!");
+
+       if(m_preferences->getShutdownComputer())
+       {
+               QTimer::singleShot(0, this, SLOT(shutdownComputer()));
+       }
 }
 
 /*
@@ -989,7 +990,7 @@ void MainWindow::init(void)
        {
                QString text;
                text += QString("<nobr><tt>%1</tt></nobr><br><br>").arg(tr("Your version of Simple x264 Launcher is more than 6 months old!").replace("-", "&minus;"));
-               text += QString("<nobr><tt>%1<br><a href=\"%2\">%2</a><br><br>").arg(tr("You can download the most recent version from the official web-site now:").replace("-", "&minus;"), QString::fromLatin1(update_url));
+               text += QString("<nobr><tt>%1<br><a href=\"%2\">%3</a><br><br>").arg(tr("You can download the most recent version from the official web-site now:").replace("-", "&minus;"), QString::fromLatin1(update_url), QString::fromLatin1(update_url).replace("-", "&minus;"));
                text += QString("<nobr><tt>%1</tt></nobr><br>").arg(tr("Alternatively, click 'Check for Updates' to run the auto-update utility.").replace("-", "&minus;"));
                QMessageBox msgBox(this);
                msgBox.setIconPixmap(QIcon(":/images/update.png").pixmap(56,56));
@@ -1088,6 +1089,9 @@ void MainWindow::handlePendingFiles(void)
        }
 }
 
+/*
+ * Handle incoming IPC command
+ */
 void MainWindow::handleCommand(const int &command, const QStringList &args, const quint32 &flags)
 {
        if((m_status != STATUS_IDLE) && (m_status != STATUS_AWAITING))
@@ -1162,6 +1166,9 @@ void MainWindow::handleCommand(const int &command, const QStringList &args, cons
        }
 }
 
+/*
+ * Check for new updates
+ */
 void MainWindow::checkUpdates(void)
 {
        ENSURE_APP_IS_IDLE();
@@ -1174,7 +1181,7 @@ void MainWindow::checkUpdates(void)
                return;
        }
 
-       UpdaterDialog *updater = new UpdaterDialog(this, m_sysinfo);
+       UpdaterDialog *updater = new UpdaterDialog(this, m_sysinfo, update_url);
        const int ret = updater->exec();
 
        if(updater->getSuccess())
@@ -1199,6 +1206,9 @@ void MainWindow::checkUpdates(void)
        }
 }
 
+/*
+ * Handle mouse event for version label
+ */
 void MainWindow::versionLabelMouseClicked(const int &tag)
 {
        if(tag == 0)
@@ -1207,6 +1217,9 @@ void MainWindow::versionLabelMouseClicked(const int &tag)
        }
 }
 
+/*
+ * Handle key event for job list
+ */
 void MainWindow::jobListKeyPressed(const int &tag)
 {
        switch(tag)
index b965873..4cc19c5 100644 (file)
@@ -64,11 +64,12 @@ while(0)
 // Constructor & Destructor
 ///////////////////////////////////////////////////////////////////////////////
 
-UpdaterDialog::UpdaterDialog(QWidget *parent, const SysinfoModel *sysinfo)
+UpdaterDialog::UpdaterDialog(QWidget *parent, const SysinfoModel *sysinfo, const char *const updateUrl)
 :
        QDialog(parent),
        ui(new Ui::UpdaterDialog()),
        m_sysinfo(sysinfo),
+       m_updateUrl(updateUrl),
        m_status(UpdateCheckThread::UpdateStatus_NotStartedYet),
        m_thread(NULL),
        m_updaterProcess(NULL),
@@ -193,7 +194,11 @@ void UpdaterDialog::initUpdate(void)
        if(!checkBinaries(wgetBin, gpgvBin))
        {
                ui->buttonCancel->setEnabled(true);
-               QMessageBox::critical(this, tr("File Error"), tr("At least one file required by web-update is missing or corrupted.<br>Please re-install this application and then try again!"));
+               const QString message = QString("%1<br><br><nobr><a href=\"%2\">%3</a></nobr><br>").arg(tr("At least one file required by the web-update tool is missing or corrupted.<br>Please re-install this application and then try again!"), QString::fromLatin1(m_updateUrl), QString::fromLatin1(m_updateUrl).replace("-", "&minus;"));
+               if(QMessageBox::critical(this, tr("File Error"), message, tr("Download Latest Version"), tr("Discard")) == 0)
+               {
+                       QDesktopServices::openUrl(QUrl(QString::fromLatin1(m_updateUrl)));
+               }
                close(); return;
        }
 
@@ -456,7 +461,7 @@ bool UpdaterDialog::checkBinaries(QString &wgetBin, QString &gpgvBin)
        }
        FILE_INFO[] =
        {
-               { "wget.exe", "7b522345239bcb95b5b0f7f50a883ba5957894a1feb769763e38ed789a8a0f63fead0155f54b9ffd0f1cdc5dfd855d207a6e7a8e4fd192589a8838ce646c504e" },
+               { "wget.exe", "17b522345239bcb95b5b0f7f50a883ba5957894a1feb769763e38ed789a8a0f63fead0155f54b9ffd0f1cdc5dfd855d207a6e7a8e4fd192589a8838ce646c504e" },
                { "gpgv.exe", "b42b7ef5650cd78d92773f03d4eefc90d9ba6ffe6af19d389851e32b5ab1c58c91c3dfceb2cbe0d0d13774ee2cf100c20f0add7f33463229999da5aaa861f064" },
                { "gpgv.gpg", "58e0f0e462bbd0b5aa4f638801c1097da7da4b3eb38c8c88ad1db23705c0f11e174b083fa55fe76bd3ba196341c967833a6f3427d6f63ad8565900745535d8fa" },
                { "wupd.exe", "e8ee5fb11e4964c0091311a41b46e2ea49cf675755ee830c38a26027c81aecc78842c25facc0ac6b797586e4c4b22ac116dd1735b0b11b67c13e4a17fb1e5f5e" },
index 81a8e61..1668695 100644 (file)
@@ -37,7 +37,7 @@ class UpdaterDialog : public QDialog
        Q_OBJECT
 
 public:
-       UpdaterDialog(QWidget *parent, const SysinfoModel *sysinfo);
+       UpdaterDialog(QWidget *parent, const SysinfoModel *sysinfo, const char *const updateUrl);
        ~UpdaterDialog(void);
 
        static const int READY_TO_INSTALL_UPDATE = 42;
@@ -67,6 +67,7 @@ private:
        bool checkFileHash(const QString &filePath, const char *expectedHash);
 
        const SysinfoModel *const m_sysinfo;
+       const char *const m_updateUrl;
 
        bool m_firstShow;
        bool m_success;