Libksieve

sieveeditorwidget.cpp
1 /*
2  SPDX-FileCopyrightText: 2014-2021 Laurent Montel <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 
6 */
7 
8 #include "sieveeditorwidget.h"
9 #include "sievepurposemenuwidget.h"
10 
11 #include "autocreatescripts/sieveeditorgraphicalmodewidget.h"
12 #include "autocreatescripts/sievescriptparsingerrordialog.h"
13 #include "editor/sieveinfodialog.h"
14 #include "scriptsparsing/parsingutil.h"
15 #include "sieve-editor.h"
16 #include "sieveeditormenubar.h"
17 #include "sieveeditortextmodewidget.h"
18 
19 #include <KActionMenu>
20 #include <KIconEngine>
21 #include <KIconLoader>
22 #include <KLocalizedString>
23 #include <KStandardAction>
24 #include <QTemporaryDir>
25 #include <kns3/uploaddialog.h>
26 #include <kzip.h>
27 
28 #include <PimCommon/PurposeMenuWidget>
29 
30 #include "libksieve_debug.h"
31 #include <QAction>
32 #include <QLabel>
33 #include <QLineEdit>
34 #include <QPointer>
35 #include <QPushButton>
36 #include <QStackedWidget>
37 #include <QStandardPaths>
38 #include <QTemporaryFile>
39 #include <QToolBar>
40 #include <QVBoxLayout>
41 
42 using namespace KSieveUi;
43 
44 SieveEditorWidget::SieveEditorWidget(bool useMenuBar, QWidget *parent)
45  : QWidget(parent)
46 {
47  auto lay = new QVBoxLayout(this);
48  mDebug = !qEnvironmentVariableIsEmpty("KDEPIM_DEBUGGING");
49 
50  auto toolbar = new QToolBar;
52 
53  mCheckSyntax = new QAction(i18n("Check Syntax"), this);
54  connect(mCheckSyntax, &QAction::triggered, this, &SieveEditorWidget::slotCheckSyntax);
55  toolbar->addAction(mCheckSyntax);
56  mSaveAs = KStandardAction::saveAs(this, &SieveEditorWidget::slotSaveAs, this);
57  toolbar->addAction(mSaveAs);
58  toolbar->addAction(i18n("Import..."), this, &SieveEditorWidget::slotImport);
59 
60  mCreateRulesGraphically = new QAction(i18n("Create Rules Graphically..."), this);
61  connect(mCreateRulesGraphically, &QAction::triggered, this, &SieveEditorWidget::slotCreateRulesGraphically);
62  toolbar->addAction(mCreateRulesGraphically);
63  mSwitchMode = new QAction(this);
64  toolbar->addAction(mSwitchMode);
65  connect(mSwitchMode, &QAction::triggered, this, &SieveEditorWidget::slotSwitchMode);
66 
67  if (mDebug) {
68  // Not necessary to translate it.
69  mGenerateXml = new QAction(QStringLiteral("Generate xml"), this);
70  connect(mGenerateXml, &QAction::triggered, this, &SieveEditorWidget::slotGenerateXml);
71  toolbar->addAction(mGenerateXml);
72  }
73 
74  QStringList overlays;
75  overlays << QStringLiteral("list-add");
76  mShareScript = new QAction(QIcon(new KIconEngine(QStringLiteral("get-hot-new-stuff"), KIconLoader::global(), overlays)), i18n("Share Script..."), this);
77  connect(mShareScript, &QAction::triggered, this, &SieveEditorWidget::slotShareScript);
78  // Add action to toolBar
79 
80  toolbar->addAction(mShareScript);
81 
82  auto purposeMenu = new SievePurposeMenuWidget(this, this);
83  auto shareAction = new KActionMenu(i18n("Share..."), this);
84  shareAction->setPopupMode(QToolButton::InstantPopup);
85  shareAction->setMenu(purposeMenu->menu());
86  shareAction->setIcon(QIcon::fromTheme(QStringLiteral("document-share")));
87  purposeMenu->setEditorWidget(this);
88  toolbar->addAction(shareAction);
89 
90  mServerInfo = new QAction(i18n("Server Info"), this);
91  connect(mServerInfo, &QAction::triggered, this, &SieveEditorWidget::slotServerInfo);
92  toolbar->addAction(mServerInfo);
93 
94  SieveEditorMenuBar *menuBar = nullptr;
95  if (useMenuBar) {
96  menuBar = new SieveEditorMenuBar;
97  connect(this, &SieveEditorWidget::changeModeEditor, menuBar, &SieveEditorMenuBar::setEditorMode);
98  connect(menuBar, &SieveEditorMenuBar::copy, this, &SieveEditorWidget::copy);
99  connect(menuBar, &SieveEditorMenuBar::find, this, &SieveEditorWidget::find);
100  connect(menuBar, &SieveEditorMenuBar::replace, this, &SieveEditorWidget::replace);
101  connect(menuBar, &SieveEditorMenuBar::undo, this, &SieveEditorWidget::undo);
102  connect(menuBar, &SieveEditorMenuBar::redo, this, &SieveEditorWidget::redo);
103  connect(menuBar, &SieveEditorMenuBar::paste, this, &SieveEditorWidget::paste);
104  connect(menuBar, &SieveEditorMenuBar::cut, this, &SieveEditorWidget::cut);
105  connect(menuBar, &SieveEditorMenuBar::selectAll, this, &SieveEditorWidget::selectAll);
106  connect(menuBar, &SieveEditorMenuBar::gotoLine, this, &SieveEditorWidget::goToLine);
107  connect(menuBar, &SieveEditorMenuBar::comment, this, &SieveEditorWidget::comment);
108  connect(menuBar, &SieveEditorMenuBar::uncomment, this, &SieveEditorWidget::uncomment);
109  connect(menuBar, &SieveEditorMenuBar::zoomIn, this, &SieveEditorWidget::zoomIn);
110  connect(menuBar, &SieveEditorMenuBar::zoomOut, this, &SieveEditorWidget::zoomOut);
111  connect(menuBar, &SieveEditorMenuBar::zoomReset, this, &SieveEditorWidget::zoomReset);
112  connect(menuBar, &SieveEditorMenuBar::debugSieveScript, this, &SieveEditorWidget::debugSieveScript);
113  connect(menuBar, &SieveEditorMenuBar::wordWrap, this, &SieveEditorWidget::wordWrap);
114  connect(menuBar, &SieveEditorMenuBar::print, this, &SieveEditorWidget::print);
115  connect(menuBar, &SieveEditorMenuBar::printPreview, this, &SieveEditorWidget::printPreview);
116 
117  connect(this, &SieveEditorWidget::copyAvailable, menuBar, &SieveEditorMenuBar::slotCopyAvailable);
118  connect(this, &SieveEditorWidget::redoAvailable, menuBar, &SieveEditorMenuBar::slotRedoAvailable);
119  connect(this, &SieveEditorWidget::undoAvailable, menuBar, &SieveEditorMenuBar::slotUndoAvailable);
120  menuBar->fileMenu()->addSeparator();
121  menuBar->fileMenu()->addAction(mSaveAs);
122  menuBar->fileMenu()->addSeparator();
123  menuBar->fileMenu()->addAction(mShareScript);
124  menuBar->toolsMenu()->addSeparator();
125  menuBar->fileMenu()->addAction(shareAction);
126  menuBar->toolsMenu()->addSeparator();
127  menuBar->toolsMenu()->addAction(mCreateRulesGraphically);
128  menuBar->toolsMenu()->addAction(mCheckSyntax);
129  lay->addWidget(menuBar);
130  }
131 
132  lay->addWidget(toolbar);
133 
134  auto nameLayout = new QHBoxLayout;
135  auto label = new QLabel(i18n("Script name:"), this);
136  nameLayout->addWidget(label);
137  mScriptName = new QLineEdit(this);
138  mScriptName->setReadOnly(true);
139  nameLayout->addWidget(mScriptName);
140  lay->addLayout(nameLayout);
141 
142  lay->setContentsMargins({});
143  mStackedWidget = new QStackedWidget;
144 
145  mTextModeWidget = new SieveEditorTextModeWidget;
146  connect(mTextModeWidget, &SieveEditorTextModeWidget::valueChanged, this, &SieveEditorWidget::slotModified);
147  if (menuBar) {
148  menuBar->setTextModeWidget(mTextModeWidget);
149  }
150  mStackedWidget->addWidget(mTextModeWidget);
151  mGraphicalModeWidget = new SieveEditorGraphicalModeWidget;
152  connect(mGraphicalModeWidget, &SieveEditorGraphicalModeWidget::valueChanged, this, &SieveEditorWidget::slotModified);
153  mStackedWidget->addWidget(mGraphicalModeWidget);
154 
155  lay->addWidget(mStackedWidget);
156  connect(mTextModeWidget, &SieveEditorTextModeWidget::enableButtonOk, this, &SieveEditorWidget::slotEnableButtonOk);
157  connect(mGraphicalModeWidget, &SieveEditorGraphicalModeWidget::enableButtonOk, this, &SieveEditorWidget::slotEnableButtonOk);
158  connect(mGraphicalModeWidget, &SieveEditorGraphicalModeWidget::switchTextMode, this, &SieveEditorWidget::slotSwitchTextMode);
159  connect(mTextModeWidget, &SieveEditorTextModeWidget::switchToGraphicalMode, this, &SieveEditorWidget::slotSwitchToGraphicalMode);
160  connect(mTextModeWidget, &SieveEditorTextModeWidget::undoAvailable, this, &SieveEditorWidget::undoAvailable);
161  connect(mTextModeWidget, &SieveEditorTextModeWidget::redoAvailable, this, &SieveEditorWidget::redoAvailable);
162  connect(mTextModeWidget, &SieveEditorTextModeWidget::copyAvailable, this, &SieveEditorWidget::copyAvailable);
163  connect(mTextModeWidget, &SieveEditorTextModeWidget::sieveEditorTabCurrentChanged, this, &SieveEditorWidget::sieveEditorTabCurrentChanged);
164  if (KSieveUi::EditorSettings::useGraphicEditorByDefault()) {
165  changeMode(GraphicMode);
166  } else {
167  changeSwitchButtonText();
168  }
169 }
170 
171 SieveEditorWidget::~SieveEditorWidget()
172 {
173 }
174 
175 void SieveEditorWidget::setReadOnly(bool b)
176 {
177  mTextModeWidget->setReadOnly(b);
178  mGraphicalModeWidget->setDisabled(b);
179 }
180 
181 void SieveEditorWidget::slotModified()
182 {
183  mModified = true;
184  Q_EMIT valueChanged(mModified);
185 }
186 
187 bool SieveEditorWidget::isModified() const
188 {
189  return mModified;
190 }
191 
192 void SieveEditorWidget::undo()
193 {
194  if (mMode == TextMode) {
195  mTextModeWidget->undo();
196  }
197 }
198 
199 void SieveEditorWidget::redo()
200 {
201  if (mMode == TextMode) {
202  mTextModeWidget->redo();
203  }
204 }
205 
206 void SieveEditorWidget::goToLine()
207 {
208  if (mMode == TextMode) {
209  mTextModeWidget->slotShowGoToLine();
210  }
211 }
212 
213 void SieveEditorWidget::cut()
214 {
215  if (mMode == TextMode) {
216  mTextModeWidget->cut();
217  }
218 }
219 
220 void SieveEditorWidget::paste()
221 {
222  if (mMode == TextMode) {
223  mTextModeWidget->paste();
224  }
225 }
226 
227 void SieveEditorWidget::copy()
228 {
229  if (mMode == TextMode) {
230  mTextModeWidget->copy();
231  }
232 }
233 
234 void SieveEditorWidget::zoomIn()
235 {
236  if (mMode == TextMode) {
237  mTextModeWidget->zoomIn();
238  }
239 }
240 
241 bool SieveEditorWidget::isWordWrap() const
242 {
243  if (mMode == TextMode) {
244  return mTextModeWidget->isWordWrap();
245  }
246  return false;
247 }
248 
249 void SieveEditorWidget::updateOriginalScript()
250 {
251  mOriginalScript = script();
252 }
253 
254 void SieveEditorWidget::print()
255 {
256  switch (mMode) {
257  case TextMode: {
258  bool wasModified = isModified();
259  mTextModeWidget->print();
260  setModified(wasModified);
261  break;
262  }
263  case GraphicMode:
264  break;
265  case Unknown:
266  qCDebug(LIBKSIEVE_LOG) << " Unknown mode";
267  break;
268  }
269 }
270 
271 void SieveEditorWidget::printPreview()
272 {
273  switch (mMode) {
274  case TextMode: {
275  bool wasModified = isModified();
276  mTextModeWidget->printPreview();
277  setModified(wasModified);
278  break;
279  }
280  case GraphicMode:
281  break;
282  case Unknown:
283  qCDebug(LIBKSIEVE_LOG) << " Unknown mode";
284  break;
285  }
286 }
287 
288 void SieveEditorWidget::wordWrap(bool state)
289 {
290  if (mMode == TextMode) {
291  mTextModeWidget->wordWrap(state);
292  }
293 }
294 
295 void SieveEditorWidget::zoomReset()
296 {
297  if (mMode == TextMode) {
298  mTextModeWidget->zoomReset();
299  }
300 }
301 
302 void SieveEditorWidget::zoomOut()
303 {
304  if (mMode == TextMode) {
305  mTextModeWidget->zoomOut();
306  }
307 }
308 
309 void SieveEditorWidget::selectAll()
310 {
311  if (mMode == TextMode) {
312  mTextModeWidget->selectAll();
313  }
314 }
315 
316 void SieveEditorWidget::find()
317 {
318  if (mMode == TextMode) {
319  mTextModeWidget->find();
320  }
321 }
322 
323 void SieveEditorWidget::replace()
324 {
325  if (mMode == TextMode) {
326  mTextModeWidget->replace();
327  }
328 }
329 
330 bool SieveEditorWidget::isUndoAvailable() const
331 {
332  if (mMode == TextMode) {
333  return mTextModeWidget->isUndoAvailable();
334  }
335  return false;
336 }
337 
338 bool SieveEditorWidget::isRedoAvailable() const
339 {
340  if (mMode == TextMode) {
341  return mTextModeWidget->isRedoAvailable();
342  }
343  return false;
344 }
345 
346 bool SieveEditorWidget::hasSelection() const
347 {
348  if (mMode == TextMode) {
349  return mTextModeWidget->hasSelection();
350  }
351  return false;
352 }
353 
354 void SieveEditorWidget::comment()
355 {
356  if (mMode == TextMode) {
357  mTextModeWidget->comment();
358  }
359 }
360 
361 void SieveEditorWidget::uncomment()
362 {
363  if (mMode == TextMode) {
364  mTextModeWidget->uncomment();
365  }
366 }
367 
368 SieveEditorWidget::EditorMode SieveEditorWidget::mode() const
369 {
370  return mMode;
371 }
372 
373 void SieveEditorWidget::setModified(bool b)
374 {
375  if (mModified != b) {
376  mModified = b;
377  Q_EMIT valueChanged(mModified);
378  }
379 }
380 
381 void SieveEditorWidget::slotShareScript()
382 {
383  QTemporaryDir tmp;
384  QTemporaryFile tmpFile;
385  if (tmpFile.open()) {
386  QTextStream out(&tmpFile);
387 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
388  out.setCodec("UTF-8");
389 #endif
390  out << script();
391  tmpFile.close();
392  const QString sourceName = mScriptName->text();
393  const QString zipFileName = tmp.path() + QLatin1Char('/') + sourceName + QLatin1String(".zip");
394  KZip *zip = new KZip(zipFileName);
395  if (zip->open(QIODevice::WriteOnly)) {
396  if (zip->addLocalFile(tmpFile.fileName(), sourceName + QLatin1String(".siv"))) {
397  zip->close();
398  const QString knsrcPath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("knsrcfiles/ksieve_script.knsrc"));
399  QPointer<KNS3::UploadDialog> dialog = new KNS3::UploadDialog(knsrcPath, this);
400  dialog->setUploadFile(QUrl::fromLocalFile(zipFileName));
401  dialog->setUploadName(sourceName);
402  dialog->setDescription(i18nc("Default description for the source", "My Sieve Script"));
403  dialog->exec();
404  delete dialog;
405  } else {
406  zip->close();
407  }
408  }
409  delete zip;
410  } else {
411  qCWarning(LIBKSIEVE_LOG) << "Impossible to open temp file";
412  }
413 }
414 
415 void SieveEditorWidget::changeMode(EditorMode mode)
416 {
417  if (mode != mMode) {
418  mMode = mode;
419  mStackedWidget->setCurrentIndex(static_cast<int>(mode));
420  const bool isTextMode = (mMode == TextMode);
421  mCreateRulesGraphically->setEnabled(isTextMode);
422  if (mGenerateXml) {
423  mGenerateXml->setEnabled(isTextMode);
424  }
425  if (isTextMode) {
426  mCheckSyntax->setEnabled(!mTextModeWidget->currentscript().isEmpty());
427  } else {
428  mCheckSyntax->setEnabled(false);
429  }
430  Q_EMIT modeEditorChanged(mode);
431  Q_EMIT changeModeEditor(isTextMode);
432  changeSwitchButtonText();
433  }
434 }
435 
436 void SieveEditorWidget::changeSwitchButtonText()
437 {
438  mSwitchMode->setText((mMode == TextMode) ? i18n("Simple Mode") : i18n("Advanced Mode"));
439 }
440 
441 void SieveEditorWidget::slotEnableButtonOk(bool b)
442 {
443  Q_EMIT enableButtonOk(b);
444  mSaveAs->setEnabled(b);
445  if (mMode == TextMode) {
446  mCheckSyntax->setEnabled(b);
447  } else {
448  mCheckSyntax->setEnabled(false);
449  }
450 }
451 
452 QString SieveEditorWidget::script() const
453 {
454  QString currentScript;
455  switch (mMode) {
456  case TextMode:
457  currentScript = mTextModeWidget->script();
458  break;
459  case GraphicMode:
460  currentScript = mGraphicalModeWidget->currentscript();
461  break;
462  case Unknown:
463  qCDebug(LIBKSIEVE_LOG) << " Unknown Mode!";
464  break;
465  }
466  return currentScript;
467 }
468 
469 QString SieveEditorWidget::originalScript() const
470 {
471  return mOriginalScript;
472 }
473 
474 void SieveEditorWidget::setScript(const QString &script, bool clearUndoRedo)
475 {
476  mTextModeWidget->setScript(script, clearUndoRedo);
477  // Necessary to take text from editor otherwise script has \r\n
478  mOriginalScript = mTextModeWidget->script();
479 }
480 
481 void SieveEditorWidget::addFailedMessage(const QString &err)
482 {
483  addMessageEntry(err, QColor(Qt::darkRed));
484 }
485 
486 void SieveEditorWidget::addOkMessage(const QString &msg)
487 {
488  addMessageEntry(msg, QColor(Qt::darkGreen));
489 }
490 
491 void SieveEditorWidget::addNormalMessage(const QString &msg)
492 {
493  addMessageEntry(msg, palette().color(QPalette::WindowText));
494 }
495 
496 void SieveEditorWidget::addMessageEntry(const QString &errorMsg, const QColor &color)
497 {
498  QString msg = errorMsg;
499  msg.replace(QLatin1Char('\n'), QStringLiteral("<br>"));
500  const QString logText = QStringLiteral("<font color=%1>%2</font>").arg(color.name(), msg);
501 
502  setDebugScript(logText);
503 }
504 
505 void SieveEditorWidget::setDebugScript(const QString &debug)
506 {
507  mTextModeWidget->setDebugScript(debug);
508 }
509 
510 void SieveEditorWidget::setScriptName(const QString &name)
511 {
512  mScriptName->setText(name);
513 }
514 
515 void SieveEditorWidget::resultDone()
516 {
517  mCheckSyntax->setEnabled(true);
518 }
519 
520 void SieveEditorWidget::setSieveCapabilities(const QStringList &capabilities)
521 {
522  mTextModeWidget->setSieveCapabilities(capabilities);
523  mGraphicalModeWidget->setSieveCapabilities(capabilities);
524 }
525 
526 void SieveEditorWidget::setSieveImapAccountSettings(const SieveImapAccountSettings &sieveImapAccountSettings)
527 {
528  mGraphicalModeWidget->setSieveImapAccountSettings(sieveImapAccountSettings);
529  mTextModeWidget->setSieveImapAccountSettings(sieveImapAccountSettings);
530 }
531 
532 void SieveEditorWidget::setListOfIncludeFile(const QStringList &listOfIncludeFile)
533 {
534  mTextModeWidget->setListOfIncludeFile(listOfIncludeFile);
535  mGraphicalModeWidget->setListOfIncludeFile(listOfIncludeFile);
536 }
537 
538 void SieveEditorWidget::slotCreateRulesGraphically()
539 {
540  switch (mMode) {
541  case TextMode:
542  mTextModeWidget->createRulesGraphically();
543  break;
544  case GraphicMode:
545  case Unknown:
546  break;
547  }
548 }
549 
550 void SieveEditorWidget::slotCheckSyntax()
551 {
552  switch (mMode) {
553  case TextMode:
554  mCheckSyntax->setEnabled(false);
555  Q_EMIT checkSyntax();
556  break;
557  case GraphicMode:
558  case Unknown:
559  break;
560  }
561 }
562 
563 void SieveEditorWidget::slotGenerateXml()
564 {
565  switch (mMode) {
566  case TextMode:
567  mTextModeWidget->generateXml();
568  break;
569  case GraphicMode:
570  case Unknown:
571  break;
572  }
573 }
574 
575 void SieveEditorWidget::checkSpelling()
576 {
577  switch (mMode) {
578  case TextMode:
579  mTextModeWidget->checkSpelling();
580  break;
581  case GraphicMode:
582  case Unknown:
583  break;
584  }
585 }
586 
587 void SieveEditorWidget::slotSaveAs()
588 {
589  switch (mMode) {
590  case TextMode:
591  mTextModeWidget->saveAs(mScriptName->text());
592  break;
593  case GraphicMode:
594  mGraphicalModeWidget->saveAs(mScriptName->text());
595  break;
596  case Unknown:
597  qCDebug(LIBKSIEVE_LOG) << " Unknown mode";
598  break;
599  }
600 }
601 
602 void SieveEditorWidget::slotImport()
603 {
604  switch (mMode) {
605  case TextMode:
606  mTextModeWidget->slotImport();
607  break;
608  case GraphicMode:
609  mGraphicalModeWidget->slotImport();
610  break;
611  case Unknown:
612  qCDebug(LIBKSIEVE_LOG) << " Unknown mode";
613  break;
614  }
615 }
616 
617 void SieveEditorWidget::slotSwitchToGraphicalMode()
618 {
619  mTextModeWidget->hideEditorWarning();
620  changeMode(GraphicMode);
621 }
622 
623 void SieveEditorWidget::slotSwitchMode()
624 {
625  switch (mMode) {
626  case TextMode: {
627  bool result = false;
628  const QString doc = ParsingUtil::parseScript(mTextModeWidget->currentscript(), result);
629  if (result) {
630  QString error;
631  mGraphicalModeWidget->loadScript(doc, error);
632  if (!error.isEmpty()) {
633  mTextModeWidget->setParsingEditorWarningError(mTextModeWidget->currentscript(), error);
634  mTextModeWidget->showParsingEditorWarning();
635  } else {
636  mTextModeWidget->hideEditorWarning();
637  changeMode(GraphicMode);
638  }
639  } else {
640  mTextModeWidget->showEditorWarning();
641  qCDebug(LIBKSIEVE_LOG) << "Impossible to parse file";
642  }
643  break;
644  }
645  case GraphicMode: {
646  const QString script = mGraphicalModeWidget->currentscript();
647  changeMode(TextMode);
648  mTextModeWidget->setScript(script);
649  break;
650  }
651  case Unknown:
652  qCDebug(LIBKSIEVE_LOG) << " Unknown mode";
653  break;
654  }
655 }
656 
657 void SieveEditorWidget::slotSwitchTextMode(const QString &script)
658 {
659  changeMode(TextMode);
660  mTextModeWidget->setScript(script);
661 }
662 
663 void SieveEditorWidget::reverseCase()
664 {
665  if (mMode == TextMode) {
666  mTextModeWidget->reverseCase();
667  }
668 }
669 
670 void SieveEditorWidget::lowerCase()
671 {
672  if (mMode == TextMode) {
673  mTextModeWidget->lowerCase();
674  }
675 }
676 
677 void SieveEditorWidget::debugSieveScript()
678 {
679  if (mMode == TextMode) {
680  mTextModeWidget->debugSieveScript();
681  }
682 }
683 
684 void SieveEditorWidget::upperCase()
685 {
686  if (mMode == TextMode) {
687  mTextModeWidget->upperCase();
688  }
689 }
690 
691 void SieveEditorWidget::sentenceCase()
692 {
693  if (mMode == TextMode) {
694  mTextModeWidget->sentenceCase();
695  }
696 }
697 
698 void SieveEditorWidget::openBookmarkUrl(const QUrl &url)
699 {
700  if (mMode == TextMode) {
701  mTextModeWidget->openBookmarkUrl(url);
702  }
703 }
704 
705 QString SieveEditorWidget::currentHelpTitle() const
706 {
707  if (mMode == TextMode) {
708  return mTextModeWidget->currentHelpTitle();
709  }
710  return QString();
711 }
712 
713 QUrl SieveEditorWidget::currentHelpUrl() const
714 {
715  if (mMode == TextMode) {
716  return mTextModeWidget->currentHelpUrl();
717  }
718  return QUrl();
719 }
720 
721 bool SieveEditorWidget::isTextEditor() const
722 {
723  if (mMode == TextMode) {
724  return mTextModeWidget->isTextEditor();
725  }
726  return false;
727 }
728 
729 bool SieveEditorWidget::printSupportEnabled() const
730 {
731  if (mMode == TextMode) {
732  return mTextModeWidget->printSupportEnabled();
733  }
734  return false;
735 }
736 
737 void SieveEditorWidget::slotServerInfo()
738 {
739  SieveInfoDialog dlg(this);
740  dlg.setServerInfo(mTextModeWidget->sieveCapabilities());
741  dlg.exec();
742 }
void triggered(bool checked)
const QPalette & palette() const const
QString name() const const
QAction * saveAs(const QObject *recvr, const char *slot, QObject *parent)
The SieveEditorTextModeWidget class.
virtual bool close()
void setToolButtonStyle(Qt::ToolButtonStyle toolButtonStyle)
virtual bool open(QIODevice::OpenMode mode)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString label(StandardShortcut id)
bool isEmpty() const const
void error(QWidget *parent, const QString &text, const QString &caption=QString(), Options options=Notify)
ToolButtonTextBesideIcon
static KIconLoader * global()
bool addLocalFile(const QString &fileName, const QString &destName)
QString path() const const
virtual QString fileName() const const override
QString i18n(const char *text, const TYPE &arg...)
QString & replace(int position, int n, QChar after)
virtual void close() override
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
The SieveImapAccountSettings class.
QIcon fromTheme(const QString &name)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QDebug mDebug()
Q_EMITQ_EMIT
QUrl fromLocalFile(const QString &localFile)
QString locate(QStandardPaths::StandardLocation type, const QString &fileName, QStandardPaths::LocateOptions options)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Apr 16 2021 23:09:34 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.