7#include "sieveeditormenubar.h"
8#include "sieveeditortabwidget.h"
9#include "sieveeditortextmodewidget.h"
11#include <KLocalizedString>
12#include <KStandardActions>
15using namespace KSieveUi;
17SieveEditorMenuBar::SieveEditorMenuBar(
QWidget *parent)
24SieveEditorMenuBar::~SieveEditorMenuBar() =
default;
26void SieveEditorMenuBar::setEditorMode(
bool editorMode)
28 mGoToLine->setEnabled(editorMode);
29 mFindAction->setEnabled(editorMode);
30 mReplaceAction->setEnabled(editorMode);
31 mUndoAction->setEnabled(editorMode);
32 mRedoAction->setEnabled(editorMode);
33 mCopyAction->setEnabled(editorMode);
34 mPasteAction->setEnabled(editorMode);
35 mCutAction->setEnabled(editorMode);
36 mSelectAllAction->setEnabled(editorMode);
37 mCommentCodeAction->setEnabled(editorMode);
38 mUncommentCodeAction->setEnabled(editorMode);
39 mZoomInAction->setEnabled(editorMode);
40 mZoomOutAction->setEnabled(editorMode);
41 mZoomResetAction->setEnabled(editorMode);
42 mDebugSieveAction->setEnabled(editorMode);
43 mWordWrapAction->setEnabled(editorMode);
44 mPrintAction->setEnabled(editorMode);
45 mPrintPreviewAction->setEnabled(editorMode);
48void SieveEditorMenuBar::initActions()
50 mGoToLine =
new QAction(
i18nc(
"@action",
"Go to Line"),
this);
55 mCommentCodeAction =
new QAction(
i18nc(
"@action",
"Comment"),
this);
59 mUncommentCodeAction =
new QAction(
i18nc(
"@action",
"Uncomment"),
this);
63 mDebugSieveAction =
new QAction(
i18nc(
"@action",
"Debug Sieve Script…"),
this);
67 mFindAction = KStandardActions::find(
this, &SieveEditorMenuBar::find,
this);
68 mReplaceAction = KStandardActions::replace(
this, &SieveEditorMenuBar::replace,
this);
69 mUndoAction = KStandardActions::undo(
this, &SieveEditorMenuBar::undo,
this);
70 mRedoAction = KStandardActions::redo(
this, &SieveEditorMenuBar::redo,
this);
71 mCopyAction = KStandardActions::copy(
this, &SieveEditorMenuBar::copy,
this);
72 mPasteAction = KStandardActions::paste(
this, &SieveEditorMenuBar::paste,
this);
73 mCutAction = KStandardActions::cut(
this, &SieveEditorMenuBar::cut,
this);
74 mSelectAllAction = KStandardActions::selectAll(
this, &SieveEditorMenuBar::selectAll,
this);
75 mZoomInAction = KStandardActions::zoomIn(
this, &SieveEditorMenuBar::zoomIn,
this);
76 mZoomOutAction = KStandardActions::zoomOut(
this, &SieveEditorMenuBar::zoomOut,
this);
77 mPrintAction = KStandardActions::print(
this, &SieveEditorMenuBar::print,
this);
78 mPrintPreviewAction = KStandardActions::printPreview(
this, &SieveEditorMenuBar::printPreview,
this);
80 mZoomResetAction = KStandardActions::actualSize(
this, &SieveEditorMenuBar::zoomReset,
this);
81 mWordWrapAction =
new QAction(
i18nc(
"@action",
"Wordwrap"),
this);
82 mWordWrapAction->setCheckable(
true);
85 mUndoAction->setEnabled(
false);
86 mRedoAction->setEnabled(
false);
87 mCopyAction->setEnabled(
false);
88 mCutAction->setEnabled(
false);
91QMenu *SieveEditorMenuBar::editorMenu()
const
96void SieveEditorMenuBar::initMenus()
99 mFileMenu->addAction(mPrintAction);
100 mFileMenu->addAction(mPrintPreviewAction);
102 mEditorMenu->addAction(mUndoAction);
103 mEditorMenu->addAction(mRedoAction);
104 mEditorMenu->addSeparator();
105 mEditorMenu->addAction(mCutAction);
106 mEditorMenu->addAction(mCopyAction);
107 mEditorMenu->addAction(mPasteAction);
108 mEditorMenu->addSeparator();
109 mEditorMenu->addAction(mSelectAllAction);
110 mEditorMenu->addSeparator();
111 mEditorMenu->addAction(mFindAction);
112 mEditorMenu->addAction(mReplaceAction);
113 mEditorMenu->addSeparator();
114 mEditorMenu->addAction(mGoToLine);
115 mEditorMenu->addSeparator();
116 mEditorMenu->addAction(mWordWrapAction);
117 mEditorMenu->addSeparator();
118 mEditorMenu->addAction(mCommentCodeAction);
119 mEditorMenu->addAction(mUncommentCodeAction);
122 mViewMenu->addAction(mZoomInAction);
123 mViewMenu->addAction(mZoomOutAction);
124 mViewMenu->addSeparator();
125 mViewMenu->addAction(mZoomResetAction);
128 mToolsMenu->addAction(mDebugSieveAction);
131QAction *SieveEditorMenuBar::printAction()
const
136void SieveEditorMenuBar::slotUpdateActions()
138 const bool hasActionInHtmlModeToo = mTextModeWidget->tabWidget()->currentPageIsHtmlPage();
140 mGoToLine->setEnabled(!hasActionInHtmlModeToo);
141 mFindAction->setEnabled(
true);
142 mReplaceAction->setEnabled(!hasActionInHtmlModeToo);
143 mUndoAction->setEnabled(!hasActionInHtmlModeToo);
144 mRedoAction->setEnabled(!hasActionInHtmlModeToo);
145 mCopyAction->setEnabled(
true);
146 mPasteAction->setEnabled(!hasActionInHtmlModeToo);
147 mCutAction->setEnabled(!hasActionInHtmlModeToo);
148 mSelectAllAction->setEnabled(
true);
149 mCommentCodeAction->setEnabled(!hasActionInHtmlModeToo);
150 mUncommentCodeAction->setEnabled(!hasActionInHtmlModeToo);
151 mZoomInAction->setEnabled(
true);
152 mZoomOutAction->setEnabled(
true);
153 mZoomResetAction->setEnabled(
true);
154 mDebugSieveAction->setEnabled(!hasActionInHtmlModeToo);
155 mWordWrapAction->setEnabled(!hasActionInHtmlModeToo);
156 mPrintAction->setEnabled(!hasActionInHtmlModeToo);
157 mPrintPreviewAction->setEnabled(!hasActionInHtmlModeToo);
160QMenu *SieveEditorMenuBar::viewMenu()
const
167 if (!mTextModeWidget) {
168 mTextModeWidget = textModeWidget;
173QAction *SieveEditorMenuBar::printPreviewAction()
const
175 return mPrintPreviewAction;
178QAction *SieveEditorMenuBar::uncommentCodeAction()
const
180 return mUncommentCodeAction;
183QAction *SieveEditorMenuBar::zoomResetAction()
const
185 return mZoomResetAction;
188QAction *SieveEditorMenuBar::wordWrapAction()
const
190 return mWordWrapAction;
193QAction *SieveEditorMenuBar::zoomInAction()
const
195 return mZoomInAction;
198QAction *SieveEditorMenuBar::zoomOutAction()
const
200 return mZoomOutAction;
203QAction *SieveEditorMenuBar::debugSieveScriptAction()
const
205 return mDebugSieveAction;
208QAction *SieveEditorMenuBar::commentCodeAction()
const
210 return mCommentCodeAction;
213QMenu *SieveEditorMenuBar::fileMenu()
const
218QMenu *SieveEditorMenuBar::toolsMenu()
const
223QAction *SieveEditorMenuBar::selectAllAction()
const
225 return mSelectAllAction;
228QAction *SieveEditorMenuBar::cutAction()
const
233QAction *SieveEditorMenuBar::pasteAction()
const
238QAction *SieveEditorMenuBar::copyAction()
const
243QAction *SieveEditorMenuBar::redoAction()
const
248QAction *SieveEditorMenuBar::undoAction()
const
253QAction *SieveEditorMenuBar::replaceAction()
const
255 return mReplaceAction;
258QAction *SieveEditorMenuBar::findAction()
const
263QAction *SieveEditorMenuBar::goToLineAction()
const
268void SieveEditorMenuBar::slotUndoAvailable(
bool b)
270 mUndoAction->setEnabled(b);
273void SieveEditorMenuBar::slotRedoAvailable(
bool b)
275 mRedoAction->setEnabled(b);
278void SieveEditorMenuBar::slotCopyAvailable(
bool b)
280 mCutAction->setEnabled(b);
281 mCopyAction->setEnabled(b);
284#include "moc_sieveeditormenubar.cpp"
The SieveEditorTextModeWidget class.
QString i18nc(const char *context, const char *text, const TYPE &arg...)
void triggered(bool checked)
QIcon fromTheme(const QString &name)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)