8 #include "ui_preferences_dialog.h"
11 #include <QFileDialog>
19 QString theme = settings.value(
"Preferences::theme",
"light").toString();
22 ui->comboBoxTheme->setCurrentIndex(1);
26 ui->comboBoxTheme->setCurrentIndex(0);
29 bool use_plot_color_index =
30 settings.value(
"Preferences::use_plot_color_index",
false).toBool();
31 bool remember_color = settings.value(
"Preferences::remember_color",
true).toBool();
33 ui->checkBoxRememberColor->setChecked(remember_color);
34 ui->radioLocalColorIndex->setChecked(use_plot_color_index);
35 ui->radioGlobalColorIndex->setChecked(!use_plot_color_index);
37 ui->pushButtonAdd->setIcon(
LoadSvg(
":/resources/svg/add_tab.svg", theme));
38 ui->pushButtonRemove->setIcon(
LoadSvg(
":/resources/svg/trash.svg", theme));
40 bool use_separator = settings.value(
"Preferences::use_separator",
true).toBool();
41 ui->checkBoxSeparator->setChecked(use_separator);
43 bool use_opengl = settings.value(
"Preferences::use_opengl",
true).toBool();
44 ui->checkBoxOpenGL->setChecked(use_opengl);
46 bool autozoom_visibility =
47 settings.value(
"Preferences::autozoom_visibility",
true).toBool();
48 ui->checkBoxAutoZoomVisibility->setChecked(autozoom_visibility);
50 bool autozoom_curve_added =
51 settings.value(
"Preferences::autozoom_curve_added",
true).toBool();
52 ui->checkBoxAutoZoomAdded->setChecked(autozoom_curve_added);
54 bool autozoom_filter_applied =
55 settings.value(
"Preferences::autozoom_filter_applied",
true).toBool();
56 ui->checkBoxAutoZoomFilter->setChecked(autozoom_filter_applied);
58 bool truncation_check = settings.value(
"Preferences::truncation_check",
true).toBool();
59 ui->checkBoxTruncation->setChecked(truncation_check);
62 auto custom_plugin_folders =
63 settings.value(
"Preferences::plugin_folders",
true).toStringList();
64 for (
const auto& folder : custom_plugin_folders)
67 auto item =
new QListWidgetItem(folder);
70 item->setForeground(Qt::red);
72 ui->listWidgetCustom->addItem(item);
74 ui->pushButtonRemove->setEnabled(!
ui->listWidgetCustom->selectedItems().isEmpty());
76 auto builtin_plugin_folders =
77 settings.value(
"Preferences::builtin_plugin_folders",
true).toStringList();
78 for (
const auto& folder : builtin_plugin_folders)
80 ui->listWidgetBuiltin->addItem(
new QListWidgetItem(folder));
92 settings.setValue(
"Preferences::theme",
93 ui->comboBoxTheme->currentIndex() == 1 ?
"dark" :
"light");
94 settings.setValue(
"Preferences::remember_color",
95 ui->checkBoxRememberColor->isChecked());
96 settings.setValue(
"Preferences::use_plot_color_index",
97 ui->radioLocalColorIndex->isChecked());
98 settings.setValue(
"Preferences::use_separator",
ui->checkBoxSeparator->isChecked());
99 settings.setValue(
"Preferences::use_opengl",
ui->checkBoxOpenGL->isChecked());
100 settings.setValue(
"Preferences::autozoom_visibility",
101 ui->checkBoxAutoZoomVisibility->isChecked());
102 settings.setValue(
"Preferences::autozoom_curve_added",
103 ui->checkBoxAutoZoomAdded->isChecked());
104 settings.setValue(
"Preferences::autozoom_filter_applied",
105 ui->checkBoxAutoZoomFilter->isChecked());
106 settings.setValue(
"Preferences::truncation_check",
ui->checkBoxTruncation->isChecked());
108 QStringList plugin_folders;
109 for (
int row = 0; row <
ui->listWidgetCustom->count(); row++)
111 plugin_folders.push_back(
ui->listWidgetCustom->item(row)->text());
113 settings.setValue(
"Preferences::plugin_folders", plugin_folders);
120 QString dir = QFileDialog::getExistingDirectory(
121 this, tr(
"Select a Directory"), QDir::homePath(),
122 QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
123 auto item =
new QListWidgetItem(dir);
124 ui->listWidgetCustom->addItem(item);
129 auto selected =
ui->listWidgetCustom->selectedItems();
131 for (QListWidgetItem* item : selected)
133 ui->listWidgetCustom->removeItemWidget(item);
140 ui->pushButtonRemove->setEnabled(!
ui->listWidgetCustom->selectedItems().isEmpty());