diff --git a/src/tiled/preferencesdialog.cpp b/src/tiled/preferencesdialog.cpp index 426e68dec3..adeebc8be0 100644 --- a/src/tiled/preferencesdialog.cpp +++ b/src/tiled/preferencesdialog.cpp @@ -35,6 +35,8 @@ #include #include +#include + using namespace Tiled; PreferencesDialog::PreferencesDialog(QWidget *parent) @@ -176,6 +178,26 @@ PreferencesDialog::PreferencesDialog(QWidget *parent) }); resize(sizeHint()); + + connect(mUi->defaultGeneral, &QPushButton::clicked, this, [=] { + this->restoreToDefault(QString::fromUtf8("(Export|Storage|Startup)/")); + }); + + connect(mUi->defaultInterface, &QPushButton::clicked, this, [=] { + this->restoreToDefault(QString::fromUtf8( + "Interface/(?!(ApplicationStyle|BaseColor|SelectionColor|UseCustomFont|CustomFont))")); + this->restoreToDefault(QString::fromUtf8("Install/(DisplayNews|CheckForUpdates)")); + this->restoreToDefault(QString::fromUtf8("AbstractObjectTool/")); + }); + + connect(mUi->defaultTheme, &QPushButton::clicked, preferences, [preferences, this] { + this->restoreToDefault(QString::fromUtf8( + "Interface/(ApplicationStyle|BaseColor|SelectionColor|UseCustomFont|CustomFont)")); + + QFont customFont = preferences->customFont(); + mUi->fontComboBox->setCurrentFont(customFont); + mUi->fontSize->setValue(customFont.pointSize()); + }); } PreferencesDialog::~PreferencesDialog() @@ -294,4 +316,14 @@ void PreferencesDialog::styleComboChanged() mUi->selectionColorLabel->setEnabled(!systemStyle); } +void PreferencesDialog::restoreToDefault(QString regexKey) +{ + Preferences *prefs = Preferences::instance(); + QStringList generalKeys = prefs->allKeys().filter(QRegularExpression(regexKey)); + for ( const auto& key : generalKeys) + prefs->remove(key); + + this->fromPreferences(); +} + #include "moc_preferencesdialog.cpp" diff --git a/src/tiled/preferencesdialog.h b/src/tiled/preferencesdialog.h index 7962cf6618..94189ce9c4 100644 --- a/src/tiled/preferencesdialog.h +++ b/src/tiled/preferencesdialog.h @@ -54,6 +54,8 @@ class PreferencesDialog : public QDialog void styleComboChanged(); + void restoreToDefault(QString regexKey); + Ui::PreferencesDialog *mUi; QStringList mLanguages; }; diff --git a/src/tiled/preferencesdialog.ui b/src/tiled/preferencesdialog.ui index 27c83fbcd0..5ae95abb21 100644 --- a/src/tiled/preferencesdialog.ui +++ b/src/tiled/preferencesdialog.ui @@ -7,7 +7,7 @@ 0 0 544 - 595 + 626 @@ -20,7 +20,13 @@ - 0 + 3 + + + false + + + false @@ -165,6 +171,57 @@ + + + + QLayout::SetMinimumSize + + + + + + 0 + 0 + + + + + 120 + 25 + + + + Reset to default + + + + 16 + 16 + + + + false + + + false + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + @@ -398,6 +455,36 @@ + + + + + + + 120 + 25 + + + + Reset to default + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + @@ -555,6 +642,45 @@ + + + + + + + 0 + 0 + + + + + 120 + 25 + + + + Reset to default + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 40 + 20 + + + + + +