Libksieve

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

KDE's Doxygen guidelines are available online.