diff --git a/panel/lxqtpanelpluginconfigdialog.cpp b/panel/lxqtpanelpluginconfigdialog.cpp index 0978f13a6..a92d46c81 100644 --- a/panel/lxqtpanelpluginconfigdialog.cpp +++ b/panel/lxqtpanelpluginconfigdialog.cpp @@ -58,6 +58,15 @@ PluginSettings& LXQtPanelPluginConfigDialog::settings() const } +/************************************************ + + ************************************************/ +void LXQtPanelPluginConfigDialog::closeEvent(QCloseEvent *event) +{ + mSettings.storeToCache(); + return QDialog::closeEvent(event); +} + /************************************************ diff --git a/panel/lxqtpanelpluginconfigdialog.h b/panel/lxqtpanelpluginconfigdialog.h index 93bd4e0d5..8fdb14e7b 100644 --- a/panel/lxqtpanelpluginconfigdialog.h +++ b/panel/lxqtpanelpluginconfigdialog.h @@ -35,6 +35,7 @@ #include "pluginsettings.h" class QComboBox; +class QCloseEvent; class LXQT_PANEL_API LXQtPanelPluginConfigDialog : public QDialog { @@ -46,6 +47,9 @@ class LXQT_PANEL_API LXQtPanelPluginConfigDialog : public QDialog PluginSettings &settings() const; +protected: + virtual void closeEvent(QCloseEvent *event) override; + protected slots: /* Saves settings in conf file. diff --git a/panel/plugin.cpp b/panel/plugin.cpp index c4d3c440d..25903a100 100644 --- a/panel/plugin.cpp +++ b/panel/plugin.cpp @@ -188,6 +188,8 @@ Plugin::Plugin(const LXQt::PluginInfo &desktopFile, LXQt::Settings *settings, co ************************************************/ Plugin::~Plugin() { + if (mConfigDialog) + delete mConfigDialog.data(); delete mPlugin; delete mPluginLoader; delete mSettings; @@ -515,7 +517,6 @@ void Plugin::showConfigureDialog() if (!mConfigDialog) return; - connect(this, &Plugin::destroyed, mConfigDialog.data(), &QWidget::close); mPanel->willShowWindow(mConfigDialog); mConfigDialog->show(); mConfigDialog->raise(); diff --git a/panel/pluginsettings.cpp b/panel/pluginsettings.cpp index d5a2be958..3f6c86459 100644 --- a/panel/pluginsettings.cpp +++ b/panel/pluginsettings.cpp @@ -28,15 +28,18 @@ #include "pluginsettings.h" #include "pluginsettings_p.h" #include +#include class PluginSettingsPrivate { public: PluginSettingsPrivate(LXQt::Settings* settings, const QString &group) : mSettings(settings) - , mOldSettings(settings) , mGroup(group) { + mSettings->beginGroup(mGroup); + mOldSettings = std::make_unique(mSettings); + mSettings->endGroup(); } QString prefix() const; @@ -46,7 +49,7 @@ class PluginSettingsPrivate } LXQt::Settings *mSettings; - LXQt::SettingsCache mOldSettings; + std::unique_ptr mOldSettings; QString mGroup; QStringList mSubGroups; }; @@ -163,10 +166,8 @@ void PluginSettings::clear() void PluginSettings::sync() { Q_D(PluginSettings); - d->mSettings->beginGroup(d->mGroup); d->mSettings->sync(); - d->mOldSettings.loadFromSettings(); - d->mSettings->endGroup(); + storeToCache(); emit settingsChanged(); } @@ -205,7 +206,17 @@ void PluginSettings::loadFromCache() { Q_D(PluginSettings); d->mSettings->beginGroup(d->mGroup); - d->mOldSettings.loadToSettings(); + d->mSettings->remove(QString{}); + d->mOldSettings->loadToSettings(); + d->mSettings->endGroup(); + emit settingsChanged(); +} + +void PluginSettings::storeToCache() +{ + Q_D(PluginSettings); + d->mSettings->beginGroup(d->mGroup); + d->mOldSettings = std::make_unique(d->mSettings); d->mSettings->endGroup(); } diff --git a/panel/pluginsettings.h b/panel/pluginsettings.h index 19e5f5f7b..d9b01d554 100644 --- a/panel/pluginsettings.h +++ b/panel/pluginsettings.h @@ -81,6 +81,7 @@ class LXQT_PANEL_API PluginSettings : public QObject void endGroup(); void loadFromCache(); + void storeToCache(); signals: void settingsChanged(); diff --git a/plugin-taskbar/lxqttaskbar.cpp b/plugin-taskbar/lxqttaskbar.cpp index aa4abe580..e6e4866ae 100644 --- a/plugin-taskbar/lxqttaskbar.cpp +++ b/plugin-taskbar/lxqttaskbar.cpp @@ -485,10 +485,10 @@ void LXQtTaskBar::settingsChanged() else setButtonStyle(Qt::ToolButtonTextBesideIcon); - mShowOnlyOneDesktopTasks = mPlugin->settings()->value(QStringLiteral("showOnlyOneDesktopTasks"), mShowOnlyOneDesktopTasks).toBool(); - mShowDesktopNum = mPlugin->settings()->value(QStringLiteral("showDesktopNum"), mShowDesktopNum).toInt(); - mShowOnlyCurrentScreenTasks = mPlugin->settings()->value(QStringLiteral("showOnlyCurrentScreenTasks"), mShowOnlyCurrentScreenTasks).toBool(); - mShowOnlyMinimizedTasks = mPlugin->settings()->value(QStringLiteral("showOnlyMinimizedTasks"), mShowOnlyMinimizedTasks).toBool(); + mShowOnlyOneDesktopTasks = mPlugin->settings()->value(QStringLiteral("showOnlyOneDesktopTasks"), false).toBool(); + mShowDesktopNum = mPlugin->settings()->value(QStringLiteral("showDesktopNum"), 0).toInt(); + mShowOnlyCurrentScreenTasks = mPlugin->settings()->value(QStringLiteral("showOnlyCurrentScreenTasks"), false).toBool(); + mShowOnlyMinimizedTasks = mPlugin->settings()->value(QStringLiteral("showOnlyMinimizedTasks"), false).toBool(); mAutoRotate = mPlugin->settings()->value(QStringLiteral("autoRotate"), true).toBool(); mCloseOnMiddleClick = mPlugin->settings()->value(QStringLiteral("closeOnMiddleClick"), true).toBool(); mRaiseOnCurrentDesktop = mPlugin->settings()->value(QStringLiteral("raiseOnCurrentDesktop"), false).toBool();