summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2017-04-27 20:56:04 +0200
committerMontel Laurent <[email protected]>2017-04-27 20:56:04 +0200
commit315e6c88d94f959f62fd5337d199656cbb400363 (patch)
tree8e21b324994612cbcb5e6fb436e564fe588e2e7f
parent4120bb762fede76f113ea2d92bd0db6631600cb4 (diff)
Continue to implement plugin
-rw-r--r--kmail/editorinitplugins/CMakeLists.txt3
-rw-r--r--kmail/editorinitplugins/autotests/CMakeLists.txt0
-rw-r--r--kmail/editorinitplugins/externalcomposer/CMakeLists.txt8
-rw-r--r--kmail/editorinitplugins/externalcomposer/autotests/CMakeLists.txt11
-rw-r--r--kmail/editorinitplugins/externalcomposer/autotests/externalcomposerconfigurewidgettest.cpp35
-rw-r--r--kmail/editorinitplugins/externalcomposer/autotests/externalcomposerconfigurewidgettest.h37
-rw-r--r--kmail/editorinitplugins/externalcomposer/externalcomposerconfigurewidget.cpp43
-rw-r--r--kmail/editorinitplugins/externalcomposer/externalcomposerconfigurewidget.h5
-rw-r--r--kmail/editorinitplugins/externalcomposer/externalcomposerplugineditorinterface.cpp18
-rw-r--r--kmail/editorinitplugins/externalcomposer/externalcomposerplugineditorinterface.h5
10 files changed, 156 insertions, 9 deletions
diff --git a/kmail/editorinitplugins/CMakeLists.txt b/kmail/editorinitplugins/CMakeLists.txt
index 16d0c49..5c3aaf9 100644
--- a/kmail/editorinitplugins/CMakeLists.txt
+++ b/kmail/editorinitplugins/CMakeLists.txt
@@ -1,4 +1 @@
add_subdirectory(externalcomposer)
-if(BUILD_TESTING)
- add_subdirectory(autotests)
-endif()
diff --git a/kmail/editorinitplugins/autotests/CMakeLists.txt b/kmail/editorinitplugins/autotests/CMakeLists.txt
deleted file mode 100644
index e69de29..0000000
--- a/kmail/editorinitplugins/autotests/CMakeLists.txt
+++ /dev/null
diff --git a/kmail/editorinitplugins/externalcomposer/CMakeLists.txt b/kmail/editorinitplugins/externalcomposer/CMakeLists.txt
index c512f7c..52024f7 100644
--- a/kmail/editorinitplugins/externalcomposer/CMakeLists.txt
+++ b/kmail/editorinitplugins/externalcomposer/CMakeLists.txt
@@ -9,10 +9,10 @@ kcoreaddons_add_plugin(kmail_externalcomposereditorplugin JSON kmail_externalcom
${kmail_externalcomposereditorplugin_SRCS} INSTALL_NAMESPACE kmail)
target_link_libraries(kmail_externalcomposereditorplugin
- KF5::IconThemes KF5::MessageComposer KF5::XmlGui KF5::I18n
+ KF5::IconThemes KF5::MessageComposer KF5::XmlGui KF5::I18n KF5::KIOWidgets
)
-#if(BUILD_TESTING)
-# add_subdirectory(autotests)
-#endif()
+if(BUILD_TESTING)
+ add_subdirectory(autotests)
+endif()
diff --git a/kmail/editorinitplugins/externalcomposer/autotests/CMakeLists.txt b/kmail/editorinitplugins/externalcomposer/autotests/CMakeLists.txt
new file mode 100644
index 0000000..1ab90a9
--- /dev/null
+++ b/kmail/editorinitplugins/externalcomposer/autotests/CMakeLists.txt
@@ -0,0 +1,11 @@
+macro(add_kmail_externalcomposer_unittest _source _additional)
+ set( _test ${_source} ${_additional})
+ get_filename_component(_name ${_source} NAME_WE)
+ add_executable( ${_name} ${_test} )
+ add_test( ${_name} ${_name} )
+
+ ecm_mark_as_test(kmail_editorinitplugin-${_name})
+ target_link_libraries( ${_name} Qt5::Test KF5::IconThemes KF5::MessageComposer KF5::I18n KF5::PimCommon KF5::Libkdepim)
+endmacro ()
+
+add_kmail_externalcomposer_unittest(externalcomposerconfigurewidgettest.cpp "")
diff --git a/kmail/editorinitplugins/externalcomposer/autotests/externalcomposerconfigurewidgettest.cpp b/kmail/editorinitplugins/externalcomposer/autotests/externalcomposerconfigurewidgettest.cpp
new file mode 100644
index 0000000..55bbc74
--- /dev/null
+++ b/kmail/editorinitplugins/externalcomposer/autotests/externalcomposerconfigurewidgettest.cpp
@@ -0,0 +1,35 @@
+/*
+ Copyright (C) 2017 Montel Laurent <[email protected]>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ 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; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "externalcomposerconfigurewidgettest.h"
+#include "../externalcomposerconfigurewidget.h"
+#include <QTest>
+
+ExternalComposerConfigureWidgetTest::ExternalComposerConfigureWidgetTest(QObject *parent)
+ : QObject(parent)
+{
+
+}
+
+void ExternalComposerConfigureWidgetTest::shouldHaveDefaultValues()
+{
+
+}
+
+QTEST_MAIN(ExternalComposerConfigureWidgetTest)
diff --git a/kmail/editorinitplugins/externalcomposer/autotests/externalcomposerconfigurewidgettest.h b/kmail/editorinitplugins/externalcomposer/autotests/externalcomposerconfigurewidgettest.h
new file mode 100644
index 0000000..1e860c5
--- /dev/null
+++ b/kmail/editorinitplugins/externalcomposer/autotests/externalcomposerconfigurewidgettest.h
@@ -0,0 +1,37 @@
+/*
+ Copyright (C) 2017 Montel Laurent <[email protected]>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ 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; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+
+#ifndef EXTERNALCOMPOSERCONFIGUREWIDGETTEST_H
+#define EXTERNALCOMPOSERCONFIGUREWIDGETTEST_H
+
+#include <QObject>
+
+class ExternalComposerConfigureWidgetTest : public QObject
+{
+ Q_OBJECT
+public:
+ explicit ExternalComposerConfigureWidgetTest(QObject *parent = nullptr);
+ ~ExternalComposerConfigureWidgetTest() = default;
+
+private Q_SLOTS:
+ void shouldHaveDefaultValues();
+};
+
+#endif // EXTERNALCOMPOSERCONFIGUREWIDGETTEST_H
diff --git a/kmail/editorinitplugins/externalcomposer/externalcomposerconfigurewidget.cpp b/kmail/editorinitplugins/externalcomposer/externalcomposerconfigurewidget.cpp
index 6ccf3ce..9eace45 100644
--- a/kmail/editorinitplugins/externalcomposer/externalcomposerconfigurewidget.cpp
+++ b/kmail/editorinitplugins/externalcomposer/externalcomposerconfigurewidget.cpp
@@ -22,6 +22,9 @@
#include <KConfigGroup>
#include <KSharedConfig>
#include <QVBoxLayout>
+#include <QCheckBox>
+#include <KUrlRequester>
+#include <QLabel>
ExternalComposerConfigureWidget::ExternalComposerConfigureWidget(QWidget *parent)
: MessageComposer::PluginEditorInitConfigureWidget(parent)
@@ -29,6 +32,44 @@ ExternalComposerConfigureWidget::ExternalComposerConfigureWidget(QWidget *parent
QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->setMargin(0);
mainLayout->setObjectName(QStringLiteral("mainlayout"));
+
+ mExternalEditorCheck = new QCheckBox(i18n("Use external editor instead of composer"), this);
+ mExternalEditorCheck->setObjectName(QStringLiteral("enabled"));
+ mExternalEditorCheck->setChecked(false);
+ mainLayout->addWidget(mExternalEditorCheck);
+
+ QHBoxLayout *hbox = new QHBoxLayout;
+ QLabel *label = new QLabel(QStringLiteral("Specify editor:"), this);
+ hbox->addWidget(label);
+
+
+ mEditorRequester = new KUrlRequester(this);
+ mEditorRequester->setObjectName(QStringLiteral("mEditorRequester"));
+ hbox->addWidget(mEditorRequester);
+
+ mEditorRequester->setFilter(QStringLiteral("application/x-executable "
+ "application/x-shellscript "
+ "application/x-desktop"));
+
+ mEditorRequester->setMode(KFile::File | KFile::ExistingOnly | KFile::LocalOnly);
+ mEditorRequester->setEnabled(false); // !mExternalEditorCheck->isChecked()
+
+ mainLayout->addLayout(hbox);
+
+ label = new QLabel(i18n("<b>%f</b> will be replaced with the "
+ "filename to edit.<br />"
+ "<b>%w</b> will be replaced with the window id.<br />"
+ "<b>%l</b> will be replaced with the line number."), this);
+ label->setObjectName(QStringLiteral("label"));
+ label->setEnabled(false); // see above
+ mainLayout->addWidget(label);
+
+ mainLayout->addStretch(1);
+
+ connect(mExternalEditorCheck, &QAbstractButton::toggled,
+ label, &QWidget::setEnabled);
+ connect(mExternalEditorCheck, &QAbstractButton::toggled,
+ mEditorRequester, &QWidget::setEnabled);
}
ExternalComposerConfigureWidget::~ExternalComposerConfigureWidget()
@@ -45,4 +86,6 @@ void ExternalComposerConfigureWidget::saveSettings()
void ExternalComposerConfigureWidget::resetSettings()
{
+ mExternalEditorCheck->setChecked(false);
+ //kwrite %f
}
diff --git a/kmail/editorinitplugins/externalcomposer/externalcomposerconfigurewidget.h b/kmail/editorinitplugins/externalcomposer/externalcomposerconfigurewidget.h
index f591c26..18dc431 100644
--- a/kmail/editorinitplugins/externalcomposer/externalcomposerconfigurewidget.h
+++ b/kmail/editorinitplugins/externalcomposer/externalcomposerconfigurewidget.h
@@ -23,6 +23,8 @@
#include <QWidget>
#include <MessageComposer/PluginEditorInitConfigureWidget>
class ExternalComposerConfigureTab;
+class QCheckBox;
+class KUrlRequester;
class ExternalComposerConfigureWidget : public MessageComposer::PluginEditorInitConfigureWidget
{
Q_OBJECT
@@ -33,6 +35,9 @@ public:
void loadSettings() Q_DECL_OVERRIDE;
void saveSettings() Q_DECL_OVERRIDE;
void resetSettings() Q_DECL_OVERRIDE;
+private:
+ QCheckBox *mExternalEditorCheck;
+ KUrlRequester *mEditorRequester;
};
#endif // CONFIRMADDRESSCONFIGUREWIDGET_H
diff --git a/kmail/editorinitplugins/externalcomposer/externalcomposerplugineditorinterface.cpp b/kmail/editorinitplugins/externalcomposer/externalcomposerplugineditorinterface.cpp
index a37bcef..d8aece6 100644
--- a/kmail/editorinitplugins/externalcomposer/externalcomposerplugineditorinterface.cpp
+++ b/kmail/editorinitplugins/externalcomposer/externalcomposerplugineditorinterface.cpp
@@ -18,13 +18,16 @@
*/
#include "externalcomposerplugineditorinterface.h"
-#include <KPIMTextEdit/RichTextEditor>
+#include <KPIMTextEdit/RichTextComposer>
#include <KLocalizedString>
#include <KActionCollection>
#include <QAction>
+#include <KSharedConfig>
+#include <KConfigGroup>
ExternalComposerPluginEditorInterface::ExternalComposerPluginEditorInterface(QObject *parent)
- : MessageComposer::PluginEditorInitInterface(parent)
+ : MessageComposer::PluginEditorInitInterface(parent),
+ mEnabled(false)
{
}
@@ -34,5 +37,16 @@ ExternalComposerPluginEditorInterface::~ExternalComposerPluginEditorInterface()
bool ExternalComposerPluginEditorInterface::exec()
{
+ richTextEditor()->setUseExternalEditor(mEnabled);
+ richTextEditor()->setExternalEditorPath(mExternalComposerPath);
return true;
}
+
+
+void ExternalComposerPluginEditorInterface::reloadConfig()
+{
+ KSharedConfig::Ptr config = KSharedConfig::openConfig();
+ KConfigGroup group = config->group(QStringLiteral("External Composer"));
+ mEnabled = group.readEntry("Enabled", false);
+ mExternalComposerPath = group.readEntry("ComposerPath", QString());
+}
diff --git a/kmail/editorinitplugins/externalcomposer/externalcomposerplugineditorinterface.h b/kmail/editorinitplugins/externalcomposer/externalcomposerplugineditorinterface.h
index 163567f..33ec95c 100644
--- a/kmail/editorinitplugins/externalcomposer/externalcomposerplugineditorinterface.h
+++ b/kmail/editorinitplugins/externalcomposer/externalcomposerplugineditorinterface.h
@@ -30,6 +30,11 @@ public:
explicit ExternalComposerPluginEditorInterface(QObject *parent = nullptr);
~ExternalComposerPluginEditorInterface();
bool exec() Q_DECL_OVERRIDE;
+
+ void reloadConfig() Q_DECL_OVERRIDE;
+private:
+ QString mExternalComposerPath;
+ bool mEnabled;
};
#endif