Skip to content

Commit 8244dfa

Browse files
authored
Fix #13986 (GUI: thread count configuration) (danmar#7664)
1 parent 8f3d36a commit 8244dfa

File tree

2 files changed

+8
-19
lines changed

2 files changed

+8
-19
lines changed

gui/settings.ui

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,9 @@
6565
<height>20</height>
6666
</size>
6767
</property>
68-
<property name="inputMask">
69-
<string notr="true">009</string>
70-
</property>
7168
<property name="text">
7269
<string notr="true"/>
7370
</property>
74-
<property name="maxLength">
75-
<number>3</number>
76-
</property>
7771
<property name="alignment">
7872
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
7973
</property>
@@ -82,12 +76,12 @@
8276
<item>
8377
<widget class="QLabel" name="label_3">
8478
<property name="text">
85-
<string>Ideal count:</string>
79+
<string>Max count:</string>
8680
</property>
8781
</widget>
8882
</item>
8983
<item>
90-
<widget class="QLabel" name="mLblIdealThreads">
84+
<widget class="QLabel" name="mLblMaxThreads">
9185
<property name="text">
9286
<string notr="true">TextLabel</string>
9387
</property>

gui/settingsdialog.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ SettingsDialog::SettingsDialog(ApplicationList *list,
6363
QSettings settings;
6464
mTempApplications->copy(list);
6565

66+
int maxjobs = QThread::idealThreadCount();
67+
6668
mUI->mJobs->setText(settings.value(SETTINGS_CHECK_THREADS, 1).toString());
69+
mUI->mJobs->setValidator(new QIntValidator(1, maxjobs, this));
6770
mUI->mForce->setCheckState(boolToCheckState(settings.value(SETTINGS_CHECK_FORCE, false).toBool()));
6871
mUI->mShowFullPath->setCheckState(boolToCheckState(settings.value(SETTINGS_SHOW_FULL_PATH, false).toBool()));
6972
mUI->mShowNoErrorsMessage->setCheckState(boolToCheckState(settings.value(SETTINGS_SHOW_NO_ERRORS, false).toBool()));
@@ -119,11 +122,7 @@ SettingsDialog::SettingsDialog(ApplicationList *list,
119122
mUI->mListWidget->setSortingEnabled(false);
120123
populateApplicationList();
121124

122-
const int count = QThread::idealThreadCount();
123-
if (count != -1)
124-
mUI->mLblIdealThreads->setText(QString::number(count));
125-
else
126-
mUI->mLblIdealThreads->setText(tr("N/A"));
125+
mUI->mLblMaxThreads->setText(QString::number(maxjobs));
127126

128127
loadSettings();
129128
initTranslationsList();
@@ -179,13 +178,9 @@ void SettingsDialog::saveSettings() const
179178

180179
void SettingsDialog::saveSettingValues() const
181180
{
182-
int jobs = mUI->mJobs->text().toInt();
183-
if (jobs <= 0) {
184-
jobs = 1;
185-
}
186-
187181
QSettings settings;
188-
settings.setValue(SETTINGS_CHECK_THREADS, jobs);
182+
if (mUI->mJobs->hasAcceptableInput())
183+
settings.setValue(SETTINGS_CHECK_THREADS, mUI->mJobs->text().toInt());
189184
saveCheckboxValue(&settings, mUI->mForce, SETTINGS_CHECK_FORCE);
190185
saveCheckboxValue(&settings, mUI->mSaveAllErrors, SETTINGS_SAVE_ALL_ERRORS);
191186
saveCheckboxValue(&settings, mUI->mSaveFullPath, SETTINGS_SAVE_FULL_PATH);

0 commit comments

Comments
 (0)