From 9c1e992b4203605f8b26821fa936d988ee7edddc Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 <0xFEEDC0DE64@gmail.com> Date: Wed, 11 Apr 2018 23:39:59 +0200 Subject: [PATCH 01/11] Fixed loading of translations of corelib --- zeiterfassung/main.cpp | 8 +++++--- zeiterfassungcorelib/zeiterfassungcorelib.pro | 4 ++-- zeiterfassungguilib/zeiterfassungguilib.pro | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/zeiterfassung/main.cpp b/zeiterfassung/main.cpp index 21a4aef..b185274 100755 --- a/zeiterfassung/main.cpp +++ b/zeiterfassung/main.cpp @@ -31,6 +31,7 @@ struct { QTranslator qtTranslator; QTranslator zeiterfassungTranslator; + QTranslator zeiterfassungcorelibTranslator; QTranslator zeiterfassungguilibTranslator; } translators; @@ -80,9 +81,10 @@ bool loadTranslations(QSplashScreen &splashScreen, ZeiterfassungSettings &settin QLocale::setDefault(QLocale(settings.language(), QLocale::Austria)); - loadAndInstallTranslator(translators.qtTranslator, QStringLiteral("qt")); - loadAndInstallTranslator(translators.zeiterfassungTranslator, QStringLiteral("zeiterfassung")); - loadAndInstallTranslator(translators.zeiterfassungguilibTranslator, QStringLiteral("zeiterfassungguilib")); + loadAndInstallTranslator(translators.qtTranslator, QStringLiteral("qt")); + loadAndInstallTranslator(translators.zeiterfassungTranslator, QStringLiteral("zeiterfassung")); + loadAndInstallTranslator(translators.zeiterfassungcorelibTranslator, QStringLiteral("zeiterfassungcorelib")); + loadAndInstallTranslator(translators.zeiterfassungguilibTranslator, QStringLiteral("zeiterfassungguilib")); return true; } diff --git a/zeiterfassungcorelib/zeiterfassungcorelib.pro b/zeiterfassungcorelib/zeiterfassungcorelib.pro index ad1b953..f64770b 100644 --- a/zeiterfassungcorelib/zeiterfassungcorelib.pro +++ b/zeiterfassungcorelib/zeiterfassungcorelib.pro @@ -54,7 +54,7 @@ FORMS += RESOURCES += -TRANSLATIONS += translations/zeiterfassungcorelib_en.ts \ - translations/zeiterfassungcorelib_de.ts +TRANSLATIONS += translations/zeiterfassungcorelib_en.ts \ + translations/zeiterfassungcorelib_de.ts include($${PROJECT_ROOT}/project.pri) diff --git a/zeiterfassungguilib/zeiterfassungguilib.pro b/zeiterfassungguilib/zeiterfassungguilib.pro index 61021a1..617b6f6 100644 --- a/zeiterfassungguilib/zeiterfassungguilib.pro +++ b/zeiterfassungguilib/zeiterfassungguilib.pro @@ -38,8 +38,8 @@ FORMS += mainwindow.ui \ RESOURCES += zeiterfassungguilib_resources.qrc -TRANSLATIONS += translations/zeiterfassungguilib_en.ts \ - translations/zeiterfassungguilib_de.ts +TRANSLATIONS += translations/zeiterfassungguilib_en.ts \ + translations/zeiterfassungguilib_de.ts include($${PROJECT_ROOT}/project.pri) -- 2.50.1 From 40168628c2d37976e971785abb1a4dc6ecb3e12e Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 <0xFEEDC0DE64@gmail.com> Date: Wed, 11 Apr 2018 23:48:17 +0200 Subject: [PATCH 02/11] Added sketchplugin project --- plugins/plugins.pro | 1 + plugins/sketchplugin/sketchplugin.cpp | 26 +++++++++++++++++++ plugins/sketchplugin/sketchplugin.h | 21 +++++++++++++++ plugins/sketchplugin/sketchplugin.json | 0 plugins/sketchplugin/sketchplugin.pro | 20 ++++++++++++++ .../sketchplugin/sketchplugin_resources.qrc | 4 +++ .../translations/sketchplugin_de.ts | 4 +++ .../translations/sketchplugin_en.ts | 4 +++ 8 files changed, 80 insertions(+) create mode 100644 plugins/sketchplugin/sketchplugin.cpp create mode 100644 plugins/sketchplugin/sketchplugin.h create mode 100644 plugins/sketchplugin/sketchplugin.json create mode 100644 plugins/sketchplugin/sketchplugin.pro create mode 100644 plugins/sketchplugin/sketchplugin_resources.qrc create mode 100644 plugins/sketchplugin/translations/sketchplugin_de.ts create mode 100644 plugins/sketchplugin/translations/sketchplugin_en.ts diff --git a/plugins/plugins.pro b/plugins/plugins.pro index 2857a61..09d0bcd 100644 --- a/plugins/plugins.pro +++ b/plugins/plugins.pro @@ -7,6 +7,7 @@ SUBDIRS += absenceplugin \ profileplugin \ presenceplugin \ reportsplugin \ + sketchplugin \ updaterplugin \ weatherplugin \ webradioplugin diff --git a/plugins/sketchplugin/sketchplugin.cpp b/plugins/sketchplugin/sketchplugin.cpp new file mode 100644 index 0000000..1e7b643 --- /dev/null +++ b/plugins/sketchplugin/sketchplugin.cpp @@ -0,0 +1,26 @@ +#include "sketchplugin.h" + +#include +#include +#include +#include + +SketchPlugin::SketchPlugin(QObject *parent) : + ZeiterfassungPlugin(parent) +{ + qDebug() << "called"; + + static auto dir = QDir(QCoreApplication::applicationDirPath()).absoluteFilePath(QStringLiteral("translations")); + + if(m_translator.load(QLocale(), QStringLiteral("sketchplugin"), QStringLiteral("_"), dir)) + { + if(!QCoreApplication::installTranslator(&m_translator)) + { + qWarning() << "could not install translation sketchplugin"; + } + } + else + { + qWarning() << "could not load translation sketchplugin"; + } +} diff --git a/plugins/sketchplugin/sketchplugin.h b/plugins/sketchplugin/sketchplugin.h new file mode 100644 index 0000000..471d06c --- /dev/null +++ b/plugins/sketchplugin/sketchplugin.h @@ -0,0 +1,21 @@ +#pragma once + +#include +#include + +#include "zeiterfassungplugin.h" + +class MainWindow; + +class Q_DECL_EXPORT SketchPlugin : public ZeiterfassungPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "dbsoftware.zeiterfassung.plugin/1.0" FILE "sketchplugin.json") + Q_INTERFACES(ZeiterfassungPlugin) + +public: + explicit SketchPlugin(QObject *parent = Q_NULLPTR); + +private: + QTranslator m_translator; +}; diff --git a/plugins/sketchplugin/sketchplugin.json b/plugins/sketchplugin/sketchplugin.json new file mode 100644 index 0000000..e69de29 diff --git a/plugins/sketchplugin/sketchplugin.pro b/plugins/sketchplugin/sketchplugin.pro new file mode 100644 index 0000000..6929490 --- /dev/null +++ b/plugins/sketchplugin/sketchplugin.pro @@ -0,0 +1,20 @@ +QT += core network gui widgets + +TARGET = sketchplugin + +DBLIBS += core gui + +HEADERS += sketchplugin.h + +SOURCES += sketchplugin.cpp + +FORMS += + +RESOURCES += sketchplugin_resources.qrc + +TRANSLATIONS += translations/sketchplugin_en.ts \ + translations/sketchplugin_de.ts + +OTHER_FILES += sketchplugin.json + +include(../plugin.pri) diff --git a/plugins/sketchplugin/sketchplugin_resources.qrc b/plugins/sketchplugin/sketchplugin_resources.qrc new file mode 100644 index 0000000..b69afa7 --- /dev/null +++ b/plugins/sketchplugin/sketchplugin_resources.qrc @@ -0,0 +1,4 @@ + + + + diff --git a/plugins/sketchplugin/translations/sketchplugin_de.ts b/plugins/sketchplugin/translations/sketchplugin_de.ts new file mode 100644 index 0000000..1552582 --- /dev/null +++ b/plugins/sketchplugin/translations/sketchplugin_de.ts @@ -0,0 +1,4 @@ + + + + diff --git a/plugins/sketchplugin/translations/sketchplugin_en.ts b/plugins/sketchplugin/translations/sketchplugin_en.ts new file mode 100644 index 0000000..bc6d6e7 --- /dev/null +++ b/plugins/sketchplugin/translations/sketchplugin_en.ts @@ -0,0 +1,4 @@ + + + + -- 2.50.1 From 412c083c9ea24fb4e111b2b40fbb5377ccc2099a Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 <0xFEEDC0DE64@gmail.com> Date: Wed, 11 Apr 2018 23:50:33 +0200 Subject: [PATCH 03/11] Added QtSketch submodule --- .gitmodules | 3 +++ plugins/sketchplugin/QtSketch | 1 + 2 files changed, 4 insertions(+) create mode 160000 plugins/sketchplugin/QtSketch diff --git a/.gitmodules b/.gitmodules index 464f0ed..627633b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "zeiterfassungguilib/QStringListWidget"] path = zeiterfassungguilib/QStringListWidget url = https://github.com/0xFEEDC0DE64/QStringListWidget.git +[submodule "plugins/sketchplugin/QtSketch"] + path = plugins/sketchplugin/QtSketch + url = https://github.com/0xFEEDC0DE64/QtSketch.git diff --git a/plugins/sketchplugin/QtSketch b/plugins/sketchplugin/QtSketch new file mode 160000 index 0000000..a059f6a --- /dev/null +++ b/plugins/sketchplugin/QtSketch @@ -0,0 +1 @@ +Subproject commit a059f6a157868670a4311021d311688a7a72fa3e -- 2.50.1 From 3214f2f1e18ea5716668dc9f405456584a834c15 Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 <0xFEEDC0DE64@gmail.com> Date: Thu, 12 Apr 2018 00:03:44 +0200 Subject: [PATCH 04/11] sketchlib now gets compiled with sketch plugin --- plugins/sketchplugin/QtSketch | 2 +- plugins/sketchplugin/sketchplugin.pro | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/sketchplugin/QtSketch b/plugins/sketchplugin/QtSketch index a059f6a..e510829 160000 --- a/plugins/sketchplugin/QtSketch +++ b/plugins/sketchplugin/QtSketch @@ -1 +1 @@ -Subproject commit a059f6a157868670a4311021d311688a7a72fa3e +Subproject commit e510829dfdb2b83b6ed82e48d6a069f834b8baa6 diff --git a/plugins/sketchplugin/sketchplugin.pro b/plugins/sketchplugin/sketchplugin.pro index 6929490..4414097 100644 --- a/plugins/sketchplugin/sketchplugin.pro +++ b/plugins/sketchplugin/sketchplugin.pro @@ -18,3 +18,5 @@ TRANSLATIONS += translations/sketchplugin_en.ts \ OTHER_FILES += sketchplugin.json include(../plugin.pri) + +include(QtSketch/sketchlib.pri) -- 2.50.1 From 9502a77073a55bfd1e4605e1e8ab1333f32b9ec6 Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 <0xFEEDC0DE64@gmail.com> Date: Thu, 12 Apr 2018 00:06:27 +0200 Subject: [PATCH 05/11] Updated QStringListWidget lib --- zeiterfassungguilib/QStringListWidget | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zeiterfassungguilib/QStringListWidget b/zeiterfassungguilib/QStringListWidget index a975450..f83c27a 160000 --- a/zeiterfassungguilib/QStringListWidget +++ b/zeiterfassungguilib/QStringListWidget @@ -1 +1 @@ -Subproject commit a975450b63ba065bc2036f0b413eeec95fb1ccb8 +Subproject commit f83c27ab3cbfa2804f38329b24df561afc3b08f2 -- 2.50.1 From 80d8a6bd87a34a12d39e7997b60b78bcb27c796d Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 <0xFEEDC0DE64@gmail.com> Date: Thu, 12 Apr 2018 00:08:27 +0200 Subject: [PATCH 06/11] Eliminated the need for QStringListWidget include prefix --- plugins/webradioplugin/webradiosettingswidget.cpp | 2 +- project.pri | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/webradioplugin/webradiosettingswidget.cpp b/plugins/webradioplugin/webradiosettingswidget.cpp index 84ab61c..c66eff1 100644 --- a/plugins/webradioplugin/webradiosettingswidget.cpp +++ b/plugins/webradioplugin/webradiosettingswidget.cpp @@ -2,7 +2,7 @@ #include -#include "QStringListWidget/qstringlistwidget.h" +#include "qstringlistwidget.h" WebRadioSettingsWidget::WebRadioSettingsWidget(ZeiterfassungSettings &settings, QWidget *parent) : SettingsWidget(parent), diff --git a/project.pri b/project.pri index 23337c2..bffcdcc 100644 --- a/project.pri +++ b/project.pri @@ -24,8 +24,8 @@ contains(DBLIBS, core) { contains(DBLIBS, gui) { LIBS += -lzeiterfassungguilib - INCLUDEPATH += $$PWD/zeiterfassungguilib - DEPENDPATH += $$PWD/zeiterfassungguilib + INCLUDEPATH += $$PWD/zeiterfassungguilib $$PWD/zeiterfassungguilib/QStringListWidget + DEPENDPATH += $$PWD/zeiterfassungguilib $$PWD/zeiterfassungguilib/QStringListWidget } isEmpty(QMAKE_LRELEASE) { -- 2.50.1 From 45d901191c598e79baa251d5e2d398549f142ced Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 <0xFEEDC0DE64@gmail.com> Date: Thu, 12 Apr 2018 19:41:27 +0200 Subject: [PATCH 07/11] Updated QtSketch library --- plugins/sketchplugin/QtSketch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/sketchplugin/QtSketch b/plugins/sketchplugin/QtSketch index e510829..6a0122c 160000 --- a/plugins/sketchplugin/QtSketch +++ b/plugins/sketchplugin/QtSketch @@ -1 +1 @@ -Subproject commit e510829dfdb2b83b6ed82e48d6a069f834b8baa6 +Subproject commit 6a0122cf268e4cea87d1d80bc8458b438dd1b1db -- 2.50.1 From 61c52b8d777610ca6c4950850b6a20156f2e6c44 Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 <0xFEEDC0DE64@gmail.com> Date: Thu, 12 Apr 2018 19:53:14 +0200 Subject: [PATCH 08/11] Implemented menu action for sketch viewer --- plugins/sketchplugin/QtSketch | 2 +- plugins/sketchplugin/images/sketch.png | Bin 0 -> 3139 bytes plugins/sketchplugin/sketchplugin.cpp | 9 +++++++++ plugins/sketchplugin/sketchplugin.h | 3 +++ plugins/sketchplugin/sketchplugin_resources.qrc | 1 + 5 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 plugins/sketchplugin/images/sketch.png diff --git a/plugins/sketchplugin/QtSketch b/plugins/sketchplugin/QtSketch index 6a0122c..534892b 160000 --- a/plugins/sketchplugin/QtSketch +++ b/plugins/sketchplugin/QtSketch @@ -1 +1 @@ -Subproject commit 6a0122cf268e4cea87d1d80bc8458b438dd1b1db +Subproject commit 534892b633ee07af16d2ce0f5a86459c3880fe91 diff --git a/plugins/sketchplugin/images/sketch.png b/plugins/sketchplugin/images/sketch.png new file mode 100644 index 0000000000000000000000000000000000000000..05310ffe63965d93c364c66d3b4a626b0986d124 GIT binary patch literal 3139 zcmeAS@N?(olHy`uVBq!ia0y~yU~m9o4mJh`hElEaktaqI1@+zCsr zh90kferNga=X;kw@7<6PvuVvE?#KzNa>5P=F?~{E<;<7#+MLtl=`eYU-jOMe+&bYt z8uZ*20_MBVFiEG~oq2ceyO-~t@BIGbp`GpN zGv{~?`+aBWwhTV+6Yl$c@AH4}cRv4f{=Zqyjka76`Zeq4uiws}C$t`G{9(c$`Qd8+ ze~p@nWqi}F#v2?mnIwDskLQVH2mPJRnCqlYr%lLV`{P})K47OElhI$(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plugin/sketchplugin.cpp index 1e7b643..9acc62e 100644 --- a/plugins/sketchplugin/sketchplugin.cpp +++ b/plugins/sketchplugin/sketchplugin.cpp @@ -4,6 +4,10 @@ #include #include #include +#include +#include + +#include "mainwindow.h" SketchPlugin::SketchPlugin(QObject *parent) : ZeiterfassungPlugin(parent) @@ -24,3 +28,8 @@ SketchPlugin::SketchPlugin(QObject *parent) : qWarning() << "could not load translation sketchplugin"; } } + +void SketchPlugin::attachTo(MainWindow &mainWindow) +{ + mainWindow.menuTools()->addAction(QIcon(QStringLiteral(":/zeiterfassung/plugins/sketchplugin/images/sketch.png")), tr("Open Sketch viewer")); +} diff --git a/plugins/sketchplugin/sketchplugin.h b/plugins/sketchplugin/sketchplugin.h index 471d06c..991b067 100644 --- a/plugins/sketchplugin/sketchplugin.h +++ b/plugins/sketchplugin/sketchplugin.h @@ -16,6 +16,9 @@ class Q_DECL_EXPORT SketchPlugin : public ZeiterfassungPlugin public: explicit SketchPlugin(QObject *parent = Q_NULLPTR); + // ZeiterfassungPlugin interface + void attachTo(MainWindow &mainWindow) Q_DECL_OVERRIDE; + private: QTranslator m_translator; }; diff --git a/plugins/sketchplugin/sketchplugin_resources.qrc b/plugins/sketchplugin/sketchplugin_resources.qrc index b69afa7..01ae86b 100644 --- a/plugins/sketchplugin/sketchplugin_resources.qrc +++ b/plugins/sketchplugin/sketchplugin_resources.qrc @@ -1,4 +1,5 @@ + images/sketch.png -- 2.50.1 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 09/11] 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 -- 2.50.1 From a1ec681ee0276d9f9d2fff0231b7b9aca49f49c5 Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 <0xFEEDC0DE64@gmail.com> Date: Thu, 12 Apr 2018 20:11:07 +0200 Subject: [PATCH 10/11] Added file open dialog --- plugins/sketchplugin/sketchmainwindow.cpp | 12 ++++ plugins/sketchplugin/sketchmainwindow.h | 3 + plugins/sketchplugin/sketchmainwindow.ui | 69 +++++++++++++++++++---- 3 files changed, 74 insertions(+), 10 deletions(-) diff --git a/plugins/sketchplugin/sketchmainwindow.cpp b/plugins/sketchplugin/sketchmainwindow.cpp index fc8f26a..c9e23c4 100644 --- a/plugins/sketchplugin/sketchmainwindow.cpp +++ b/plugins/sketchplugin/sketchmainwindow.cpp @@ -1,14 +1,26 @@ #include "sketchmainwindow.h" #include "ui_sketchmainwindow.h" +#include + SketchMainWindow::SketchMainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::SketchMainWindow) { ui->setupUi(this); + + ui->actionOpen->setShortcut(QKeySequence::Open); + ui->actionQuit->setShortcut(QKeySequence::Quit); + + connect(ui->actionOpen, &QAction::triggered, this, &SketchMainWindow::openPressed); } SketchMainWindow::~SketchMainWindow() { delete ui; } + +void SketchMainWindow::openPressed() +{ + QFileDialog::getOpenFileName(this, tr("Select a sketch file"), QString(), QStringLiteral("%0 (*.sketch)").arg(tr("Sketch file"))); +} diff --git a/plugins/sketchplugin/sketchmainwindow.h b/plugins/sketchplugin/sketchmainwindow.h index ede19cb..d2970a4 100644 --- a/plugins/sketchplugin/sketchmainwindow.h +++ b/plugins/sketchplugin/sketchmainwindow.h @@ -15,6 +15,9 @@ public: explicit SketchMainWindow(QWidget *parent = 0); ~SketchMainWindow(); +private Q_SLOTS: + void openPressed(); + private: Ui::SketchMainWindow *ui; }; diff --git a/plugins/sketchplugin/sketchmainwindow.ui b/plugins/sketchplugin/sketchmainwindow.ui index 71a9d3b..0fe15fa 100644 --- a/plugins/sketchplugin/sketchmainwindow.ui +++ b/plugins/sketchplugin/sketchmainwindow.ui @@ -1,9 +1,7 @@ + - - - SketchMainWindow - + 0 @@ -13,12 +11,63 @@ - MainWindow + Sketch Viewer - - - + + + + + + + + + + + 0 + 0 + 800 + 20 + + + + + &File + + + + + + + + + + + &Open + + + + + &Quit + + - - + + + + actionQuit + triggered() + SketchMainWindow + close() + + + -1 + -1 + + + 399 + 299 + + + + -- 2.50.1 From 68688fb53971252ad0234af0a18d47cf47ecbef4 Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 <0xFEEDC0DE64@gmail.com> Date: Thu, 12 Apr 2018 20:23:36 +0200 Subject: [PATCH 11/11] Implemented SketchMainWindow --- plugins/sketchplugin/sketchmainwindow.cpp | 59 ++++++++++++++++++++++- plugins/sketchplugin/sketchmainwindow.h | 2 + 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/plugins/sketchplugin/sketchmainwindow.cpp b/plugins/sketchplugin/sketchmainwindow.cpp index c9e23c4..04d057b 100644 --- a/plugins/sketchplugin/sketchmainwindow.cpp +++ b/plugins/sketchplugin/sketchmainwindow.cpp @@ -2,6 +2,15 @@ #include "ui_sketchmainwindow.h" #include +#include +#include +#include +#include + +#include "sketchfile.h" +#include "container/document.h" +#include "container/page.h" +#include "container/msjsonfilereference.h" SketchMainWindow::SketchMainWindow(QWidget *parent) : QMainWindow(parent), @@ -22,5 +31,53 @@ SketchMainWindow::~SketchMainWindow() void SketchMainWindow::openPressed() { - QFileDialog::getOpenFileName(this, tr("Select a sketch file"), QString(), QStringLiteral("%0 (*.sketch)").arg(tr("Sketch file"))); + auto filename = QFileDialog::getOpenFileName(this, tr("Select a sketch file"), QString(), QStringLiteral("%0 (*.sketch)").arg(tr("Sketch file"))); + if(filename.isEmpty()) + return; + + load(filename); +} + +void SketchMainWindow::load(const QString &filename) +{ + while(ui->tabWidget->count()) + { + auto widget = ui->tabWidget->widget(0); + ui->tabWidget->removeTab(0); + widget->deleteLater(); + } + + SketchFile file; + try + { + file.open(filename); + } + catch(const QString &msg) + { + QMessageBox::warning(this, tr("Could not load sketch file!"), tr("Could not load sketch file!") % "\n\n" % msg); + return; + } + + for(auto pageRef : file.document()->pages()) + { + Page *page; + try + { + page = file.loadPage(pageRef->_ref()); + } catch (QString msg) { + ui->tabWidget->addTab(new QLabel(QStringLiteral("Could not parse page: %0").arg(msg), ui->tabWidget), pageRef->_ref()); + continue; + } + + QGraphicsScene *scene; + try + { + scene = file.createScene(page); + } catch (QString msg) { + ui->tabWidget->addTab(new QLabel(QStringLiteral("Could not render page: %0").arg(msg), ui->tabWidget), page->name()); + continue; + } + + ui->tabWidget->addTab(new QGraphicsView(scene, ui->tabWidget), page->name()); + } } diff --git a/plugins/sketchplugin/sketchmainwindow.h b/plugins/sketchplugin/sketchmainwindow.h index d2970a4..f29296b 100644 --- a/plugins/sketchplugin/sketchmainwindow.h +++ b/plugins/sketchplugin/sketchmainwindow.h @@ -19,6 +19,8 @@ private Q_SLOTS: void openPressed(); private: + void load(const QString &filename); + Ui::SketchMainWindow *ui; }; -- 2.50.1