26 #include "ui_OptionsDialog.h"
30 #include <QMessageBox>
31 #include <QTableWidgetItem>
33 #include <QCoreApplication>
38 _ui =
new Ui::OptionsDialog;
41 _ui->bBox->setStandardButtons(
42 _ui->bBox->standardButtons() | QDialogButtonBox::Help);
45 if (settings.allKeys().isEmpty()) {
55 OptionsDialog::~OptionsDialog() {
60 if (tab >= 0 && tab < _ui->tabOptions->count()) {
61 _ui->tabOptions->setCurrentIndex(tab);
68 _ui->eGlobPath->setText(
69 settings.value(
"globalPluginPath").toStringList().join(
"; "));
70 _ui->ePrivPath->setText(
71 settings.value(
"privatePluginPath").toStringList().join(
"; "));
72 _ui->ePrivPathD->setText(
73 settings.value(
"privatePluginPathD").toStringList().join(
"; "));
74 _ui->checkDebug->setChecked(
75 settings.value(
"suffixedPlugins",
false).toBool());
76 _ui->checkSplash->setChecked(
77 settings.value(
"splashScreen",
true).toBool());
78 _ui->checkPathPopup->setChecked(
79 settings.value(
"pathDialogPopup",
false).toBool());
80 _ui->checkDelay->setChecked(
81 settings.value(
"delayExecution",
false).toBool());
82 _ui->checkReload->setChecked(
83 settings.value(
"reloadOnStartup",
false).toBool());
84 _ui->comboCheckLevel->setCurrentIndex(
85 settings.value(
"versionCheckLevel",2).toInt());
86 _setExcludes(settings.value(
"excludeList").toStringList());
87 _ui->bButtonStyle->setCurrentIndex(
88 settings.value(
"toolButtonStyle",Qt::ToolButtonFollowStyle).toInt());
89 _ui->checkRelativePaths->setChecked(
90 settings.value(
"relativePaths",
true).toBool());
95 settings.setValue(
"globalPluginPath",
_ui->eGlobPath->text()
96 .split(QRegExp(
"\\s*;\\s*"),QString::SkipEmptyParts));
97 settings.setValue(
"privatePluginPath",
_ui->ePrivPath->text()
98 .split(QRegExp(
"\\s*;\\s*"),QString::SkipEmptyParts));
99 settings.setValue(
"privatePluginPathD",
_ui->ePrivPathD->text()
100 .split(QRegExp(
"\\s*;\\s*"),QString::SkipEmptyParts));
101 settings.setValue(
"suffixedPlugins",
_ui->checkDebug->isChecked());
102 settings.setValue(
"splashScreen",
_ui->checkSplash->isChecked());
103 settings.setValue(
"delayExecution",
_ui->checkDelay->isChecked());
104 settings.setValue(
"reloadOnStartup",
_ui->checkReload->isChecked());
105 settings.setValue(
"pathDialogPopup",
_ui->checkPathPopup->isChecked());
106 settings.setValue(
"versionCheckLevel",
_ui->comboCheckLevel->currentIndex());
108 settings.setValue(
"toolButtonStyle",
_ui->bButtonStyle->currentIndex());
109 settings.setValue(
"relativePaths",
_ui->checkRelativePaths->isChecked());
116 QSettings defaults(
":/config/default.ini",QSettings::IniFormat);
119 QString globalPath =
"/usr/lib/charon-plugins";
123 QString globalPath = QCoreApplication::applicationDirPath();
125 _ui->checkSplash->setChecked(
true);
126 _ui->eGlobPath->setText(globalPath);
127 _ui->ePrivPath->setText(QString());
128 _ui->ePrivPathD->setText(QString());
129 _ui->checkRelease->setChecked(
true);
130 _ui->checkDelay->setChecked(
false);
131 _ui->checkReload->setChecked(
false);
132 _ui->checkPathPopup->setChecked(
false);
133 _ui->comboCheckLevel->setCurrentIndex(2);
134 _setExcludes(defaults.value(
"excludeList").toStringList());
135 _ui->bButtonStyle->setCurrentIndex(Qt::ToolButtonFollowStyle);
136 _ui->checkRelativePaths->setChecked(
true);
140 switch (
_ui->bBox->buttonRole(button)) {
141 case QDialogButtonBox::ResetRole:
144 case QDialogButtonBox::ApplyRole:
145 case QDialogButtonBox::AcceptRole:
155 switch (
_ui->tabOptions->currentIndex()) {
157 page=
"#options-config";
160 page=
"#options-paths";
163 page=
"#options-excludes";
166 page=
"#options-appearance";
172 QString(
"tuchulcha-options.html%1").arg(page));
176 _ui->tableExclude->clear();
177 _ui->tableExclude->setRowCount(list.size()+1);
178 for (
int i = 0; i < list.size(); i++) {
179 _ui->tableExclude->setItem(i,0,
new QTableWidgetItem(list[i]));
181 _ui->tableExclude->setItem(list.size(),0,
new QTableWidgetItem());
186 for (
int i=0; i <
_ui->tableExclude->rowCount(); i++) {
187 QTableWidgetItem* it =
_ui->tableExclude->item(i,0);
189 res << it->data(Qt::DisplayRole).toString().trimmed();
192 res.removeAll(QString(
""));
193 res.removeAll(QString::null);
198 QTableWidget* tab =
_ui->tableExclude;
199 int row = item->row();
200 int rowc = tab->rowCount();
201 if (item->data(Qt::DisplayRole).toString().isEmpty()) {
208 tab->insertRow(rowc);
215 if (settings.allKeys().isEmpty()) {
223 QSettings defaults(
":/config/default.ini",QSettings::IniFormat);
224 if(!settings.contains(
"excludeList")) {
225 settings.setValue(
"excludeList",defaults.value(
"excludeList"));
229 QStringList pVars, allPaths;
230 pVars<<
"globalPluginPath"<<
"privatePluginPath"<<
"privatePluginPathD";
232 foreach (
const QString& pVar, pVars) {
233 QStringList paths = settings.value(pVar).toStringList();
234 QStringListIterator pIter(paths);
235 while (pIter.hasNext()) {
236 const QString& p = pIter.next();
239 if (QMessageBox::question(
240 0,tr(
"path not found"),
241 tr(
"path <tt>%1</tt> has not been found.</br>"
242 "Remove it from <em>%2</em>?").arg(p).arg(pVar),
243 QMessageBox::Yes,QMessageBox::No) ==
249 settings.setValue(pVar,paths);
252 if (allPaths.isEmpty()) {
Ui::OptionsDialog * _ui
designer gui
void on_bBox_clicked(QAbstractButton *button)
handle button click events
void _setExcludes(QStringList list) const
set exclude list
void apply()
apply new settings values
void on_bBox_helpRequested()
handle help request
void setTab(int tab=-1)
set shown tab
OptionsDialog(QWidget *parent=0, Qt::WindowFlags f=0)
constructor
Declaration of class OptionsDialog.
void on_tableExclude_itemChanged(QTableWidgetItem *item) const
handle exclude list changes
void helpRequested(QString)
request help on specified page
QStringList _getExcludes() const
get exclude list
void restore()
restore default values
void refresh()
refresh from saved settings
static bool check()
Configures plugin paths.