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)
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);
91QMenu *SieveEditorMenuBar::editorMenu()
const
96void SieveEditorMenuBar::initMenus()
100 mFileMenu->
addAction(mPrintPreviewAction);
109 mEditorMenu->
addAction(mSelectAllAction);
118 mEditorMenu->
addAction(mCommentCodeAction);
119 mEditorMenu->
addAction(mUncommentCodeAction);
128 mToolsMenu->
addAction(mDebugSieveAction);
131QAction *SieveEditorMenuBar::printAction()
const
136void SieveEditorMenuBar::slotUpdateActions()
138 const bool hasActionInHtmlModeToo = mTextModeWidget->tabWidget()->currentPageIsHtmlPage();
140 mGoToLine->
setEnabled(!hasActionInHtmlModeToo);
142 mReplaceAction->
setEnabled(!hasActionInHtmlModeToo);
143 mUndoAction->
setEnabled(!hasActionInHtmlModeToo);
144 mRedoAction->
setEnabled(!hasActionInHtmlModeToo);
146 mPasteAction->
setEnabled(!hasActionInHtmlModeToo);
147 mCutAction->
setEnabled(!hasActionInHtmlModeToo);
149 mCommentCodeAction->
setEnabled(!hasActionInHtmlModeToo);
150 mUncommentCodeAction->
setEnabled(!hasActionInHtmlModeToo);
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)
273void SieveEditorMenuBar::slotRedoAvailable(
bool b)
278void SieveEditorMenuBar::slotCopyAvailable(
bool b)
284#include "moc_sieveeditormenubar.cpp"
The SieveEditorTextModeWidget class.
QString i18nc(const char *context, const char *text, const TYPE &arg...)
void setIcon(const QIcon &icon)
void setShortcut(const QKeySequence &shortcut)
void triggered(bool checked)
QIcon fromTheme(const QString &name)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)