Commit 1fe1ac8e authored by Laurent Montel's avatar Laurent Montel 😁

Allow to restore default settings

parent 8af7c87f
......@@ -43,7 +43,7 @@ void KDebugSettingsDialogTest::shouldHaveDefaultValue()
KDebugSettingsDialog dlg;
QDialogButtonBox *buttonBox = dlg.findChild<QDialogButtonBox *>(QStringLiteral("buttonbox"));
QVERIFY(buttonBox);
QCOMPARE(buttonBox->standardButtons(), QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help | QDialogButtonBox::Apply);
QCOMPARE(buttonBox->standardButtons(), QDialogButtonBox::RestoreDefaults | QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help | QDialogButtonBox::Apply);
QTabWidget *tab = dlg.findChild<QTabWidget *>(QStringLiteral("tabwidget"));
QVERIFY(tab);
for (int i = 0; i < tab->count(); ++i) {
......
......@@ -99,3 +99,8 @@ void KDEApplicationDebugSettingPage::insertCategories(const LoggingCategory::Lis
{
mTreeListWidget->insertCategories(list);
}
void KDEApplicationDebugSettingPage::restoreToDefault()
{
mTreeListWidget->restoreToDefault();
}
......@@ -31,10 +31,13 @@ class KDEApplicationDebugSettingPage : public QWidget
Q_OBJECT
public:
explicit KDEApplicationDebugSettingPage(QWidget *parent = nullptr);
~KDEApplicationDebugSettingPage();
~KDEApplicationDebugSettingPage() override;
void fillList(const LoggingCategory::List &list);
LoggingCategory::List rules() const;
void insertCategories(const LoggingCategory::List &list);
void restoreToDefault();
protected:
bool eventFilter(QObject *obj, QEvent *event) override;
......
......@@ -126,3 +126,12 @@ LoggingCategory::List KDEApplicationTreeListWidget::rules() const
return lst;
}
void KDEApplicationTreeListWidget::restoreToDefault()
{
//TODO use default value
for (int i = 0; i < topLevelItemCount(); ++i) {
KDEApplicationTreeListWidgetItem *itemWidget = static_cast<KDEApplicationTreeListWidgetItem *>(topLevelItem(i));
itemWidget->setType(LoggingCategory::Info);
}
}
......@@ -58,6 +58,9 @@ public:
void fillList(const LoggingCategory::List &list);
void insertCategories(const LoggingCategory::List &list);
LoggingCategory::List rules() const;
void restoreToDefault();
private:
void addListItems(const LoggingCategory::List &list, bool clearList);
};
......
......@@ -68,7 +68,7 @@ KDebugSettingsDialog::KDebugSettingsDialog(QWidget *parent)
mTabWidget->addTab(mEnvironmentSettingsRulesPage, i18n("Rules Settings With Environment Variable"));
mTabWidget->setFocusPolicy(Qt::NoFocus);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help | QDialogButtonBox::Apply, this);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::RestoreDefaults | QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help | QDialogButtonBox::Apply, this);
buttonBox->setObjectName(QStringLiteral("buttonbox"));
QPushButton *saveAs = new QPushButton(i18n("Save As..."), this);
......@@ -90,6 +90,7 @@ KDebugSettingsDialog::KDebugSettingsDialog(QWidget *parent)
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
connect(buttonBox, &QDialogButtonBox::helpRequested, this, &KDebugSettingsDialog::slotHelpRequested);
connect(buttonBox->button(QDialogButtonBox::Apply), &QPushButton::clicked, this, &KDebugSettingsDialog::slotApply);
connect(buttonBox->button(QDialogButtonBox::RestoreDefaults), &QPushButton::clicked, this, &KDebugSettingsDialog::slotRestoreDefault);
mainLayout->addWidget(buttonBox);
readConfig();
readQtLoggingFile();
......@@ -274,3 +275,8 @@ void KDebugSettingsDialog::slotLoad()
readCategoriesFiles(path);
}
}
void KDebugSettingsDialog::slotRestoreDefault()
{
mKdeApplicationSettingsPage->restoreToDefault();
}
......@@ -45,6 +45,7 @@ private:
void slotSaveAs();
void slotLoad();
void slotInsertCategories();
void slotRestoreDefault();
void readQtLoggingFile();
bool saveRules(const QString &path);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment