1 /* 2 SPDX-FileCopyrightText: 2014-2021 Laurent Montel <montel@kde.org> 3 4 SPDX-License-Identifier: GPL-2.0-or-later 5 */ 6 7 #pragma once 8 #include <KSieveUi/ManageSieveWidget> 9 #include <KSieveUi/SieveEditorWidget> 10 #include <QUrl> 11 #include <QWidget> 12 namespace KManageSieve 13 { 14 class SieveJob; 15 } 16 namespace KSieveUi 17 { 18 class SieveEditorWidget; 19 } 20 21 class SieveEditorPageWidget : public QWidget 22 { 23 Q_OBJECT 24 public: 25 explicit SieveEditorPageWidget(QWidget *parent = nullptr); 26 ~SieveEditorPageWidget() override; 27 28 void loadScript(const KSieveUi::ManageSieveWidget::ScriptInfo &info); 29 Q_REQUIRED_RESULT QUrl currentUrl() const; 30 void setCurrentUrl(const QUrl &url); 31 void setIsNewScript(bool isNewScript); 32 void uploadScript(bool showInformation = true, bool forceSave = false); 33 Q_REQUIRED_RESULT bool needToSaveScript(); 34 35 Q_REQUIRED_RESULT bool isModified() const; 36 void goToLine(); 37 Q_REQUIRED_RESULT KSieveUi::SieveEditorWidget::EditorMode pageMode() const; 38 39 void find(); 40 void replace(); 41 void redo(); 42 void undo(); 43 Q_REQUIRED_RESULT bool isUndoAvailable() const; 44 Q_REQUIRED_RESULT bool isRedoAvailable() const; 45 void paste(); 46 void cut(); 47 void copy(); 48 Q_REQUIRED_RESULT bool hasSelection() const; 49 50 void selectAll(); 51 void saveAs(); 52 void checkSpelling(); 53 void import(); 54 void createRulesGraphically(); 55 void checkSyntax(); 56 void comment(); 57 void uncomment(); 58 void lowerCase(); 59 void upperCase(); 60 void sentenceCase(); 61 void reverseCase(); 62 void zoomIn(); 63 void zoomOut(); 64 Q_REQUIRED_RESULT QString currentText() const; 65 Q_REQUIRED_RESULT QString currentHelpTitle() const; 66 Q_REQUIRED_RESULT QUrl currentHelpUrl() const; 67 void openBookmarkUrl(const QUrl &url); 68 void debugSieveScript(); 69 void zoomReset(); 70 void wordWrap(bool state); 71 Q_REQUIRED_RESULT bool isWordWrap() const; 72 void print(); 73 void printPreview(); 74 bool printSupportEnabled() const; 75 bool isTextEditor() const; 76 void renameScriptName(const QString &newName); 77 Q_REQUIRED_RESULT bool uploadScriptAndCloseTab(int index); 78 Q_SIGNALS: 79 void refreshList(); 80 void scriptModified(bool, SieveEditorPageWidget *); 81 void modeEditorChanged(KSieveUi::SieveEditorWidget::EditorMode); 82 void undoAvailable(bool); 83 void redoAvailable(bool); 84 void copyAvailable(bool); 85 void sieveEditorTabCurrentChanged(); 86 void requestCloseTab(int index); 87 88 private: 89 void slotGetResult(KManageSieve::SieveJob *, bool success, const QString &script, bool isActive); 90 void slotCheckSyntaxClicked(); 91 void slotPutResult(KManageSieve::SieveJob *, bool success); 92 void slotValueChanged(bool b); 93 void slotCheckScriptJobFinished(const QString &errorMsg, bool success); 94 95 private: 96 void setModified(bool b); 97 QUrl mCurrentURL; 98 KSieveUi::SieveEditorWidget *mSieveEditorWidget = nullptr; 99 bool mWasActive = false; 100 bool mIsNewScript = false; 101 }; 102 103