Commit 451363da authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Allow to insert rule where we want

parent 00db14c1
......@@ -98,6 +98,7 @@ SieveEditorTextModeWidget::SieveEditorTextModeWidget(QWidget *parent)
connect(mTextEdit, &SieveTextEdit::openHelp, mTabWidget, &SieveEditorTabWidget::slotAddHelpPage);
connect(mTextEdit, &SieveTextEdit::say, mTextToSpeechWidget, &KPIMTextEdit::TextToSpeechWidget::say);
connect(mTextEdit, &SieveTextEdit::editRule, this, &SieveEditorTextModeWidget::slotEditRule);
connect(mTextEdit, &SieveTextEdit::insertRule, this, &SieveEditorTextModeWidget::slotInsertRule);
mGotoLineSliderContainer = new KPIMTextEdit::SlideContainer(this);
mGoToLine = new KPIMTextEdit::TextGoToLineWidget;
......@@ -252,6 +253,20 @@ void SieveEditorTextModeWidget::slotEditRule(const QString &selectedText)
}
}
void SieveEditorTextModeWidget::slotInsertRule()
{
QPointer<AutoCreateScriptDialog> dlg = new AutoCreateScriptDialog(this);
dlg->setSieveCapabilities(mSieveCapabilities);
dlg->setSieveImapAccountSettings(mSieveImapAccountSettings);
dlg->setListOfIncludeFile(mListOfIncludeFile);
if (dlg->exec()) {
QString requireModules;
const QString newScript = dlg->script(requireModules);
mTextEdit->insertPlainText(newScript);
}
delete dlg;
}
void SieveEditorTextModeWidget::createRulesGraphically()
{
QPointer<AutoCreateScriptDialog> dlg = new AutoCreateScriptDialog(this);
......
......@@ -125,6 +125,7 @@ private:
void readConfig();
void writeConfig();
void slotEditRule(const QString &selectedText);
void slotInsertRule();
QString mOriginalScript;
QStringList mSieveCapabilities;
QStringList mListOfIncludeFile;
......
......@@ -291,6 +291,12 @@ void SieveTextEdit::addExtraMenuEntry(QMenu *menu, QPoint pos)
}
if (!textCursor().hasSelection()) {
QAction *insertRules = new QAction(i18n("Insert Rule"), menu);
//editRules->setIcon(QIcon::fromTheme(QStringLiteral("help-hint")));
connect(insertRules, &QAction::triggered, this, &SieveTextEdit::insertRule);
QAction *act = menu->addSeparator();
menu->insertActions(menu->actions().at(0), {insertRules, act});
const QString word = selectedWord(pos);
const KSieveUi::SieveEditorUtil::HelpVariableName type = KSieveUi::SieveEditorUtil::strToVariableName(word);
if (type != KSieveUi::SieveEditorUtil::UnknownHelp) {
......
......@@ -67,6 +67,7 @@ protected:
Q_SIGNALS:
void openHelp(const QUrl &url);
void editRule(const QString &selectedText);
void insertRule();
private:
void slotUpdateLineNumberAreaWidth(int newBlockCount);
......
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