diff --git a/src/plugins/AccessKeysNavigation/akn_plugin.cpp b/src/plugins/AccessKeysNavigation/akn_plugin.cpp index 195f4b549..c21aee20f 100644 --- a/src/plugins/AccessKeysNavigation/akn_plugin.cpp +++ b/src/plugins/AccessKeysNavigation/akn_plugin.cpp @@ -36,7 +36,7 @@ PluginSpec AKN_Plugin::pluginSpec() spec.name = "Access Keys Navigation"; spec.info = "Access keys navigation for QupZilla"; spec.description = "Provides support for navigating in webpages by keyboard shortcuts"; - spec.version = "0.4.1"; + spec.version = "0.4.2"; spec.author = "David Rosca "; spec.icon = QPixmap(":/accesskeysnavigation/data/icon.png"); spec.hasSettings = true; @@ -53,6 +53,8 @@ void AKN_Plugin::init(const QString &sPath) void AKN_Plugin::unload() { + delete m_settings.data(); + m_handler->deleteLater(); } @@ -72,10 +74,12 @@ QTranslator* AKN_Plugin::getTranslator(const QString &locale) void AKN_Plugin::showSettings(QWidget* parent) { - AKN_Settings* settings = new AKN_Settings(m_handler, parent); - settings->setAttribute(Qt::WA_DeleteOnClose); + if (!m_settings) { + m_settings = new AKN_Settings(m_handler, parent); + } - settings->show(); + m_settings.data()->show(); + m_settings.data()->raise(); } bool AKN_Plugin::keyPress(const Qz::ObjectName &type, QObject* obj, QKeyEvent* event) diff --git a/src/plugins/AccessKeysNavigation/akn_plugin.h b/src/plugins/AccessKeysNavigation/akn_plugin.h index efc8943e9..83ec943d6 100644 --- a/src/plugins/AccessKeysNavigation/akn_plugin.h +++ b/src/plugins/AccessKeysNavigation/akn_plugin.h @@ -18,9 +18,12 @@ #ifndef AKN_PLUGIN_H #define AKN_PLUGIN_H +#include + #include "plugininterface.h" class AKN_Handler; +class AKN_Settings; class AKN_Plugin : public QObject, public PluginInterface { @@ -41,6 +44,7 @@ public: bool keyPress(const Qz::ObjectName &type, QObject* obj, QKeyEvent* event); private: + QWeakPointer m_settings; AKN_Handler* m_handler; }; diff --git a/src/plugins/AccessKeysNavigation/akn_settings.cpp b/src/plugins/AccessKeysNavigation/akn_settings.cpp index 4c9321a52..eef566ba6 100644 --- a/src/plugins/AccessKeysNavigation/akn_settings.cpp +++ b/src/plugins/AccessKeysNavigation/akn_settings.cpp @@ -30,6 +30,7 @@ AKN_Settings::AKN_Settings(AKN_Handler* handler, QWidget* parent) , m_handler(handler) , m_settingsFile(handler->settingsFile()) { + setAttribute(Qt::WA_DeleteOnClose); ui->setupUi(this); QSettings settings(m_settingsFile, QSettings::IniFormat); diff --git a/src/plugins/GreaseMonkey/gm_manager.cpp b/src/plugins/GreaseMonkey/gm_manager.cpp index 6ba67a9e9..a8f27d905 100644 --- a/src/plugins/GreaseMonkey/gm_manager.cpp +++ b/src/plugins/GreaseMonkey/gm_manager.cpp @@ -40,8 +40,12 @@ GM_Manager::GM_Manager(const QString &sPath, QObject* parent) void GM_Manager::showSettings(QWidget* parent) { - GM_Settings settings(this, parent); - settings.exec(); + if (!m_settings) { + m_settings = new GM_Settings(this, parent); + } + + m_settings.data()->show(); + m_settings.data()->raise(); } void GM_Manager::downloadScript(const QNetworkRequest &request) @@ -81,11 +85,15 @@ QString GM_Manager::requireScripts(const QStringList &urlList) const return script; } -void GM_Manager::saveSettings() +void GM_Manager::unloadPlugin() { + // Save settings QSettings settings(m_settingsPath + "extensions.ini", QSettings::IniFormat); settings.beginGroup("GreaseMonkey"); settings.setValue("disabledScripts", m_disabledScripts); + settings.endGroup(); + + delete m_settings.data(); } QList GM_Manager::allScripts() const diff --git a/src/plugins/GreaseMonkey/gm_manager.h b/src/plugins/GreaseMonkey/gm_manager.h index f389a33d8..f15c5c4be 100644 --- a/src/plugins/GreaseMonkey/gm_manager.h +++ b/src/plugins/GreaseMonkey/gm_manager.h @@ -20,11 +20,13 @@ #include #include +#include class QUrl; class QNetworkRequest; class GM_Script; +class GM_Settings; class GM_Manager : public QObject { @@ -39,7 +41,7 @@ public: QString scriptsDirectory() const; QString requireScripts(const QStringList &urlList) const; - void saveSettings(); + void unloadPlugin(); QList allScripts() const; bool containsScript(const QString &fullName) const; @@ -66,6 +68,7 @@ private slots: private: QString m_settingsPath; QString m_bootstrap; + QWeakPointer m_settings; QStringList m_disabledScripts; QList m_endScripts; diff --git a/src/plugins/GreaseMonkey/gm_plugin.cpp b/src/plugins/GreaseMonkey/gm_plugin.cpp index 33d688951..396601e3e 100644 --- a/src/plugins/GreaseMonkey/gm_plugin.cpp +++ b/src/plugins/GreaseMonkey/gm_plugin.cpp @@ -38,7 +38,7 @@ PluginSpec GM_Plugin::pluginSpec() spec.name = "GreaseMonkey"; spec.info = "Userscripts for QupZilla"; spec.description = "Provides support for userscripts (www.userscripts.org)"; - spec.version = "0.2.2"; + spec.version = "0.2.3"; spec.author = "David Rosca "; spec.icon = QPixmap(":gm/data/icon.png"); spec.hasSettings = true; @@ -56,7 +56,7 @@ void GM_Plugin::init(const QString &sPath) void GM_Plugin::unload() { - m_manager->saveSettings(); + m_manager->unloadPlugin(); delete m_manager; } diff --git a/src/plugins/GreaseMonkey/settings/gm_settings.cpp b/src/plugins/GreaseMonkey/settings/gm_settings.cpp index 8ca0f68b4..b4f01e967 100644 --- a/src/plugins/GreaseMonkey/settings/gm_settings.cpp +++ b/src/plugins/GreaseMonkey/settings/gm_settings.cpp @@ -31,6 +31,7 @@ GM_Settings::GM_Settings(GM_Manager* manager, QWidget* parent) , ui(new Ui::GM_Settings) , m_manager(manager) { + setAttribute(Qt::WA_DeleteOnClose); ui->setupUi(this); connect(ui->listWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(showItemInfo(QListWidgetItem*))); diff --git a/src/plugins/MouseGestures/mousegestures.cpp b/src/plugins/MouseGestures/mousegestures.cpp index f40a4e50d..792a3a713 100644 --- a/src/plugins/MouseGestures/mousegestures.cpp +++ b/src/plugins/MouseGestures/mousegestures.cpp @@ -107,8 +107,17 @@ bool MouseGestures::mouseMove(QObject* obj, QMouseEvent* event) void MouseGestures::showSettings(QWidget* parent) { - MouseGesturesSettingsDialog* d = new MouseGesturesSettingsDialog(parent); - d->show(); + if (!m_settings) { + m_settings = new MouseGesturesSettingsDialog(parent); + } + + m_settings.data()->show(); + m_settings.data()->raise(); +} + +void MouseGestures::unloadPlugin() +{ + delete m_settings.data(); } void MouseGestures::upGestured() @@ -192,7 +201,7 @@ void MouseGestures::upLeftGestured() } if (QApplication::isRightToLeft()) { - view->tabWidget()->nextTab(); + view->tabWidget()->nextTab(); } else { view->tabWidget()->previousTab(); @@ -210,7 +219,7 @@ void MouseGestures::upRightGestured() view->tabWidget()->previousTab(); } else { - view->tabWidget()->nextTab(); + view->tabWidget()->nextTab(); } } diff --git a/src/plugins/MouseGestures/mousegestures.h b/src/plugins/MouseGestures/mousegestures.h index 5bb236c1b..c98a3116f 100644 --- a/src/plugins/MouseGestures/mousegestures.h +++ b/src/plugins/MouseGestures/mousegestures.h @@ -25,6 +25,7 @@ class QMouseEvent; class WebView; class QjtMouseGestureFilter; +class MouseGesturesSettingsDialog; class MouseGestures : public QObject { @@ -38,6 +39,7 @@ public: bool mouseMove(QObject* obj, QMouseEvent* event); void showSettings(QWidget* parent); + void unloadPlugin(); private slots: void upGestured(); @@ -54,8 +56,8 @@ private slots: private: QjtMouseGestureFilter* m_filter; + QWeakPointer m_settings; QWeakPointer m_view; - }; #endif // MOUSEGESTURES_H diff --git a/src/plugins/MouseGestures/mousegesturesplugin.cpp b/src/plugins/MouseGestures/mousegesturesplugin.cpp index b3e7eea6d..402128039 100644 --- a/src/plugins/MouseGestures/mousegesturesplugin.cpp +++ b/src/plugins/MouseGestures/mousegesturesplugin.cpp @@ -35,7 +35,7 @@ PluginSpec MouseGesturesPlugin::pluginSpec() spec.name = "Mouse Gestures"; spec.info = "Mouse gestures for QupZilla"; spec.description = "Provides support for navigating in webpages by mouse gestures"; - spec.version = "0.3.2"; + spec.version = "0.3.3"; spec.author = "David Rosca "; spec.icon = QPixmap(":/mousegestures/data/icon.png"); spec.hasSettings = true; @@ -56,6 +56,7 @@ void MouseGesturesPlugin::init(const QString &sPath) void MouseGesturesPlugin::unload() { + m_gestures->unloadPlugin(); m_gestures->deleteLater(); } @@ -78,7 +79,6 @@ void MouseGesturesPlugin::showSettings(QWidget* parent) m_gestures->showSettings(parent); } - bool MouseGesturesPlugin::mousePress(const Qz::ObjectName &type, QObject* obj, QMouseEvent* event) { if (type == Qz::ON_WebView) { diff --git a/src/plugins/MouseGestures/mousegesturessettingsdialog.cpp b/src/plugins/MouseGestures/mousegesturessettingsdialog.cpp index c5b7b79fb..b3b92e7fb 100644 --- a/src/plugins/MouseGestures/mousegesturessettingsdialog.cpp +++ b/src/plugins/MouseGestures/mousegesturessettingsdialog.cpp @@ -25,6 +25,7 @@ MouseGesturesSettingsDialog::MouseGesturesSettingsDialog(QWidget* parent) : QDialog(parent) , ui(new Ui::MouseGesturesSettingsDialog) { + setAttribute(Qt::WA_DeleteOnClose); ui->setupUi(this); if (QApplication::isRightToLeft()) { diff --git a/src/plugins/PIM/PIM_handler.cpp b/src/plugins/PIM/PIM_handler.cpp index e7180953b..706b4cfd2 100644 --- a/src/plugins/PIM/PIM_handler.cpp +++ b/src/plugins/PIM/PIM_handler.cpp @@ -89,10 +89,14 @@ void PIM_Handler::loadSettings() void PIM_Handler::showSettings(QWidget* parent) { - PIM_Settings* settings = new PIM_Settings(m_settingsFile, parent); - settings->show(); + if (!m_settings) { + m_settings = new PIM_Settings(m_settingsFile, parent); - connect(settings, SIGNAL(accepted()), this, SLOT(loadSettings())); + connect(m_settings.data(), SIGNAL(accepted()), this, SLOT(loadSettings())); + } + + m_settings.data()->show(); + m_settings.data()->raise(); } void PIM_Handler::populateWebViewMenu(QMenu* menu, WebView* view, const QWebHitTestResult &hitTest) @@ -159,6 +163,11 @@ bool PIM_Handler::keyPress(WebView* view, QKeyEvent* event) return true; } +void PIM_Handler::unloadPlugin() +{ + delete m_settings.data(); +} + void PIM_Handler::webPageCreated(WebPage* page) { connect(page, SIGNAL(loadFinished(bool)), this, SLOT(pageLoadFinished())); diff --git a/src/plugins/PIM/PIM_handler.h b/src/plugins/PIM/PIM_handler.h index a40d0de33..9a1ff4eea 100644 --- a/src/plugins/PIM/PIM_handler.h +++ b/src/plugins/PIM/PIM_handler.h @@ -30,6 +30,8 @@ class WebView; class WebPage; +class PIM_Settings; + class PIM_Handler : public QObject { Q_OBJECT @@ -39,6 +41,8 @@ public: void populateWebViewMenu(QMenu* menu, WebView* view, const QWebHitTestResult &hitTest); bool keyPress(WebView* view, QKeyEvent* event); + void unloadPlugin(); + signals: public slots: @@ -77,6 +81,7 @@ private: QHash m_infoMatches; QHash m_translations; + QWeakPointer m_settings; QWeakPointer m_view; QWebElement m_element; diff --git a/src/plugins/PIM/PIM_plugin.cpp b/src/plugins/PIM/PIM_plugin.cpp index 7198cfdc5..0618a2afd 100644 --- a/src/plugins/PIM/PIM_plugin.cpp +++ b/src/plugins/PIM/PIM_plugin.cpp @@ -38,7 +38,7 @@ PluginSpec PIM_Plugin::pluginSpec() spec.name = "PIM"; spec.info = "Personal Information Manager"; spec.description = "Adds ability for Qupzilla to store some personal data"; - spec.version = "0.1.1"; + spec.version = "0.1.2"; spec.author = QString::fromUtf8("Mladen Pejaković "); spec.icon = QPixmap(":/PIM/data/PIM.png"); spec.hasSettings = true; @@ -57,6 +57,7 @@ void PIM_Plugin::init(const QString &sPath) void PIM_Plugin::unload() { + m_handler->unloadPlugin(); m_handler->deleteLater(); } diff --git a/src/plugins/TestPlugin/testplugin.cpp b/src/plugins/TestPlugin/testplugin.cpp index 64eeb8c38..c431878b7 100644 --- a/src/plugins/TestPlugin/testplugin.cpp +++ b/src/plugins/TestPlugin/testplugin.cpp @@ -43,7 +43,7 @@ PluginSpec TestPlugin::pluginSpec() spec.name = "Example Plugin"; spec.info = "Example minimal plugin"; spec.description = "Very simple minimal plugin example"; - spec.version = "0.1.5"; + spec.version = "0.1.6"; spec.author = "David Rosca "; spec.icon = QPixmap(":qupzilla.png"); spec.hasSettings = true; @@ -81,6 +81,9 @@ void TestPlugin::unload() // Removing sidebar from application SideBarManager::removeSidebar("testplugin-sidebar"); + + // Deleting settings dialog if opened + delete m_settings.data(); } bool TestPlugin::testPlugin() @@ -107,24 +110,27 @@ void TestPlugin::showSettings(QWidget* parent) // This function will be called from Preferences after clicking on Settings button. // Settings button will be enabled if PluginSpec.hasSettings == true - QDialog* dialog = new QDialog(parent); - QPushButton* b = new QPushButton("Example Plugin v0.0.1"); - QPushButton* closeButton = new QPushButton(tr("Close")); - QLabel* label = new QLabel(); - label->setPixmap(QPixmap(":icons/other/about.png")); + if (!m_settings) { + m_settings = new QDialog(parent); + QPushButton* b = new QPushButton("Example Plugin v0.0.1"); + QPushButton* closeButton = new QPushButton(tr("Close")); + QLabel* label = new QLabel(); + label->setPixmap(QPixmap(":icons/other/about.png")); - QVBoxLayout* l = new QVBoxLayout(dialog); - l->addWidget(label); - l->addWidget(b); - l->addWidget(closeButton); - dialog->setLayout(l); + QVBoxLayout* l = new QVBoxLayout(m_settings.data()); + l->addWidget(label); + l->addWidget(b); + l->addWidget(closeButton); + m_settings.data()->setLayout(l); - dialog->setAttribute(Qt::WA_DeleteOnClose); - dialog->setWindowTitle(tr("Example Plugin Settings")); - dialog->setWindowIcon(QIcon(":qupzilla.png")); - connect(closeButton, SIGNAL(clicked()), dialog, SLOT(close())); + m_settings.data()->setAttribute(Qt::WA_DeleteOnClose); + m_settings.data()->setWindowTitle(tr("Example Plugin Settings")); + m_settings.data()->setWindowIcon(QIcon(":qupzilla.png")); + connect(closeButton, SIGNAL(clicked()), m_settings.data(), SLOT(close())); + } - dialog->show(); + m_settings.data()->show(); + m_settings.data()->raise(); } void TestPlugin::populateWebViewMenu(QMenu* menu, WebView* view, const QWebHitTestResult &r) diff --git a/src/plugins/TestPlugin/testplugin.h b/src/plugins/TestPlugin/testplugin.h index 922c60e45..f46cbeb64 100644 --- a/src/plugins/TestPlugin/testplugin.h +++ b/src/plugins/TestPlugin/testplugin.h @@ -31,6 +31,7 @@ #include #include #include +#include class TestPlugin : public QObject, public PluginInterface { @@ -56,6 +57,8 @@ private slots: void actionSlot(); private: + QWeakPointer m_settings; + WebView* m_view; QString m_settingsPath; };