Commit 315e6c88 authored by Laurent Montel's avatar Laurent Montel 😁

Continue to implement plugin

parent 4120bb76
add_subdirectory(externalcomposer)
if(BUILD_TESTING)
add_subdirectory(autotests)
endif()
......@@ -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()
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 "")
/*
Copyright (C) 2017 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 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)
/*
Copyright (C) 2017 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 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
......@@ -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
}
......@@ -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
......@@ -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());
}
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment