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..925db67b1 100644 --- a/panel/pluginsettings.cpp +++ b/panel/pluginsettings.cpp @@ -207,6 +207,15 @@ void PluginSettings::loadFromCache() d->mSettings->beginGroup(d->mGroup); d->mOldSettings.loadToSettings(); d->mSettings->endGroup(); + emit settingsChanged(); +} + +void PluginSettings::storeToCache() +{ + Q_D(PluginSettings); + d->mSettings->beginGroup(d->mGroup); + d->mOldSettings.loadFromSettings(); + d->mSettings->endGroup(); } PluginSettings* PluginSettingsFactory::create(LXQt::Settings *settings, const QString &group, QObject *parent/* = nullptr*/) 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();