OSDN Git Service

Fixed priority control in Preferences dialog.
authorlordmulder <mulder2@gmx.de>
Tue, 12 Nov 2013 22:29:13 +0000 (23:29 +0100)
committerlordmulder <mulder2@gmx.de>
Tue, 12 Nov 2013 22:29:13 +0000 (23:29 +0100)
src/thread_encode.cpp
src/version.h
src/win_preferences.cpp

index 6d64a6f..9b2772a 100644 (file)
@@ -143,7 +143,7 @@ EncodeThread::EncodeThread(const QString &sourceFileName, const QString &outputF
        m_x264_10bit(x264_10bit),
        m_avs2yuv_x64(avs2yuv_x64),
        m_skipVersionTest(skipVersionTest),
-       m_processPriority(processPriroity),
+       m_processPriority(qBound(-2, processPriroity, 1)),
        m_abortOnTimeout(abortOnTimeout),
        m_jobObject(new JobObject),
        m_semaphorePaused(0)
index 25d8c58..e919d23 100644 (file)
@@ -25,8 +25,8 @@
 
 #define VER_X264_MAJOR 2
 #define VER_X264_MINOR 2
-#define VER_X264_PATCH 5
-#define VER_X264_BUILD 625
+#define VER_X264_PATCH 6
+#define VER_X264_BUILD 630
 
 #define VER_X264_MINIMUM_REV 2363
 #define VER_X264_CURRENT_API 140
index 157b8db..1fbe89a 100644 (file)
 #include <QMouseEvent>
 #include <QMessageBox>
 
-#define UPDATE_CHECKBOX(CHKBOX, VALUE, BLOCK) \
+#define UPDATE_CHECKBOX(CHKBOX, VALUE, BLOCK) do \
 { \
        if((BLOCK)) { (CHKBOX)->blockSignals(true); } \
        if((CHKBOX)->isChecked() != (VALUE)) (CHKBOX)->click(); \
        if((CHKBOX)->isChecked() != (VALUE)) (CHKBOX)->setChecked(VALUE); \
        if((BLOCK)) { (CHKBOX)->blockSignals(false); } \
-}
+} \
+while(0)
+
+#define UPDATE_COMBOBOX(COBOX, VALUE, DEFAULT) do \
+{ \
+       const int _cnt = (COBOX)->count(); \
+       const int _val = (VALUE); \
+       const int _def = (DEFAULT); \
+       for(int _i = 0; _i < _cnt; _i++) \
+       { \
+               const int _current = (COBOX)->itemData(_i).toInt(); \
+               if((_current == _val) || (_current == _def)) \
+               { \
+                       (COBOX)->setCurrentIndex(_i); \
+                       if((_current == _val)) break; \
+               } \
+       } \
+} \
+while(0)
 
 PreferencesDialog::PreferencesDialog(QWidget *parent, PreferencesModel *preferences, bool x64)
 :
@@ -47,6 +65,11 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, PreferencesModel *preferen
        setFixedSize(minimumSize());
        x264_enable_close_button(this, false);
        
+       comboBoxPriority->setItemData(0, QVariant::fromValue( 1)); //Above Normal
+       comboBoxPriority->setItemData(1, QVariant::fromValue( 0)); //Normal
+       comboBoxPriority->setItemData(2, QVariant::fromValue(-1)); //Below Normal
+       comboBoxPriority->setItemData(3, QVariant::fromValue(-2)); //Idle
+
        labelRunNextJob->installEventFilter(this);
        labelUse10BitEncoding->installEventFilter(this);
        labelUse64BitAvs2YUV->installEventFilter(this);
@@ -81,8 +104,9 @@ void PreferencesDialog::showEvent(QShowEvent *event)
        UPDATE_CHECKBOX(checkUse10BitEncoding, m_preferences->use10BitEncoding(), true);
 
        spinBoxJobCount->setValue(m_preferences->maxRunningJobCount());
-       comboBoxPriority->setCurrentIndex(qBound(0, m_preferences->processPriority() + 2, comboBoxPriority->count()-1));
-
+       
+       UPDATE_COMBOBOX(comboBoxPriority, qBound(-2, m_preferences->processPriority(), 1), 0);
+       
        checkUse64BitAvs2YUV->setEnabled(m_x64);
        labelUse64BitAvs2YUV->setEnabled(m_x64);
 }
@@ -129,7 +153,7 @@ void PreferencesDialog::done(int n)
        m_preferences->setSaveLogFiles(checkSaveLogFiles->isChecked());
        m_preferences->setSaveToSourcePath(checkSaveToSourceFolder->isChecked());
        m_preferences->setMaxRunningJobCount(spinBoxJobCount->value());
-       m_preferences->setProcessPriority(comboBoxPriority->currentIndex() - 2);
+       m_preferences->setProcessPriority(comboBoxPriority->itemData(comboBoxPriority->currentIndex()).toInt());
        m_preferences->setEnableSounds(checkEnableSounds->isChecked());
        m_preferences->setDisableWarnings(checkDisableWarnings->isChecked());