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 5a677af8 authored by Laurent Montel's avatar Laurent Montel 😁

Use new api. Plugin action can be disable/enable when they need text selection

parent 4181145a
......@@ -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")
......
......@@ -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());
}
......@@ -545,6 +545,8 @@ private:
void initializePluginActions();
bool showErrorMessage(KJob *job);
int validateLineWrapWidth();
void slotSelectionChanged();
Akonadi::Collection mCollectionForNewMessage;
QMap<QByteArray, QString> mExtraHeaders;
......
......@@ -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);
......
......@@ -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;
......
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