Skip to content

Commit a6a63fa

Browse files
committed
Settings of CQPreferenceDialog are in the resource :/preference.ini
1 parent c6af9e1 commit a6a63fa

2 files changed

Lines changed: 76 additions & 38 deletions

File tree

copasi/UI/CQPreferenceDialog.cpp

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -146,24 +146,44 @@ void CQPreferenceDialog::initTabsFromSettings(QSettings& settings)
146146
auto tooltip = settings.value("tooltip").toString();
147147

148148
if (type == "string")
149-
{
150-
auto edit = new QLineEdit(value.toString());
151-
edit->setToolTip(tooltip);
152-
153-
if (pNode)
154-
edit->setText(FROM_UTF8(pNode->getValue<std::string>()));
155-
layout->addRow(name, edit);
156-
connect(edit, &QLineEdit::textChanged, this, &CQPreferenceDialog::slotPropertyChanged);
157-
mWidgetToParameter[edit] = pNode;
158-
}
149+
{
150+
// If the parameter has valid values, we should use a combo box instead of a line edit
151+
if (pNode && pNode->hasValidValues())
152+
{
153+
auto edit = new QComboBox();
154+
edit->setToolTip(tooltip);
155+
156+
for (const auto & validValue : pNode->getValidValues< std::string >())
157+
edit->addItem(FROM_UTF8(validValue.second));
158+
159+
if (pNode)
160+
edit->setCurrentText(FROM_UTF8(pNode->getValue< std::string >()));
161+
162+
layout->addRow(name, edit);
163+
connect(edit, &QComboBox::currentTextChanged, this, &CQPreferenceDialog::slotPropertyChanged);
164+
mWidgetToParameter[edit] = pNode;
165+
}
166+
else
167+
{
168+
auto edit = new QLineEdit(value.toString());
169+
edit->setToolTip(tooltip);
170+
171+
if (pNode)
172+
edit->setText(FROM_UTF8(pNode->getValue< std::string >()));
173+
174+
layout->addRow(name, edit);
175+
connect(edit, &QLineEdit::textChanged, this, &CQPreferenceDialog::slotPropertyChanged);
176+
mWidgetToParameter[edit] = pNode;
177+
}
178+
}
159179
else if (type == "bool")
160-
{
161-
auto edit = new QCheckBox(name);
162-
edit->setChecked(value.toBool());
163-
if (pNode)
164-
edit->setChecked(pNode->getValue< bool >());
165-
edit->setToolTip(tooltip);
166-
layout->addRow(edit);
180+
{
181+
auto edit = new QCheckBox(name);
182+
edit->setChecked(value.toBool());
183+
if (pNode)
184+
edit->setChecked(pNode->getValue< bool >());
185+
edit->setToolTip(tooltip);
186+
layout->addRow(edit);
167187

168188
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
169189
connect(edit, &QCheckBox::stateChanged, this, &CQPreferenceDialog::slotPropertyChanged);
@@ -211,28 +231,9 @@ void CQPreferenceDialog::init()
211231
mpTreeView->setAdvanced(false);
212232
mpTreeView->pushGroup(mpConfiguration);
213233

214-
// initialize other tabs from config file
215-
auto copasiDir = COptions::getConfigDir();
216-
auto preferenceConfigFile = copasiDir + "/preferences.ini";
217-
if (!CDirEntry::exist(preferenceConfigFile))
218-
{
219-
// load default preference.ini from resource
220-
Q_INIT_RESOURCE(copasi);
221-
222-
QFile file(":/preferences.ini");
223-
if (file.open(QIODevice::ReadOnly))
224-
{
225-
QFile outFile(FROM_UTF8(preferenceConfigFile));
226-
if (outFile.open(QIODevice::WriteOnly))
227-
{
228-
outFile.write(file.readAll());
229-
outFile.close();
230-
}
231-
file.close();
232-
}
233-
}
234+
Q_INIT_RESOURCE(copasi);
235+
QSettings settings(":/preferences.ini", QSettings::IniFormat, this);
234236

235-
QSettings settings(preferenceConfigFile.c_str(), QSettings::IniFormat, this);
236237
initTabsFromSettings(settings);
237238
}
238239

copasi/resourcesUI/preferences.ini

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,40 @@ name=Proxy Password
157157
type=string
158158
value=
159159
parameter=Proxy Password
160+
161+
[Parallel Processing]
162+
[Parallel Processing/1:Enabled]
163+
name=Enabled
164+
type=bool
165+
value=
166+
parameter=Parallel Processing.Enabled
167+
tooltip=Enable or disable parallel processing.
168+
169+
[Parallel Processing/2:Max Number Threads]
170+
name=Number of Threads
171+
type=int
172+
value=
173+
parameter=Parallel Processing.Max Number Threads
174+
tooltip=The number of threads used for parallel processing.
175+
176+
[Parallel Processing/3:Schedule Strategy]
177+
name=Schedule Strategy
178+
type=string
179+
value=
180+
parameter=Parallel Processing.Schedule Strategy
181+
tooltip=The strategy used for scheduling chunks to the parallel processes.
182+
183+
[Parallel Processing/4:Monotonicity]
184+
name=Monotonicity
185+
type=string
186+
value=
187+
parameter=Parallel Processing.Monotonicity
188+
tooltip=Specify whether each chunk is processed in logical iteration order (monotonic).
189+
190+
[Parallel Processing/5:Chunk Size]
191+
name=Chunk Size
192+
type=int
193+
value=
194+
parameter=Parallel Processing.Chunk Size
195+
tooltip=The targeted chunk size (0 = schedule strategy default).
196+

0 commit comments

Comments
 (0)