Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 1d7b2536 authored by Laurent Montel's avatar Laurent Montel 😁

Extract pluginactiontype

parent e7f60202
cmake_minimum_required(VERSION 3.0)
set(PIM_VERSION "5.7.81")
set(PIM_VERSION "5.7.82")
if (POLICY CMP0053)
cmake_policy(SET CMP0053 NEW)
......
......@@ -96,6 +96,7 @@ set(messagecomposer_plugineditor_SRCS
plugineditor/plugineditormanager.cpp
plugineditor/plugineditor.cpp
plugineditor/plugineditorinterface.cpp
plugineditor/pluginactiontype.cpp
)
set(messagecomposer_plugineditorcheckbeforesend_SRCS
......@@ -216,6 +217,7 @@ install(TARGETS
ecm_generate_headers(MessageComposer_Camelplugineditor_HEADERS
HEADER_NAMES
PluginEditor
PluginActionType
PluginEditorInterface
PluginEditorManager
REQUIRED_HEADERS MessageComposer_plugineditor_HEADERS
......
/*
Copyright (C) 2015-2018 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "pluginactiontype.h"
using namespace MessageComposer;
PluginActionType::PluginActionType()
: mAction(nullptr)
, mType(Tools)
{
}
PluginActionType::PluginActionType(QAction *action, PluginActionType::Type type)
: mAction(action)
, mType(type)
{
}
QAction *PluginActionType::action() const
{
return mAction;
}
PluginActionType::Type PluginActionType::type() const
{
return mType;
}
QString PluginActionType::actionXmlExtension(PluginActionType::Type type)
{
switch (type) {
case MessageComposer::PluginActionType::Tools:
return QStringLiteral("_plugins_tools");
case MessageComposer::PluginActionType::Edit:
return QStringLiteral("_plugins_edit");
case MessageComposer::PluginActionType::File:
return QStringLiteral("_plugins_file");
case MessageComposer::PluginActionType::Action:
return QStringLiteral("_plugins_actions");
case MessageComposer::PluginActionType::PopupMenu:
return QStringLiteral("_popupmenu_actions");
case MessageComposer::PluginActionType::ToolBar:
return QStringLiteral("_toolbar_actions");
case MessageComposer::PluginActionType::Options:
return QStringLiteral("_plugins_options");
case MessageComposer::PluginActionType::None:
return QString();
}
return {};
}
/*
Copyright (C) 2015-2018 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef PLUGINACTIONTYPE_H
#define PLUGINACTIONTYPE_H
#include "messagecomposer_export.h"
#include <QString>
class QAction;
namespace MessageComposer {
class MESSAGECOMPOSER_EXPORT PluginActionType
{
public:
enum Type {
Tools = 0,
Edit = 1,
File = 2,
Action = 3,
PopupMenu = 4,
ToolBar = 5,
Options = 6,
None = 7
};
PluginActionType();
PluginActionType(QAction *action, Type type);
QAction *action() const;
Type type() const;
static QString actionXmlExtension(PluginActionType::Type type);
private:
QAction *mAction = nullptr;
Type mType;
};
}
#endif // PLUGINEDITORINTERFACE_H
......@@ -21,28 +21,6 @@
using namespace MessageComposer;
ActionType::ActionType()
: mAction(nullptr)
, mType(Tools)
{
}
ActionType::ActionType(QAction *action, ActionType::Type type)
: mAction(action)
, mType(type)
{
}
QAction *ActionType::action() const
{
return mAction;
}
ActionType::Type ActionType::type() const
{
return mType;
}
class MessageComposer::PluginEditorInterfacePrivate
{
public:
......@@ -50,7 +28,7 @@ public:
{
}
ActionType mActionType;
PluginActionType mActionType;
QWidget *mParentWidget = nullptr;
KPIMTextEdit::RichTextEditor *mRichTextEditor = nullptr;
PluginEditor *plugin = nullptr;
......@@ -68,12 +46,12 @@ PluginEditorInterface::~PluginEditorInterface()
delete d;
}
void PluginEditorInterface::setActionType(ActionType type)
void PluginEditorInterface::setActionType(PluginActionType type)
{
d->mActionType = type;
}
ActionType PluginEditorInterface::actionType() const
PluginActionType PluginEditorInterface::actionType() const
{
return d->mActionType;
}
......@@ -97,26 +75,3 @@ bool PluginEditorInterface::needSelectedText() const
{
return d->mSelectedText;
}
QString PluginEditorInterface::actionXmlExtension(ActionType::Type type)
{
switch (type) {
case MessageComposer::ActionType::Tools:
return QStringLiteral("_plugins_tools");
case MessageComposer::ActionType::Edit:
return QStringLiteral("_plugins_edit");
case MessageComposer::ActionType::File:
return QStringLiteral("_plugins_file");
case MessageComposer::ActionType::Action:
return QStringLiteral("_plugins_actions");
case MessageComposer::ActionType::PopupMenu:
return QStringLiteral("_popupmenu_actions");
case MessageComposer::ActionType::ToolBar:
return QStringLiteral("_toolbar_actions");
case MessageComposer::ActionType::Options:
return QStringLiteral("_plugins_options");
case MessageComposer::ActionType::None:
return QString();
}
return {};
}
......@@ -22,6 +22,7 @@
#include <QObject>
#include <PimCommon/AbstractGenericPluginInterface>
#include <MessageComposer/PluginActionType>
#include "messagecomposer_export.h"
class QAction;
......@@ -30,30 +31,6 @@ class RichTextEditor;
}
namespace MessageComposer {
class MESSAGECOMPOSER_EXPORT ActionType
{
public:
enum Type {
Tools = 0,
Edit = 1,
File = 2,
Action = 3,
PopupMenu = 4,
ToolBar = 5,
Options = 6,
None = 7
};
ActionType();
ActionType(QAction *action, Type type);
QAction *action() const;
Type type() const;
private:
QAction *mAction = nullptr;
Type mType;
};
class PluginEditorInterfacePrivate;
class PluginEditor;
class MESSAGECOMPOSER_EXPORT PluginEditorInterface : public PimCommon::AbstractGenericPluginInterface
......@@ -63,8 +40,8 @@ public:
explicit PluginEditorInterface(QObject *parent = nullptr);
~PluginEditorInterface();
void setActionType(ActionType type);
ActionType actionType() const;
void setActionType(PluginActionType type);
PluginActionType actionType() const;
KPIMTextEdit::RichTextEditor *richTextEditor() const;
void setRichTextEditor(KPIMTextEdit::RichTextEditor *richTextEditor);
......@@ -72,7 +49,6 @@ public:
void setNeedSelectedText(bool b);
bool needSelectedText() const;
static QString actionXmlExtension(ActionType::Type type);
Q_SIGNALS:
void emitPluginActivated(MessageComposer::PluginEditorInterface *interface);
......
......@@ -29,6 +29,7 @@ public:
, mEditor(nullptr)
{
}
PluginActionType mActionType;
QWidget *mParentWidget = nullptr;
KPIMTextEdit::RichTextComposer *mEditor = nullptr;
......@@ -60,6 +61,16 @@ QWidget *PluginEditorConvertTextInterface::parentWidget() const
return d->mParentWidget;
}
void PluginEditorConvertTextInterface::setActionType(PluginActionType type)
{
d->mActionType = type;
}
PluginActionType PluginEditorConvertTextInterface::actionType() const
{
return d->mActionType;
}
KPIMTextEdit::RichTextComposer *PluginEditorConvertTextInterface::richTextEditor() const
{
return d->mEditor;
......
......@@ -22,6 +22,7 @@
#include <QObject>
#include "messagecomposer_export.h"
#include <MessageComposer/PluginActionType>
namespace KPIMTextEdit {
class RichTextComposer;
......@@ -37,8 +38,6 @@ public:
explicit PluginEditorConvertTextInterface(QObject *parent = nullptr);
~PluginEditorConvertTextInterface();
//TODO add action too
virtual bool reformatText();
virtual bool convertTextToFormat(MessageComposer::TextPart *textPart) = 0;
......@@ -49,6 +48,8 @@ public:
KPIMTextEdit::RichTextComposer *richTextEditor() const;
void setRichTextEditor(KPIMTextEdit::RichTextComposer *richTextEditor);
void setActionType(PluginActionType type);
PluginActionType actionType() const;
public Q_SLOTS:
virtual void reloadConfig();
......
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