From 733d514436d4bc00876fd9ab17ce99ef2101cf37 Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 <0xFEEDC0DE64@gmail.com> Date: Thu, 12 Apr 2018 19:57:11 +0200 Subject: [PATCH] Added sketch viewer window --- plugins/sketchplugin/sketchmainwindow.cpp | 14 +++++++++++++ plugins/sketchplugin/sketchmainwindow.h | 22 +++++++++++++++++++++ plugins/sketchplugin/sketchmainwindow.ui | 24 +++++++++++++++++++++++ plugins/sketchplugin/sketchplugin.cpp | 11 ++++++++++- plugins/sketchplugin/sketchplugin.h | 3 +++ plugins/sketchplugin/sketchplugin.pro | 8 +++++--- 6 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 plugins/sketchplugin/sketchmainwindow.cpp create mode 100644 plugins/sketchplugin/sketchmainwindow.h create mode 100644 plugins/sketchplugin/sketchmainwindow.ui diff --git a/plugins/sketchplugin/sketchmainwindow.cpp b/plugins/sketchplugin/sketchmainwindow.cpp new file mode 100644 index 0000000..fc8f26a --- /dev/null +++ b/plugins/sketchplugin/sketchmainwindow.cpp @@ -0,0 +1,14 @@ +#include "sketchmainwindow.h" +#include "ui_sketchmainwindow.h" + +SketchMainWindow::SketchMainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::SketchMainWindow) +{ + ui->setupUi(this); +} + +SketchMainWindow::~SketchMainWindow() +{ + delete ui; +} diff --git a/plugins/sketchplugin/sketchmainwindow.h b/plugins/sketchplugin/sketchmainwindow.h new file mode 100644 index 0000000..ede19cb --- /dev/null +++ b/plugins/sketchplugin/sketchmainwindow.h @@ -0,0 +1,22 @@ +#ifndef SKETCHMAINWINDOW_H +#define SKETCHMAINWINDOW_H + +#include + +namespace Ui { +class SketchMainWindow; +} + +class SketchMainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit SketchMainWindow(QWidget *parent = 0); + ~SketchMainWindow(); + +private: + Ui::SketchMainWindow *ui; +}; + +#endif // SKETCHMAINWINDOW_H diff --git a/plugins/sketchplugin/sketchmainwindow.ui b/plugins/sketchplugin/sketchmainwindow.ui new file mode 100644 index 0000000..71a9d3b --- /dev/null +++ b/plugins/sketchplugin/sketchmainwindow.ui @@ -0,0 +1,24 @@ + + + + + SketchMainWindow + + + + 0 + 0 + 800 + 600 + + + + MainWindow + + + + + + + + diff --git a/plugins/sketchplugin/sketchplugin.cpp b/plugins/sketchplugin/sketchplugin.cpp index 9acc62e..0d65840 100644 --- a/plugins/sketchplugin/sketchplugin.cpp +++ b/plugins/sketchplugin/sketchplugin.cpp @@ -8,6 +8,7 @@ #include #include "mainwindow.h" +#include "sketchmainwindow.h" SketchPlugin::SketchPlugin(QObject *parent) : ZeiterfassungPlugin(parent) @@ -31,5 +32,13 @@ SketchPlugin::SketchPlugin(QObject *parent) : void SketchPlugin::attachTo(MainWindow &mainWindow) { - mainWindow.menuTools()->addAction(QIcon(QStringLiteral(":/zeiterfassung/plugins/sketchplugin/images/sketch.png")), tr("Open Sketch viewer")); + mainWindow.menuTools()->addAction(QIcon(QStringLiteral(":/zeiterfassung/plugins/sketchplugin/images/sketch.png")), tr("Open Sketch viewer"), + this, &SketchPlugin::openWindow); +} + +void SketchPlugin::openWindow() +{ + auto window = new SketchMainWindow; + window->setAttribute(Qt::WA_DeleteOnClose); + window->show(); } diff --git a/plugins/sketchplugin/sketchplugin.h b/plugins/sketchplugin/sketchplugin.h index 991b067..4285c74 100644 --- a/plugins/sketchplugin/sketchplugin.h +++ b/plugins/sketchplugin/sketchplugin.h @@ -19,6 +19,9 @@ public: // ZeiterfassungPlugin interface void attachTo(MainWindow &mainWindow) Q_DECL_OVERRIDE; +private Q_SLOTS: + void openWindow(); + private: QTranslator m_translator; }; diff --git a/plugins/sketchplugin/sketchplugin.pro b/plugins/sketchplugin/sketchplugin.pro index 4414097..bbc92f6 100644 --- a/plugins/sketchplugin/sketchplugin.pro +++ b/plugins/sketchplugin/sketchplugin.pro @@ -4,11 +4,13 @@ TARGET = sketchplugin DBLIBS += core gui -HEADERS += sketchplugin.h +HEADERS += sketchmainwindow.h \ + sketchplugin.h -SOURCES += sketchplugin.cpp +SOURCES += sketchmainwindow.cpp \ + sketchplugin.cpp -FORMS += +FORMS += sketchmainwindow.ui RESOURCES += sketchplugin_resources.qrc