diff --git a/README.md b/README.md index 6e3b550..40176c6 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,27 @@ # Zeiterfassung -This tool helps me assigning my working hours to various accounts at work. +This tool helps me assigning my working hours to projects at work. + +![Screenshot of the main window](https://raw.githubusercontent.com/0xFEEDC0DE64/QtZeiterfassung/master/screenshot.png) ## Building from source +The build process has only been tested with gcc. On windows you have to use MinGW (provided by the Qt setup). All necessary config files or translations should be copied over to the build folder. The executable with all plugin lands in your build folder under /bin + +The simplest way to get it up and running is to just open it in QtCreator. If you are more like a terminal monkey, you can build it there too: ``` git clone https://github.com/0xFEEDC0DE64/QtZeiterfassung.git -pushd QtZeiterfassung -lrelease translations/zeiterfassung_*.ts -popd mkdir build_QtZeiterfassung cd build_QtZeiterfassung qmake ../QtZeiterfassung make -make install # to copy Qt's translations ``` -## Launching +## Launching (on unix) ``` -./zeiterfassung +LD_LIBRARY_PATH=../lib ./zeiterfassung # or just use start.sh ``` +## Launching (on win32) +Double click the **zeiterfassung.exe**. Please report any error message like missing libraries or plugins! + +## Configuration This tool saves its configuration using [QSettings](https://doc.qt.io/qt-5/qsettings.html). On linux, the configuration files are placed in `~/.config/db-software/zeiterfassung.conf`. **Be careful!** This config file contains your password in plain text (if you log in correctly). You can alter the code in main.cpp to change the behaviour of QSettings (for example: saving into an ini file at working directory). - -![Screenshot of the main window](https://raw.githubusercontent.com/0xFEEDC0DE64/QtZeiterfassung/master/screenshot.png) diff --git a/lrelease.pri b/lrelease.pri new file mode 100644 index 0000000..a0ad8fa --- /dev/null +++ b/lrelease.pri @@ -0,0 +1,11 @@ +isEmpty(QMAKE_LRELEASE) { + win32:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]\lrelease.exe + else:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease +} + +lrelease.input = TRANSLATIONS +lrelease.output = $${OUT_PWD}/translations/${QMAKE_FILE_BASE}.qm +lrelease.commands = $$QMAKE_LRELEASE ${QMAKE_FILE_IN} -qm ${QMAKE_FILE_OUT} +lrelease.CONFIG += no_link +QMAKE_EXTRA_COMPILERS += lrelease +PRE_TARGETDEPS += compiler_lrelease_make_all diff --git a/plugins/lunchmealplugin/lunchmealplugin.cpp b/plugins/lunchmealplugin/lunchmealplugin.cpp new file mode 100644 index 0000000..e1b1b92 --- /dev/null +++ b/plugins/lunchmealplugin/lunchmealplugin.cpp @@ -0,0 +1,9 @@ +#include "lunchmealplugin.h" + +#include + +LunchMealPlugin::LunchMealPlugin(QObject *parent) : + ZeiterfassungPlugin(parent) +{ + +} diff --git a/plugins/lunchmealplugin/lunchmealplugin.h b/plugins/lunchmealplugin/lunchmealplugin.h new file mode 100644 index 0000000..e73e062 --- /dev/null +++ b/plugins/lunchmealplugin/lunchmealplugin.h @@ -0,0 +1,20 @@ +#ifndef LUNCHMEALPLUGIN_H +#define LUNCHMEALPLUGIN_H + +#include + +#include "zeiterfassungplugin.h" + +class Q_DECL_EXPORT LunchMealPlugin : public ZeiterfassungPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "dbsoftware.zeiterfassung.plugin/1.0" FILE "lunchmealplugin.json") + Q_INTERFACES(ZeiterfassungPlugin) + +public: + explicit LunchMealPlugin(QObject *parent = 0); + + // ZeiterfassungPlugin interface +}; + +#endif // LUNCHMEALPLUGIN_H diff --git a/plugins/lunchmealplugin/lunchmealplugin.json b/plugins/lunchmealplugin/lunchmealplugin.json new file mode 100644 index 0000000..e69de29 diff --git a/plugins/lunchmealplugin/lunchmealplugin.pro b/plugins/lunchmealplugin/lunchmealplugin.pro new file mode 100644 index 0000000..d0dd373 --- /dev/null +++ b/plugins/lunchmealplugin/lunchmealplugin.pro @@ -0,0 +1,21 @@ +QT += core network gui widgets + +TARGET = lunchmealplugin +TEMPLATE = lib + +CONFIG += shared c++14 + +DESTDIR = $${OUT_PWD}/../../bin/plugins/zeiterfassung + +LIBS += -L$$OUT_PWD/../../lib -lzeiterfassunglib + +INCLUDEPATH += $$PWD/../../zeiterfassunglib +DEPENDPATH += $$PWD/../../zeiterfassunglib + +DEFINES += QT_DEPRECATED_WARNINGS QT_DISABLE_DEPRECATED_BEFORE=0x060000 QT_MESSAGELOGCONTEXT + +HEADERS += lunchmealplugin.h + +SOURCES += lunchmealplugin.cpp + +OTHER_FILES += lunchmealplugin.json diff --git a/plugins/plugins.pro b/plugins/plugins.pro new file mode 100644 index 0000000..5335e51 --- /dev/null +++ b/plugins/plugins.pro @@ -0,0 +1,5 @@ +TEMPLATE = subdirs + +SUBDIRS += lunchmealplugin \ + presenceplugin \ + weatherplugin diff --git a/plugins/presenceplugin/presenceplugin.cpp b/plugins/presenceplugin/presenceplugin.cpp new file mode 100644 index 0000000..0560bb6 --- /dev/null +++ b/plugins/presenceplugin/presenceplugin.cpp @@ -0,0 +1,17 @@ +#include "presenceplugin.h" + +#include + +#include "mainwindow.h" +#include "presencewidget.h" + +PresencePlugin::PresencePlugin(QObject *parent) : + ZeiterfassungPlugin(parent) +{ + qDebug() << "called"; +} + +void PresencePlugin::attachTo(MainWindow &mainWindow) +{ + new PresenceWidget(mainWindow); +} diff --git a/plugins/presenceplugin/presenceplugin.h b/plugins/presenceplugin/presenceplugin.h new file mode 100644 index 0000000..5ccdc86 --- /dev/null +++ b/plugins/presenceplugin/presenceplugin.h @@ -0,0 +1,23 @@ +#ifndef PRESENCEPLUGIN_H +#define PRESENCEPLUGIN_H + +#include + +#include "zeiterfassungplugin.h" + +class MainWindow; + +class Q_DECL_EXPORT PresencePlugin : public ZeiterfassungPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "dbsoftware.zeiterfassung.plugin/1.0" FILE "presenceplugin.json") + Q_INTERFACES(ZeiterfassungPlugin) + +public: + explicit PresencePlugin(QObject *parent = 0); + + // ZeiterfassungPlugin interface + void attachTo(MainWindow &mainWindow); +}; + +#endif // PRESENCEPLUGIN_H diff --git a/plugins/presenceplugin/presenceplugin.json b/plugins/presenceplugin/presenceplugin.json new file mode 100644 index 0000000..e69de29 diff --git a/plugins/presenceplugin/presenceplugin.pro b/plugins/presenceplugin/presenceplugin.pro new file mode 100644 index 0000000..7767bfe --- /dev/null +++ b/plugins/presenceplugin/presenceplugin.pro @@ -0,0 +1,23 @@ +QT += core network gui widgets + +TARGET = presenceplugin +TEMPLATE = lib + +CONFIG += shared c++14 + +DESTDIR = $${OUT_PWD}/../../bin/plugins/zeiterfassung + +LIBS += -L$$OUT_PWD/../../lib -lzeiterfassunglib + +INCLUDEPATH += $$PWD/../../zeiterfassunglib +DEPENDPATH += $$PWD/../../zeiterfassunglib + +DEFINES += QT_DEPRECATED_WARNINGS QT_DISABLE_DEPRECATED_BEFORE=0x060000 QT_MESSAGELOGCONTEXT + +HEADERS += presenceplugin.h \ + presencewidget.h + +SOURCES += presenceplugin.cpp \ + presencewidget.cpp + +OTHER_FILES += presenceplugin.json diff --git a/plugins/presenceplugin/presencewidget.cpp b/plugins/presenceplugin/presencewidget.cpp new file mode 100644 index 0000000..05d6223 --- /dev/null +++ b/plugins/presenceplugin/presencewidget.cpp @@ -0,0 +1,77 @@ +#include "presencewidget.h" + +#include +#include +#include +#include +#include + +#include "mainwindow.h" +#include "zeiterfassungapi.h" + +PresenceWidget::PresenceWidget(MainWindow &mainWindow) : + QWidget(&mainWindow), + m_mainWindow(mainWindow) +{ + m_labelAvailable = new QLabel(this); + m_labelAvailable->setFrameShape(QFrame::Panel); + m_labelAvailable->setFrameShadow(QFrame::Sunken); + m_mainWindow.statusBar()->addWidget(m_labelAvailable); + + m_labelNotAvailable = new QLabel(this); + m_labelNotAvailable->setFrameShape(QFrame::Panel); + m_labelNotAvailable->setFrameShadow(QFrame::Sunken); + m_mainWindow.statusBar()->addWidget(m_labelNotAvailable); + + auto timer = new QTimer(this); + timer->setInterval(60000); + connect(timer, &QTimer::timeout, this, &PresenceWidget::timeout); + timer->start(); + + timeout(); +} + +void PresenceWidget::timeout() +{ + if(m_reply) + { + qWarning() << "last request not finished yet!"; + return; + } + + m_labelAvailable->setText(tr("%0: %1").arg(tr("Available")).arg(tr("???"))); + m_labelNotAvailable->setText(tr("%0: %1").arg(tr("Not available")).arg(tr("???"))); + + m_reply = m_mainWindow.erfassung().doGetPresenceStatus(); + connect(m_reply.get(), &ZeiterfassungReply::finished, this, &PresenceWidget::finished); +} + +void PresenceWidget::finished() +{ + if(!m_reply->success()) + { + QMessageBox::warning(&m_mainWindow, tr("Could not get presence status!"), + tr("Could not get presence status!") % "\n\n" % m_reply->message()); + goto after; + } + + { + int available = 0, + notAvailable = 0; + for(const auto &status : m_reply->presenceStatuses()) + { + if(status.presence == QStringLiteral("J")) + available++; + else if(status.presence == QStringLiteral("N")) + notAvailable++; + else + qWarning() << "unknown presence" << status.firstName << status.lastName << status.presence; + } + + m_labelAvailable->setText(tr("%0: %1").arg(tr("Available")).arg(available)); + m_labelNotAvailable->setText(tr("%0: %1").arg(tr("Not available")).arg(notAvailable)); + } + + after: + m_reply = Q_NULLPTR; +} diff --git a/plugins/presenceplugin/presencewidget.h b/plugins/presenceplugin/presencewidget.h new file mode 100644 index 0000000..2c1e578 --- /dev/null +++ b/plugins/presenceplugin/presencewidget.h @@ -0,0 +1,31 @@ +#ifndef PRESENCEWIDGET_H +#define PRESENCEWIDGET_H + +#include + +#include "replies/getpresencestatusreply.h" + +class QLabel; + +class MainWindow; + +class PresenceWidget : public QWidget +{ + Q_OBJECT +public: + explicit PresenceWidget(MainWindow &mainWindow); + +private Q_SLOTS: + void timeout(); + void finished(); + +private: + MainWindow &m_mainWindow; + + QLabel *m_labelAvailable; + QLabel *m_labelNotAvailable; + + std::unique_ptr m_reply; +}; + +#endif // PRESENCEWIDGET_H diff --git a/plugins/weatherplugin/weatherplugin.cpp b/plugins/weatherplugin/weatherplugin.cpp new file mode 100644 index 0000000..0be043f --- /dev/null +++ b/plugins/weatherplugin/weatherplugin.cpp @@ -0,0 +1,9 @@ +#include "weatherplugin.h" + +#include + +WeatherPlugin::WeatherPlugin(QObject *parent) : + ZeiterfassungPlugin(parent) +{ + +} diff --git a/plugins/weatherplugin/weatherplugin.h b/plugins/weatherplugin/weatherplugin.h new file mode 100644 index 0000000..9db873d --- /dev/null +++ b/plugins/weatherplugin/weatherplugin.h @@ -0,0 +1,20 @@ +#ifndef WEATHERPLUGIN_H +#define WEATHERPLUGIN_H + +#include + +#include "zeiterfassungplugin.h" + +class Q_DECL_EXPORT WeatherPlugin : public ZeiterfassungPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "dbsoftware.zeiterfassung.plugin/1.0" FILE "weatherplugin.json") + Q_INTERFACES(ZeiterfassungPlugin) + +public: + explicit WeatherPlugin(QObject *parent = 0); + + // ZeiterfassungPlugin interface +}; + +#endif // WEATHERPLUGIN_H diff --git a/plugins/weatherplugin/weatherplugin.json b/plugins/weatherplugin/weatherplugin.json new file mode 100644 index 0000000..e69de29 diff --git a/plugins/weatherplugin/weatherplugin.pro b/plugins/weatherplugin/weatherplugin.pro new file mode 100644 index 0000000..b67c6dd --- /dev/null +++ b/plugins/weatherplugin/weatherplugin.pro @@ -0,0 +1,21 @@ +QT += core network gui widgets + +TARGET = weatherplugin +TEMPLATE = lib + +CONFIG += shared c++14 + +DESTDIR = $${OUT_PWD}/../../bin/plugins/zeiterfassung + +LIBS += -L$$OUT_PWD/../../lib -lzeiterfassunglib + +INCLUDEPATH += $$PWD/../../zeiterfassunglib +DEPENDPATH += $$PWD/../../zeiterfassunglib + +DEFINES += QT_DEPRECATED_WARNINGS QT_DISABLE_DEPRECATED_BEFORE=0x060000 QT_MESSAGELOGCONTEXT + +HEADERS += weatherplugin.h + +SOURCES += weatherplugin.cpp + +OTHER_FILES += weatherplugin.json diff --git a/replies/gettimeassignmentsreply.h b/replies/gettimeassignmentsreply.h deleted file mode 100644 index 153064e..0000000 --- a/replies/gettimeassignmentsreply.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef GETTIMEASSIGNMENTSREPLY_H -#define GETTIMEASSIGNMENTSREPLY_H - -#include - -#include -#include - -#include "zeiterfassungreply.h" -#include "zeiterfassungapi.h" - -class GetTimeAssignmentsReply : public ZeiterfassungReply -{ - Q_OBJECT - -public: - GetTimeAssignmentsReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung); - - const QVector &timeAssignments() const; - -private Q_SLOTS: - void requestFinished(); - -private: - std::unique_ptr m_reply; - QVector m_timeAssignments; -}; - -#endif // GETTIMEASSIGNMENTSREPLY_H diff --git a/replies/userinforeply.h b/replies/userinforeply.h deleted file mode 100644 index aeee527..0000000 --- a/replies/userinforeply.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef USERINFOREPLY_H -#define USERINFOREPLY_H - -#include - -#include - -#include "zeiterfassungreply.h" -#include "zeiterfassungapi.h" - -class UserInfoReply : public ZeiterfassungReply -{ - Q_OBJECT - -public: - UserInfoReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung); - - const ZeiterfassungApi::UserInfo &userInfo() const; - -private Q_SLOTS: - void requestFinished(); - -private: - std::unique_ptr m_reply; - ZeiterfassungApi::UserInfo m_userInfo; -}; - -#endif // USERINFOREPLY_H diff --git a/timeutils.h b/timeutils.h deleted file mode 100644 index c42555d..0000000 --- a/timeutils.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef TIMEUTILS_H -#define TIMEUTILS_H - -#include - -int timeToSeconds(const QTime &time); -QTime timeBetween(const QTime &l, const QTime &r); -QTime timeAdd(const QTime &l, const QTime &r); -QTime timeNormalise(const QTime &time); - -#endif // TIMEUTILS_H diff --git a/translations/zeiterfassung_de.qm b/translations/zeiterfassung_de.qm deleted file mode 100644 index 681992c..0000000 Binary files a/translations/zeiterfassung_de.qm and /dev/null differ diff --git a/translations/zeiterfassung_en.qm b/translations/zeiterfassung_en.qm deleted file mode 100644 index 9dad8df..0000000 Binary files a/translations/zeiterfassung_en.qm and /dev/null differ diff --git a/zeiterfassung.conf b/zeiterfassung.conf deleted file mode 100644 index 36a5d44..0000000 --- a/zeiterfassung.conf +++ /dev/null @@ -1,8 +0,0 @@ -[General] -password=HAHA -projekte=0000001142, 0000010001, SONSTIGES -subprojekte= -texte= -url=http://localhost:8080/evoApps/ -username=danielb -workpackages=[D.1315], [M.0200] diff --git a/zeiterfassung.pro b/zeiterfassung.pro old mode 100755 new mode 100644 index 4fdd91e..337265b --- a/zeiterfassung.pro +++ b/zeiterfassung.pro @@ -1,186 +1,8 @@ -QT += network gui widgets uitools +TEMPLATE = subdirs -CONFIG += c++14 -CONFIG -= app_bundle +SUBDIRS += plugins \ + zeiterfassung \ + zeiterfassunglib -# The following define makes your compiler emit warnings if you use -# any feature of Qt which as been marked deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if you use deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -RC_ICONS = icon.ico - -SOURCES += main.cpp \ - mainwindow.cpp \ - dialogs/aboutmedialog.cpp \ - dialogs/authenticationdialog.cpp \ - zeiterfassungsettings.cpp \ - dialogs/settingsdialog.cpp \ - dialogs/languageselectiondialog.cpp \ - dialogs/timeassignmentdialog.cpp \ - models/timeassignmentsmodel.cpp \ - dialogs/bookingdialog.cpp \ - models/bookingsmodel.cpp \ - dialogs/updatedialog.cpp \ - stripswidget.cpp \ - timeutils.cpp \ - stripfactory.cpp \ - zeiterfassungapi.cpp \ - replies/loginpagereply.cpp \ - replies/loginreply.cpp \ - replies/userinforeply.cpp \ - replies/getbookingsreply.cpp \ - replies/createbookingreply.cpp \ - replies/updatebookingreply.cpp \ - replies/deletebookingreply.cpp \ - replies/gettimeassignmentsreply.cpp \ - replies/createtimeassignmentreply.cpp \ - replies/updatetimeassignmentreply.cpp \ - replies/getprojectsreply.cpp \ - replies/getauswertungreply.cpp \ - replies/zeiterfassungreply.cpp \ - replies/deletetimeassignmentreply.cpp \ - replies/getpresencestatusreply.cpp - -HEADERS += \ - mainwindow.h \ - dialogs/aboutmedialog.h \ - dialogs/authenticationdialog.h \ - zeiterfassungsettings.h \ - dialogs/settingsdialog.h \ - dialogs/languageselectiondialog.h \ - dialogs/timeassignmentdialog.h \ - models/timeassignmentsmodel.h \ - dialogs/bookingdialog.h \ - models/bookingsmodel.h \ - dialogs/updatedialog.h \ - stripswidget.h \ - timeutils.h \ - stripfactory.h \ - zeiterfassungapi.h \ - replies/loginpagereply.h \ - replies/loginreply.h \ - replies/userinforeply.h \ - replies/getbookingsreply.h \ - replies/createbookingreply.h \ - replies/updatebookingreply.h \ - replies/deletebookingreply.h \ - replies/gettimeassignmentsreply.h \ - replies/createtimeassignmentreply.h \ - replies/updatetimeassignmentreply.h \ - replies/getprojectsreply.h \ - replies/getauswertungreply.h \ - replies/zeiterfassungreply.h \ - replies/deletetimeassignmentreply.h \ - cpp14polyfills.h \ - replies/getpresencestatusreply.h - -FORMS += \ - mainwindow.ui \ - dialogs/aboutmedialog.ui \ - dialogs/authenticationdialog.ui \ - dialogs/settingsdialog.ui \ - dialogs/languageselectiondialog.ui \ - dialogs/timeassignmentdialog.ui \ - dialogs/bookingdialog.ui \ - dialogs/updatedialog.ui - -RESOURCES += \ - resources.qrc - -TRANSLATIONS += \ - translations/zeiterfassung_en.ts \ - translations/zeiterfassung_de.ts - -win32 { - CONFIG(debug, release|debug) { - translationsinstall.path = $${OUT_PWD}/debug/translations - themesinstall.path = $${OUT_PWD}/debug/themes - darkthemeinstall.path = $${OUT_PWD}/debug/themes/dark_theme - stripsinstall.path = $${OUT_PWD}/debug/strips - } else { - translationsinstall.path = $${OUT_PWD}/release/translations - themesinstall.path = $${OUT_PWD}/release/themes - darkthemeinstall.path = $${OUT_PWD}/release/themes/dark_theme - stripsinstall.path = $${OUT_PWD}/release/strips - } -} -unix { - translationsinstall.path = $${OUT_PWD}/translations - themesinstall.path = $${OUT_PWD}/themes - darkthemeinstall.path = $${OUT_PWD}/themes/dark_theme - stripsinstall.path = $${OUT_PWD}/strips -} - -translationsinstall.files = $$[QT_INSTALL_TRANSLATIONS]/qt_en.qm \ - $$[QT_INSTALL_TRANSLATIONS]/qtbase_en.qm \ - $$[QT_INSTALL_TRANSLATIONS]/qtmultimedia_en.qm \ - $$[QT_INSTALL_TRANSLATIONS]/qtquick1_en.qm \ - $$[QT_INSTALL_TRANSLATIONS]/qtscript_nen.qm \ - $$[QT_INSTALL_TRANSLATIONS]/qtxmlpatterns_en.qm \ - $$[QT_INSTALL_TRANSLATIONS]/qt_de.qm \ - $$[QT_INSTALL_TRANSLATIONS]/qtbase_de.qm \ - $$[QT_INSTALL_TRANSLATIONS]/qtmultimedia_de.qm \ - $$[QT_INSTALL_TRANSLATIONS]/qtquick1_de.qm \ - $$[QT_INSTALL_TRANSLATIONS]/qtscript_de.qm \ - $$[QT_INSTALL_TRANSLATIONS]/qtxmlpatterns_de.qm \ - translations/zeiterfassung_en.qm \ - translations/zeiterfassung_de.qm - -themesinstall.files = themes/dark_theme.qss - -darkthemeinstall.files = themes/dark_theme/checkbox_indeterminate_disabled.png \ - themes/dark_theme/radio_unchecked.png \ - themes/dark_theme/up_arrow.png \ - themes/dark_theme/branch_closed-on.png \ - themes/dark_theme/checkbox_checked_disabled.png \ - themes/dark_theme/checkbox_unchecked.png \ - themes/dark_theme/checkbox_indeterminate.png \ - themes/dark_theme/stylesheet-branch-more.png \ - themes/dark_theme/checkbox_checked.png \ - themes/dark_theme/checkbox_unchecked_disabled.png \ - themes/dark_theme/radio_checked.png \ - themes/dark_theme/checkbox_indeterminate_focus.png \ - themes/dark_theme/checkbox_checked_focus.png \ - themes/dark_theme/branch_closed.png \ - themes/dark_theme/Vsepartoolbar.png \ - themes/dark_theme/radio_checked_disabled.png \ - themes/dark_theme/left_arrow.png \ - themes/dark_theme/Vmovetoolbar.png \ - themes/dark_theme/branch_open-on.png \ - themes/dark_theme/close.png \ - themes/dark_theme/stylesheet-branch-end.png \ - themes/dark_theme/stylesheet-vline.png \ - themes/dark_theme/down_arrow_disabled.png \ - themes/dark_theme/radio_unchecked_disabled.png \ - themes/dark_theme/left_arrow_disabled.png \ - themes/dark_theme/Hmovetoolbar.png \ - themes/dark_theme/close-pressed.png \ - themes/dark_theme/up_arrow_disabled.png \ - themes/dark_theme/branch_open.png \ - themes/dark_theme/radio_checked_focus.png \ - themes/dark_theme/sizegrip.png \ - themes/dark_theme/checkbox_unchecked_focus.png \ - themes/dark_theme/right_arrow_disabled.png \ - themes/dark_theme/Hsepartoolbar.png \ - themes/dark_theme/undock.png \ - themes/dark_theme/transparent.png \ - themes/dark_theme/close-hover.png \ - themes/dark_theme/radio_unchecked_focus.png \ - themes/dark_theme/down_arrow.png \ - themes/dark_theme/right_arrow.png - -stripsinstall.files = strips/bookingstartstrip.ui \ - strips/bookingendstrip.ui \ - strips/timeassignmentstrip.ui - -INSTALLS += translationsinstall -INSTALLS += themesinstall -INSTALLS += darkthemeinstall -INSTALLS += stripsinstall +plugins.depends += zeiterfassunglib +zeiterfassung.depends += zeiterfassunglib diff --git a/icon.ico b/zeiterfassung/icon.ico similarity index 100% rename from icon.ico rename to zeiterfassung/icon.ico diff --git a/zeiterfassung/installs.pri b/zeiterfassung/installs.pri new file mode 100644 index 0000000..7782a92 --- /dev/null +++ b/zeiterfassung/installs.pri @@ -0,0 +1,91 @@ +COMPILED_TRANSLATIONS += $$[QT_INSTALL_TRANSLATIONS]/qt_en.qm \ + $$[QT_INSTALL_TRANSLATIONS]/qtbase_en.qm \ + $$[QT_INSTALL_TRANSLATIONS]/qtmultimedia_en.qm \ + $$[QT_INSTALL_TRANSLATIONS]/qtquick1_en.qm \ + $$[QT_INSTALL_TRANSLATIONS]/qtscript_en.qm \ + $$[QT_INSTALL_TRANSLATIONS]/qtxmlpatterns_en.qm \ + $$[QT_INSTALL_TRANSLATIONS]/qt_de.qm \ + $$[QT_INSTALL_TRANSLATIONS]/qtbase_de.qm \ + $$[QT_INSTALL_TRANSLATIONS]/qtmultimedia_de.qm \ + $$[QT_INSTALL_TRANSLATIONS]/qtquick1_de.qm \ + $$[QT_INSTALL_TRANSLATIONS]/qtscript_de.qm \ + $$[QT_INSTALL_TRANSLATIONS]/qtxmlpatterns_de.qm \ + $${OUT_PWD}/translations/zeiterfassung_en.qm \ + $${OUT_PWD}/translations/zeiterfassung_de.qm \ + $${OUT_PWD}/../zeiterfassunglib/translations/zeiterfassunglib_en.qm \ + $${OUT_PWD}/../zeiterfassunglib/translations/zeiterfassunglib_de.qm + +copy_compiled_translations.input = COMPILED_TRANSLATIONS +copy_compiled_translations.output = $${DESTDIR}/translations/${QMAKE_FILE_BASE}${QMAKE_FILE_EXT} +copy_compiled_translations.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT} +copy_compiled_translations.CONFIG += no_link +QMAKE_EXTRA_COMPILERS += copy_compiled_translations +PRE_TARGETDEPS += compiler_copy_compiled_translations_make_all + +THEMES += themes/dark_theme.qss + +copy_themes.input = THEMES +copy_themes.output = $${DESTDIR}/themes/${QMAKE_FILE_BASE}${QMAKE_FILE_EXT} +copy_themes.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT} +copy_themes.CONFIG += no_link +QMAKE_EXTRA_COMPILERS += copy_themes +PRE_TARGETDEPS += compiler_copy_themes_make_all + +DARK_THEME_RESOURCES += themes/dark_theme/checkbox_indeterminate_disabled.png \ + themes/dark_theme/radio_unchecked.png \ + themes/dark_theme/up_arrow.png \ + themes/dark_theme/branch_closed-on.png \ + themes/dark_theme/checkbox_checked_disabled.png \ + themes/dark_theme/checkbox_unchecked.png \ + themes/dark_theme/checkbox_indeterminate.png \ + themes/dark_theme/stylesheet-branch-more.png \ + themes/dark_theme/checkbox_checked.png \ + themes/dark_theme/checkbox_unchecked_disabled.png \ + themes/dark_theme/radio_checked.png \ + themes/dark_theme/checkbox_indeterminate_focus.png \ + themes/dark_theme/checkbox_checked_focus.png \ + themes/dark_theme/branch_closed.png \ + themes/dark_theme/Vsepartoolbar.png \ + themes/dark_theme/radio_checked_disabled.png \ + themes/dark_theme/left_arrow.png \ + themes/dark_theme/Vmovetoolbar.png \ + themes/dark_theme/branch_open-on.png \ + themes/dark_theme/close.png \ + themes/dark_theme/stylesheet-branch-end.png \ + themes/dark_theme/stylesheet-vline.png \ + themes/dark_theme/down_arrow_disabled.png \ + themes/dark_theme/radio_unchecked_disabled.png \ + themes/dark_theme/left_arrow_disabled.png \ + themes/dark_theme/Hmovetoolbar.png \ + themes/dark_theme/close-pressed.png \ + themes/dark_theme/up_arrow_disabled.png \ + themes/dark_theme/branch_open.png \ + themes/dark_theme/radio_checked_focus.png \ + themes/dark_theme/sizegrip.png \ + themes/dark_theme/checkbox_unchecked_focus.png \ + themes/dark_theme/right_arrow_disabled.png \ + themes/dark_theme/Hsepartoolbar.png \ + themes/dark_theme/undock.png \ + themes/dark_theme/transparent.png \ + themes/dark_theme/close-hover.png \ + themes/dark_theme/radio_unchecked_focus.png \ + themes/dark_theme/down_arrow.png \ + themes/dark_theme/right_arrow.png + +copy_dark_theme_resouces.input = DARK_THEME_RESOURCES +copy_dark_theme_resouces.output = $${DESTDIR}/themes/dark_theme/${QMAKE_FILE_BASE}${QMAKE_FILE_EXT} +copy_dark_theme_resouces.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT} +copy_dark_theme_resouces.CONFIG += no_link +QMAKE_EXTRA_COMPILERS += copy_dark_theme_resouces +PRE_TARGETDEPS += compiler_copy_dark_theme_resouces_make_all + +STRIPLAYOUTS += strips/bookingstartstrip.ui \ + strips/bookingendstrip.ui \ + strips/timeassignmentstrip.ui + +copy_striplayouts.input = STRIPLAYOUTS +copy_striplayouts.output = $${DESTDIR}/strips/${QMAKE_FILE_BASE}${QMAKE_FILE_EXT} +copy_striplayouts.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT} +copy_striplayouts.CONFIG += no_link +QMAKE_EXTRA_COMPILERS += copy_striplayouts +PRE_TARGETDEPS += compiler_copy_striplayouts_make_all diff --git a/zeiterfassung/installs_unix.pri b/zeiterfassung/installs_unix.pri new file mode 100644 index 0000000..c8dd1f2 --- /dev/null +++ b/zeiterfassung/installs_unix.pri @@ -0,0 +1,8 @@ +SCRIPTS += unix/start.sh + +copy_scripts.input = SCRIPTS +copy_scripts.output = $${DESTDIR}/${QMAKE_FILE_BASE}${QMAKE_FILE_EXT} +copy_scripts.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT} +copy_scripts.CONFIG += no_link +QMAKE_EXTRA_COMPILERS += copy_scripts +PRE_TARGETDEPS += compiler_copy_scripts_make_all diff --git a/zeiterfassung/installs_win32.pri b/zeiterfassung/installs_win32.pri new file mode 100644 index 0000000..a953930 --- /dev/null +++ b/zeiterfassung/installs_win32.pri @@ -0,0 +1,44 @@ +CONFIG(debug, release|debug): DEBUG_SIGN = d + +LIBRARIES += win32/Qt.conf \ + $$OUT_PWD/../lib/zeiterfassunglib.dll \ + $$[QT_INSTALL_BINS]/Qt5Core$${DEBUG_SIGN}.dll \ + $$[QT_INSTALL_BINS]/Qt5Gui$${DEBUG_SIGN}.dll \ + $$[QT_INSTALL_BINS]/Qt5Network$${DEBUG_SIGN}.dll \ + $$[QT_INSTALL_BINS]/Qt5Widgets$${DEBUG_SIGN}.dll \ + $$[QT_INSTALL_BINS]/libgcc_s_dw2-1.dll \ + $$[QT_INSTALL_BINS]/libstdc++-6.dll \ + $$[QT_INSTALL_BINS]/libwinpthread-1.dll + +copy_libraries.input = LIBRARIES +copy_libraries.output = $${DESTDIR}/${QMAKE_FILE_BASE}${QMAKE_FILE_EXT} +copy_libraries.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT} +copy_libraries.CONFIG += no_link +QMAKE_EXTRA_COMPILERS += copy_libraries +PRE_TARGETDEPS += compiler_copy_libraries_make_all + +IMAGE_FORMATS += $$[QT_INSTALL_PLUGINS]/imageformats/qgif$${DEBUG_SIGN}.dll \ + $$[QT_INSTALL_PLUGINS]/imageformats/qicns$${DEBUG_SIGN}.dll \ + $$[QT_INSTALL_PLUGINS]/imageformats/qico$${DEBUG_SIGN}.dll \ + $$[QT_INSTALL_PLUGINS]/imageformats/qjpeg$${DEBUG_SIGN}.dll \ + $$[QT_INSTALL_PLUGINS]/imageformats/qsvg$${DEBUG_SIGN}.dll \ + $$[QT_INSTALL_PLUGINS]/imageformats/qtga$${DEBUG_SIGN}.dll \ + $$[QT_INSTALL_PLUGINS]/imageformats/qtiff$${DEBUG_SIGN}.dll \ + $$[QT_INSTALL_PLUGINS]/imageformats/qwbmp$${DEBUG_SIGN}.dll \ + $$[QT_INSTALL_PLUGINS]/imageformats/qwebp$${DEBUG_SIGN}.dll + +copy_image_formats.input = IMAGE_FORMATS +copy_image_formats.output = $${DESTDIR}/plugins/imageformats/${QMAKE_FILE_BASE}${QMAKE_FILE_EXT} +copy_image_formats.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT} +copy_image_formats.CONFIG += no_link +QMAKE_EXTRA_COMPILERS += copy_image_formats +PRE_TARGETDEPS += compiler_copy_image_formats_make_all + +PLATFORMS += $$[QT_INSTALL_PLUGINS]/platforms/qwindows$${DEBUG_SIGN}.dll + +copy_platforms.input = PLATFORMS +copy_platforms.output = $${DESTDIR}/plugins/platforms/${QMAKE_FILE_BASE}${QMAKE_FILE_EXT} +copy_platforms.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT} +copy_platforms.CONFIG += no_link +QMAKE_EXTRA_COMPILERS += copy_platforms +PRE_TARGETDEPS += compiler_copy_platforms_make_all diff --git a/main.cpp b/zeiterfassung/main.cpp similarity index 55% rename from main.cpp rename to zeiterfassung/main.cpp index 33b9c3f..f06aea9 100755 --- a/main.cpp +++ b/zeiterfassung/main.cpp @@ -12,18 +12,29 @@ #include #include #include +#include +#include #include #include "zeiterfassungsettings.h" #include "dialogs/languageselectiondialog.h" #include "zeiterfassungapi.h" #include "dialogs/authenticationdialog.h" +#include "zeiterfassungplugin.h" #include "mainwindow.h" #include "replies/loginpagereply.h" #include "replies/loginreply.h" -#include "replies/userinforeply.h" +#include "replies/getuserinforeply.h" #include "stripfactory.h" +struct { + QTranslator qtTranslator; + QTranslator zeiterfassungTranslator; + QTranslator zeiterfassunglibTranslator; +} translators; + +QVector plugins; + bool loadAndInstallTranslator(QTranslator &translator, const QLocale &locale, const QString &filename, @@ -46,49 +57,24 @@ bool loadAndInstallTranslator(QTranslator &translator, return true; } -int main(int argc, char *argv[]) +bool loadTranslations(QSplashScreen &splashScreen, ZeiterfassungSettings &settings) { - QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts); - QApplication app(argc, argv); - - qSetMessagePattern(QStringLiteral("%{time dd.MM.yyyy HH:mm:ss.zzz} " - "[" - "%{if-debug}D%{endif}" - "%{if-info}I%{endif}" - "%{if-warning}W%{endif}" - "%{if-critical}C%{endif}" - "%{if-fatal}F%{endif}" - "] " - "%{function}(): " - "%{message}")); - - QCoreApplication::setOrganizationDomain(QStringLiteral("brunner.ninja")); - QCoreApplication::setOrganizationName(QStringLiteral("db-software")); - QCoreApplication::setApplicationName(QStringLiteral("zeiterfassung")); - QCoreApplication::setApplicationVersion(QStringLiteral("1.3.1")); - - QSplashScreen splashScreen(QPixmap(QStringLiteral(":/zeiterfassung/images/splash.png"))); - splashScreen.showMessage(QCoreApplication::translate("main", "Loading settings...")); - splashScreen.show(); - - ZeiterfassungSettings settings(&app); - splashScreen.showMessage(QCoreApplication::translate("main", "Loading translations...")); if(settings.language() == QLocale::AnyLanguage) { LanguageSelectionDialog dialog(&splashScreen); - again0: + again: if(dialog.exec() != QDialog::Accepted) - return -1; + return false; if(dialog.language() == QLocale::AnyLanguage) { QMessageBox::warning(&splashScreen, QCoreApplication::translate("main", "Invalid language selection!"), QCoreApplication::translate("main", "Invalid language selection!") % "\n\n" % QCoreApplication::translate("main", "You did not select a valid language!")); - goto again0; + goto again; } settings.setLanguage(dialog.language()); @@ -97,90 +83,143 @@ int main(int argc, char *argv[]) QLocale locale(settings.language(), QLocale::Austria); QLocale::setDefault(locale); - QTranslator qtTranslator(&app); - QTranslator zeiterfassungTranslator(&app); + auto translationsDir = QDir(QCoreApplication::applicationDirPath()).absoluteFilePath(QStringLiteral("translations")); + loadAndInstallTranslator(translators.qtTranslator, locale, QStringLiteral("qt"), QStringLiteral("_"), translationsDir); + loadAndInstallTranslator(translators.zeiterfassungTranslator, locale, QStringLiteral("zeiterfassung"), QStringLiteral("_"), translationsDir); + loadAndInstallTranslator(translators.zeiterfassunglibTranslator, locale, QStringLiteral("zeiterfassunglib"), QStringLiteral("_"), translationsDir); + return true; +} + +bool loadTheme(QSplashScreen &splashScreen, ZeiterfassungSettings &settings) +{ + splashScreen.showMessage(QCoreApplication::translate("main", "Loading theme...")); + + if(settings.theme().isEmpty()) + return true; + + auto themePath = QDir(QDir(QCoreApplication::applicationDirPath()).absoluteFilePath(QStringLiteral("themes"))).absoluteFilePath(settings.theme()); + + QFile file(themePath % ".qss"); + + if(!file.exists()) { - auto translationsDir = QDir(QCoreApplication::applicationDirPath()).absoluteFilePath(QStringLiteral("translations")); - loadAndInstallTranslator(qtTranslator, locale, QStringLiteral("qt"), QStringLiteral("_"), translationsDir); - loadAndInstallTranslator(zeiterfassungTranslator, locale, QStringLiteral("zeiterfassung"), QStringLiteral("_"), translationsDir); + QMessageBox::warning(&splashScreen, QCoreApplication::translate("main", "Could not load theme!"), + QCoreApplication::translate("main", "Could not load theme!") % "\n\n" % + QCoreApplication::translate("main", "Theme file does not exist!")); + return false; } - if(!settings.theme().isEmpty()) + if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - splashScreen.showMessage(QCoreApplication::translate("main", "Loading theme...")); - - auto themePath = QDir(QDir(QCoreApplication::applicationDirPath()).absoluteFilePath(QStringLiteral("themes"))).absoluteFilePath(settings.theme()); - - QFile file(themePath % ".qss"); - - if(!file.exists()) - { - QMessageBox::warning(&splashScreen, QCoreApplication::translate("main", "Could not load theme!"), - QCoreApplication::translate("main", "Could not load theme!") % "\n\n" % - QCoreApplication::translate("main", "Theme file does not exist!")); - goto after; - } - - if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) - { - QMessageBox::warning(&splashScreen, QCoreApplication::translate("main", "Could not load theme!"), - QCoreApplication::translate("main", "Could not load theme!") % "\n\n" % - file.errorString()); - goto after; - } - - QTextStream textStream(&file); - app.setStyleSheet(textStream.readAll().replace(QStringLiteral("@THEME_RESOURCES@"), themePath)); + QMessageBox::warning(&splashScreen, QCoreApplication::translate("main", "Could not load theme!"), + QCoreApplication::translate("main", "Could not load theme!") % "\n\n" % + file.errorString()); + return false; } - after: + QTextStream textStream(&file); + qApp->setStyleSheet(textStream.readAll().replace(QStringLiteral("@THEME_RESOURCES@"), themePath)); + return true; +} + +bool loadStripLayouts(QSplashScreen &splashScreen, StripFactory &stripFactory) +{ + splashScreen.showMessage(QCoreApplication::translate("main", "Loading strip layouts...")); + + if(!stripFactory.load(QDir(QCoreApplication::applicationDirPath()).absoluteFilePath(QStringLiteral("strips")))) + { + QMessageBox::warning(&splashScreen, QCoreApplication::translate("main", "Could not load strips!"), + QCoreApplication::translate("main", "Could not load strips!") % "\n\n" % stripFactory.errorString()); + return false; + } + + { + auto widget = stripFactory.createBookingStartStrip(); + if(!widget) + { + QMessageBox::warning(&splashScreen, QCoreApplication::translate("main", "Could not load strips!"), + QCoreApplication::translate("main", "Could not load strips!") % "\n\n" % stripFactory.errorString()); + return false; + } + } + + { + auto widget = stripFactory.createBookingEndStrip(); + if(!widget) + { + QMessageBox::warning(&splashScreen, QCoreApplication::translate("main", "Could not load strips!"), + QCoreApplication::translate("main", "Could not load strips!") % "\n\n" % stripFactory.errorString()); + return false; + } + } + + { + auto widget = stripFactory.createTimeAssignmentStrip(); + if(!widget) + { + QMessageBox::warning(&splashScreen, QCoreApplication::translate("main", "Could not load strips!"), + QCoreApplication::translate("main", "Could not load strips!") % "\n\n" % stripFactory.errorString()); + return false; + } + } + + return true; +} + +bool loadLoginPage(QSplashScreen &splashScreen, ZeiterfassungSettings &settings, ZeiterfassungApi &erfassung) +{ splashScreen.showMessage(QCoreApplication::translate("main", "Loading login page...")); - ZeiterfassungApi erfassung(settings.url(), &app); + again: + auto reply = erfassung.doLoginPage(); { - again1: - auto reply = erfassung.doLoginPage(); - - { - QEventLoop eventLoop; - QObject::connect(reply.get(), &ZeiterfassungReply::finished, &eventLoop, &QEventLoop::quit); - eventLoop.exec(); - } - - if(!reply->success()) - { - bool ok; - QMessageBox::warning(&splashScreen, QCoreApplication::translate("main", "Could not access Zeiterfassung!"), - QCoreApplication::translate("main", "Could not access Zeiterfassung!") % "\n\n" % reply->message()); - - auto url = QInputDialog::getText(&splashScreen, QCoreApplication::translate("main", "Base url"), - QCoreApplication::translate("main", "Please enter the base url to the Zeiterfassung:"), - QLineEdit::Normal, settings.url(), &ok); - if(!ok) - return -1; - settings.setUrl(url); - erfassung.setUrl(url); - - goto again1; - } + QEventLoop eventLoop; + QObject::connect(reply.get(), &ZeiterfassungReply::finished, &eventLoop, &QEventLoop::quit); + eventLoop.exec(); } + if(!reply->success()) + { + QMessageBox::warning(&splashScreen, QCoreApplication::translate("main", "Could not access Zeiterfassung!"), + QCoreApplication::translate("main", "Could not access Zeiterfassung!") % "\n\n" % reply->message()); + + bool ok; + auto url = QInputDialog::getText(&splashScreen, QCoreApplication::translate("main", "Base url"), + QCoreApplication::translate("main", "Please enter the base url to the Zeiterfassung:"), + QLineEdit::Normal, settings.url(), &ok); + + if(!ok) + return false; + + settings.setUrl(url); + erfassung.setUrl(url); + + goto again; + } + + return true; +} + +bool doAuthentication(QSplashScreen &splashScreen, ZeiterfassungSettings &settings, ZeiterfassungApi &erfassung) +{ splashScreen.showMessage(QCoreApplication::translate("main", "Authenticating...")); if(settings.username().isNull() || settings.password().isNull()) { AuthenticationDialog dialog(&splashScreen); + if(dialog.exec() != QDialog::Accepted) - return -1; + return false; + settings.setUsername(dialog.username()); settings.setPassword(dialog.password()); } { - again2: + again: auto reply = erfassung.doLogin(settings.username(), settings.password()); { @@ -197,18 +236,23 @@ int main(int argc, char *argv[]) AuthenticationDialog dialog(&splashScreen); dialog.setUsername(settings.username()); dialog.setPassword(settings.password()); + if(dialog.exec() != QDialog::Accepted) - return -1; + return false; + settings.setUsername(dialog.username()); settings.setPassword(dialog.password()); - goto again2; + goto again; } } - splashScreen.showMessage(QCoreApplication::translate("main", "Getting user information...")); + return true; +} - ZeiterfassungApi::UserInfo userInfo; +bool loadUserInfo(QSplashScreen &splashScreen, ZeiterfassungApi &erfassung, GetUserInfoReply::UserInfo &userInfo) +{ + splashScreen.showMessage(QCoreApplication::translate("main", "Getting user information...")); { auto reply = erfassung.doUserInfo(); @@ -223,56 +267,123 @@ int main(int argc, char *argv[]) { QMessageBox::warning(&splashScreen, QCoreApplication::translate("main", "Could not get user information!"), QCoreApplication::translate("main", "Could not get user information!") % "\n\n" % reply->message()); - return -1; + return false; } userInfo = reply->userInfo(); } - splashScreen.showMessage(QCoreApplication::translate("main", "Loading strip layouts...")); + return true; +} + +bool loadPlugins(QSplashScreen &splashScreen) +{ + auto ok = true; + + QDir dir( + QDir( + QDir( + QCoreApplication::applicationDirPath() + ).absoluteFilePath(QStringLiteral("plugins")) + ).absoluteFilePath(QStringLiteral("zeiterfassung")) + ); + + for(const auto &fileInfo : dir.entryInfoList(QDir::Files)) + { + if(fileInfo.isSymLink()) + continue; // to skip unix so symlinks + + if(!QLibrary::isLibrary(fileInfo.filePath())) + continue; // to skip windows junk files + + QPluginLoader loader(fileInfo.filePath()); + if(!loader.load()) + { + QMessageBox::warning(&splashScreen, QCoreApplication::translate("main", "Could not load plugin %0!"), + QCoreApplication::translate("main", "Could not load plugin %0!").arg(fileInfo.fileName()) % + "\n\n" % loader.errorString()); + ok = false; + continue; + } + + auto plugin = qobject_cast(loader.instance()); + + if(!plugin) + { + QMessageBox::warning(&splashScreen, QCoreApplication::translate("main", "Plugin not valid %0!"), + QCoreApplication::translate("main", "Plugin not valid %0!").arg(fileInfo.fileName()) % + "\n\n" % loader.errorString()); + ok = false; + continue; + } + + plugins.append(plugin); + } + + return ok; +} + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + qSetMessagePattern(QStringLiteral("%{time dd.MM.yyyy HH:mm:ss.zzz} " + "[" + "%{if-debug}D%{endif}" + "%{if-info}I%{endif}" + "%{if-warning}W%{endif}" + "%{if-critical}C%{endif}" + "%{if-fatal}F%{endif}" + "] " + "%{function}(): " + "%{message}")); + + QCoreApplication::setOrganizationDomain(QStringLiteral("brunner.ninja")); + QCoreApplication::setOrganizationName(QStringLiteral("db-software")); + QCoreApplication::setApplicationName(QStringLiteral("zeiterfassung")); + QCoreApplication::setApplicationVersion(QStringLiteral("1.4")); + + QSplashScreen splashScreen(QPixmap(QStringLiteral(":/zeiterfassunglib/images/splash.png"))); + splashScreen.showMessage(QCoreApplication::translate("main", "Loading settings...")); + splashScreen.show(); + + ZeiterfassungSettings settings(&app); + + if(!loadTranslations(splashScreen, settings)) + return -1; + + // not critical if it fails + //if(!loadTheme(splashScreen, settings)) + // return -2; + loadTheme(splashScreen, settings); StripFactory stripFactory(&app); - if(!stripFactory.load(QDir(QCoreApplication::applicationDirPath()).absoluteFilePath(QStringLiteral("strips")))) - { - QMessageBox::warning(&splashScreen, QCoreApplication::translate("main", "Could not load strips!"), - QCoreApplication::translate("main", "Could not load strips!") % "\n\n" % stripFactory.errorString()); - return -1; - } - { - auto widget = stripFactory.createBookingStartStrip(); - if(!widget) - { - QMessageBox::warning(&splashScreen, QCoreApplication::translate("main", "Could not load strips!"), - QCoreApplication::translate("main", "Could not load strips!") % "\n\n" % stripFactory.errorString()); - return -1; - } - } + if(!loadStripLayouts(splashScreen, stripFactory)) + return -3; - { - auto widget = stripFactory.createBookingEndStrip(); - if(!widget) - { - QMessageBox::warning(&splashScreen, QCoreApplication::translate("main", "Could not load strips!"), - QCoreApplication::translate("main", "Could not load strips!") % "\n\n" % stripFactory.errorString()); - return -1; - } - } + ZeiterfassungApi erfassung(settings.url(), &app); - { - auto widget = stripFactory.createTimeAssignmentStrip(); - if(!widget) - { - QMessageBox::warning(&splashScreen, QCoreApplication::translate("main", "Could not load strips!"), - QCoreApplication::translate("main", "Could not load strips!") % "\n\n" % stripFactory.errorString()); - return -1; - } - } + if(!loadLoginPage(splashScreen, settings, erfassung)) + return -4; + + if(!doAuthentication(splashScreen, settings, erfassung)) + return -5; + + GetUserInfoReply::UserInfo userInfo; + + if(!loadUserInfo(splashScreen, erfassung, userInfo)) + return -6; + + loadPlugins(splashScreen); MainWindow mainWindow(settings, erfassung, userInfo, stripFactory); - mainWindow.show(); - splashScreen.finish(&mainWindow); + for(auto plugin : plugins) + plugin->attachTo(mainWindow); + + mainWindow.show(); + return app.exec(); } diff --git a/strips/bookingendstrip.ui b/zeiterfassung/strips/bookingendstrip.ui similarity index 100% rename from strips/bookingendstrip.ui rename to zeiterfassung/strips/bookingendstrip.ui diff --git a/strips/bookingstartstrip.ui b/zeiterfassung/strips/bookingstartstrip.ui similarity index 100% rename from strips/bookingstartstrip.ui rename to zeiterfassung/strips/bookingstartstrip.ui diff --git a/strips/timeassignmentstrip.ui b/zeiterfassung/strips/timeassignmentstrip.ui similarity index 100% rename from strips/timeassignmentstrip.ui rename to zeiterfassung/strips/timeassignmentstrip.ui diff --git a/themes/dark_theme.qss b/zeiterfassung/themes/dark_theme.qss similarity index 100% rename from themes/dark_theme.qss rename to zeiterfassung/themes/dark_theme.qss diff --git a/themes/dark_theme/Hmovetoolbar.png b/zeiterfassung/themes/dark_theme/Hmovetoolbar.png similarity index 100% rename from themes/dark_theme/Hmovetoolbar.png rename to zeiterfassung/themes/dark_theme/Hmovetoolbar.png diff --git a/themes/dark_theme/Hsepartoolbar.png b/zeiterfassung/themes/dark_theme/Hsepartoolbar.png similarity index 100% rename from themes/dark_theme/Hsepartoolbar.png rename to zeiterfassung/themes/dark_theme/Hsepartoolbar.png diff --git a/themes/dark_theme/Vmovetoolbar.png b/zeiterfassung/themes/dark_theme/Vmovetoolbar.png similarity index 100% rename from themes/dark_theme/Vmovetoolbar.png rename to zeiterfassung/themes/dark_theme/Vmovetoolbar.png diff --git a/themes/dark_theme/Vsepartoolbar.png b/zeiterfassung/themes/dark_theme/Vsepartoolbar.png similarity index 100% rename from themes/dark_theme/Vsepartoolbar.png rename to zeiterfassung/themes/dark_theme/Vsepartoolbar.png diff --git a/themes/dark_theme/branch_closed-on.png b/zeiterfassung/themes/dark_theme/branch_closed-on.png similarity index 100% rename from themes/dark_theme/branch_closed-on.png rename to zeiterfassung/themes/dark_theme/branch_closed-on.png diff --git a/themes/dark_theme/branch_closed.png b/zeiterfassung/themes/dark_theme/branch_closed.png similarity index 100% rename from themes/dark_theme/branch_closed.png rename to zeiterfassung/themes/dark_theme/branch_closed.png diff --git a/themes/dark_theme/branch_open-on.png b/zeiterfassung/themes/dark_theme/branch_open-on.png similarity index 100% rename from themes/dark_theme/branch_open-on.png rename to zeiterfassung/themes/dark_theme/branch_open-on.png diff --git a/themes/dark_theme/branch_open.png b/zeiterfassung/themes/dark_theme/branch_open.png similarity index 100% rename from themes/dark_theme/branch_open.png rename to zeiterfassung/themes/dark_theme/branch_open.png diff --git a/themes/dark_theme/checkbox_checked.png b/zeiterfassung/themes/dark_theme/checkbox_checked.png similarity index 100% rename from themes/dark_theme/checkbox_checked.png rename to zeiterfassung/themes/dark_theme/checkbox_checked.png diff --git a/themes/dark_theme/checkbox_checked_disabled.png b/zeiterfassung/themes/dark_theme/checkbox_checked_disabled.png similarity index 100% rename from themes/dark_theme/checkbox_checked_disabled.png rename to zeiterfassung/themes/dark_theme/checkbox_checked_disabled.png diff --git a/themes/dark_theme/checkbox_checked_focus.png b/zeiterfassung/themes/dark_theme/checkbox_checked_focus.png similarity index 100% rename from themes/dark_theme/checkbox_checked_focus.png rename to zeiterfassung/themes/dark_theme/checkbox_checked_focus.png diff --git a/themes/dark_theme/checkbox_indeterminate.png b/zeiterfassung/themes/dark_theme/checkbox_indeterminate.png similarity index 100% rename from themes/dark_theme/checkbox_indeterminate.png rename to zeiterfassung/themes/dark_theme/checkbox_indeterminate.png diff --git a/themes/dark_theme/checkbox_indeterminate_disabled.png b/zeiterfassung/themes/dark_theme/checkbox_indeterminate_disabled.png similarity index 100% rename from themes/dark_theme/checkbox_indeterminate_disabled.png rename to zeiterfassung/themes/dark_theme/checkbox_indeterminate_disabled.png diff --git a/themes/dark_theme/checkbox_indeterminate_focus.png b/zeiterfassung/themes/dark_theme/checkbox_indeterminate_focus.png similarity index 100% rename from themes/dark_theme/checkbox_indeterminate_focus.png rename to zeiterfassung/themes/dark_theme/checkbox_indeterminate_focus.png diff --git a/themes/dark_theme/checkbox_unchecked.png b/zeiterfassung/themes/dark_theme/checkbox_unchecked.png similarity index 100% rename from themes/dark_theme/checkbox_unchecked.png rename to zeiterfassung/themes/dark_theme/checkbox_unchecked.png diff --git a/themes/dark_theme/checkbox_unchecked_disabled.png b/zeiterfassung/themes/dark_theme/checkbox_unchecked_disabled.png similarity index 100% rename from themes/dark_theme/checkbox_unchecked_disabled.png rename to zeiterfassung/themes/dark_theme/checkbox_unchecked_disabled.png diff --git a/themes/dark_theme/checkbox_unchecked_focus.png b/zeiterfassung/themes/dark_theme/checkbox_unchecked_focus.png similarity index 100% rename from themes/dark_theme/checkbox_unchecked_focus.png rename to zeiterfassung/themes/dark_theme/checkbox_unchecked_focus.png diff --git a/themes/dark_theme/close-hover.png b/zeiterfassung/themes/dark_theme/close-hover.png similarity index 100% rename from themes/dark_theme/close-hover.png rename to zeiterfassung/themes/dark_theme/close-hover.png diff --git a/themes/dark_theme/close-pressed.png b/zeiterfassung/themes/dark_theme/close-pressed.png similarity index 100% rename from themes/dark_theme/close-pressed.png rename to zeiterfassung/themes/dark_theme/close-pressed.png diff --git a/themes/dark_theme/close.png b/zeiterfassung/themes/dark_theme/close.png similarity index 100% rename from themes/dark_theme/close.png rename to zeiterfassung/themes/dark_theme/close.png diff --git a/themes/dark_theme/down_arrow.png b/zeiterfassung/themes/dark_theme/down_arrow.png similarity index 100% rename from themes/dark_theme/down_arrow.png rename to zeiterfassung/themes/dark_theme/down_arrow.png diff --git a/themes/dark_theme/down_arrow_disabled.png b/zeiterfassung/themes/dark_theme/down_arrow_disabled.png similarity index 100% rename from themes/dark_theme/down_arrow_disabled.png rename to zeiterfassung/themes/dark_theme/down_arrow_disabled.png diff --git a/themes/dark_theme/left_arrow.png b/zeiterfassung/themes/dark_theme/left_arrow.png similarity index 100% rename from themes/dark_theme/left_arrow.png rename to zeiterfassung/themes/dark_theme/left_arrow.png diff --git a/themes/dark_theme/left_arrow_disabled.png b/zeiterfassung/themes/dark_theme/left_arrow_disabled.png similarity index 100% rename from themes/dark_theme/left_arrow_disabled.png rename to zeiterfassung/themes/dark_theme/left_arrow_disabled.png diff --git a/themes/dark_theme/radio_checked.png b/zeiterfassung/themes/dark_theme/radio_checked.png similarity index 100% rename from themes/dark_theme/radio_checked.png rename to zeiterfassung/themes/dark_theme/radio_checked.png diff --git a/themes/dark_theme/radio_checked_disabled.png b/zeiterfassung/themes/dark_theme/radio_checked_disabled.png similarity index 100% rename from themes/dark_theme/radio_checked_disabled.png rename to zeiterfassung/themes/dark_theme/radio_checked_disabled.png diff --git a/themes/dark_theme/radio_checked_focus.png b/zeiterfassung/themes/dark_theme/radio_checked_focus.png similarity index 100% rename from themes/dark_theme/radio_checked_focus.png rename to zeiterfassung/themes/dark_theme/radio_checked_focus.png diff --git a/themes/dark_theme/radio_unchecked.png b/zeiterfassung/themes/dark_theme/radio_unchecked.png similarity index 100% rename from themes/dark_theme/radio_unchecked.png rename to zeiterfassung/themes/dark_theme/radio_unchecked.png diff --git a/themes/dark_theme/radio_unchecked_disabled.png b/zeiterfassung/themes/dark_theme/radio_unchecked_disabled.png similarity index 100% rename from themes/dark_theme/radio_unchecked_disabled.png rename to zeiterfassung/themes/dark_theme/radio_unchecked_disabled.png diff --git a/themes/dark_theme/radio_unchecked_focus.png b/zeiterfassung/themes/dark_theme/radio_unchecked_focus.png similarity index 100% rename from themes/dark_theme/radio_unchecked_focus.png rename to zeiterfassung/themes/dark_theme/radio_unchecked_focus.png diff --git a/themes/dark_theme/right_arrow.png b/zeiterfassung/themes/dark_theme/right_arrow.png similarity index 100% rename from themes/dark_theme/right_arrow.png rename to zeiterfassung/themes/dark_theme/right_arrow.png diff --git a/themes/dark_theme/right_arrow_disabled.png b/zeiterfassung/themes/dark_theme/right_arrow_disabled.png similarity index 100% rename from themes/dark_theme/right_arrow_disabled.png rename to zeiterfassung/themes/dark_theme/right_arrow_disabled.png diff --git a/themes/dark_theme/sizegrip.png b/zeiterfassung/themes/dark_theme/sizegrip.png similarity index 100% rename from themes/dark_theme/sizegrip.png rename to zeiterfassung/themes/dark_theme/sizegrip.png diff --git a/themes/dark_theme/stylesheet-branch-end.png b/zeiterfassung/themes/dark_theme/stylesheet-branch-end.png similarity index 100% rename from themes/dark_theme/stylesheet-branch-end.png rename to zeiterfassung/themes/dark_theme/stylesheet-branch-end.png diff --git a/themes/dark_theme/stylesheet-branch-more.png b/zeiterfassung/themes/dark_theme/stylesheet-branch-more.png similarity index 100% rename from themes/dark_theme/stylesheet-branch-more.png rename to zeiterfassung/themes/dark_theme/stylesheet-branch-more.png diff --git a/themes/dark_theme/stylesheet-vline.png b/zeiterfassung/themes/dark_theme/stylesheet-vline.png similarity index 100% rename from themes/dark_theme/stylesheet-vline.png rename to zeiterfassung/themes/dark_theme/stylesheet-vline.png diff --git a/themes/dark_theme/transparent.png b/zeiterfassung/themes/dark_theme/transparent.png similarity index 100% rename from themes/dark_theme/transparent.png rename to zeiterfassung/themes/dark_theme/transparent.png diff --git a/themes/dark_theme/undock.png b/zeiterfassung/themes/dark_theme/undock.png similarity index 100% rename from themes/dark_theme/undock.png rename to zeiterfassung/themes/dark_theme/undock.png diff --git a/themes/dark_theme/up_arrow.png b/zeiterfassung/themes/dark_theme/up_arrow.png similarity index 100% rename from themes/dark_theme/up_arrow.png rename to zeiterfassung/themes/dark_theme/up_arrow.png diff --git a/themes/dark_theme/up_arrow_disabled.png b/zeiterfassung/themes/dark_theme/up_arrow_disabled.png similarity index 100% rename from themes/dark_theme/up_arrow_disabled.png rename to zeiterfassung/themes/dark_theme/up_arrow_disabled.png diff --git a/zeiterfassung/translations/zeiterfassung_de.ts b/zeiterfassung/translations/zeiterfassung_de.ts new file mode 100644 index 0000000..9206edb --- /dev/null +++ b/zeiterfassung/translations/zeiterfassung_de.ts @@ -0,0 +1,134 @@ + + + + + bookingEndStrip + + + END + GEHEN + + + + bookingStartStrip + + + START + KOMMEN + + + + main + + + Loading settings... + Lade Einstellungen... + + + + Loading translations... + Lade Übersetzungen... + + + + + Invalid language selection! + Ungültige Sprachauswahl! + + + + You did not select a valid language! + Sie haben keine gültige Sprachauswahl getroffen! + + + + Loading theme... + Lade Aussehen... + + + + + + + Could not load theme! + Konnte Aussehen nicht laden! + + + + Theme file does not exist! + Aussehen-Datei existiert nicht! + + + + Loading login page... + Lade Login-Seite... + + + + + Could not access Zeiterfassung! + Konnte Zeiterfassung nicht erreichen! + + + + Base url + Basis URL + + + + Please enter the base url to the Zeiterfassung: + Bitte geben Sie die Basis URL zur Zeiterfassung ein: + + + + Authenticating... + Authentifiziere... + + + + + Could not authenticate with Zeiterfassung! + Konnte nicht mit Zeiterfassung authentifizieren! + + + + Getting user information... + Hole Benutzer Information... + + + + + Could not get user information! + Konnte Benutzer Information nicht holen! + + + + + Could not load plugin %0! + Konnte Plugin %0 nicht laden! + + + + + Plugin not valid %0! + Plugin %0 nicht gültig! + + + + Loading strip layouts... + Lade Streifenlayouts... + + + + + + + + + + + Could not load strips! + Konnte Streifenlayouts nicht laden! + + + diff --git a/zeiterfassung/translations/zeiterfassung_en.ts b/zeiterfassung/translations/zeiterfassung_en.ts new file mode 100644 index 0000000..81507c1 --- /dev/null +++ b/zeiterfassung/translations/zeiterfassung_en.ts @@ -0,0 +1,134 @@ + + + + + bookingEndStrip + + + END + + + + + bookingStartStrip + + + START + + + + + main + + + Loading settings... + + + + + Loading translations... + + + + + + Invalid language selection! + + + + + You did not select a valid language! + + + + + Loading theme... + + + + + + + + Could not load theme! + + + + + Theme file does not exist! + + + + + Loading login page... + + + + + + Could not access Zeiterfassung! + + + + + Base url + + + + + Please enter the base url to the Zeiterfassung: + + + + + Authenticating... + + + + + + Could not authenticate with Zeiterfassung! + + + + + Getting user information... + + + + + + Could not get user information! + + + + + + Could not load plugin %0! + + + + + + Plugin not valid %0! + + + + + Loading strip layouts... + + + + + + + + + + + + Could not load strips! + + + + diff --git a/zeiterfassung/unix/start.sh b/zeiterfassung/unix/start.sh new file mode 100755 index 0000000..59aa5f8 --- /dev/null +++ b/zeiterfassung/unix/start.sh @@ -0,0 +1 @@ +LD_LIBRARY_PATH=../lib ./zeiterfassung diff --git a/zeiterfassung/win32/Qt.conf b/zeiterfassung/win32/Qt.conf new file mode 100644 index 0000000..e69de29 diff --git a/zeiterfassung/zeiterfassung.pro b/zeiterfassung/zeiterfassung.pro new file mode 100755 index 0000000..23b76b5 --- /dev/null +++ b/zeiterfassung/zeiterfassung.pro @@ -0,0 +1,37 @@ +QT += core network gui widgets + +TARGET = zeiterfassung +TEMPLATE = app + +CONFIG += c++14 +CONFIG -= app_bundle + +DESTDIR = $${OUT_PWD}/../bin + +LIBS += -L$$OUT_PWD/../lib -lzeiterfassunglib + +INCLUDEPATH += $$PWD/../zeiterfassunglib +DEPENDPATH += $$PWD/../zeiterfassunglib + +DEFINES += QT_DEPRECATED_WARNINGS QT_DISABLE_DEPRECATED_BEFORE=0x060000 QT_MESSAGELOGCONTEXT + +RC_ICONS = icon.ico + +SOURCES += main.cpp + +HEADERS += + +FORMS += strips/bookingstartstrip.ui \ + strips/bookingendstrip.ui \ + strips/timeassignmentstrip.ui + +RESOURCES += + +TRANSLATIONS += translations/zeiterfassung_en.ts \ + translations/zeiterfassung_de.ts + +include(../lrelease.pri) + +include(installs.pri) +unix: include(installs_unix.pri) +win32: include(installs_win32.pri) diff --git a/cpp14polyfills.h b/zeiterfassunglib/cpp14polyfills.h similarity index 100% rename from cpp14polyfills.h rename to zeiterfassunglib/cpp14polyfills.h diff --git a/dialogs/aboutmedialog.cpp b/zeiterfassunglib/dialogs/aboutmedialog.cpp similarity index 78% rename from dialogs/aboutmedialog.cpp rename to zeiterfassunglib/dialogs/aboutmedialog.cpp index 9747cb6..338a67b 100644 --- a/dialogs/aboutmedialog.cpp +++ b/zeiterfassunglib/dialogs/aboutmedialog.cpp @@ -1,10 +1,9 @@ #include "aboutmedialog.h" #include "ui_aboutmedialog.h" -AboutMeDialog::AboutMeDialog(const ZeiterfassungApi::UserInfo &userInfo, QWidget *parent) : +AboutMeDialog::AboutMeDialog(const GetUserInfoReply::UserInfo &userInfo, QWidget *parent) : QDialog(parent), - ui(new Ui::AboutMeDialog), - m_userInfo(userInfo) + ui(new Ui::AboutMeDialog) { ui->setupUi(this); diff --git a/dialogs/aboutmedialog.h b/zeiterfassunglib/dialogs/aboutmedialog.h similarity index 55% rename from dialogs/aboutmedialog.h rename to zeiterfassunglib/dialogs/aboutmedialog.h index 5336433..d33fbd4 100644 --- a/dialogs/aboutmedialog.h +++ b/zeiterfassunglib/dialogs/aboutmedialog.h @@ -3,21 +3,21 @@ #include -#include "zeiterfassungapi.h" +#include "zeiterfassunglib_global.h" +#include "replies/getuserinforeply.h" namespace Ui { class AboutMeDialog; } -class AboutMeDialog : public QDialog +class ZEITERFASSUNGLIBSHARED_EXPORT AboutMeDialog : public QDialog { Q_OBJECT public: - explicit AboutMeDialog(const ZeiterfassungApi::UserInfo &userInfo, QWidget *parent = Q_NULLPTR); + explicit AboutMeDialog(const GetUserInfoReply::UserInfo &userInfo, QWidget *parent = Q_NULLPTR); ~AboutMeDialog(); private: Ui::AboutMeDialog *ui; - const ZeiterfassungApi::UserInfo &m_userInfo; }; #endif // ABOUTMEDIALOG_H diff --git a/dialogs/aboutmedialog.ui b/zeiterfassunglib/dialogs/aboutmedialog.ui similarity index 100% rename from dialogs/aboutmedialog.ui rename to zeiterfassunglib/dialogs/aboutmedialog.ui diff --git a/dialogs/authenticationdialog.cpp b/zeiterfassunglib/dialogs/authenticationdialog.cpp similarity index 100% rename from dialogs/authenticationdialog.cpp rename to zeiterfassunglib/dialogs/authenticationdialog.cpp diff --git a/dialogs/authenticationdialog.h b/zeiterfassunglib/dialogs/authenticationdialog.h similarity index 81% rename from dialogs/authenticationdialog.h rename to zeiterfassunglib/dialogs/authenticationdialog.h index 7a4f86c..712059c 100644 --- a/dialogs/authenticationdialog.h +++ b/zeiterfassunglib/dialogs/authenticationdialog.h @@ -3,11 +3,13 @@ #include +#include "zeiterfassunglib_global.h" + namespace Ui { class AuthenticationDialog; } -class AuthenticationDialog : public QDialog +class ZEITERFASSUNGLIBSHARED_EXPORT AuthenticationDialog : public QDialog { Q_OBJECT diff --git a/dialogs/authenticationdialog.ui b/zeiterfassunglib/dialogs/authenticationdialog.ui similarity index 97% rename from dialogs/authenticationdialog.ui rename to zeiterfassunglib/dialogs/authenticationdialog.ui index 16ff60c..cbb43c6 100644 --- a/dialogs/authenticationdialog.ui +++ b/zeiterfassunglib/dialogs/authenticationdialog.ui @@ -37,7 +37,7 @@ - :/zeiterfassung/images/authentication.png + :/zeiterfassunglib/images/authentication.png true diff --git a/dialogs/bookingdialog.cpp b/zeiterfassunglib/dialogs/bookingdialog.cpp similarity index 100% rename from dialogs/bookingdialog.cpp rename to zeiterfassunglib/dialogs/bookingdialog.cpp diff --git a/dialogs/bookingdialog.h b/zeiterfassunglib/dialogs/bookingdialog.h similarity index 84% rename from dialogs/bookingdialog.h rename to zeiterfassunglib/dialogs/bookingdialog.h index 4a308f2..67a95e7 100644 --- a/dialogs/bookingdialog.h +++ b/zeiterfassunglib/dialogs/bookingdialog.h @@ -4,9 +4,11 @@ #include #include +#include "zeiterfassunglib_global.h" + namespace Ui { class BookingDialog; } -class BookingDialog : public QDialog +class ZEITERFASSUNGLIBSHARED_EXPORT BookingDialog : public QDialog { Q_OBJECT diff --git a/dialogs/bookingdialog.ui b/zeiterfassunglib/dialogs/bookingdialog.ui similarity index 100% rename from dialogs/bookingdialog.ui rename to zeiterfassunglib/dialogs/bookingdialog.ui diff --git a/dialogs/languageselectiondialog.cpp b/zeiterfassunglib/dialogs/languageselectiondialog.cpp similarity index 100% rename from dialogs/languageselectiondialog.cpp rename to zeiterfassunglib/dialogs/languageselectiondialog.cpp diff --git a/dialogs/languageselectiondialog.h b/zeiterfassunglib/dialogs/languageselectiondialog.h similarity index 79% rename from dialogs/languageselectiondialog.h rename to zeiterfassunglib/dialogs/languageselectiondialog.h index 33bf90e..e28b883 100644 --- a/dialogs/languageselectiondialog.h +++ b/zeiterfassunglib/dialogs/languageselectiondialog.h @@ -4,9 +4,11 @@ #include #include +#include "zeiterfassunglib_global.h" + namespace Ui { class LanguageSelectionDialog; } -class LanguageSelectionDialog : public QDialog +class ZEITERFASSUNGLIBSHARED_EXPORT LanguageSelectionDialog : public QDialog { Q_OBJECT diff --git a/dialogs/languageselectiondialog.ui b/zeiterfassunglib/dialogs/languageselectiondialog.ui similarity index 100% rename from dialogs/languageselectiondialog.ui rename to zeiterfassunglib/dialogs/languageselectiondialog.ui diff --git a/dialogs/settingsdialog.cpp b/zeiterfassunglib/dialogs/settingsdialog.cpp similarity index 100% rename from dialogs/settingsdialog.cpp rename to zeiterfassunglib/dialogs/settingsdialog.cpp diff --git a/dialogs/settingsdialog.h b/zeiterfassunglib/dialogs/settingsdialog.h similarity index 79% rename from dialogs/settingsdialog.h rename to zeiterfassunglib/dialogs/settingsdialog.h index 9db52de..5cafed2 100644 --- a/dialogs/settingsdialog.h +++ b/zeiterfassunglib/dialogs/settingsdialog.h @@ -3,10 +3,12 @@ #include +#include "zeiterfassunglib_global.h" + class ZeiterfassungSettings; namespace Ui { class SettingsDialog; } -class SettingsDialog : public QDialog +class ZEITERFASSUNGLIBSHARED_EXPORT SettingsDialog : public QDialog { Q_OBJECT diff --git a/dialogs/settingsdialog.ui b/zeiterfassunglib/dialogs/settingsdialog.ui similarity index 100% rename from dialogs/settingsdialog.ui rename to zeiterfassunglib/dialogs/settingsdialog.ui diff --git a/dialogs/timeassignmentdialog.cpp b/zeiterfassunglib/dialogs/timeassignmentdialog.cpp similarity index 100% rename from dialogs/timeassignmentdialog.cpp rename to zeiterfassunglib/dialogs/timeassignmentdialog.cpp diff --git a/dialogs/timeassignmentdialog.h b/zeiterfassunglib/dialogs/timeassignmentdialog.h similarity index 89% rename from dialogs/timeassignmentdialog.h rename to zeiterfassunglib/dialogs/timeassignmentdialog.h index a8d253c..160b057 100644 --- a/dialogs/timeassignmentdialog.h +++ b/zeiterfassunglib/dialogs/timeassignmentdialog.h @@ -4,13 +4,15 @@ #include #include +#include "zeiterfassunglib_global.h" + template class QMap; class ZeiterfassungSettings; namespace Ui { class TimeAssignmentDialog; } -class TimeAssignmentDialog : public QDialog +class ZEITERFASSUNGLIBSHARED_EXPORT TimeAssignmentDialog : public QDialog { Q_OBJECT diff --git a/dialogs/timeassignmentdialog.ui b/zeiterfassunglib/dialogs/timeassignmentdialog.ui similarity index 100% rename from dialogs/timeassignmentdialog.ui rename to zeiterfassunglib/dialogs/timeassignmentdialog.ui diff --git a/dialogs/updatedialog.cpp b/zeiterfassunglib/dialogs/updatedialog.cpp similarity index 100% rename from dialogs/updatedialog.cpp rename to zeiterfassunglib/dialogs/updatedialog.cpp diff --git a/dialogs/updatedialog.h b/zeiterfassunglib/dialogs/updatedialog.h similarity index 84% rename from dialogs/updatedialog.h rename to zeiterfassunglib/dialogs/updatedialog.h index 9175684..d2a9c08 100644 --- a/dialogs/updatedialog.h +++ b/zeiterfassunglib/dialogs/updatedialog.h @@ -4,13 +4,15 @@ #include #include +#include "zeiterfassunglib_global.h" + class QNetworkAccessManager; class QNetworkReply; class ZeiterfassungSettings; namespace Ui { class UpdateDialog; } -class UpdateDialog : public QDialog +class ZEITERFASSUNGLIBSHARED_EXPORT UpdateDialog : public QDialog { Q_OBJECT diff --git a/dialogs/updatedialog.ui b/zeiterfassunglib/dialogs/updatedialog.ui similarity index 100% rename from dialogs/updatedialog.ui rename to zeiterfassunglib/dialogs/updatedialog.ui diff --git a/images/about.png b/zeiterfassunglib/images/about.png similarity index 100% rename from images/about.png rename to zeiterfassunglib/images/about.png diff --git a/images/auswertung.png b/zeiterfassunglib/images/auswertung.png similarity index 100% rename from images/auswertung.png rename to zeiterfassunglib/images/auswertung.png diff --git a/images/authentication.png b/zeiterfassunglib/images/authentication.png similarity index 100% rename from images/authentication.png rename to zeiterfassunglib/images/authentication.png diff --git a/images/help.png b/zeiterfassunglib/images/help.png similarity index 100% rename from images/help.png rename to zeiterfassunglib/images/help.png diff --git a/images/icon.png b/zeiterfassunglib/images/icon.png similarity index 100% rename from images/icon.png rename to zeiterfassunglib/images/icon.png diff --git a/images/next.png b/zeiterfassunglib/images/next.png similarity index 100% rename from images/next.png rename to zeiterfassunglib/images/next.png diff --git a/images/now.png b/zeiterfassunglib/images/now.png similarity index 100% rename from images/now.png rename to zeiterfassunglib/images/now.png diff --git a/images/previous.png b/zeiterfassunglib/images/previous.png similarity index 100% rename from images/previous.png rename to zeiterfassunglib/images/previous.png diff --git a/images/quit.png b/zeiterfassunglib/images/quit.png similarity index 100% rename from images/quit.png rename to zeiterfassunglib/images/quit.png diff --git a/images/refresh.png b/zeiterfassunglib/images/refresh.png similarity index 100% rename from images/refresh.png rename to zeiterfassunglib/images/refresh.png diff --git a/images/settings.png b/zeiterfassunglib/images/settings.png similarity index 100% rename from images/settings.png rename to zeiterfassunglib/images/settings.png diff --git a/images/splash.png b/zeiterfassunglib/images/splash.png similarity index 100% rename from images/splash.png rename to zeiterfassunglib/images/splash.png diff --git a/images/today.png b/zeiterfassunglib/images/today.png similarity index 100% rename from images/today.png rename to zeiterfassunglib/images/today.png diff --git a/images/user.png b/zeiterfassunglib/images/user.png similarity index 100% rename from images/user.png rename to zeiterfassunglib/images/user.png diff --git a/mainwindow.cpp b/zeiterfassunglib/mainwindow.cpp similarity index 94% rename from mainwindow.cpp rename to zeiterfassunglib/mainwindow.cpp index 6233128..da35f4b 100644 --- a/mainwindow.cpp +++ b/zeiterfassunglib/mainwindow.cpp @@ -15,6 +15,7 @@ #include #include +#include "zeiterfassungapi.h" #include "timeutils.h" #include "zeiterfassungsettings.h" #include "stripfactory.h" @@ -36,7 +37,7 @@ #include "replies/createtimeassignmentreply.h" #include "replies/createbookingreply.h" -MainWindow::MainWindow(ZeiterfassungSettings &settings, ZeiterfassungApi &erfassung, const ZeiterfassungApi::UserInfo &userInfo, +MainWindow::MainWindow(ZeiterfassungSettings &settings, ZeiterfassungApi &erfassung, const GetUserInfoReply::UserInfo &userInfo, StripFactory &stripFactory, QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), @@ -48,8 +49,7 @@ MainWindow::MainWindow(ZeiterfassungSettings &settings, ZeiterfassungApi &erfass m_getAuswertungReply(Q_NULLPTR), m_bookingsModel(new BookingsModel(this)), m_timeAssignmentsModel(new TimeAssignmentsModel(this)), - m_currentStripWidget(Q_NULLPTR), - m_getPresenceStatusReply(Q_NULLPTR) + m_currentStripWidget(Q_NULLPTR) { ui->setupUi(this); @@ -108,10 +108,6 @@ MainWindow::MainWindow(ZeiterfassungSettings &settings, ZeiterfassungApi &erfass connect(m_timeAssignmentsModel, &TimeAssignmentsModel::enabledChanged, ui->treeViewTimeAssignments, &QWidget::setEnabled); connect(ui->treeViewTimeAssignments, &QWidget::customContextMenuRequested, this, &MainWindow::contextMenuTimeAssignment); - ui->statusbar->addWidget(m_presenceLabel = new QLabel(tr("???"), ui->statusbar)); - m_presenceLabel->setFrameShape(QFrame::Panel); - m_presenceLabel->setFrameShadow(QFrame::Sunken); - ui->statusbar->addPermanentWidget(m_balanceLabel = new QLabel(ui->statusbar)); m_balanceLabel->setFrameShape(QFrame::Panel); m_balanceLabel->setFrameShadow(QFrame::Sunken); @@ -121,15 +117,6 @@ MainWindow::MainWindow(ZeiterfassungSettings &settings, ZeiterfassungApi &erfass dateChanged(); - { - auto timer = new QTimer(this); - timer->setInterval(60000); - connect(timer, &QTimer::timeout, this, &MainWindow::refreshPresence); - timer->start(); - } - - refreshPresence(); - if(settings.lastUpdateCheck().isNull() || settings.lastUpdateCheck() < QDate::currentDate()) new UpdateDialog(settings, erfassung.manager(), this); } @@ -139,6 +126,46 @@ MainWindow::~MainWindow() delete ui; } +QMenu *MainWindow::menuFile() const +{ + return ui->menuFile; +} + +QMenu *MainWindow::menuView() const +{ + return ui->menuView; +} + +QMenu *MainWindow::menuTools() const +{ + return ui->menuTools; +} + +QMenu *MainWindow::menuAbout() const +{ + return ui->menuAbout; +} + +ZeiterfassungSettings &MainWindow::settings() const +{ + return m_settings; +} + +ZeiterfassungApi &MainWindow::erfassung() const +{ + return m_erfassung; +} + +const GetUserInfoReply::UserInfo &MainWindow::userInfo() const +{ + return m_userInfo; +} + +StripFactory &MainWindow::stripFactory() const +{ + return m_stripFactory; +} + void MainWindow::getProjectsFinished() { if(m_getProjectsReply->success()) @@ -225,7 +252,7 @@ void MainWindow::contextMenuBooking(const QPoint &pos) { QMenu menu; auto createAction = menu.addAction(tr("Create booking")); - auto refreshAction = menu.addAction(QIcon(QPixmap(QStringLiteral(":/zeiterfassung/images/refresh.png"))), tr("Refresh bookings")); + auto refreshAction = menu.addAction(QIcon(QPixmap(QStringLiteral(":/zeiterfassunglib/images/refresh.png"))), tr("Refresh bookings")); auto selectedAction = menu.exec(ui->treeViewBookings->viewport()->mapToGlobal(pos)); if(selectedAction == createAction) { @@ -332,7 +359,7 @@ void MainWindow::contextMenuTimeAssignment(const QPoint &pos) { QMenu menu; auto createAction = menu.addAction(tr("Create time assignment")); - auto refreshAction = menu.addAction(QIcon(QPixmap(QStringLiteral(":/zeiterfassung/images/refresh.png"))), tr("Refresh time assignments")); + auto refreshAction = menu.addAction(QIcon(QPixmap(QStringLiteral(":/zeiterfassunglib/images/refresh.png"))), tr("Refresh time assignments")); auto selectedAction = menu.exec(ui->treeViewTimeAssignments->viewport()->mapToGlobal(pos)); if(selectedAction == createAction) { @@ -663,34 +690,6 @@ void MainWindow::openAuswertung() } } -void MainWindow::refreshPresence() -{ - m_presenceLabel->setText(tr("???")); - - m_getPresenceStatusReply = m_erfassung.doGetPresenceStatus(); - connect(m_getPresenceStatusReply.get(), &ZeiterfassungReply::finished, this, &MainWindow::getPresenceStatusFinished); -} - -void MainWindow::getPresenceStatusFinished() -{ - if(m_getPresenceStatusReply->success()) - { - QMap counts; - for(const auto &presenceStatus : m_getPresenceStatusReply->presenceStatuses()) - counts[presenceStatus.presence]++; - QString text; - for(auto iter = counts.constBegin(); iter != counts.constEnd(); iter++) - { - if(!text.isEmpty()) - text.append(' '); - text.append(QStringLiteral("%0: %1").arg(iter.key()).arg(iter.value())); - } - m_presenceLabel->setText(text); - } - - m_getPresenceStatusReply = Q_NULLPTR; -} - void MainWindow::minimumTimeChanged() { ui->timeEditTime->setMinimumTime(m_currentStripWidget->minimumTime()); diff --git a/mainwindow.h b/zeiterfassunglib/mainwindow.h similarity index 75% rename from mainwindow.h rename to zeiterfassunglib/mainwindow.h index ccb5d66..a41e9cc 100644 --- a/mainwindow.h +++ b/zeiterfassunglib/mainwindow.h @@ -6,7 +6,8 @@ #include #include -#include "zeiterfassungapi.h" +#include "zeiterfassunglib_global.h" +#include "replies/getuserinforeply.h" #include "replies/getprojectsreply.h" #include "replies/getauswertungreply.h" #include "replies/getpresencestatusreply.h" @@ -21,15 +22,25 @@ class StripsWidget; class BookingsModel; class TimeAssignmentsModel; -class MainWindow : public QMainWindow +class ZEITERFASSUNGLIBSHARED_EXPORT MainWindow : public QMainWindow { Q_OBJECT public: - explicit MainWindow(ZeiterfassungSettings &settings, ZeiterfassungApi &erfassung, const ZeiterfassungApi::UserInfo &userInfo, + explicit MainWindow(ZeiterfassungSettings &settings, ZeiterfassungApi &erfassung, const GetUserInfoReply::UserInfo &userInfo, StripFactory &stripFactory, QWidget *parent = Q_NULLPTR); ~MainWindow(); + QMenu *menuFile() const; + QMenu *menuView() const; + QMenu *menuTools() const; + QMenu *menuAbout() const; + + ZeiterfassungSettings &settings() const; + ZeiterfassungApi &erfassung() const; + const GetUserInfoReply::UserInfo &userInfo() const; + StripFactory &stripFactory() const; + private Q_SLOTS: void getProjectsFinished(); void getAuswertungFinished(); @@ -39,8 +50,6 @@ private Q_SLOTS: void pushButtonEndPressed(); void dateChanged(bool force = false); void openAuswertung(); - void refreshPresence(); - void getPresenceStatusFinished(); void minimumTimeChanged(); void refreshingChanged(); @@ -54,7 +63,7 @@ private: Ui::MainWindow *ui; ZeiterfassungSettings &m_settings; ZeiterfassungApi &m_erfassung; - const ZeiterfassungApi::UserInfo &m_userInfo; + const GetUserInfoReply::UserInfo &m_userInfo; StripFactory &m_stripFactory; std::unique_ptr m_getProjectsReply; @@ -68,15 +77,11 @@ private: QDate m_auswertungDate; QByteArray m_auswertung; - QLabel *m_presenceLabel; - QLabel *m_balanceLabel; QLabel *m_holidaysLabel; std::array m_stripsWidgets; StripsWidget *m_currentStripWidget; - - std::unique_ptr m_getPresenceStatusReply; }; #endif // MAINWINDOW_H diff --git a/mainwindow.ui b/zeiterfassunglib/mainwindow.ui similarity index 86% rename from mainwindow.ui rename to zeiterfassunglib/mainwindow.ui index 87a9f30..1097f45 100644 --- a/mainwindow.ui +++ b/zeiterfassunglib/mainwindow.ui @@ -12,7 +12,7 @@ - :/zeiterfassung/images/icon.png:/zeiterfassung/images/icon.png + :/zeiterfassunglib/images/icon.png:/zeiterfassunglib/images/icon.png @@ -31,7 +31,7 @@ - :/zeiterfassung/images/previous.png:/zeiterfassung/images/previous.png + :/zeiterfassunglib/images/previous.png:/zeiterfassunglib/images/previous.png @@ -45,7 +45,7 @@ - :/zeiterfassung/images/next.png:/zeiterfassung/images/next.png + :/zeiterfassunglib/images/next.png:/zeiterfassunglib/images/next.png @@ -75,7 +75,7 @@ - :/zeiterfassung/images/now.png:/zeiterfassung/images/now.png + :/zeiterfassunglib/images/now.png:/zeiterfassunglib/images/now.png @@ -251,7 +251,7 @@ - + &About @@ -262,23 +262,23 @@ - + &View - + &Tools - - - + + + @@ -296,7 +296,7 @@ - :/zeiterfassung/images/quit.png:/zeiterfassung/images/quit.png + :/zeiterfassunglib/images/quit.png:/zeiterfassunglib/images/quit.png &Quit @@ -305,7 +305,7 @@ - :/zeiterfassung/images/user.png:/zeiterfassung/images/user.png + :/zeiterfassunglib/images/user.png:/zeiterfassunglib/images/user.png About &Me @@ -314,7 +314,7 @@ - :/zeiterfassung/images/about.png:/zeiterfassung/images/about.png + :/zeiterfassunglib/images/about.png:/zeiterfassunglib/images/about.png About &zeiterfassung @@ -328,7 +328,7 @@ - :/zeiterfassung/images/today.png:/zeiterfassung/images/today.png + :/zeiterfassunglib/images/today.png:/zeiterfassunglib/images/today.png &Today @@ -337,7 +337,7 @@ - :/zeiterfassung/images/refresh.png:/zeiterfassung/images/refresh.png + :/zeiterfassunglib/images/refresh.png:/zeiterfassunglib/images/refresh.png &Refresh everything @@ -346,7 +346,7 @@ - :/zeiterfassung/images/auswertung.png:/zeiterfassung/images/auswertung.png + :/zeiterfassunglib/images/auswertung.png:/zeiterfassunglib/images/auswertung.png &Auswertung @@ -355,7 +355,7 @@ - :/zeiterfassung/images/settings.png:/zeiterfassung/images/settings.png + :/zeiterfassunglib/images/settings.png:/zeiterfassunglib/images/settings.png &Settings @@ -364,7 +364,7 @@ - :/zeiterfassung/images/help.png:/zeiterfassung/images/help.png + :/zeiterfassunglib/images/help.png:/zeiterfassunglib/images/help.png Help diff --git a/models/bookingsmodel.cpp b/zeiterfassunglib/models/bookingsmodel.cpp similarity index 100% rename from models/bookingsmodel.cpp rename to zeiterfassunglib/models/bookingsmodel.cpp diff --git a/models/bookingsmodel.h b/zeiterfassunglib/models/bookingsmodel.h similarity index 91% rename from models/bookingsmodel.h rename to zeiterfassunglib/models/bookingsmodel.h index ea95bd6..c6a0e5e 100644 --- a/models/bookingsmodel.h +++ b/zeiterfassunglib/models/bookingsmodel.h @@ -4,11 +4,12 @@ #include #include +#include "zeiterfassunglib_global.h" #include "zeiterfassungapi.h" class StripsWidget; -class BookingsModel : public QAbstractListModel +class ZEITERFASSUNGLIBSHARED_EXPORT BookingsModel : public QAbstractListModel { Q_OBJECT Q_PROPERTY(StripsWidget* stripsWidget READ stripsWidget WRITE setStripsWidget NOTIFY stripsWidgetChanged) diff --git a/models/timeassignmentsmodel.cpp b/zeiterfassunglib/models/timeassignmentsmodel.cpp similarity index 100% rename from models/timeassignmentsmodel.cpp rename to zeiterfassunglib/models/timeassignmentsmodel.cpp diff --git a/models/timeassignmentsmodel.h b/zeiterfassunglib/models/timeassignmentsmodel.h similarity index 90% rename from models/timeassignmentsmodel.h rename to zeiterfassunglib/models/timeassignmentsmodel.h index 1caacf1..a860a40 100644 --- a/models/timeassignmentsmodel.h +++ b/zeiterfassunglib/models/timeassignmentsmodel.h @@ -4,11 +4,12 @@ #include #include +#include "zeiterfassunglib_global.h" #include "zeiterfassungapi.h" class StripsWidget; -class TimeAssignmentsModel : public QAbstractListModel +class ZEITERFASSUNGLIBSHARED_EXPORT TimeAssignmentsModel : public QAbstractListModel { Q_OBJECT Q_PROPERTY(StripsWidget* stripsWidget READ stripsWidget WRITE setStripsWidget NOTIFY stripsWidgetChanged) diff --git a/replies/createbookingreply.cpp b/zeiterfassunglib/replies/createbookingreply.cpp similarity index 100% rename from replies/createbookingreply.cpp rename to zeiterfassunglib/replies/createbookingreply.cpp diff --git a/replies/createbookingreply.h b/zeiterfassunglib/replies/createbookingreply.h similarity index 78% rename from replies/createbookingreply.h rename to zeiterfassunglib/replies/createbookingreply.h index accc5dd..7111181 100644 --- a/replies/createbookingreply.h +++ b/zeiterfassunglib/replies/createbookingreply.h @@ -5,9 +5,10 @@ #include +#include "zeiterfassunglib_global.h" #include "zeiterfassungreply.h" -class CreateBookingReply : public ZeiterfassungReply +class ZEITERFASSUNGLIBSHARED_EXPORT CreateBookingReply : public ZeiterfassungReply { Q_OBJECT diff --git a/replies/createtimeassignmentreply.cpp b/zeiterfassunglib/replies/createtimeassignmentreply.cpp similarity index 100% rename from replies/createtimeassignmentreply.cpp rename to zeiterfassunglib/replies/createtimeassignmentreply.cpp diff --git a/replies/createtimeassignmentreply.h b/zeiterfassunglib/replies/createtimeassignmentreply.h similarity index 79% rename from replies/createtimeassignmentreply.h rename to zeiterfassunglib/replies/createtimeassignmentreply.h index 634b907..0224410 100644 --- a/replies/createtimeassignmentreply.h +++ b/zeiterfassunglib/replies/createtimeassignmentreply.h @@ -5,9 +5,10 @@ #include +#include "zeiterfassunglib_global.h" #include "zeiterfassungreply.h" -class CreateTimeAssignmentReply : public ZeiterfassungReply +class ZEITERFASSUNGLIBSHARED_EXPORT CreateTimeAssignmentReply : public ZeiterfassungReply { Q_OBJECT diff --git a/replies/deletebookingreply.cpp b/zeiterfassunglib/replies/deletebookingreply.cpp similarity index 100% rename from replies/deletebookingreply.cpp rename to zeiterfassunglib/replies/deletebookingreply.cpp diff --git a/replies/deletebookingreply.h b/zeiterfassunglib/replies/deletebookingreply.h similarity index 76% rename from replies/deletebookingreply.h rename to zeiterfassunglib/replies/deletebookingreply.h index 94796c4..6e701fa 100644 --- a/replies/deletebookingreply.h +++ b/zeiterfassunglib/replies/deletebookingreply.h @@ -5,9 +5,10 @@ #include +#include "zeiterfassunglib_global.h" #include "zeiterfassungreply.h" -class DeleteBookingReply : public ZeiterfassungReply +class ZEITERFASSUNGLIBSHARED_EXPORT DeleteBookingReply : public ZeiterfassungReply { Q_OBJECT diff --git a/replies/deletetimeassignmentreply.cpp b/zeiterfassunglib/replies/deletetimeassignmentreply.cpp similarity index 100% rename from replies/deletetimeassignmentreply.cpp rename to zeiterfassunglib/replies/deletetimeassignmentreply.cpp diff --git a/replies/deletetimeassignmentreply.h b/zeiterfassunglib/replies/deletetimeassignmentreply.h similarity index 76% rename from replies/deletetimeassignmentreply.h rename to zeiterfassunglib/replies/deletetimeassignmentreply.h index b2a545e..ec7a4d0 100644 --- a/replies/deletetimeassignmentreply.h +++ b/zeiterfassunglib/replies/deletetimeassignmentreply.h @@ -5,9 +5,10 @@ #include +#include "zeiterfassunglib_global.h" #include "zeiterfassungreply.h" -class DeleteTimeAssignmentReply : public ZeiterfassungReply +class ZEITERFASSUNGLIBSHARED_EXPORT DeleteTimeAssignmentReply : public ZeiterfassungReply { Q_OBJECT diff --git a/replies/getauswertungreply.cpp b/zeiterfassunglib/replies/getauswertungreply.cpp similarity index 100% rename from replies/getauswertungreply.cpp rename to zeiterfassunglib/replies/getauswertungreply.cpp diff --git a/replies/getauswertungreply.h b/zeiterfassunglib/replies/getauswertungreply.h similarity index 81% rename from replies/getauswertungreply.h rename to zeiterfassunglib/replies/getauswertungreply.h index b220880..c39e93e 100644 --- a/replies/getauswertungreply.h +++ b/zeiterfassunglib/replies/getauswertungreply.h @@ -6,9 +6,10 @@ #include #include +#include "zeiterfassunglib_global.h" #include "zeiterfassungreply.h" -class GetAuswertungReply : public ZeiterfassungReply +class ZEITERFASSUNGLIBSHARED_EXPORT GetAuswertungReply : public ZeiterfassungReply { Q_OBJECT diff --git a/replies/getbookingsreply.cpp b/zeiterfassunglib/replies/getbookingsreply.cpp similarity index 95% rename from replies/getbookingsreply.cpp rename to zeiterfassunglib/replies/getbookingsreply.cpp index d08704a..b7941fa 100644 --- a/replies/getbookingsreply.cpp +++ b/zeiterfassunglib/replies/getbookingsreply.cpp @@ -6,6 +6,8 @@ #include #include +#include "zeiterfassungapi.h" + GetBookingsReply::GetBookingsReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung) : ZeiterfassungReply(zeiterfassung), m_reply(std::move(reply)) @@ -13,7 +15,7 @@ GetBookingsReply::GetBookingsReply(std::unique_ptr &&reply, Zeite connect(m_reply.get(), &QNetworkReply::finished, this, &GetBookingsReply::requestFinished); } -const QVector &GetBookingsReply::bookings() const +const QVector &GetBookingsReply::bookings() const { return m_bookings; } diff --git a/replies/getbookingsreply.h b/zeiterfassunglib/replies/getbookingsreply.h similarity index 51% rename from replies/getbookingsreply.h rename to zeiterfassunglib/replies/getbookingsreply.h index 459a426..59344b9 100644 --- a/replies/getbookingsreply.h +++ b/zeiterfassunglib/replies/getbookingsreply.h @@ -6,24 +6,36 @@ #include #include +#include "zeiterfassunglib_global.h" #include "zeiterfassungreply.h" -#include "zeiterfassungapi.h" -class GetBookingsReply : public ZeiterfassungReply +class ZeiterfassungApi; + +class ZEITERFASSUNGLIBSHARED_EXPORT GetBookingsReply : public ZeiterfassungReply { Q_OBJECT public: GetBookingsReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung); - const QVector &bookings() const; + struct Booking + { + int id; + QDate date; + QTime time; + QTime timespan; + QString type; + QString text; + }; + + const QVector &bookings() const; private Q_SLOTS: void requestFinished(); private: std::unique_ptr m_reply; - QVector m_bookings; + QVector m_bookings; }; #endif // GETBOOKINGSREPLY_H diff --git a/replies/getpresencestatusreply.cpp b/zeiterfassunglib/replies/getpresencestatusreply.cpp similarity index 93% rename from replies/getpresencestatusreply.cpp rename to zeiterfassunglib/replies/getpresencestatusreply.cpp index de95aa3..5ee41db 100644 --- a/replies/getpresencestatusreply.cpp +++ b/zeiterfassunglib/replies/getpresencestatusreply.cpp @@ -6,6 +6,8 @@ #include #include +#include "zeiterfassungapi.h" + GetPresenceStatusReply::GetPresenceStatusReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung) : ZeiterfassungReply(zeiterfassung), m_reply(std::move(reply)) @@ -13,7 +15,7 @@ GetPresenceStatusReply::GetPresenceStatusReply(std::unique_ptr && connect(m_reply.get(), &QNetworkReply::finished, this, &GetPresenceStatusReply::requestFinished); } -const QVector &GetPresenceStatusReply::presenceStatuses() const +const QVector &GetPresenceStatusReply::presenceStatuses() const { return m_presenceStatuses; } diff --git a/replies/getpresencestatusreply.h b/zeiterfassunglib/replies/getpresencestatusreply.h similarity index 51% rename from replies/getpresencestatusreply.h rename to zeiterfassunglib/replies/getpresencestatusreply.h index f75b230..e220379 100644 --- a/replies/getpresencestatusreply.h +++ b/zeiterfassunglib/replies/getpresencestatusreply.h @@ -5,24 +5,34 @@ #include +#include "zeiterfassunglib_global.h" #include "zeiterfassungreply.h" -#include "zeiterfassungapi.h" -class GetPresenceStatusReply : public ZeiterfassungReply +class ZeiterfassungApi; + +class ZEITERFASSUNGLIBSHARED_EXPORT GetPresenceStatusReply : public ZeiterfassungReply { Q_OBJECT public: explicit GetPresenceStatusReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung); - const QVector &presenceStatuses() const; + struct PresenceStatus + { + int userId; + QString firstName; + QString lastName; + QString presence; + }; + + const QVector &presenceStatuses() const; private Q_SLOTS: void requestFinished(); private: std::unique_ptr m_reply; - QVector m_presenceStatuses; + QVector m_presenceStatuses; }; #endif // GETPRESENCESTATUSREPLY_H diff --git a/replies/getprojectsreply.cpp b/zeiterfassunglib/replies/getprojectsreply.cpp similarity index 95% rename from replies/getprojectsreply.cpp rename to zeiterfassunglib/replies/getprojectsreply.cpp index 9c18ebb..1800d10 100644 --- a/replies/getprojectsreply.cpp +++ b/zeiterfassunglib/replies/getprojectsreply.cpp @@ -6,6 +6,8 @@ #include #include +#include "zeiterfassungapi.h" + GetProjectsReply::GetProjectsReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung) : ZeiterfassungReply(zeiterfassung), m_reply(std::move(reply)) @@ -13,7 +15,7 @@ GetProjectsReply::GetProjectsReply(std::unique_ptr &&reply, Zeite connect(m_reply.get(), &QNetworkReply::finished, this, &GetProjectsReply::requestFinished); } -const QVector &GetProjectsReply::projects() const +const QVector &GetProjectsReply::projects() const { return m_projects; } diff --git a/replies/getprojectsreply.h b/zeiterfassunglib/replies/getprojectsreply.h similarity index 57% rename from replies/getprojectsreply.h rename to zeiterfassunglib/replies/getprojectsreply.h index faa4886..576728a 100644 --- a/replies/getprojectsreply.h +++ b/zeiterfassunglib/replies/getprojectsreply.h @@ -6,24 +6,32 @@ #include #include +#include "zeiterfassunglib_global.h" #include "zeiterfassungreply.h" -#include "zeiterfassungapi.h" -class GetProjectsReply : public ZeiterfassungReply +class ZeiterfassungApi; + +class ZEITERFASSUNGLIBSHARED_EXPORT GetProjectsReply : public ZeiterfassungReply { Q_OBJECT public: GetProjectsReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung); - const QVector &projects() const; + struct Project + { + QString label; + QString value; + }; + + const QVector &projects() const; private Q_SLOTS: void requestFinished(); private: std::unique_ptr m_reply; - QVector m_projects; + QVector m_projects; }; #endif // GETPROJECTSREPLY_H diff --git a/replies/gettimeassignmentsreply.cpp b/zeiterfassunglib/replies/gettimeassignmentsreply.cpp similarity index 94% rename from replies/gettimeassignmentsreply.cpp rename to zeiterfassunglib/replies/gettimeassignmentsreply.cpp index 9d04093..a4b62ef 100644 --- a/replies/gettimeassignmentsreply.cpp +++ b/zeiterfassunglib/replies/gettimeassignmentsreply.cpp @@ -7,6 +7,8 @@ #include #include +#include "zeiterfassungapi.h" + GetTimeAssignmentsReply::GetTimeAssignmentsReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung) : ZeiterfassungReply(zeiterfassung), m_reply(std::move(reply)) @@ -14,7 +16,7 @@ GetTimeAssignmentsReply::GetTimeAssignmentsReply(std::unique_ptr connect(m_reply.get(), &QNetworkReply::finished, this, &GetTimeAssignmentsReply::requestFinished); } -const QVector &GetTimeAssignmentsReply::timeAssignments() const +const QVector &GetTimeAssignmentsReply::timeAssignments() const { return m_timeAssignments; } diff --git a/zeiterfassunglib/replies/gettimeassignmentsreply.h b/zeiterfassunglib/replies/gettimeassignmentsreply.h new file mode 100644 index 0000000..a335a70 --- /dev/null +++ b/zeiterfassunglib/replies/gettimeassignmentsreply.h @@ -0,0 +1,43 @@ +#ifndef GETTIMEASSIGNMENTSREPLY_H +#define GETTIMEASSIGNMENTSREPLY_H + +#include + +#include +#include + +#include "zeiterfassunglib_global.h" +#include "zeiterfassungreply.h" + +class ZeiterfassungApi; + +class ZEITERFASSUNGLIBSHARED_EXPORT GetTimeAssignmentsReply : public ZeiterfassungReply +{ + Q_OBJECT + +public: + GetTimeAssignmentsReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung); + + struct TimeAssignment + { + int id; + QDate date; + QTime time; + QTime timespan; + QString text; + QString project; + QString subproject; + QString workpackage; + }; + + const QVector &timeAssignments() const; + +private Q_SLOTS: + void requestFinished(); + +private: + std::unique_ptr m_reply; + QVector m_timeAssignments; +}; + +#endif // GETTIMEASSIGNMENTSREPLY_H diff --git a/replies/userinforeply.cpp b/zeiterfassunglib/replies/getuserinforeply.cpp similarity index 83% rename from replies/userinforeply.cpp rename to zeiterfassunglib/replies/getuserinforeply.cpp index 4e45625..73d751b 100644 --- a/replies/userinforeply.cpp +++ b/zeiterfassunglib/replies/getuserinforeply.cpp @@ -1,23 +1,25 @@ -#include "userinforeply.h" +#include "getuserinforeply.h" #include #include #include #include -UserInfoReply::UserInfoReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung) : +#include "zeiterfassungapi.h" + +GetUserInfoReply::GetUserInfoReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung) : ZeiterfassungReply(zeiterfassung), m_reply(std::move(reply)) { - connect(m_reply.get(), &QNetworkReply::finished, this, &UserInfoReply::requestFinished); + connect(m_reply.get(), &QNetworkReply::finished, this, &GetUserInfoReply::requestFinished); } -const ZeiterfassungApi::UserInfo &UserInfoReply::userInfo() const +const GetUserInfoReply::UserInfo &GetUserInfoReply::userInfo() const { return m_userInfo; } -void UserInfoReply::requestFinished() +void GetUserInfoReply::requestFinished() { if(m_reply->error() != QNetworkReply::NoError) { diff --git a/zeiterfassunglib/replies/getuserinforeply.h b/zeiterfassunglib/replies/getuserinforeply.h new file mode 100644 index 0000000..30e2579 --- /dev/null +++ b/zeiterfassunglib/replies/getuserinforeply.h @@ -0,0 +1,39 @@ +#ifndef GETUSERINFOREPLY_H +#define GETUSERINFOREPLY_H + +#include + +#include + +#include "zeiterfassunglib_global.h" +#include "zeiterfassungreply.h" + +class ZeiterfassungApi; + +class ZEITERFASSUNGLIBSHARED_EXPORT GetUserInfoReply : public ZeiterfassungReply +{ + Q_OBJECT + +public: + GetUserInfoReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung); + + struct UserInfo + { + int userId; + QString email; + QString longUsername; + QString text; + QString username; + }; + + const UserInfo &userInfo() const; + +private Q_SLOTS: + void requestFinished(); + +private: + std::unique_ptr m_reply; + UserInfo m_userInfo; +}; + +#endif // GETUSERINFOREPLY_H diff --git a/replies/loginpagereply.cpp b/zeiterfassunglib/replies/loginpagereply.cpp similarity index 100% rename from replies/loginpagereply.cpp rename to zeiterfassunglib/replies/loginpagereply.cpp diff --git a/replies/loginpagereply.h b/zeiterfassunglib/replies/loginpagereply.h similarity index 76% rename from replies/loginpagereply.h rename to zeiterfassunglib/replies/loginpagereply.h index 203cb5d..daf0f44 100644 --- a/replies/loginpagereply.h +++ b/zeiterfassunglib/replies/loginpagereply.h @@ -5,9 +5,10 @@ #include +#include "zeiterfassunglib_global.h" #include "zeiterfassungreply.h" -class LoginPageReply : public ZeiterfassungReply +class ZEITERFASSUNGLIBSHARED_EXPORT LoginPageReply : public ZeiterfassungReply { Q_OBJECT diff --git a/replies/loginreply.cpp b/zeiterfassunglib/replies/loginreply.cpp similarity index 100% rename from replies/loginreply.cpp rename to zeiterfassunglib/replies/loginreply.cpp diff --git a/replies/loginreply.h b/zeiterfassunglib/replies/loginreply.h similarity index 76% rename from replies/loginreply.h rename to zeiterfassunglib/replies/loginreply.h index bcf7dc1..2626d7a 100644 --- a/replies/loginreply.h +++ b/zeiterfassunglib/replies/loginreply.h @@ -5,9 +5,10 @@ #include +#include "zeiterfassunglib_global.h" #include "zeiterfassungreply.h" -class LoginReply : public ZeiterfassungReply +class ZEITERFASSUNGLIBSHARED_EXPORT LoginReply : public ZeiterfassungReply { Q_OBJECT diff --git a/replies/updatebookingreply.cpp b/zeiterfassunglib/replies/updatebookingreply.cpp similarity index 100% rename from replies/updatebookingreply.cpp rename to zeiterfassunglib/replies/updatebookingreply.cpp diff --git a/replies/updatebookingreply.h b/zeiterfassunglib/replies/updatebookingreply.h similarity index 77% rename from replies/updatebookingreply.h rename to zeiterfassunglib/replies/updatebookingreply.h index f61e179..c948485 100644 --- a/replies/updatebookingreply.h +++ b/zeiterfassunglib/replies/updatebookingreply.h @@ -5,9 +5,10 @@ #include +#include "zeiterfassunglib_global.h" #include "zeiterfassungreply.h" -class UpdateBookingReply : public ZeiterfassungReply +class ZEITERFASSUNGLIBSHARED_EXPORT UpdateBookingReply : public ZeiterfassungReply { Q_OBJECT diff --git a/replies/updatetimeassignmentreply.cpp b/zeiterfassunglib/replies/updatetimeassignmentreply.cpp similarity index 100% rename from replies/updatetimeassignmentreply.cpp rename to zeiterfassunglib/replies/updatetimeassignmentreply.cpp diff --git a/replies/updatetimeassignmentreply.h b/zeiterfassunglib/replies/updatetimeassignmentreply.h similarity index 79% rename from replies/updatetimeassignmentreply.h rename to zeiterfassunglib/replies/updatetimeassignmentreply.h index 84b4cca..ea9977a 100644 --- a/replies/updatetimeassignmentreply.h +++ b/zeiterfassunglib/replies/updatetimeassignmentreply.h @@ -5,9 +5,10 @@ #include +#include "zeiterfassunglib_global.h" #include "zeiterfassungreply.h" -class UpdateTimeAssignmentReply : public ZeiterfassungReply +class ZEITERFASSUNGLIBSHARED_EXPORT UpdateTimeAssignmentReply : public ZeiterfassungReply { Q_OBJECT diff --git a/replies/zeiterfassungreply.cpp b/zeiterfassunglib/replies/zeiterfassungreply.cpp similarity index 100% rename from replies/zeiterfassungreply.cpp rename to zeiterfassunglib/replies/zeiterfassungreply.cpp diff --git a/replies/zeiterfassungreply.h b/zeiterfassunglib/replies/zeiterfassungreply.h similarity index 83% rename from replies/zeiterfassungreply.h rename to zeiterfassunglib/replies/zeiterfassungreply.h index 58f31f4..6ac1b68 100644 --- a/replies/zeiterfassungreply.h +++ b/zeiterfassunglib/replies/zeiterfassungreply.h @@ -3,9 +3,11 @@ #include +#include "zeiterfassunglib_global.h" + class ZeiterfassungApi; -class ZeiterfassungReply : public QObject +class ZEITERFASSUNGLIBSHARED_EXPORT ZeiterfassungReply : public QObject { Q_OBJECT diff --git a/resources.qrc b/zeiterfassunglib/resources.qrc similarity index 93% rename from resources.qrc rename to zeiterfassunglib/resources.qrc index 37eb951..13f4b93 100644 --- a/resources.qrc +++ b/zeiterfassunglib/resources.qrc @@ -1,5 +1,5 @@ - + images/about.png images/auswertung.png images/authentication.png diff --git a/stripfactory.cpp b/zeiterfassunglib/stripfactory.cpp similarity index 100% rename from stripfactory.cpp rename to zeiterfassunglib/stripfactory.cpp diff --git a/stripfactory.h b/zeiterfassunglib/stripfactory.h similarity index 87% rename from stripfactory.h rename to zeiterfassunglib/stripfactory.h index 4aae50e..af3e1d3 100644 --- a/stripfactory.h +++ b/zeiterfassunglib/stripfactory.h @@ -6,10 +6,12 @@ #include #include +#include "zeiterfassunglib_global.h" + class QUiLoader; class QByteArray; -class StripFactory : public QObject +class ZEITERFASSUNGLIBSHARED_EXPORT StripFactory : public QObject { Q_OBJECT diff --git a/stripswidget.cpp b/zeiterfassunglib/stripswidget.cpp similarity index 98% rename from stripswidget.cpp rename to zeiterfassunglib/stripswidget.cpp index 150a711..6b00f52 100644 --- a/stripswidget.cpp +++ b/zeiterfassunglib/stripswidget.cpp @@ -7,6 +7,7 @@ #include #include +#include "zeiterfassungapi.h" #include "timeutils.h" #include "stripfactory.h" @@ -40,12 +41,12 @@ void StripsWidget::setDate(const QDate &date) refresh(); } -const QVector &StripsWidget::bookings() const +const QVector &StripsWidget::bookings() const { return m_bookings; } -const QVector &StripsWidget::timeAssignments() const +const QVector &StripsWidget::timeAssignments() const { return m_timeAssignments; } @@ -167,7 +168,7 @@ bool StripsWidget::createStrips() auto bookingTimespan = QTime(0, 0); - const ZeiterfassungApi::Booking *lastBooking = Q_NULLPTR; + const GetBookingsReply::Booking *lastBooking = Q_NULLPTR; QString errorMessage; diff --git a/stripswidget.h b/zeiterfassunglib/stripswidget.h similarity index 82% rename from stripswidget.h rename to zeiterfassunglib/stripswidget.h index 689511d..8995538 100644 --- a/stripswidget.h +++ b/zeiterfassunglib/stripswidget.h @@ -6,7 +6,7 @@ #include #include -#include "zeiterfassungapi.h" +#include "zeiterfassunglib_global.h" #include "replies/getbookingsreply.h" #include "replies/gettimeassignmentsreply.h" @@ -14,9 +14,10 @@ class QBoxLayout; template class QMap; template class QVector; +class ZeiterfassungApi; class StripFactory; -class StripsWidget : public QWidget +class ZEITERFASSUNGLIBSHARED_EXPORT StripsWidget : public QWidget { Q_OBJECT @@ -27,8 +28,8 @@ public: const QDate &date() const; void setDate(const QDate &date); - const QVector &bookings() const; - const QVector &timeAssignments() const; + const QVector &bookings() const; + const QVector &timeAssignments() const; const QTime &timeAssignmentTime() const; const QTime &lastTimeAssignmentStart() const; @@ -46,8 +47,8 @@ public: void clearStrips(); Q_SIGNALS: - void bookingsChanged(const QVector &bookings); - void timeAssignmentsChanged(const QVector &timeAssignments); + void bookingsChanged(const QVector &bookings); + void timeAssignmentsChanged(const QVector &timeAssignments); void timeAssignmentTimeChanged(const QTime &timeAssignmentTime); void lastTimeAssignmentStartChanged(const QTime &lastTimeAssignmentStart); @@ -81,8 +82,8 @@ private: QDate m_date; - QVector m_bookings; - QVector m_timeAssignments; + QVector m_bookings; + QVector m_timeAssignments; QTime m_timeAssignmentTime; QTime m_lastTimeAssignmentStart; diff --git a/timeutils.cpp b/zeiterfassunglib/timeutils.cpp similarity index 100% rename from timeutils.cpp rename to zeiterfassunglib/timeutils.cpp diff --git a/zeiterfassunglib/timeutils.h b/zeiterfassunglib/timeutils.h new file mode 100644 index 0000000..0bc866a --- /dev/null +++ b/zeiterfassunglib/timeutils.h @@ -0,0 +1,13 @@ +#ifndef TIMEUTILS_H +#define TIMEUTILS_H + +#include + +#include "zeiterfassunglib_global.h" + +int ZEITERFASSUNGLIBSHARED_EXPORT timeToSeconds(const QTime &time); +QTime ZEITERFASSUNGLIBSHARED_EXPORT timeBetween(const QTime &l, const QTime &r); +QTime ZEITERFASSUNGLIBSHARED_EXPORT timeAdd(const QTime &l, const QTime &r); +QTime ZEITERFASSUNGLIBSHARED_EXPORT timeNormalise(const QTime &time); + +#endif // TIMEUTILS_H diff --git a/translations/zeiterfassung_de.ts b/zeiterfassunglib/translations/zeiterfassunglib_de.ts similarity index 72% rename from translations/zeiterfassung_de.ts rename to zeiterfassunglib/translations/zeiterfassunglib_de.ts index 370f0de..db4389c 100644 --- a/translations/zeiterfassung_de.ts +++ b/zeiterfassunglib/translations/zeiterfassunglib_de.ts @@ -116,22 +116,22 @@ Request error occured: %0 - Fehler bei Anfrage aufgetreten: %0 + Parsing JSON failed: %0 - JSON konnte nicht geparst werden: %0 + JSON document is not an object! - JSON Dokument ist kein Objekt! + JSON does not contain bookingNr! - JSON beinhaltet keine bookingNr! + @@ -139,22 +139,22 @@ Request error occured: %0 - Fehler bei Anfrage aufgetreten: %0 + Parsing JSON failed: %0 - JSON konnte nicht geparst werden: %0 + JSON document is not an object! - JSON Dokument ist kein Objekt! + JSON does not contain bookingNr! - JSON beinhaltet keine bookingNr! + @@ -162,7 +162,7 @@ Request error occured: %0 - Fehler bei Anfrage aufgetreten: %0 + @@ -170,7 +170,7 @@ Request error occured: %0 - Fehler bei Anfrage aufgetreten: %0 + @@ -179,71 +179,117 @@ Request error occured: %0 - Fehler bei Anfrage aufgetreten: %0 + GetBookingsReply - + Request error occured: %0 - Fehler bei Anfrage aufgetreten: %0 + - + Parsing JSON failed: %0 - JSON konnte nicht geparst werden: %0 + - + JSON document is not an array! - JSON Dokument ist keine Liste! + + + + + GetPresenceStatusReply + + + Request error occured: %0 + + + + + Parsing JSON failed: %0 + + + + + JSON document is not an array! + GetProjectsReply - + Request error occured: %0 - Fehler bei Anfrage aufgetreten: %0 + - + Parsing JSON failed: %0 - JSON konnte nicht geparst werden: %0 + - + JSON document is not an object! - JSON Dokument ist kein Objekt! + - + JSON does not contain elements! - JSON beinhaltet kein elements! + - + elements is not an array! - elements ist keine Liste! + GetTimeAssignmentsReply - + Request error occured: %0 - Fehler bei Anfrage aufgetreten: %0 + - + Parsing JSON failed: %0 - JSON konnte nicht geparst werden: %0 + - + JSON document is not an array! - JSON Dokument ist keine Liste! + + + + + GetUserInfoReply + + + Request error occured: %0 + + + + + Parsing JSON failed: %0 + + + + + JSON document is not an object! + + + + + JSON does not contain evoAppsUser! + + + + + evoAppsUser is not an object! + @@ -280,12 +326,12 @@ Request error occured: %0 - Fehler bei Anfrage aufgetreten: %0 + Could not find necessary keywords in login page! - Konnte notwendiges Schlüsselwort in der Login-Seite finden! + @@ -293,22 +339,22 @@ Request error occured: %0 - Fehler bei Anfrage aufgetreten: %0 + Response did not contain a Location header. - Antwort enthielt keinen Location-Header. + Authentication failure. Please check username and password. - Authentifizierungsfehler. Bitte überprüfen Sie Benutzername und Passwort. + An unknown authentication failure occured. Redirected to: %0 - Bei der Authentifizierung ist ein unbekannter Fehler aufgetreten. Weiterleitung nach %0 + @@ -330,8 +376,8 @@ - - + + Start Kommen @@ -426,178 +472,178 @@ Hilfe - + Zeiterfassung - %0 (%1) Zeiterfassung - %0 (%1) - - + + Could not open auswertung! - + Could not open default PDF viewer! Konnte den PDF-Anzeiger nicht öffnen! - + Subproject Subprojekt - + Workpackage Arbeitspaket - + Text Text - - - - + + + + %0: %1 %0: %1 - - + + ??? ??? - - + + Balance Saldo - - + + Holidays Urlaubstage - - + + Could not load bookings! Konnte Buchungen nicht laden! - + Could not load Auswertung! - + %0h %0h - + Could not delete booking! Konnte Buchung nicht löschen! - + Edit booking Buchung bearbeiten - + Delete booking Buchung löschen - + Could not edit booking! Konnte Buchung nicht bearbeiten! - + Create booking Buchung erstellen - - + + n/a n/v - + Refresh bookings Buchungen aktualisieren - - - + + + Could not create booking! Konnte Buchung nicht erstellen! - + Do you really want to delete the booking? Möchten Sie die Buchung wirklich löschen? - + Refresh time assignments Kontierungen aktualisieren - + Edit time assignment Kontierung bearbeiten - + Delete time assignment Kontierung löschen - - - + + + Could not edit time assignment! Konnte Kontierung nicht bearbeiten! - + Do you really want to delete the time assignment? Möchten Sie die Kontierung wirklich löschen? - + Could not delete time assignment! Konnte Kontierung nicht löschen! - - + + %0 (%1) %0 (%1) - + Create time assignment Kontierung erstellen - - + + Could not create time assignment! Konnte Kontierung nicht erstellen! - - + + Switch Wechseln @@ -682,178 +728,178 @@ StripsWidget - + Loading... Lade... - + Missing booking! Kontierung fehlend! - + Expected start booking, instead got type %0 Booking ID: %1 - - + + %0: %1 %0: %1 - + Break Pause - - - + + + %0h %0h - - - - - + + + + + HH:mm HH:mm - + Missing time assignment! Kontierung fehlend! - - - + + + Expected %0 but received %1 in time assignment. Time assignment ID: %2 - - + - - + + - + + HH:mm:ss HH:mm:ss - - + + There is another booking after an unfinished time assignment. Booking ID: %0 Time assignment ID: %1 - - - + + + There is another time assignment after an unfinished time assignment. Time assignment ID: %0 Time assignment ID: %1 - + The last time assignment is finished without end booking Time assignment ID: %0 - + Expected end booking, instead got type %0 Booking ID: %1 - + Missing time assignment! Missing: %0 Kontierung fehlend! %0 nicht kontiert - + Assigned time Kontierte Zeit - + dd.MM.yyyy dd.MM.yyyy - + %0 (%1) %0 (%1) - + Time assignment time longer than booking time! Time assignment: %0 Booking: %1 - + Strip rendering aborted due error. Your bookings and time assignments for this day are in an illegal state! - + Monday Montag - + Tuesday Dienstag - + Wednesday Mittwoch - + Thursday Donnerstag - + Friday Freitag - + Saturday Samstag - + Sunday Sonntag - + Invalid Ungültig - + Open Offen @@ -946,22 +992,22 @@ Your bookings and time assignments for this day are in an illegal state! Request error occured: %0 - Fehler bei Anfrage aufgetreten: %0 + Parsing JSON failed: %0 - JSON konnte nicht geparst werden: %0 + JSON document is not an object! - JSON Dokument ist kein Objekt! + JSON does not contain bookingNr! - JSON beinhaltet keine bookingNr! + @@ -983,7 +1029,7 @@ Your bookings and time assignments for this day are in an illegal state!Heute nicht mehr anzeigen - + Could not open default webbrowser! Konnte den Standard-Browser nicht öffnen! @@ -993,168 +1039,22 @@ Your bookings and time assignments for this day are in an illegal state! Request error occured: %0 - Fehler bei Anfrage aufgetreten: %0 + Parsing JSON failed: %0 - JSON konnte nicht geparst werden: %0 + JSON document is not an object! - JSON Dokument ist kein Objekt! + JSON does not contain bookingNr! - JSON beinhaltet keine bookingNr! - - - - UserInfoReply - - - Request error occured: %0 - Fehler bei Anfrage aufgetreten: %0 - - - - Parsing JSON failed: %0 - JSON konnte nicht geparst werden: %0 - - - - JSON document is not an object! - JSON Dokument ist kein Objekt! - - - - JSON does not contain evoAppsUser! - JSON beinhaltet kein evoAppsUser! - - - - evoAppsUser is not an object! - evoAppsUser ist kein Objekt! - - - - bookingEndStrip - - - END - GEHEN - - - - bookingStartStrip - - - START - KOMMEN - - - - main - - - Loading settings... - Lade Einstellungen... - - - - Loading translations... - Lade Übersetzungen... - - - - - Invalid language selection! - Ungültige Sprachauswahl! - - - - You did not select a valid language! - Sie haben keine gültige Sprachauswahl getroffen! - - - - Loading theme... - Lade Aussehen... - - - - - - - Could not load theme! - Konnte Aussehen nicht laden! - - - - Theme file does not exist! - Aussehen-Datei existiert nicht! - - - - Loading login page... - Lade Login-Seite... - - - - - Could not access Zeiterfassung! - Konnte Zeiterfassung nicht erreichen! - - - - Base url - Basis URL - - - - Please enter the base url to the Zeiterfassung: - Bitte geben Sie die Basis URL zur Zeiterfassung ein: - - - - Authenticating... - Authentifiziere... - - - - - Could not authenticate with Zeiterfassung! - Konnte nicht mit Zeiterfassung authentifizieren! - - - - Getting user information... - Hole Benutzer Information... - - - - - Could not get user information! - Konnte Benutzer Information nicht holen! - - - - Loading strip layouts... - Lade Streifenlayouts... - - - - - - - - - - - Could not load strips! - Konnte Streifenlayouts nicht laden! + diff --git a/translations/zeiterfassung_en.ts b/zeiterfassunglib/translations/zeiterfassunglib_en.ts similarity index 79% rename from translations/zeiterfassung_en.ts rename to zeiterfassunglib/translations/zeiterfassunglib_en.ts index 281e6e6..7fb33eb 100644 --- a/translations/zeiterfassung_en.ts +++ b/zeiterfassunglib/translations/zeiterfassunglib_en.ts @@ -185,17 +185,35 @@ GetBookingsReply - + Request error occured: %0 - + Parsing JSON failed: %0 - + + JSON document is not an array! + + + + + GetPresenceStatusReply + + + Request error occured: %0 + + + + + Parsing JSON failed: %0 + + + + JSON document is not an array! @@ -203,27 +221,27 @@ GetProjectsReply - + Request error occured: %0 - + Parsing JSON failed: %0 - + JSON document is not an object! - + JSON does not contain elements! - + elements is not an array! @@ -231,21 +249,49 @@ GetTimeAssignmentsReply - + Request error occured: %0 - + Parsing JSON failed: %0 - + JSON document is not an array! + + GetUserInfoReply + + + Request error occured: %0 + + + + + Parsing JSON failed: %0 + + + + + JSON document is not an object! + + + + + JSON does not contain evoAppsUser! + + + + + evoAppsUser is not an object! + + + LanguageSelectionDialog @@ -330,8 +376,8 @@ - - + + Start @@ -426,181 +472,181 @@ - + Zeiterfassung - %0 (%1) - - - Could not open auswertung! - - - - - Could not open default PDF viewer! - - - - + Subproject - + Workpackage - + Text - - - - - %0: %1 - - - - - + + ??? - - - Balance - - - - - - Holidays - - - - - + + Could not load bookings! - + Could not load Auswertung! - - %0h - - - - - Could not delete booking! - - - - - Edit booking - - - - - Delete booking - - - - - Could not edit booking! - - - - - Create booking - - - - - + + n/a - + + %0h + + + + + + + + %0: %1 + + + + + + Balance + + + + + + Holidays + + + + + Create booking + + + + Refresh bookings - - - + + + Could not create booking! - + + Edit booking + + + + + Delete booking + + + + + Could not edit booking! + + + + Do you really want to delete the booking? - - Refresh time assignments + + Could not delete booking! - Edit time assignment - - - - - Delete time assignment - - - - - - - Could not edit time assignment! - - - - - Do you really want to delete the time assignment? - - - - - Could not delete time assignment! - - - - - - %0 (%1) - - - - Create time assignment - - + + Refresh time assignments + + + + + Could not create time assignment! - - + + Edit time assignment + + + + + Delete time assignment + + + + + + + Could not edit time assignment! + + + + + Do you really want to delete the time assignment? + + + + + Could not delete time assignment! + + + + + + Could not open auswertung! + + + + + Could not open default PDF viewer! + + + + + Switch + + + + %0 (%1) + + SettingsDialog @@ -682,178 +728,178 @@ StripsWidget - + Loading... - + Missing booking! - + Expected start booking, instead got type %0 Booking ID: %1 - - + + %0: %1 - + Break - - - + + + %0h - - - - - + + + + + HH:mm - + Missing time assignment! - - - + + + Expected %0 but received %1 in time assignment. Time assignment ID: %2 - - + - - + + - + + HH:mm:ss - - + + There is another booking after an unfinished time assignment. Booking ID: %0 Time assignment ID: %1 - - - + + + There is another time assignment after an unfinished time assignment. Time assignment ID: %0 Time assignment ID: %1 - + The last time assignment is finished without end booking Time assignment ID: %0 - + Expected end booking, instead got type %0 Booking ID: %1 - + Missing time assignment! Missing: %0 - - Assigned time - - - - - dd.MM.yyyy - - - - - %0 (%1) - - - - + Time assignment time longer than booking time! Time assignment: %0 Booking: %1 - + + Assigned time + + + + Strip rendering aborted due error. Your bookings and time assignments for this day are in an illegal state! + %0 (%1) + + + + Monday - + Tuesday - + Wednesday - + Thursday - + Friday - + Saturday - + Sunday - + + dd.MM.yyyy + + + + Invalid - + Open @@ -983,7 +1029,7 @@ Your bookings and time assignments for this day are in an illegal state! - + Could not open default webbrowser! @@ -1011,150 +1057,4 @@ Your bookings and time assignments for this day are in an illegal state! - - UserInfoReply - - - Request error occured: %0 - - - - - Parsing JSON failed: %0 - - - - - JSON document is not an object! - - - - - JSON does not contain evoAppsUser! - - - - - evoAppsUser is not an object! - - - - - bookingEndStrip - - - END - - - - - bookingStartStrip - - - START - - - - - main - - - Loading settings... - - - - - Loading translations... - - - - - - Invalid language selection! - - - - - You did not select a valid language! - - - - - Loading theme... - - - - - - - - Could not load theme! - - - - - Theme file does not exist! - - - - - Loading login page... - - - - - - Could not access Zeiterfassung! - - - - - Base url - - - - - Please enter the base url to the Zeiterfassung: - - - - - Authenticating... - - - - - - Could not authenticate with Zeiterfassung! - - - - - Getting user information... - - - - - - Could not get user information! - - - - - Loading strip layouts... - - - - - - - - - - - - Could not load strips! - - - diff --git a/zeiterfassungapi.cpp b/zeiterfassunglib/zeiterfassungapi.cpp similarity index 98% rename from zeiterfassungapi.cpp rename to zeiterfassunglib/zeiterfassungapi.cpp index d723091..84bebfa 100644 --- a/zeiterfassungapi.cpp +++ b/zeiterfassunglib/zeiterfassungapi.cpp @@ -22,7 +22,7 @@ #include "replies/loginreply.h" #include "replies/updatebookingreply.h" #include "replies/updatetimeassignmentreply.h" -#include "replies/userinforeply.h" +#include "replies/getuserinforeply.h" //add support for pre cpp14 compilers #include "cpp14polyfills.h" @@ -55,6 +55,8 @@ std::unique_ptr ZeiterfassungApi::doLoginPage() auto reply = std::unique_ptr(m_manager->get(request)); + qDebug() << reply->parent(); + return std::make_unique(std::move(reply), this); } @@ -71,14 +73,14 @@ std::unique_ptr ZeiterfassungApi::doLogin(const QString &username, c return std::make_unique(std::move(reply), this); } -std::unique_ptr ZeiterfassungApi::doUserInfo() +std::unique_ptr ZeiterfassungApi::doUserInfo() { QNetworkRequest request(QUrl(m_url % "json/evoAppsUserInfoDialogController/load-EvoAppsUserInfoTO")); request.setRawHeader(QByteArrayLiteral("sisAppName"), QByteArrayLiteral("home")); auto reply = std::unique_ptr(m_manager->get(request)); - return std::make_unique(std::move(reply), this); + return std::make_unique(std::move(reply), this); } std::unique_ptr ZeiterfassungApi::doGetBookings(int userId, const QDate &start, const QDate &end) diff --git a/zeiterfassungapi.h b/zeiterfassunglib/zeiterfassungapi.h similarity index 77% rename from zeiterfassungapi.h rename to zeiterfassunglib/zeiterfassungapi.h index 86bfa0c..ff1f3b7 100644 --- a/zeiterfassungapi.h +++ b/zeiterfassunglib/zeiterfassungapi.h @@ -8,11 +8,13 @@ #include #include +#include "zeiterfassunglib_global.h" + class QNetworkAccessManager; class LoginPageReply; class LoginReply; -class UserInfoReply; +class GetUserInfoReply; class GetBookingsReply; class CreateBookingReply; class UpdateBookingReply; @@ -25,7 +27,7 @@ class GetProjectsReply; class GetAuswertungReply; class GetPresenceStatusReply; -class ZeiterfassungApi : public QObject +class ZEITERFASSUNGLIBSHARED_EXPORT ZeiterfassungApi : public QObject { Q_OBJECT @@ -37,54 +39,9 @@ public: QNetworkAccessManager *manager() const; - struct UserInfo - { - int userId; - QString email; - QString longUsername; - QString text; - QString username; - }; - - struct Booking - { - int id; - QDate date; - QTime time; - QTime timespan; - QString type; - QString text; - }; - - struct TimeAssignment - { - int id; - QDate date; - QTime time; - QTime timespan; - QString text; - QString project; - QString subproject; - QString workpackage; - }; - - struct Project - { - QString label; - QString value; - }; - - struct PresenceStatus - { - int userId; - QString firstName; - QString lastName; - QString presence; - }; - std::unique_ptr doLoginPage(); std::unique_ptr doLogin(const QString &username, const QString &password); - std::unique_ptr doUserInfo(); + std::unique_ptr doUserInfo(); std::unique_ptr doGetBookings(int userId, const QDate &start, const QDate &end); std::unique_ptr doCreateBooking(int userId, const QDate &date, const QTime &time, const QTime ×pan, diff --git a/zeiterfassunglib/zeiterfassunglib.pro b/zeiterfassunglib/zeiterfassunglib.pro new file mode 100644 index 0000000..4b10025 --- /dev/null +++ b/zeiterfassunglib/zeiterfassunglib.pro @@ -0,0 +1,98 @@ +QT += core network gui widgets uitools + +TARGET = zeiterfassunglib +TEMPLATE = lib + +CONFIG += c++14 + +DESTDIR = $${OUT_PWD}/../lib + +DEFINES += QT_DEPRECATED_WARNINGS QT_DISABLE_DEPRECATED_BEFORE=0x060000 QT_MESSAGELOGCONTEXT +DEFINES += ZEITERFASSUNGLIB_LIBRARY + +SOURCES += mainwindow.cpp \ + stripfactory.cpp \ + stripswidget.cpp \ + timeutils.cpp \ + zeiterfassungapi.cpp \ + zeiterfassungplugin.cpp \ + zeiterfassungsettings.cpp \ + dialogs/aboutmedialog.cpp \ + dialogs/authenticationdialog.cpp \ + dialogs/bookingdialog.cpp \ + dialogs/languageselectiondialog.cpp \ + dialogs/settingsdialog.cpp \ + dialogs/timeassignmentdialog.cpp \ + dialogs/updatedialog.cpp \ + models/bookingsmodel.cpp \ + models/timeassignmentsmodel.cpp \ + replies/createbookingreply.cpp \ + replies/createtimeassignmentreply.cpp \ + replies/deletebookingreply.cpp \ + replies/deletetimeassignmentreply.cpp \ + replies/getauswertungreply.cpp \ + replies/getbookingsreply.cpp \ + replies/getpresencestatusreply.cpp \ + replies/getprojectsreply.cpp \ + replies/gettimeassignmentsreply.cpp \ + replies/loginpagereply.cpp \ + replies/loginreply.cpp \ + replies/updatebookingreply.cpp \ + replies/updatetimeassignmentreply.cpp \ + replies/zeiterfassungreply.cpp \ + replies/getuserinforeply.cpp + +HEADERS += cpp14polyfills.h \ + mainwindow.h \ + stripfactory.h \ + stripswidget.h \ + timeutils.h \ + zeiterfassungapi.h \ + zeiterfassunglib_global.h \ + zeiterfassungplugin.h \ + zeiterfassungsettings.h \ + dialogs/aboutmedialog.h \ + dialogs/authenticationdialog.h \ + dialogs/bookingdialog.h \ + dialogs/languageselectiondialog.h \ + dialogs/settingsdialog.h \ + dialogs/timeassignmentdialog.h \ + dialogs/updatedialog.h \ + models/bookingsmodel.h \ + models/timeassignmentsmodel.h \ + replies/createbookingreply.h \ + replies/createtimeassignmentreply.h \ + replies/deletebookingreply.h \ + replies/deletetimeassignmentreply.h \ + replies/getauswertungreply.h \ + replies/getbookingsreply.h \ + replies/getpresencestatusreply.h \ + replies/getprojectsreply.h \ + replies/gettimeassignmentsreply.h \ + replies/loginpagereply.h \ + replies/loginreply.h \ + replies/updatebookingreply.h \ + replies/updatetimeassignmentreply.h \ + replies/zeiterfassungreply.h \ + replies/getuserinforeply.h + +FORMS += mainwindow.ui \ + dialogs/updatedialog.ui \ + dialogs/settingsdialog.ui \ + dialogs/languageselectiondialog.ui \ + dialogs/authenticationdialog.ui \ + dialogs/bookingdialog.ui \ + dialogs/aboutmedialog.ui \ + dialogs/timeassignmentdialog.ui + +RESOURCES += resources.qrc + +TRANSLATIONS += translations/zeiterfassunglib_en.ts \ + translations/zeiterfassunglib_de.ts + +include(../lrelease.pri) + +# unix { +# target.path = /usr/lib +# INSTALLS += target +# } diff --git a/zeiterfassunglib/zeiterfassunglib_global.h b/zeiterfassunglib/zeiterfassunglib_global.h new file mode 100644 index 0000000..bfb9534 --- /dev/null +++ b/zeiterfassunglib/zeiterfassunglib_global.h @@ -0,0 +1,12 @@ +#ifndef ZEITERFASSUNGLIB_GLOBAL_H +#define ZEITERFASSUNGLIB_GLOBAL_H + +#include + +#if defined(ZEITERFASSUNGLIB_LIBRARY) +# define ZEITERFASSUNGLIBSHARED_EXPORT Q_DECL_EXPORT +#else +# define ZEITERFASSUNGLIBSHARED_EXPORT Q_DECL_IMPORT +#endif + +#endif // ZEITERFASSUNGLIB_GLOBAL_H diff --git a/zeiterfassunglib/zeiterfassungplugin.cpp b/zeiterfassunglib/zeiterfassungplugin.cpp new file mode 100644 index 0000000..4436d93 --- /dev/null +++ b/zeiterfassunglib/zeiterfassungplugin.cpp @@ -0,0 +1,7 @@ +#include "zeiterfassungplugin.h" + +ZeiterfassungPlugin::ZeiterfassungPlugin(QObject *parent) : + QObject(parent) +{ + +} diff --git a/zeiterfassunglib/zeiterfassungplugin.h b/zeiterfassunglib/zeiterfassungplugin.h new file mode 100644 index 0000000..33eee20 --- /dev/null +++ b/zeiterfassunglib/zeiterfassungplugin.h @@ -0,0 +1,24 @@ +#ifndef ZEITERFASSUNGPLUGIN_H +#define ZEITERFASSUNGPLUGIN_H + +#include + +#include "zeiterfassunglib_global.h" + +class MainWindow; +class StripsWidget; + +class ZEITERFASSUNGLIBSHARED_EXPORT ZeiterfassungPlugin : public QObject +{ + Q_OBJECT + +public: + explicit ZeiterfassungPlugin(QObject *parent = 0); + + virtual void attachTo(MainWindow &mainWindow) { Q_UNUSED(mainWindow) } + virtual void attachTo(StripsWidget &stripsWidget) { Q_UNUSED(stripsWidget) } +}; + +Q_DECLARE_INTERFACE(ZeiterfassungPlugin, "dbsoftware.zeiterfassung.plugin/1.0") + +#endif // ZEITERFASSUNGPLUGIN_H diff --git a/zeiterfassungsettings.cpp b/zeiterfassunglib/zeiterfassungsettings.cpp similarity index 100% rename from zeiterfassungsettings.cpp rename to zeiterfassunglib/zeiterfassungsettings.cpp diff --git a/zeiterfassungsettings.h b/zeiterfassunglib/zeiterfassungsettings.h similarity index 94% rename from zeiterfassungsettings.h rename to zeiterfassunglib/zeiterfassungsettings.h index 34e2489..952cbdb 100644 --- a/zeiterfassungsettings.h +++ b/zeiterfassunglib/zeiterfassungsettings.h @@ -7,7 +7,9 @@ #include #include -class ZeiterfassungSettings : public QSettings +#include "zeiterfassunglib_global.h" + +class ZEITERFASSUNGLIBSHARED_EXPORT ZeiterfassungSettings : public QSettings { Q_OBJECT