Commit 9e62ddeb authored by Laurent Montel's avatar Laurent Montel 😁

add print/printpreview in tabbar

parent e4da5431
...@@ -56,6 +56,8 @@ void SieveEditorMenuBarTest::shouldDisableActions() ...@@ -56,6 +56,8 @@ void SieveEditorMenuBarTest::shouldDisableActions()
QVERIFY(!bar.cutAction()->isEnabled()); QVERIFY(!bar.cutAction()->isEnabled());
QVERIFY(bar.selectAllAction()->isEnabled()); QVERIFY(bar.selectAllAction()->isEnabled());
QVERIFY(bar.wordWrapAction()->isEnabled()); QVERIFY(bar.wordWrapAction()->isEnabled());
QVERIFY(bar.printAction()->isEnabled());
QVERIFY(bar.printPreviewAction()->isEnabled());
bar.setEditorMode(false); bar.setEditorMode(false);
QVERIFY(!bar.goToLineAction()->isEnabled()); QVERIFY(!bar.goToLineAction()->isEnabled());
...@@ -79,6 +81,9 @@ void SieveEditorMenuBarTest::shouldDisableActions() ...@@ -79,6 +81,9 @@ void SieveEditorMenuBarTest::shouldDisableActions()
QVERIFY(!bar.cutAction()->isEnabled()); QVERIFY(!bar.cutAction()->isEnabled());
QVERIFY(!bar.selectAllAction()->isEnabled()); QVERIFY(!bar.selectAllAction()->isEnabled());
QVERIFY(!bar.wordWrapAction()->isEnabled()); QVERIFY(!bar.wordWrapAction()->isEnabled());
QVERIFY(!bar.printAction()->isEnabled());
QVERIFY(!bar.printPreviewAction()->isEnabled());
bar.setEditorMode(true); bar.setEditorMode(true);
QVERIFY(bar.goToLineAction()->isEnabled()); QVERIFY(bar.goToLineAction()->isEnabled());
...@@ -102,6 +107,9 @@ void SieveEditorMenuBarTest::shouldDisableActions() ...@@ -102,6 +107,9 @@ void SieveEditorMenuBarTest::shouldDisableActions()
QVERIFY(bar.cutAction()->isEnabled()); QVERIFY(bar.cutAction()->isEnabled());
QVERIFY(bar.selectAllAction()->isEnabled()); QVERIFY(bar.selectAllAction()->isEnabled());
QVERIFY(bar.wordWrapAction()->isEnabled()); QVERIFY(bar.wordWrapAction()->isEnabled());
QVERIFY(bar.printAction()->isEnabled());
QVERIFY(bar.printPreviewAction()->isEnabled());
} }
void SieveEditorMenuBarTest::shouldHaveDefaultValue() void SieveEditorMenuBarTest::shouldHaveDefaultValue()
...@@ -126,9 +134,11 @@ void SieveEditorMenuBarTest::shouldHaveDefaultValue() ...@@ -126,9 +134,11 @@ void SieveEditorMenuBarTest::shouldHaveDefaultValue()
QVERIFY(bar.uncommentCodeAction()); QVERIFY(bar.uncommentCodeAction());
QVERIFY(bar.debugSieveScriptAction()); QVERIFY(bar.debugSieveScriptAction());
QVERIFY(bar.wordWrapAction()); QVERIFY(bar.wordWrapAction());
QVERIFY(bar.printAction());
QVERIFY(bar.printPreviewAction());
QCOMPARE(bar.actions().count(), 3); QCOMPARE(bar.actions().count(), 3);
QCOMPARE(bar.editorMenu()->actions().count(), 19); QCOMPARE(bar.editorMenu()->actions().count(), 19);
QCOMPARE(bar.fileMenu()->actions().count(), 0); QCOMPARE(bar.fileMenu()->actions().count(), 2);
QCOMPARE(bar.toolsMenu()->actions().count(), 4); QCOMPARE(bar.toolsMenu()->actions().count(), 4);
QVERIFY(bar.findAction()->isEnabled()); QVERIFY(bar.findAction()->isEnabled());
...@@ -192,6 +202,13 @@ void SieveEditorMenuBarTest::shouldEmitSignals() ...@@ -192,6 +202,13 @@ void SieveEditorMenuBarTest::shouldEmitSignals()
QSignalSpy spyWordWrapScript(&bar, SIGNAL(wordWrap(bool))); QSignalSpy spyWordWrapScript(&bar, SIGNAL(wordWrap(bool)));
bar.wordWrapAction()->trigger(); bar.wordWrapAction()->trigger();
QSignalSpy spyPrint(&bar, SIGNAL(print()));
bar.printAction()->trigger();
QSignalSpy spyPrintPreview(&bar, SIGNAL(printPreview()));
bar.printPreviewAction()->trigger();
QCOMPARE(spyZoomOut.count(), 1); QCOMPARE(spyZoomOut.count(), 1);
QCOMPARE(spyZoomIn.count(), 1); QCOMPARE(spyZoomIn.count(), 1);
QCOMPARE(spyUnComment.count(), 1); QCOMPARE(spyUnComment.count(), 1);
...@@ -208,6 +225,8 @@ void SieveEditorMenuBarTest::shouldEmitSignals() ...@@ -208,6 +225,8 @@ void SieveEditorMenuBarTest::shouldEmitSignals()
QCOMPARE(spyZoomReset.count(), 1); QCOMPARE(spyZoomReset.count(), 1);
QCOMPARE(spyDebugScript.count(), 1); QCOMPARE(spyDebugScript.count(), 1);
QCOMPARE(spyWordWrapScript.count(), 1); QCOMPARE(spyWordWrapScript.count(), 1);
QCOMPARE(spyPrint.count(), 1);
QCOMPARE(spyPrintPreview.count(), 1);
} }
QTEST_MAIN(SieveEditorMenuBarTest) QTEST_MAIN(SieveEditorMenuBarTest)
...@@ -53,6 +53,9 @@ void SieveEditorMenuBar::setEditorMode(bool editorMode) ...@@ -53,6 +53,9 @@ void SieveEditorMenuBar::setEditorMode(bool editorMode)
mZoomResetAction->setEnabled(editorMode); mZoomResetAction->setEnabled(editorMode);
mDebugSieveAction->setEnabled(editorMode); mDebugSieveAction->setEnabled(editorMode);
mWordWrapAction->setEnabled(editorMode); mWordWrapAction->setEnabled(editorMode);
mPrintAction->setEnabled(editorMode);
mPrintPreviewAction->setEnabled(editorMode);
} }
void SieveEditorMenuBar::initActions() void SieveEditorMenuBar::initActions()
...@@ -84,6 +87,9 @@ void SieveEditorMenuBar::initActions() ...@@ -84,6 +87,9 @@ void SieveEditorMenuBar::initActions()
mSelectAllAction = KStandardAction::selectAll(this, SIGNAL(selectAll()), this); mSelectAllAction = KStandardAction::selectAll(this, SIGNAL(selectAll()), this);
mZoomInAction = KStandardAction::zoomIn(this, SIGNAL(zoomIn()), this); mZoomInAction = KStandardAction::zoomIn(this, SIGNAL(zoomIn()), this);
mZoomOutAction = KStandardAction::zoomOut(this, SIGNAL(zoomOut()), 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 = new QAction(i18nc("Reset the zoom", "Reset"), this);
mZoomResetAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_0)); mZoomResetAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_0));
...@@ -107,6 +113,8 @@ QMenu *SieveEditorMenuBar::editorMenu() const ...@@ -107,6 +113,8 @@ QMenu *SieveEditorMenuBar::editorMenu() const
void SieveEditorMenuBar::initMenus() void SieveEditorMenuBar::initMenus()
{ {
mFileMenu = addMenu(i18nc("@title:menu", "File")); mFileMenu = addMenu(i18nc("@title:menu", "File"));
mFileMenu->addAction(mPrintAction);
mFileMenu->addAction(mPrintPreviewAction);
mEditorMenu = addMenu(i18nc("@title:menu", "Edit")); mEditorMenu = addMenu(i18nc("@title:menu", "Edit"));
mToolsMenu = addMenu(i18nc("@title:menu", "Tools")); mToolsMenu = addMenu(i18nc("@title:menu", "Tools"));
mEditorMenu->addAction(mUndoAction); mEditorMenu->addAction(mUndoAction);
...@@ -135,6 +143,16 @@ void SieveEditorMenuBar::initMenus() ...@@ -135,6 +143,16 @@ void SieveEditorMenuBar::initMenus()
mToolsMenu->addAction(mDebugSieveAction); mToolsMenu->addAction(mDebugSieveAction);
} }
QAction *SieveEditorMenuBar::printAction() const
{
return mPrintAction;
}
QAction *SieveEditorMenuBar::printPreviewAction() const
{
return mPrintPreviewAction;
}
QAction *SieveEditorMenuBar::uncommentCodeAction() const QAction *SieveEditorMenuBar::uncommentCodeAction() const
{ {
return mUncommentCodeAction; return mUncommentCodeAction;
......
...@@ -57,6 +57,10 @@ public: ...@@ -57,6 +57,10 @@ public:
QAction *zoomResetAction() const; QAction *zoomResetAction() const;
QAction *wordWrapAction() const; QAction *wordWrapAction() const;
QAction *printPreviewAction() const;
QAction *printAction() const;
public Q_SLOTS: public Q_SLOTS:
void setEditorMode(bool editorMode); void setEditorMode(bool editorMode);
void slotUndoAvailable(bool b); void slotUndoAvailable(bool b);
...@@ -79,6 +83,8 @@ Q_SIGNALS: ...@@ -79,6 +83,8 @@ Q_SIGNALS:
void debugSieveScript(); void debugSieveScript();
void zoomReset(); void zoomReset();
void wordWrap(bool state); void wordWrap(bool state);
void print();
void printPreview();
private: private:
void initActions(); void initActions();
...@@ -99,6 +105,9 @@ private: ...@@ -99,6 +105,9 @@ private:
QAction *mZoomResetAction; QAction *mZoomResetAction;
QAction *mDebugSieveAction; QAction *mDebugSieveAction;
QAction *mWordWrapAction; QAction *mWordWrapAction;
QAction *mPrintAction;
QAction *mPrintPreviewAction;
QMenu *mEditorMenu; QMenu *mEditorMenu;
QMenu *mToolsMenu; QMenu *mToolsMenu;
QMenu *mFileMenu; QMenu *mFileMenu;
......
...@@ -112,6 +112,8 @@ SieveEditorWidget::SieveEditorWidget(bool useMenuBar, QWidget *parent) ...@@ -112,6 +112,8 @@ SieveEditorWidget::SieveEditorWidget(bool useMenuBar, QWidget *parent)
connect(menuBar, &SieveEditorMenuBar::zoomReset, this, &SieveEditorWidget::zoomReset); connect(menuBar, &SieveEditorMenuBar::zoomReset, this, &SieveEditorWidget::zoomReset);
connect(menuBar, &SieveEditorMenuBar::debugSieveScript, this, &SieveEditorWidget::debugSieveScript); connect(menuBar, &SieveEditorMenuBar::debugSieveScript, this, &SieveEditorWidget::debugSieveScript);
connect(menuBar, &SieveEditorMenuBar::wordWrap, this, &SieveEditorWidget::wordWrap); 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::copyAvailable, menuBar, &SieveEditorMenuBar::slotCopyAvailable);
connect(this, &SieveEditorWidget::redoAvailable, menuBar, &SieveEditorMenuBar::slotRedoAvailable); connect(this, &SieveEditorWidget::redoAvailable, menuBar, &SieveEditorMenuBar::slotRedoAvailable);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment