7 #include "sieveeditormenubar.h" 8 #include "sieveeditortabwidget.h" 9 #include "sieveeditortextmodewidget.h" 11 #include <KLocalizedString> 12 #include <KStandardAction> 17 SieveEditorMenuBar::SieveEditorMenuBar(
QWidget *parent)
24 SieveEditorMenuBar::~SieveEditorMenuBar()
28 void SieveEditorMenuBar::setEditorMode(
bool editorMode)
30 mGoToLine->setEnabled(editorMode);
31 mFindAction->setEnabled(editorMode);
32 mReplaceAction->setEnabled(editorMode);
33 mUndoAction->setEnabled(editorMode);
34 mRedoAction->setEnabled(editorMode);
35 mCopyAction->setEnabled(editorMode);
36 mPasteAction->setEnabled(editorMode);
37 mCutAction->setEnabled(editorMode);
38 mSelectAllAction->setEnabled(editorMode);
39 mCommentCodeAction->setEnabled(editorMode);
40 mUncommentCodeAction->setEnabled(editorMode);
41 mZoomInAction->setEnabled(editorMode);
42 mZoomOutAction->setEnabled(editorMode);
43 mZoomResetAction->setEnabled(editorMode);
44 mDebugSieveAction->setEnabled(editorMode);
45 mWordWrapAction->setEnabled(editorMode);
46 mPrintAction->setEnabled(editorMode);
47 mPrintPreviewAction->setEnabled(editorMode);
50 void SieveEditorMenuBar::initActions()
57 mCommentCodeAction =
new QAction(
i18n(
"Comment"),
this);
61 mUncommentCodeAction =
new QAction(
i18n(
"Uncomment"),
this);
65 mDebugSieveAction =
new QAction(
i18n(
"Debug Sieve Script..."),
this);
83 mWordWrapAction =
new QAction(
i18n(
"Wordwrap"),
this);
84 mWordWrapAction->setCheckable(
true);
87 mUndoAction->setEnabled(
false);
88 mRedoAction->setEnabled(
false);
89 mCopyAction->setEnabled(
false);
90 mCutAction->setEnabled(
false);
93 QMenu *SieveEditorMenuBar::editorMenu()
const 98 void SieveEditorMenuBar::initMenus()
100 mFileMenu = addMenu(
i18nc(
"@title:menu",
"File"));
101 mFileMenu->addAction(mPrintAction);
102 mFileMenu->addAction(mPrintPreviewAction);
103 mEditorMenu = addMenu(
i18nc(
"@title:menu",
"Edit"));
104 mEditorMenu->addAction(mUndoAction);
105 mEditorMenu->addAction(mRedoAction);
106 mEditorMenu->addSeparator();
107 mEditorMenu->addAction(mCutAction);
108 mEditorMenu->addAction(mCopyAction);
109 mEditorMenu->addAction(mPasteAction);
110 mEditorMenu->addSeparator();
111 mEditorMenu->addAction(mSelectAllAction);
112 mEditorMenu->addSeparator();
113 mEditorMenu->addAction(mFindAction);
114 mEditorMenu->addAction(mReplaceAction);
115 mEditorMenu->addSeparator();
116 mEditorMenu->addAction(mGoToLine);
117 mEditorMenu->addSeparator();
118 mEditorMenu->addAction(mWordWrapAction);
119 mEditorMenu->addSeparator();
120 mEditorMenu->addAction(mCommentCodeAction);
121 mEditorMenu->addAction(mUncommentCodeAction);
123 mViewMenu = addMenu(
i18nc(
"@title:menu",
"View"));
124 mViewMenu->addAction(mZoomInAction);
125 mViewMenu->addAction(mZoomOutAction);
126 mViewMenu->addSeparator();
127 mViewMenu->addAction(mZoomResetAction);
129 mToolsMenu = addMenu(
i18nc(
"@title:menu",
"Tools"));
130 mToolsMenu->addAction(mDebugSieveAction);
133 QAction *SieveEditorMenuBar::printAction()
const 138 void SieveEditorMenuBar::slotUpdateActions()
140 const bool hasActionInHtmlModeToo = mTextModeWidget->tabWidget()->currentPageIsHtmlPage();
142 mGoToLine->
setEnabled(!hasActionInHtmlModeToo);
143 mFindAction->setEnabled(
true);
144 mReplaceAction->setEnabled(!hasActionInHtmlModeToo);
145 mUndoAction->setEnabled(!hasActionInHtmlModeToo);
146 mRedoAction->setEnabled(!hasActionInHtmlModeToo);
147 mCopyAction->setEnabled(
true);
148 mPasteAction->setEnabled(!hasActionInHtmlModeToo);
149 mCutAction->setEnabled(!hasActionInHtmlModeToo);
150 mSelectAllAction->setEnabled(
true);
151 mCommentCodeAction->setEnabled(!hasActionInHtmlModeToo);
152 mUncommentCodeAction->setEnabled(!hasActionInHtmlModeToo);
153 mZoomInAction->setEnabled(
true);
154 mZoomOutAction->setEnabled(
true);
155 mZoomResetAction->setEnabled(
true);
156 mDebugSieveAction->setEnabled(!hasActionInHtmlModeToo);
157 mWordWrapAction->setEnabled(!hasActionInHtmlModeToo);
158 mPrintAction->setEnabled(!hasActionInHtmlModeToo);
159 mPrintPreviewAction->setEnabled(!hasActionInHtmlModeToo);
162 QMenu *SieveEditorMenuBar::viewMenu()
const 169 if (!mTextModeWidget) {
170 mTextModeWidget = textModeWidget;
175 QAction *SieveEditorMenuBar::printPreviewAction()
const 177 return mPrintPreviewAction;
180 QAction *SieveEditorMenuBar::uncommentCodeAction()
const 182 return mUncommentCodeAction;
185 QAction *SieveEditorMenuBar::zoomResetAction()
const 187 return mZoomResetAction;
190 QAction *SieveEditorMenuBar::wordWrapAction()
const 192 return mWordWrapAction;
195 QAction *SieveEditorMenuBar::zoomInAction()
const 197 return mZoomInAction;
200 QAction *SieveEditorMenuBar::zoomOutAction()
const 202 return mZoomOutAction;
205 QAction *SieveEditorMenuBar::debugSieveScriptAction()
const 207 return mDebugSieveAction;
210 QAction *SieveEditorMenuBar::commentCodeAction()
const 212 return mCommentCodeAction;
215 QMenu *SieveEditorMenuBar::fileMenu()
const 220 QMenu *SieveEditorMenuBar::toolsMenu()
const 225 QAction *SieveEditorMenuBar::selectAllAction()
const 227 return mSelectAllAction;
230 QAction *SieveEditorMenuBar::cutAction()
const 235 QAction *SieveEditorMenuBar::pasteAction()
const 240 QAction *SieveEditorMenuBar::copyAction()
const 245 QAction *SieveEditorMenuBar::redoAction()
const 250 QAction *SieveEditorMenuBar::undoAction()
const 255 QAction *SieveEditorMenuBar::replaceAction()
const 257 return mReplaceAction;
260 QAction *SieveEditorMenuBar::findAction()
const 265 QAction *SieveEditorMenuBar::goToLineAction()
const 270 void SieveEditorMenuBar::slotUndoAvailable(
bool b)
275 void SieveEditorMenuBar::slotRedoAvailable(
bool b)
277 mRedoAction->setEnabled(b);
280 void SieveEditorMenuBar::slotCopyAvailable(
bool b)
282 mCutAction->setEnabled(b);
283 mCopyAction->setEnabled(b);
QAction * selectAll(const QObject *recvr, const char *slot, QObject *parent)
void triggered(bool checked)
QAction * cut(const QObject *recvr, const char *slot, QObject *parent)
QAction * actualSize(const QObject *recvr, const char *slot, QObject *parent)
QAction * paste(const QObject *recvr, const char *slot, QObject *parent)
The SieveEditorTextModeWidget class.
QAction * undo(const QObject *recvr, const char *slot, QObject *parent)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QAction * copy(const QObject *recvr, const char *slot, QObject *parent)
QAction * print(const QObject *recvr, const char *slot, QObject *parent)
QAction * replace(const QObject *recvr, const char *slot, QObject *parent)
QString i18n(const char *text, const TYPE &arg...)
QAction * zoomIn(const QObject *recvr, const char *slot, QObject *parent)
QAction * redo(const QObject *recvr, const char *slot, QObject *parent)
QIcon fromTheme(const QString &name)
QAction * printPreview(const QObject *recvr, const char *slot, QObject *parent)
QAction * zoomOut(const QObject *recvr, const char *slot, QObject *parent)
QAction * find(const QObject *recvr, const char *slot, QObject *parent)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)