Now we can insert text too

wilder
Laurent Montel 6 years ago
parent 71f8798a02
commit 4b17da033c
  1. 2
      CMakeLists.txt
  2. 40
      src/editor/kmcomposerwin.cpp
  3. 2
      src/editor/kmcomposerwin.h

@ -65,7 +65,7 @@ option(KDEPIM_RUN_AKONADI_TEST "Enable autotest based on Akonadi." TRUE)
find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED DBus Network Test Widgets WebEngine WebEngineWidgets)
set(LIBGRAVATAR_VERSION_LIB "5.12.40")
set(MAILCOMMON_LIB_VERSION_LIB "5.12.46")
set(MAILCOMMON_LIB_VERSION_LIB "5.12.50")
set(KDEPIM_APPS_LIB_VERSION_LIB "5.12.43")
set(MESSAGELIB_LIB_VERSION_LIB "5.12.68")
set(LIBKLEO_LIB_VERSION_LIB "5.12.40")

@ -383,7 +383,7 @@ KMComposerWin::KMComposerWin(const KMime::Message::Ptr &aMsg, bool lastSignState
connect(composerEditorNg, &KMComposerEditorNg::insertModeChanged, this, &KMComposerWin::slotOverwriteModeChanged);
connect(composerEditorNg, &KMComposerEditorNg::spellCheckingFinished, this, &KMComposerWin::slotDelayedCheckSendNow);
mSnippetWidget = new MailCommon::SnippetTreeView(actionCollection(), mSnippetSplitter);
connect(mSnippetWidget, &MailCommon::SnippetTreeView::insertSnippetText, this, &KMComposerWin::insertSnippetText);
connect(mSnippetWidget, &MailCommon::SnippetTreeView::insertSubjectAndPlainText, this, &KMComposerWin::insertSubjectAndPlainText);
connect(composerEditorNg, &KMComposerEditorNg::insertSnippet, mSnippetWidget->snippetsManager(), &MailCommon::SnippetsManager::insertSnippet);
mSnippetWidget->setVisible(KMailSettings::self()->showSnippetManager());
mSnippetSplitter->addWidget(mSnippetWidget);
@ -513,16 +513,36 @@ KMComposerWin::~KMComposerWin()
delete mComposerBase;
}
void KMComposerWin::insertSnippetText(const QString &str)
void KMComposerWin::insertSubjectAndPlainText(const QString &subject, const QString &str)
{
MessageComposer::ConvertSnippetVariablesJob *job = new MessageComposer::ConvertSnippetVariablesJob(this);
job->setText(str);
MessageComposer::ComposerViewInterface *interface = new MessageComposer::ComposerViewInterface(mComposerBase);
job->setComposerViewInterface(interface);
connect(job, &MessageComposer::ConvertSnippetVariablesJob::textConverted, this, [this](const QString &str) {
mComposerBase->editor()->insertPlainText(str);
});
job->start();
{
//Convert plain text
MessageComposer::ConvertSnippetVariablesJob *job = new MessageComposer::ConvertSnippetVariablesJob(this);
job->setText(str);
MessageComposer::ComposerViewInterface *interface = new MessageComposer::ComposerViewInterface(mComposerBase);
job->setComposerViewInterface(interface);
connect(job, &MessageComposer::ConvertSnippetVariablesJob::textConverted, this, [this](const QString &str) {
mComposerBase->editor()->insertPlainText(str);
});
job->start();
}
{
//Convert subject
MessageComposer::ConvertSnippetVariablesJob *job = new MessageComposer::ConvertSnippetVariablesJob(this);
job->setText(subject);
MessageComposer::ComposerViewInterface *interface = new MessageComposer::ComposerViewInterface(mComposerBase);
job->setComposerViewInterface(interface);
connect(job, &MessageComposer::ConvertSnippetVariablesJob::textConverted, this, [this](const QString &str) {
if (!str.isEmpty()) {
if (mComposerBase->subject().isEmpty()) { //Add subject only if we don't have subject
mEdtSubject->setText(str);
}
}
});
job->start();
}
}
void KMComposerWin::slotSpellCheckingLanguage(const QString &language)

@ -548,7 +548,7 @@ private:
void slotSelectionChanged();
void slotMessage(const QString &str);
void slotEditorPluginInsertText(const QString &str);
void insertSnippetText(const QString &str);
void insertSubjectAndPlainText(const QString &subject, const QString &str);
bool sendLaterRegistered() const;
Akonadi::Collection mCollectionForNewMessage;

Loading…
Cancel
Save