summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2016-05-18 08:05:55 +0200
committerMontel Laurent <[email protected]>2016-05-18 08:05:55 +0200
commit9e62ddebbd12b5194d032caa58c62652a911debf (patch)
tree04f19735ae02faa4a9eb8e4b5aa7e745e04893a5
parente4da54313a29a87bb9d7934966c1cbb26fde20c4 (diff)
add print/printpreview in tabbar
-rw-r--r--src/ksieveui/editor/autotests/sieveeditormenubartest.cpp21
-rw-r--r--src/ksieveui/editor/sieveeditormenubar.cpp18
-rw-r--r--src/ksieveui/editor/sieveeditormenubar.h9
-rw-r--r--src/ksieveui/editor/sieveeditorwidget.cpp2
4 files changed, 49 insertions, 1 deletions
diff --git a/src/ksieveui/editor/autotests/sieveeditormenubartest.cpp b/src/ksieveui/editor/autotests/sieveeditormenubartest.cpp
index 733912a..3221693 100644
--- a/src/ksieveui/editor/autotests/sieveeditormenubartest.cpp
+++ b/src/ksieveui/editor/autotests/sieveeditormenubartest.cpp
@@ -56,6 +56,8 @@ void SieveEditorMenuBarTest::shouldDisableActions()
QVERIFY(!bar.cutAction()->isEnabled());
QVERIFY(bar.selectAllAction()->isEnabled());
QVERIFY(bar.wordWrapAction()->isEnabled());
+ QVERIFY(bar.printAction()->isEnabled());
+ QVERIFY(bar.printPreviewAction()->isEnabled());
bar.setEditorMode(false);
QVERIFY(!bar.goToLineAction()->isEnabled());
@@ -79,6 +81,9 @@ void SieveEditorMenuBarTest::shouldDisableActions()
QVERIFY(!bar.cutAction()->isEnabled());
QVERIFY(!bar.selectAllAction()->isEnabled());
QVERIFY(!bar.wordWrapAction()->isEnabled());
+ QVERIFY(!bar.printAction()->isEnabled());
+ QVERIFY(!bar.printPreviewAction()->isEnabled());
+
bar.setEditorMode(true);
QVERIFY(bar.goToLineAction()->isEnabled());
@@ -102,6 +107,9 @@ void SieveEditorMenuBarTest::shouldDisableActions()
QVERIFY(bar.cutAction()->isEnabled());
QVERIFY(bar.selectAllAction()->isEnabled());
QVERIFY(bar.wordWrapAction()->isEnabled());
+ QVERIFY(bar.printAction()->isEnabled());
+ QVERIFY(bar.printPreviewAction()->isEnabled());
+
}
void SieveEditorMenuBarTest::shouldHaveDefaultValue()
@@ -126,9 +134,11 @@ void SieveEditorMenuBarTest::shouldHaveDefaultValue()
QVERIFY(bar.uncommentCodeAction());
QVERIFY(bar.debugSieveScriptAction());
QVERIFY(bar.wordWrapAction());
+ QVERIFY(bar.printAction());
+ QVERIFY(bar.printPreviewAction());
QCOMPARE(bar.actions().count(), 3);
QCOMPARE(bar.editorMenu()->actions().count(), 19);
- QCOMPARE(bar.fileMenu()->actions().count(), 0);
+ QCOMPARE(bar.fileMenu()->actions().count(), 2);
QCOMPARE(bar.toolsMenu()->actions().count(), 4);
QVERIFY(bar.findAction()->isEnabled());
@@ -192,6 +202,13 @@ void SieveEditorMenuBarTest::shouldEmitSignals()
QSignalSpy spyWordWrapScript(&bar, SIGNAL(wordWrap(bool)));
bar.wordWrapAction()->trigger();
+ QSignalSpy spyPrint(&bar, SIGNAL(print()));
+ bar.printAction()->trigger();
+
+ QSignalSpy spyPrintPreview(&bar, SIGNAL(printPreview()));
+ bar.printPreviewAction()->trigger();
+
+
QCOMPARE(spyZoomOut.count(), 1);
QCOMPARE(spyZoomIn.count(), 1);
QCOMPARE(spyUnComment.count(), 1);
@@ -208,6 +225,8 @@ void SieveEditorMenuBarTest::shouldEmitSignals()
QCOMPARE(spyZoomReset.count(), 1);
QCOMPARE(spyDebugScript.count(), 1);
QCOMPARE(spyWordWrapScript.count(), 1);
+ QCOMPARE(spyPrint.count(), 1);
+ QCOMPARE(spyPrintPreview.count(), 1);
}
QTEST_MAIN(SieveEditorMenuBarTest)
diff --git a/src/ksieveui/editor/sieveeditormenubar.cpp b/src/ksieveui/editor/sieveeditormenubar.cpp
index 78ffa08..35cbafa 100644
--- a/src/ksieveui/editor/sieveeditormenubar.cpp
+++ b/src/ksieveui/editor/sieveeditormenubar.cpp
@@ -53,6 +53,9 @@ void SieveEditorMenuBar::setEditorMode(bool editorMode)
mZoomResetAction->setEnabled(editorMode);
mDebugSieveAction->setEnabled(editorMode);
mWordWrapAction->setEnabled(editorMode);
+ mPrintAction->setEnabled(editorMode);
+ mPrintPreviewAction->setEnabled(editorMode);
+
}
void SieveEditorMenuBar::initActions()
@@ -84,6 +87,9 @@ void SieveEditorMenuBar::initActions()
mSelectAllAction = KStandardAction::selectAll(this, SIGNAL(selectAll()), this);
mZoomInAction = KStandardAction::zoomIn(this, SIGNAL(zoomIn()), this);
mZoomOutAction = KStandardAction::zoomOut(this, SIGNAL(zoomOut()), this);
+ mPrintAction = KStandardAction::print(this, SIGNAL(print()), this);
+ mPrintPreviewAction = KStandardAction::printPreview(this, SIGNAL(printPreview()), this);
+
mZoomResetAction = new QAction(i18nc("Reset the zoom", "Reset"), this);
mZoomResetAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_0));
@@ -107,6 +113,8 @@ QMenu *SieveEditorMenuBar::editorMenu() const
void SieveEditorMenuBar::initMenus()
{
mFileMenu = addMenu(i18nc("@title:menu", "File"));
+ mFileMenu->addAction(mPrintAction);
+ mFileMenu->addAction(mPrintPreviewAction);
mEditorMenu = addMenu(i18nc("@title:menu", "Edit"));
mToolsMenu = addMenu(i18nc("@title:menu", "Tools"));
mEditorMenu->addAction(mUndoAction);
@@ -135,6 +143,16 @@ void SieveEditorMenuBar::initMenus()
mToolsMenu->addAction(mDebugSieveAction);
}
+QAction *SieveEditorMenuBar::printAction() const
+{
+ return mPrintAction;
+}
+
+QAction *SieveEditorMenuBar::printPreviewAction() const
+{
+ return mPrintPreviewAction;
+}
+
QAction *SieveEditorMenuBar::uncommentCodeAction() const
{
return mUncommentCodeAction;
diff --git a/src/ksieveui/editor/sieveeditormenubar.h b/src/ksieveui/editor/sieveeditormenubar.h
index 3b585c1..1b31580 100644
--- a/src/ksieveui/editor/sieveeditormenubar.h
+++ b/src/ksieveui/editor/sieveeditormenubar.h
@@ -57,6 +57,10 @@ public:
QAction *zoomResetAction() const;
QAction *wordWrapAction() const;
+ QAction *printPreviewAction() const;
+
+ QAction *printAction() const;
+
public Q_SLOTS:
void setEditorMode(bool editorMode);
void slotUndoAvailable(bool b);
@@ -79,6 +83,8 @@ Q_SIGNALS:
void debugSieveScript();
void zoomReset();
void wordWrap(bool state);
+ void print();
+ void printPreview();
private:
void initActions();
@@ -99,6 +105,9 @@ private:
QAction *mZoomResetAction;
QAction *mDebugSieveAction;
QAction *mWordWrapAction;
+ QAction *mPrintAction;
+ QAction *mPrintPreviewAction;
+
QMenu *mEditorMenu;
QMenu *mToolsMenu;
QMenu *mFileMenu;
diff --git a/src/ksieveui/editor/sieveeditorwidget.cpp b/src/ksieveui/editor/sieveeditorwidget.cpp
index 45a4efb..63ed08d 100644
--- a/src/ksieveui/editor/sieveeditorwidget.cpp
+++ b/src/ksieveui/editor/sieveeditorwidget.cpp
@@ -112,6 +112,8 @@ SieveEditorWidget::SieveEditorWidget(bool useMenuBar, QWidget *parent)
connect(menuBar, &SieveEditorMenuBar::zoomReset, this, &SieveEditorWidget::zoomReset);
connect(menuBar, &SieveEditorMenuBar::debugSieveScript, this, &SieveEditorWidget::debugSieveScript);
connect(menuBar, &SieveEditorMenuBar::wordWrap, this, &SieveEditorWidget::wordWrap);
+ connect(menuBar, &SieveEditorMenuBar::print, this, &SieveEditorWidget::print);
+ connect(menuBar, &SieveEditorMenuBar::printPreview, this, &SieveEditorWidget::printPreview);
connect(this, &SieveEditorWidget::copyAvailable, menuBar, &SieveEditorMenuBar::slotCopyAvailable);
connect(this, &SieveEditorWidget::redoAvailable, menuBar, &SieveEditorMenuBar::slotRedoAvailable);