summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Montel <[email protected]>2017-12-27 14:00:20 +0100
committerLaurent Montel <[email protected]>2017-12-27 14:00:20 +0100
commit5a677af80af1fb9f99a9a895206ccd8f75423276 (patch)
tree8e7fc075b824331fb090d868b9eb8f887b5b60eb
parent4181145a4ef9e74521e367579dd51653eeff6fda (diff)
Use new api. Plugin action can be disable/enable when they need text selection
-rw-r--r--CMakeLists.txt2
-rw-r--r--src/editor/kmcomposerwin.cpp6
-rw-r--r--src/editor/kmcomposerwin.h2
-rw-r--r--src/editor/plugininterface/kmailplugineditormanagerinterface.cpp6
-rw-r--r--src/editor/plugininterface/kmailplugineditormanagerinterface.h3
5 files changed, 17 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index af48701..a4f04b3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -75,7 +75,7 @@ find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED DBus Network Test Widget
set(LIBGRAVATAR_VERSION_LIB "5.7.40")
set(MAILCOMMON_LIB_VERSION_LIB "5.7.41")
set(KDEPIM_APPS_LIB_VERSION_LIB "5.7.40")
-set(MESSAGELIB_LIB_VERSION_LIB "5.7.45")
+set(MESSAGELIB_LIB_VERSION_LIB "5.7.46")
set(LIBKLEO_LIB_VERSION_LIB "5.7.40")
set(PIMCOMMON_LIB_VERSION_LIB "5.7.42")
set(LIBKDEPIM_LIB_VERSION_LIB "5.7.40")
diff --git a/src/editor/kmcomposerwin.cpp b/src/editor/kmcomposerwin.cpp
index 96a2bf7..813dfaf 100644
--- a/src/editor/kmcomposerwin.cpp
+++ b/src/editor/kmcomposerwin.cpp
@@ -359,6 +359,7 @@ KMComposerWin::KMComposerWin(const KMime::Message::Ptr &aMsg, bool lastSignState
//Don't use new connect api here. It crashs
connect(composerEditorNg, SIGNAL(textChanged()), this, SLOT(slotEditorTextChanged()));
+ connect(composerEditorNg, &KMComposerEditorNg::selectionChanged, this, &KMComposerWin::slotSelectionChanged);
//connect(editor, &KMComposerEditor::textChanged, this, &KMComposeWin::slotEditorTextChanged);
mComposerBase->setEditor(composerEditorNg);
mIncorrectIdentityFolderWarning = new IncorrectIdentityFolderWarning(this);
@@ -3478,3 +3479,8 @@ void KMComposerWin::slotTransportRemoved(int id, const QString &name)
mIncorrectIdentityFolderWarning->mailTransportIsInvalid();
}
}
+
+void KMComposerWin::slotSelectionChanged()
+{
+ Q_EMIT mPluginEditorManagerInterface->textSelectionChanged(mRichTextEditorwidget->editor()->textCursor().hasSelection());
+}
diff --git a/src/editor/kmcomposerwin.h b/src/editor/kmcomposerwin.h
index 96a9148..3a4474a 100644
--- a/src/editor/kmcomposerwin.h
+++ b/src/editor/kmcomposerwin.h
@@ -545,6 +545,8 @@ private:
void initializePluginActions();
bool showErrorMessage(KJob *job);
int validateLineWrapWidth();
+ void slotSelectionChanged();
+
Akonadi::Collection mCollectionForNewMessage;
QMap<QByteArray, QString> mExtraHeaders;
diff --git a/src/editor/plugininterface/kmailplugineditormanagerinterface.cpp b/src/editor/plugininterface/kmailplugineditormanagerinterface.cpp
index 10e85c3..3224ec6 100644
--- a/src/editor/plugininterface/kmailplugineditormanagerinterface.cpp
+++ b/src/editor/plugininterface/kmailplugineditormanagerinterface.cpp
@@ -101,8 +101,12 @@ QHash<MessageComposer::ActionType::Type, QList<QAction *> > KMailPluginEditorMan
{
if (mActionHash.isEmpty()) {
for (MessageComposer::PluginEditorInterface *interface : qAsConst(mListPluginInterface)) {
- MessageComposer::ActionType actionType = interface->actionType();
+ const MessageComposer::ActionType actionType = interface->actionType();
MessageComposer::ActionType::Type type = actionType.type();
+ const bool needSelectedText = interface->needSelectedText();
+ if (needSelectedText) {
+ connect(this, &KMailPluginEditorManagerInterface::textSelectionChanged, actionType.action(), &QAction::setEnabled);
+ }
QList<QAction *> lst = mActionHash.value(type);
if (!lst.isEmpty()) {
QAction *act = new QAction(this);
diff --git a/src/editor/plugininterface/kmailplugineditormanagerinterface.h b/src/editor/plugininterface/kmailplugineditormanagerinterface.h
index 864e158..2e40e25 100644
--- a/src/editor/plugininterface/kmailplugineditormanagerinterface.h
+++ b/src/editor/plugininterface/kmailplugineditormanagerinterface.h
@@ -51,6 +51,9 @@ public:
QHash<MessageComposer::ActionType::Type, QList<QAction *> > actionsType();
QList<QAction *> actionsType(MessageComposer::ActionType::Type type);
+Q_SIGNALS:
+ void textSelectionChanged(bool hasSelection);
+
private:
void slotPluginActivated(MessageComposer::PluginEditorInterface *interface);
KPIMTextEdit::RichTextEditor *mRichTextEditor = nullptr;