summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-09-23 11:30:27 (GMT)
committerMontel Laurent <montel@kde.org>2016-09-23 11:30:27 (GMT)
commit7e8a66c90776a1b3390ce6435d3cc28b33aec6ea (patch)
tree63f14bdd5513eab6acafa8b2b210b7eafc8ff37b
parent9c803f529b838837ea4988dc282f56ff6bf25b9d (diff)
Add template configure dialog
-rw-r--r--src/CMakeLists.txt3
-rw-r--r--src/configureplugins/configureplugindialog.cpp71
-rw-r--r--src/configureplugins/configureplugindialog.h44
-rw-r--r--src/genericplugins/abstractgenericplugin.cpp5
-rw-r--r--src/genericplugins/abstractgenericplugin.h2
5 files changed, 125 insertions, 0 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index a923695..ef84f9f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -187,6 +187,7 @@ set(libpimcommon_generericplugin_SRCS
set(libpimcommon_configure_plugins_SRCS
configureplugins/configurepluginslistwidget.cpp
configureplugins/configurepluginswidget.cpp
+ configureplugins/configureplugindialog.cpp
)
@@ -356,6 +357,7 @@ ecm_generate_headers(PimCommon_CamelCasegenericplugins_HEADERS
GenericPluginInterface
AbstractGenericPlugin
AbstractGenericPluginInterface
+
PluginUtil
PluginInterface
REQUIRED_HEADERS PimCommon_genericplugins_HEADERS
@@ -539,6 +541,7 @@ ecm_generate_headers(PimCommon_Camelcaseconfigureplugins_HEADERS
HEADER_NAMES
ConfigurePluginsListWidget
ConfigurePluginsWidget
+ ConfigurePluginDialog
REQUIRED_HEADERS PimCommon_configureplugins_HEADERS
PREFIX PimCommon
RELATIVE configureplugins
diff --git a/src/configureplugins/configureplugindialog.cpp b/src/configureplugins/configureplugindialog.cpp
new file mode 100644
index 0000000..c6af811
--- /dev/null
+++ b/src/configureplugins/configureplugindialog.cpp
@@ -0,0 +1,71 @@
+/*
+ Copyright (c) 2016 Montel Laurent <montel@kde.org>
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License, version 2, as
+ published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+
+#include "configureplugindialog.h"
+#include <QVBoxLayout>
+#include <KLocalizedString>
+#include <QDialogButtonBox>
+#include <KConfigGroup>
+#include <KSharedConfig>
+
+using namespace PimCommon;
+
+ConfigurePluginDialog::ConfigurePluginDialog(QWidget *parent)
+ : QDialog(parent)
+{
+}
+
+ConfigurePluginDialog::~ConfigurePluginDialog()
+{
+ saveConfig();
+}
+
+void ConfigurePluginDialog::initLayout()
+{
+ QVBoxLayout *layout = new QVBoxLayout(this);
+ layout->addWidget(createLayout());
+
+ QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel, this);
+ layout->addWidget(buttonBox);
+ connect(buttonBox, &QDialogButtonBox::accepted, this, &ConfigurePluginDialog::slotAccepted);
+ connect(buttonBox, &QDialogButtonBox::rejected, this, &ConfigurePluginDialog::rejected);
+ readConfig();
+ load();
+}
+
+void ConfigurePluginDialog::slotAccepted()
+{
+ save();
+ accept();
+}
+
+void ConfigurePluginDialog::readConfig()
+{
+ KConfigGroup group(KSharedConfig::openConfig(), "ConfigurePluginDialog");
+ const QSize size = group.readEntry("Size", QSize(600, 400));
+ if (size.isValid()) {
+ resize(size);
+ }
+}
+
+void ConfigurePluginDialog::saveConfig()
+{
+ KConfigGroup group(KSharedConfig::openConfig(), "ConfigurePluginDialog");
+ group.writeEntry("Size", size());
+ group.sync();
+}
diff --git a/src/configureplugins/configureplugindialog.h b/src/configureplugins/configureplugindialog.h
new file mode 100644
index 0000000..97fd016
--- /dev/null
+++ b/src/configureplugins/configureplugindialog.h
@@ -0,0 +1,44 @@
+/*
+ Copyright (c) 2016 Montel Laurent <montel@kde.org>
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License, version 2, as
+ published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#ifndef CONFIGUREPLUGINDIALOG_H
+#define CONFIGUREPLUGINDIALOG_H
+
+#include <QDialog>
+#include "pimcommon_export.h"
+namespace PimCommon
+{
+class PIMCOMMON_EXPORT ConfigurePluginDialog : public QDialog
+{
+ Q_OBJECT
+public:
+ explicit ConfigurePluginDialog(QWidget *parent = Q_NULLPTR);
+ ~ConfigurePluginDialog();
+
+ void initLayout();
+protected:
+ virtual QWidget *createLayout() = 0;
+ virtual void save() = 0;
+ virtual void load() = 0;
+private Q_SLOTS:
+ void slotAccepted();
+private:
+ void saveConfig();
+ void readConfig();
+};
+}
+#endif // CONFIGUREPLUGINDIALOG_H
diff --git a/src/genericplugins/abstractgenericplugin.cpp b/src/genericplugins/abstractgenericplugin.cpp
index 34cc73b..662a604 100644
--- a/src/genericplugins/abstractgenericplugin.cpp
+++ b/src/genericplugins/abstractgenericplugin.cpp
@@ -46,6 +46,11 @@ bool AbstractGenericPlugin::hasConfigureDialog() const
return false;
}
+void AbstractGenericPlugin::showConfigureDialog()
+{
+ //Reimplement it.
+}
+
void AbstractGenericPlugin::setIsEnabled(bool enabled)
{
mIsEnabled = enabled;
diff --git a/src/genericplugins/abstractgenericplugin.h b/src/genericplugins/abstractgenericplugin.h
index cf5d35f..9979fb0 100644
--- a/src/genericplugins/abstractgenericplugin.h
+++ b/src/genericplugins/abstractgenericplugin.h
@@ -36,6 +36,8 @@ public:
virtual bool hasToolBarSupport() const;
virtual bool hasConfigureDialog() const;
+ virtual void showConfigureDialog();
+
void setIsEnabled(bool enabled);
bool isEnabled() const;