diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..afb2677 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,27 @@ +language: cpp +os: linux +sudo: false +dist: trusty +compiler: + - gcc + - clang + +cache: + directories: + - qt5 + +before_script: + - mkdir -p qt5 + - if [ ! -d qt5/.git ] ; then rm qt5 -Rf ; git clone --branch=5.10 git://code.qt.io/qt/qt5.git ; fi + - pushd qt5 + - if [ ! -d qtbase/.git ] ; then perl init-repository --module-subset=qtbase,qtimageformats,qtmultimedia,qttools ; fi + - if [ ! -f config.summary ] ; then ./configure -prefix `pwd`/build -opensource -confirm-license -nomake examples -nomake tests ; fi + - if [ ! -d build ] ; then make -j2 > /dev/null && make install ; fi + - popd + +script: + - mkdir -p build + - pushd build + - ../qt5/build/bin/qmake .. -config release + - make -j2 + - popd diff --git a/QtZeiterfassung.pro b/QtZeiterfassung.pro new file mode 100644 index 0000000..17025d9 --- /dev/null +++ b/QtZeiterfassung.pro @@ -0,0 +1,13 @@ +TEMPLATE = subdirs + +SUBDIRS += plugins \ + zeiterfassung \ + zeiterfassungcorelib \ + zeiterfassungguilib + +plugins.depends += zeiterfassungguilib +zeiterfassung.depends += zeiterfassungcorelib zeiterfassungguilib +zeiterfassungguilib.depends += zeiterfassungcorelib + +include(installs.pri) +win32: include(installs_win32.pri) diff --git a/README.md b/README.md index 40176c6..2e8affb 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # Zeiterfassung This tool helps me assigning my working hours to projects at work. +[![Build Status](https://travis-ci.org/0xFEEDC0DE64/QtZeiterfassung.svg?branch=master)](https://travis-ci.org/0xFEEDC0DE64/QtZeiterfassung) + ![Screenshot of the main window](https://raw.githubusercontent.com/0xFEEDC0DE64/QtZeiterfassung/master/screenshot.png) ## Building from source @@ -13,11 +15,12 @@ mkdir build_QtZeiterfassung cd build_QtZeiterfassung qmake ../QtZeiterfassung make +make install # only needed on first build to copy Qt resources ``` ## Launching (on unix) ``` -LD_LIBRARY_PATH=../lib ./zeiterfassung # or just use start.sh +./zeiterfassung.sh ``` ## Launching (on win32) diff --git a/installs.pri b/installs.pri new file mode 100644 index 0000000..df38b05 --- /dev/null +++ b/installs.pri @@ -0,0 +1,14 @@ +qtTranslationsInstall.path = $${OUT_PWD}/bin/translations +qtTranslationsInstall.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_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 +INSTALLS += qtTranslationsInstall diff --git a/installs_win32.pri b/installs_win32.pri new file mode 100644 index 0000000..da5ead8 --- /dev/null +++ b/installs_win32.pri @@ -0,0 +1,28 @@ +CONFIG(debug, release|debug): DEBUG_SIGN = d + +qtLibsInstall.path = $${OUT_PWD}/bin +qtLibsInstall.files = win32/Qt.conf \ + $$[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 +INSTALLS += qtLibsInstall + +qtImageFormatsInstall.path = $${OUT_PWD}/bin/plugins/imageformats +qtImageFormatsInstall.files = $$[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 +INSTALLS += qtImageFormatsInstall + +qtPlatformsInstall.path = $${OUT_PWD}/bin/plugins/platforms +qtPlatformsInstall.files = $$[QT_INSTALL_PLUGINS]/platforms/qwindows$${DEBUG_SIGN}.dll +INSTALLS += qtPlatformsInstall diff --git a/lrelease.pri b/lrelease.pri index a0ad8fa..a17903f 100644 --- a/lrelease.pri +++ b/lrelease.pri @@ -4,8 +4,8 @@ isEmpty(QMAKE_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.output = $${OUT_PWD}/$${PROJECT_ROOT}/bin/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/absenceplugin/absencedialog.cpp b/plugins/absenceplugin/absencedialog.cpp new file mode 100644 index 0000000..e45b41b --- /dev/null +++ b/plugins/absenceplugin/absencedialog.cpp @@ -0,0 +1,34 @@ +#include "absencedialog.h" +#include "ui_absencedialog.h" + +#include +#include +#include + +#include "absencesmodel.h" + +AbsenceDialog::AbsenceDialog(int userId, const QDate &date, ZeiterfassungApi &erfassung, QWidget *parent) : + ZeiterfassungDialog(parent), + ui(new Ui::AbsenceDialog) +{ + ui->setupUi(this); + + ui->labelTitle->setText(tr("Absences for %0").arg(date.toString(tr("dd.MM.yyyy")))); + + m_model = new AbsencesModel(userId, date, erfassung, this); + connect(m_model, &AbsencesModel::errorOccured, this, &AbsenceDialog::errorOccured); + + ui->treeView->setModel(m_model); + ui->treeView->setEnabled(m_model->enabled()); + connect(m_model, &AbsencesModel::enabledChanged, ui->treeView, &QWidget::setEnabled); +} + +AbsenceDialog::~AbsenceDialog() +{ + delete ui; +} + +void AbsenceDialog::errorOccured(const QString &message) +{ + QMessageBox::warning(this, tr("Could not load absences!"), tr("Could not load absences!") % "\n\n" % message); +} diff --git a/plugins/absenceplugin/absencedialog.h b/plugins/absenceplugin/absencedialog.h new file mode 100644 index 0000000..f8d0721 --- /dev/null +++ b/plugins/absenceplugin/absencedialog.h @@ -0,0 +1,27 @@ +#pragma once + +#include "zeiterfassungdialog.h" + +class QDate; + +class ZeiterfassungApi; + +class AbsencesModel; +namespace Ui { class AbsenceDialog; } + +class AbsenceDialog : public ZeiterfassungDialog +{ + Q_OBJECT + +public: + explicit AbsenceDialog(int userId, const QDate &date, ZeiterfassungApi &erfassung, QWidget *parent = 0); + ~AbsenceDialog(); + +private Q_SLOTS: + void errorOccured(const QString &message); + +private: + Ui::AbsenceDialog *ui; + + AbsencesModel *m_model; +}; diff --git a/plugins/absenceplugin/absencedialog.ui b/plugins/absenceplugin/absencedialog.ui new file mode 100644 index 0000000..eb6a823 --- /dev/null +++ b/plugins/absenceplugin/absencedialog.ui @@ -0,0 +1,79 @@ + + + AbsenceDialog + + + + 0 + 0 + 947 + 300 + + + + Absences + + + + + + + 16 + + + + Absences for + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Close + + + + + + + + + buttonBox + accepted() + AbsenceDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + AbsenceDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/plugins/absenceplugin/absenceplugin.cpp b/plugins/absenceplugin/absenceplugin.cpp new file mode 100644 index 0000000..2e09928 --- /dev/null +++ b/plugins/absenceplugin/absenceplugin.cpp @@ -0,0 +1,38 @@ +#include "absenceplugin.h" + +#include +#include +#include +#include +#include + +#include "mainwindow.h" +#include "stripswidget.h" + +#include "absencewidget.h" + +AbsencePlugin::AbsencePlugin(QObject *parent) : + ZeiterfassungPlugin(parent) +{ + qDebug() << "called"; + + static auto dir = QDir(QCoreApplication::applicationDirPath()).absoluteFilePath(QStringLiteral("translations")); + + if(m_translator.load(QLocale(), QStringLiteral("absenceplugin"), QStringLiteral("_"), dir)) + { + if(!QCoreApplication::installTranslator(&m_translator)) + { + qWarning() << "could not install translation absenceplugin"; + } + } + else + { + qWarning() << "could not load translation absenceplugin"; + } +} + +void AbsencePlugin::attachTo(MainWindow &mainWindow) +{ + for(auto stripsWidget : mainWindow.stripsWidgets()) + stripsWidget->headerLayout()->addWidget(new AbsenceWidget(*stripsWidget)); +} diff --git a/plugins/absenceplugin/absenceplugin.h b/plugins/absenceplugin/absenceplugin.h new file mode 100644 index 0000000..b3884b8 --- /dev/null +++ b/plugins/absenceplugin/absenceplugin.h @@ -0,0 +1,24 @@ +#pragma once + +#include +#include + +#include "zeiterfassungplugin.h" + +class MainWindow; + +class Q_DECL_EXPORT AbsencePlugin : public ZeiterfassungPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "dbsoftware.zeiterfassung.plugin/1.0" FILE "absenceplugin.json") + Q_INTERFACES(ZeiterfassungPlugin) + +public: + explicit AbsencePlugin(QObject *parent = Q_NULLPTR); + + // ZeiterfassungPlugin interface + void attachTo(MainWindow &mainWindow) Q_DECL_OVERRIDE; + +private: + QTranslator m_translator; +}; diff --git a/zeiterfassung/win32/Qt.conf b/plugins/absenceplugin/absenceplugin.json similarity index 100% rename from zeiterfassung/win32/Qt.conf rename to plugins/absenceplugin/absenceplugin.json diff --git a/plugins/absenceplugin/absenceplugin.pro b/plugins/absenceplugin/absenceplugin.pro new file mode 100644 index 0000000..d938567 --- /dev/null +++ b/plugins/absenceplugin/absenceplugin.pro @@ -0,0 +1,38 @@ +QT += core network gui widgets + +TARGET = absenceplugin +TEMPLATE = lib + +CONFIG += shared c++14 + +PROJECT_ROOT = ../.. + +DESTDIR = $${OUT_PWD}/$${PROJECT_ROOT}/bin/plugins/zeiterfassung + +LIBS += -L$${OUT_PWD}/$${PROJECT_ROOT}/bin -lzeiterfassungcorelib -lzeiterfassungguilib + +INCLUDEPATH += $$PWD/$${PROJECT_ROOT}/zeiterfassungcorelib $$PWD/$${PROJECT_ROOT}/zeiterfassungguilib +DEPENDPATH += $$PWD/$${PROJECT_ROOT}/zeiterfassungcorelib $$PWD/$${PROJECT_ROOT}/zeiterfassungguilib + +DEFINES += QT_DEPRECATED_WARNINGS QT_DISABLE_DEPRECATED_BEFORE=0x060000 QT_MESSAGELOGCONTEXT + +HEADERS += absencedialog.h \ + absencesmodel.h \ + absenceplugin.h \ + absencewidget.h + +SOURCES += absencedialog.cpp \ + absencesmodel.cpp \ + absenceplugin.cpp \ + absencewidget.cpp + +FORMS += absencedialog.ui + +RESOURCES += absenceplugin_resources.qrc + +TRANSLATIONS += translations/absenceplugin_en.ts \ + translations/absenceplugin_de.ts + +OTHER_FILES += absenceplugin.json + +include(../../lrelease.pri) diff --git a/plugins/absenceplugin/absenceplugin_resources.qrc b/plugins/absenceplugin/absenceplugin_resources.qrc new file mode 100644 index 0000000..a3b089d --- /dev/null +++ b/plugins/absenceplugin/absenceplugin_resources.qrc @@ -0,0 +1,5 @@ + + + images/absence.png + + diff --git a/plugins/absenceplugin/absencesmodel.cpp b/plugins/absenceplugin/absencesmodel.cpp new file mode 100644 index 0000000..77a0043 --- /dev/null +++ b/plugins/absenceplugin/absencesmodel.cpp @@ -0,0 +1,115 @@ +#include "absencesmodel.h" + +#include "zeiterfassungapi.h" + +AbsencesModel::AbsencesModel(int userId, const QDate &date, ZeiterfassungApi &erfassung, QObject *parent) : + QAbstractListModel(parent), + m_userId(userId), + m_erfassung(erfassung) +{ + setDate(date); +} + +bool AbsencesModel::enabled() const +{ + return m_reply == Q_NULLPTR; +} + +int AbsencesModel::rowCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent) + + return m_absences.count(); +} + +int AbsencesModel::columnCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent) + + return 9; +} + +QVariant AbsencesModel::data(const QModelIndex &index, int role) const +{ + Q_ASSERT(index.row() < m_absences.count()); + const auto &absence = m_absences.at(index.row()); + + switch(role) + { + case Qt::DisplayRole: + case Qt::EditRole: + switch(index.column()) + { + case 0: return absence.altRepresentative; + case 1: return absence.compositeId; + case 2: return absence.end; + case 3: return absence.hourCategory; + case 4: return absence.openMarking; + case 5: return absence.persNr; + case 6: return absence.representative; + case 7: return absence.start; + case 8: return absence.text; + } + } + + return QVariant(); +} + +QVariant AbsencesModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + switch(orientation) + { + case Qt::Horizontal: + switch(role) + { + case Qt::DisplayRole: + case Qt::EditRole: + switch(section) + { + case 0: return tr("altRepresentative"); + case 1: return tr("compositeId"); + case 2: return tr("end"); + case 3: return tr("hourCategory"); + case 4: return tr("openMarking"); + case 5: return tr("persNr"); + case 6: return tr("representative"); + case 7: return tr("start"); + case 8: return tr("text"); + } + } + default: + qt_noop(); + } + + return QVariant(); +} + +void AbsencesModel::setDate(const QDate &date) +{ + m_date = date; + + auto oldEnabled = enabled(); + + m_reply = m_erfassung.doGetAbsences(m_userId, m_date, m_date); + connect(m_reply.get(), &ZeiterfassungReply::finished, this, &AbsencesModel::finished); + + if(oldEnabled != enabled()) + Q_EMIT enabledChanged(enabled()); +} + +void AbsencesModel::finished() +{ + if(!m_reply->success()) + Q_EMIT errorOccured(m_reply->message()); + + beginResetModel(); + m_absences = m_reply->absences(); + endResetModel(); + + auto oldEnabled = enabled(); + + m_reply = Q_NULLPTR; + + if(oldEnabled != enabled()) + Q_EMIT enabledChanged(enabled()); +} diff --git a/plugins/absenceplugin/absencesmodel.h b/plugins/absenceplugin/absencesmodel.h new file mode 100644 index 0000000..0353e5e --- /dev/null +++ b/plugins/absenceplugin/absencesmodel.h @@ -0,0 +1,44 @@ +#pragma once + +#include + +#include +#include + +#include "replies/getabsencesreply.h" + +class ZeiterfassungApi; + +class AbsencesModel : public QAbstractListModel +{ + Q_OBJECT + Q_PROPERTY(bool enabled READ enabled NOTIFY enabledChanged) + +public: + explicit AbsencesModel(int userId, const QDate &date, ZeiterfassungApi &erfassung, QObject *parent = Q_NULLPTR); + + bool enabled() const; + + // QAbstractItemModel interface + int rowCount(const QModelIndex &parent) const Q_DECL_OVERRIDE; + int columnCount(const QModelIndex &parent) const Q_DECL_OVERRIDE; + QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE; + QVariant headerData(int section, Qt::Orientation orientation, int role) const Q_DECL_OVERRIDE; + +Q_SIGNALS: + void enabledChanged(bool enabled); + void errorOccured(const QString &message); + +public Q_SLOTS: + void setDate(const QDate &date); + +private Q_SLOTS: + void finished(); + +private: + int m_userId; + QDate m_date; + ZeiterfassungApi &m_erfassung; + std::unique_ptr m_reply; + QVector m_absences; +}; diff --git a/plugins/absenceplugin/absencewidget.cpp b/plugins/absenceplugin/absencewidget.cpp new file mode 100644 index 0000000..444f87f --- /dev/null +++ b/plugins/absenceplugin/absencewidget.cpp @@ -0,0 +1,23 @@ +#include "absencewidget.h" + +#include "stripswidget.h" +#include "mainwindow.h" + +#include "absencedialog.h" + +AbsenceWidget::AbsenceWidget(StripsWidget &stripsWidget) : + QToolButton(&stripsWidget), + m_stripsWidget(stripsWidget) +{ + setIcon(QIcon(QStringLiteral(":/zeiterfassung/plugins/absenceplugin/images/absence.png"))); + setText(tr("Absence")); + + connect(this, &QAbstractButton::pressed, this, &AbsenceWidget::pressedSlot); +} + +void AbsenceWidget::pressedSlot() +{ + AbsenceDialog dialog(m_stripsWidget.mainWindow().userInfo().userId, m_stripsWidget.date(), + m_stripsWidget.mainWindow().erfassung(), this); + dialog.exec(); +} diff --git a/plugins/absenceplugin/absencewidget.h b/plugins/absenceplugin/absencewidget.h new file mode 100644 index 0000000..a93cc34 --- /dev/null +++ b/plugins/absenceplugin/absencewidget.h @@ -0,0 +1,19 @@ +#pragma once + +#include + +class StripsWidget; + +class AbsenceWidget : public QToolButton +{ + Q_OBJECT + +public: + explicit AbsenceWidget(StripsWidget &stripsWidget); + +private Q_SLOTS: + void pressedSlot(); + +private: + StripsWidget &m_stripsWidget; +}; diff --git a/plugins/absenceplugin/images/absence.png b/plugins/absenceplugin/images/absence.png new file mode 100644 index 0000000..4a33f1c Binary files /dev/null and b/plugins/absenceplugin/images/absence.png differ diff --git a/plugins/absenceplugin/translations/absenceplugin_de.ts b/plugins/absenceplugin/translations/absenceplugin_de.ts new file mode 100644 index 0000000..8f0589b --- /dev/null +++ b/plugins/absenceplugin/translations/absenceplugin_de.ts @@ -0,0 +1,83 @@ + + + + + AbsenceDialog + + + Absences + Abwesenheiten + + + + Absences for %0 + Abwesenheiten für %0 + + + + dd.MM.yyyy + dd.MM.yyyy + + + + Could not load absences! + Konnte Abwesenheiten nicht laden! + + + + AbsenceWidget + + + Absence + Abwesenheit + + + + AbsencesModel + + + altRepresentative + + + + + compositeId + + + + + end + + + + + hourCategory + + + + + openMarking + + + + + persNr + + + + + representative + + + + + start + + + + + text + + + + diff --git a/plugins/absenceplugin/translations/absenceplugin_en.ts b/plugins/absenceplugin/translations/absenceplugin_en.ts new file mode 100644 index 0000000..b02f346 --- /dev/null +++ b/plugins/absenceplugin/translations/absenceplugin_en.ts @@ -0,0 +1,83 @@ + + + + + AbsenceDialog + + + Absences + + + + + Absences for %0 + + + + + dd.MM.yyyy + + + + + Could not load absences! + + + + + AbsenceWidget + + + Absence + + + + + AbsencesModel + + + altRepresentative + + + + + compositeId + + + + + end + + + + + hourCategory + + + + + openMarking + + + + + persNr + + + + + representative + + + + + start + + + + + text + + + + diff --git a/plugins/advancedviewplugin/advancedviewdialog.cpp b/plugins/advancedviewplugin/advancedviewdialog.cpp index cc3680f..7eb5ef4 100644 --- a/plugins/advancedviewplugin/advancedviewdialog.cpp +++ b/plugins/advancedviewplugin/advancedviewdialog.cpp @@ -21,8 +21,8 @@ #include "models/bookingsmodel.h" #include "models/timeassignmentsmodel.h" -AdvancedViewDialog::AdvancedViewDialog(StripsWidget &stripsWidget) : - QDialog(&stripsWidget.mainWindow()), +AdvancedViewDialog::AdvancedViewDialog(StripsWidget &stripsWidget, QWidget *parent) : + ZeiterfassungDialog(parent), ui(new Ui::AdvancedViewDialog), m_stripsWidget(stripsWidget), m_bookingsModel(new BookingsModel(stripsWidget, this)), @@ -54,7 +54,7 @@ void AdvancedViewDialog::contextMenuBooking(const QPoint &pos) { QMenu menu; auto createAction = menu.addAction(tr("Create booking")); - auto refreshAction = menu.addAction(QIcon(QPixmap(QStringLiteral(":/zeiterfassunglib/images/refresh.png"))), tr("Refresh bookings")); + auto refreshAction = menu.addAction(QIcon(QPixmap(QStringLiteral(":/zeiterfassungguilib/images/refresh.png"))), tr("Refresh bookings")); auto selectedAction = menu.exec(ui->bookingsView->viewport()->mapToGlobal(pos)); if(selectedAction == createAction) { @@ -160,7 +160,7 @@ void AdvancedViewDialog::contextMenuTimeAssignment(const QPoint &pos) { QMenu menu; auto createAction = menu.addAction(tr("Create time assignment")); - auto refreshAction = menu.addAction(QIcon(QPixmap(QStringLiteral(":/zeiterfassunglib/images/refresh.png"))), tr("Refresh time assignments")); + auto refreshAction = menu.addAction(QIcon(QPixmap(QStringLiteral(":/zeiterfassungguilib/images/refresh.png"))), tr("Refresh time assignments")); auto selectedAction = menu.exec(ui->timeAssignmentsView->viewport()->mapToGlobal(pos)); if(selectedAction == createAction) { diff --git a/plugins/advancedviewplugin/advancedviewdialog.h b/plugins/advancedviewplugin/advancedviewdialog.h index b35068b..9a0c223 100644 --- a/plugins/advancedviewplugin/advancedviewdialog.h +++ b/plugins/advancedviewplugin/advancedviewdialog.h @@ -1,19 +1,18 @@ -#ifndef ADVANCEDVIEWDIALOG_H -#define ADVANCEDVIEWDIALOG_H +#pragma once -#include +#include "zeiterfassungdialog.h" namespace Ui { class AdvancedViewDialog; } class StripsWidget; class BookingsModel; class TimeAssignmentsModel; -class AdvancedViewDialog : public QDialog +class AdvancedViewDialog : public ZeiterfassungDialog { Q_OBJECT public: - explicit AdvancedViewDialog(StripsWidget &stripsWidget); + explicit AdvancedViewDialog(StripsWidget &stripsWidget, QWidget *parent = Q_NULLPTR); ~AdvancedViewDialog(); private Q_SLOTS: @@ -28,5 +27,3 @@ private: BookingsModel *m_bookingsModel; TimeAssignmentsModel *m_timeAssignmentsModel; }; - -#endif // ADVANCEDVIEWDIALOG_H diff --git a/plugins/advancedviewplugin/advancedviewplugin.h b/plugins/advancedviewplugin/advancedviewplugin.h index 73a4052..0e2c7ad 100644 --- a/plugins/advancedviewplugin/advancedviewplugin.h +++ b/plugins/advancedviewplugin/advancedviewplugin.h @@ -1,5 +1,4 @@ -#ifndef ADVANCEDVIEWPLUGIN_H -#define ADVANCEDVIEWPLUGIN_H +#pragma once #include #include @@ -23,5 +22,3 @@ public: private: QTranslator m_translator; }; - -#endif // ADVANCEDVIEWPLUGIN_H diff --git a/plugins/advancedviewplugin/advancedviewplugin.pro b/plugins/advancedviewplugin/advancedviewplugin.pro index 3f522ca..6c89a24 100644 --- a/plugins/advancedviewplugin/advancedviewplugin.pro +++ b/plugins/advancedviewplugin/advancedviewplugin.pro @@ -5,12 +5,14 @@ TEMPLATE = lib CONFIG += shared c++14 -DESTDIR = $${OUT_PWD}/../../bin/plugins/zeiterfassung +PROJECT_ROOT = ../.. -LIBS += -L$$OUT_PWD/../../lib -lzeiterfassunglib +DESTDIR = $${OUT_PWD}/$${PROJECT_ROOT}/bin/plugins/zeiterfassung -INCLUDEPATH += $$PWD/../../zeiterfassunglib -DEPENDPATH += $$PWD/../../zeiterfassunglib +LIBS += -L$${OUT_PWD}/$${PROJECT_ROOT}/bin -lzeiterfassungcorelib -lzeiterfassungguilib + +INCLUDEPATH += $$PWD/$${PROJECT_ROOT}/zeiterfassungcorelib $$PWD/$${PROJECT_ROOT}/zeiterfassungguilib +DEPENDPATH += $$PWD/$${PROJECT_ROOT}/zeiterfassungcorelib $$PWD/$${PROJECT_ROOT}/zeiterfassungguilib DEFINES += QT_DEPRECATED_WARNINGS QT_DISABLE_DEPRECATED_BEFORE=0x060000 QT_MESSAGELOGCONTEXT @@ -42,8 +44,3 @@ TRANSLATIONS += translations/advancedviewplugin_en.ts \ OTHER_FILES += advancedviewplugin.json include(../../lrelease.pri) - -COMPILED_TRANSLATIONS += $${OUT_PWD}/translations/advancedviewplugin_en.qm \ - $${OUT_PWD}/translations/advancedviewplugin_de.qm - -include(../copy_translations.pri) diff --git a/plugins/advancedviewplugin/advancedviewwidget.cpp b/plugins/advancedviewplugin/advancedviewwidget.cpp index 1c9c56d..be52d8d 100644 --- a/plugins/advancedviewplugin/advancedviewwidget.cpp +++ b/plugins/advancedviewplugin/advancedviewwidget.cpp @@ -25,6 +25,6 @@ void AdvancedViewWidget::dateChanged(const QDate &date) void AdvancedViewWidget::pressedSlot() { - AdvancedViewDialog dialog(m_stripsWidget); + AdvancedViewDialog dialog(m_stripsWidget, this); dialog.exec(); } diff --git a/plugins/advancedviewplugin/advancedviewwidget.h b/plugins/advancedviewplugin/advancedviewwidget.h index 52bff81..d1004a8 100644 --- a/plugins/advancedviewplugin/advancedviewwidget.h +++ b/plugins/advancedviewplugin/advancedviewwidget.h @@ -1,5 +1,4 @@ -#ifndef ADVANCEDVIEWWIDGET_H -#define ADVANCEDVIEWWIDGET_H +#pragma once #include @@ -19,5 +18,3 @@ private Q_SLOTS: private: StripsWidget &m_stripsWidget; }; - -#endif // ADVANCEDVIEWWIDGET_H diff --git a/plugins/advancedviewplugin/dialogs/bookingdialog.cpp b/plugins/advancedviewplugin/dialogs/bookingdialog.cpp index 768e872..a2d42df 100644 --- a/plugins/advancedviewplugin/dialogs/bookingdialog.cpp +++ b/plugins/advancedviewplugin/dialogs/bookingdialog.cpp @@ -2,7 +2,7 @@ #include "ui_bookingdialog.h" BookingDialog::BookingDialog(QWidget *parent) : - QDialog(parent), + ZeiterfassungDialog(parent), ui(new Ui::BookingDialog) { ui->setupUi(this); diff --git a/plugins/advancedviewplugin/dialogs/bookingdialog.h b/plugins/advancedviewplugin/dialogs/bookingdialog.h index 4a308f2..841a0db 100644 --- a/plugins/advancedviewplugin/dialogs/bookingdialog.h +++ b/plugins/advancedviewplugin/dialogs/bookingdialog.h @@ -1,12 +1,12 @@ -#ifndef BOOKINGDIALOG_H -#define BOOKINGDIALOG_H +#pragma once -#include #include +#include "zeiterfassungdialog.h" + namespace Ui { class BookingDialog; } -class BookingDialog : public QDialog +class BookingDialog : public ZeiterfassungDialog { Q_OBJECT @@ -29,5 +29,3 @@ public: private: Ui::BookingDialog *ui; }; - -#endif // BOOKINGDIALOG_H diff --git a/plugins/advancedviewplugin/dialogs/timeassignmentdialog.cpp b/plugins/advancedviewplugin/dialogs/timeassignmentdialog.cpp index 8f1c6d4..35d074a 100644 --- a/plugins/advancedviewplugin/dialogs/timeassignmentdialog.cpp +++ b/plugins/advancedviewplugin/dialogs/timeassignmentdialog.cpp @@ -9,7 +9,7 @@ TimeAssignmentDialog::TimeAssignmentDialog(const QMap &projects, const ZeiterfassungSettings &settings, QWidget *parent) : - QDialog(parent), + ZeiterfassungDialog(parent), ui(new Ui::TimeAssignmentDialog) { ui->setupUi(this); diff --git a/plugins/advancedviewplugin/dialogs/timeassignmentdialog.h b/plugins/advancedviewplugin/dialogs/timeassignmentdialog.h index a8d253c..916fd09 100644 --- a/plugins/advancedviewplugin/dialogs/timeassignmentdialog.h +++ b/plugins/advancedviewplugin/dialogs/timeassignmentdialog.h @@ -1,16 +1,16 @@ -#ifndef TIMEASSIGNMENTDIALOG_H -#define TIMEASSIGNMENTDIALOG_H +#pragma once -#include #include +#include "zeiterfassungdialog.h" + template class QMap; class ZeiterfassungSettings; namespace Ui { class TimeAssignmentDialog; } -class TimeAssignmentDialog : public QDialog +class TimeAssignmentDialog : public ZeiterfassungDialog { Q_OBJECT @@ -40,5 +40,3 @@ public: private: Ui::TimeAssignmentDialog *ui; }; - -#endif // TIMEASSIGNMENTDIALOG_H diff --git a/plugins/advancedviewplugin/models/bookingsmodel.h b/plugins/advancedviewplugin/models/bookingsmodel.h index ced2306..fd8b654 100644 --- a/plugins/advancedviewplugin/models/bookingsmodel.h +++ b/plugins/advancedviewplugin/models/bookingsmodel.h @@ -1,5 +1,4 @@ -#ifndef BOOKINGSMODEL_H -#define BOOKINGSMODEL_H +#pragma once #include #include @@ -36,5 +35,3 @@ private Q_SLOTS: private: StripsWidget &m_stripsWidget; }; - -#endif // BOOKINGSMODEL_H diff --git a/plugins/advancedviewplugin/models/timeassignmentsmodel.h b/plugins/advancedviewplugin/models/timeassignmentsmodel.h index 05ffc55..cedbcd9 100644 --- a/plugins/advancedviewplugin/models/timeassignmentsmodel.h +++ b/plugins/advancedviewplugin/models/timeassignmentsmodel.h @@ -1,5 +1,4 @@ -#ifndef TIMEASSIGNMENTSMODEL_H -#define TIMEASSIGNMENTSMODEL_H +#pragma once #include #include @@ -37,5 +36,3 @@ private Q_SLOTS: private: StripsWidget &m_stripsWidget; }; - -#endif // TIMEASSIGNMENTSMODEL_H diff --git a/plugins/advancedviewplugin/translations/advancedviewplugin_de.ts b/plugins/advancedviewplugin/translations/advancedviewplugin_de.ts index b68cae8..cc947e2 100644 --- a/plugins/advancedviewplugin/translations/advancedviewplugin_de.ts +++ b/plugins/advancedviewplugin/translations/advancedviewplugin_de.ts @@ -9,82 +9,82 @@ Erweiterte Anzeige - + Create booking Buchung erstellen - + Refresh bookings Buchungen aktualisieren - + Could not create booking! Konnte Buchung nicht erstellen! - + Edit booking Buchung bearbeiten - + Delete booking Buchung löschen - + Could not edit booking! Konnte Buchung nicht bearbeiten! - + Do you really want to delete the booking? Möchten Sie die Buchung wirklich löschen? - + Could not delete booking! Konnte Buchung nicht löschen! - + Create time assignment Kontierung erstellen - + Refresh time assignments Kontierungen aktualisieren - + Could not create time assignment! Konnte Kontierung nicht erstellen! - + 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! @@ -193,8 +193,8 @@ Text: - - + + %0 (%1) %0 (%1) diff --git a/plugins/advancedviewplugin/translations/advancedviewplugin_en.ts b/plugins/advancedviewplugin/translations/advancedviewplugin_en.ts index 80acdaf..a20f8f0 100644 --- a/plugins/advancedviewplugin/translations/advancedviewplugin_en.ts +++ b/plugins/advancedviewplugin/translations/advancedviewplugin_en.ts @@ -9,82 +9,82 @@ - + Create booking - + Refresh bookings - + Could not create booking! - + Edit booking - + Delete booking - + Could not edit booking! - + Do you really want to delete the booking? - + Could not delete booking! - + 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! @@ -193,8 +193,8 @@ - - + + %0 (%1) diff --git a/plugins/copy_translations.pri b/plugins/copy_translations.pri deleted file mode 100644 index 966c686..0000000 --- a/plugins/copy_translations.pri +++ /dev/null @@ -1,6 +0,0 @@ -copy_compiled_translations.input = COMPILED_TRANSLATIONS -copy_compiled_translations.output = $${OUT_PWD}/../../bin/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 diff --git a/plugins/devtoolsplugin/devtoolsplugin.cpp b/plugins/devtoolsplugin/devtoolsplugin.cpp new file mode 100644 index 0000000..58a1555 --- /dev/null +++ b/plugins/devtoolsplugin/devtoolsplugin.cpp @@ -0,0 +1,61 @@ +#include "devtoolsplugin.h" + +#include + +#include +#include +#include +#include +#include +#include + +#include "mainwindow.h" + +#include "logmodel.h" +#include "logdialog.h" + +std::shared_ptr model; +QtMessageHandler previousHandler; + +void myMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &message) +{ + previousHandler(type, context, message); + + model->log(type, context.file, context.line, context.function, context.category, message); +} + +void registerMessageHandler() +{ + model = std::make_shared(); + previousHandler = qInstallMessageHandler(myMessageHandler); +} + +Q_COREAPP_STARTUP_FUNCTION(registerMessageHandler) + +DevToolsPlugin::DevToolsPlugin(QObject *parent) : + ZeiterfassungPlugin(parent) +{ + qDebug() << "called"; + + static auto dir = QDir(QCoreApplication::applicationDirPath()).absoluteFilePath(QStringLiteral("translations")); + + if(m_translator.load(QLocale(), QStringLiteral("devtoolsplugin"), QStringLiteral("_"), dir)) + { + if(!QCoreApplication::installTranslator(&m_translator)) + { + qWarning() << "could not install translation devtoolsplugin"; + } + } + else + { + qWarning() << "could not load translation devtoolsplugin"; + } +} + +void DevToolsPlugin::attachTo(MainWindow &mainWindow) +{ + auto dialog = new LogDialog(&mainWindow); + dialog->setModel(model.get()); + mainWindow.menuTools()->addAction(QIcon(QStringLiteral(":/zeiterfassung/plugins/devtoolsplugin/images/dev-tools.png")), + tr("Show log"), dialog, &QWidget::show); +} diff --git a/plugins/devtoolsplugin/devtoolsplugin.h b/plugins/devtoolsplugin/devtoolsplugin.h new file mode 100644 index 0000000..f02e084 --- /dev/null +++ b/plugins/devtoolsplugin/devtoolsplugin.h @@ -0,0 +1,22 @@ +#pragma once + +#include +#include + +#include "zeiterfassungplugin.h" + +class Q_DECL_EXPORT DevToolsPlugin : public ZeiterfassungPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "dbsoftware.zeiterfassung.plugin/1.0" FILE "devtoolsplugin.json") + Q_INTERFACES(ZeiterfassungPlugin) + +public: + explicit DevToolsPlugin(QObject *parent = Q_NULLPTR); + + // ZeiterfassungPlugin interface + void attachTo(MainWindow &mainWindow) Q_DECL_OVERRIDE; + +private: + QTranslator m_translator; +}; diff --git a/plugins/devtoolsplugin/devtoolsplugin.json b/plugins/devtoolsplugin/devtoolsplugin.json new file mode 100644 index 0000000..e69de29 diff --git a/plugins/devtoolsplugin/devtoolsplugin.pro b/plugins/devtoolsplugin/devtoolsplugin.pro new file mode 100644 index 0000000..83335cb --- /dev/null +++ b/plugins/devtoolsplugin/devtoolsplugin.pro @@ -0,0 +1,36 @@ +QT += core network gui widgets + +TARGET = devtoolsplugin +TEMPLATE = lib + +CONFIG += shared c++14 + +PROJECT_ROOT = ../.. + +DESTDIR = $${OUT_PWD}/$${PROJECT_ROOT}/bin/plugins/zeiterfassung + +LIBS += -L$${OUT_PWD}/$${PROJECT_ROOT}/bin -lzeiterfassungcorelib -lzeiterfassungguilib + +INCLUDEPATH += $$PWD/$${PROJECT_ROOT}/zeiterfassungcorelib $$PWD/$${PROJECT_ROOT}/zeiterfassungguilib +DEPENDPATH += $$PWD/$${PROJECT_ROOT}/zeiterfassungcorelib $$PWD/$${PROJECT_ROOT}/zeiterfassungguilib + +DEFINES += QT_DEPRECATED_WARNINGS QT_DISABLE_DEPRECATED_BEFORE=0x060000 QT_MESSAGELOGCONTEXT + +HEADERS += devtoolsplugin.h \ + logdialog.h \ + logmodel.h + +SOURCES += devtoolsplugin.cpp \ + logdialog.cpp \ + logmodel.cpp + +FORMS += logdialog.ui + +RESOURCES += devtoolsplugin_resources.qrc + +TRANSLATIONS += translations/devtoolsplugin_en.ts \ + translations/devtoolsplugin_de.ts + +OTHER_FILES += devtoolsplugin.json + +include(../../lrelease.pri) diff --git a/plugins/devtoolsplugin/devtoolsplugin_resources.qrc b/plugins/devtoolsplugin/devtoolsplugin_resources.qrc new file mode 100644 index 0000000..5c8bd5c --- /dev/null +++ b/plugins/devtoolsplugin/devtoolsplugin_resources.qrc @@ -0,0 +1,5 @@ + + + images/dev-tools.png + + diff --git a/plugins/devtoolsplugin/images/dev-tools.png b/plugins/devtoolsplugin/images/dev-tools.png new file mode 100644 index 0000000..a12dbb0 Binary files /dev/null and b/plugins/devtoolsplugin/images/dev-tools.png differ diff --git a/plugins/devtoolsplugin/logdialog.cpp b/plugins/devtoolsplugin/logdialog.cpp new file mode 100644 index 0000000..6c4a34c --- /dev/null +++ b/plugins/devtoolsplugin/logdialog.cpp @@ -0,0 +1,19 @@ +#include "logdialog.h" +#include "ui_logdialog.h" + +LogDialog::LogDialog(QWidget *parent) : + ZeiterfassungDialog(parent), + ui(new Ui::LogDialog) +{ + ui->setupUi(this); +} + +LogDialog::~LogDialog() +{ + delete ui; +} + +void LogDialog::setModel(QAbstractItemModel *model) +{ + ui->treeView->setModel(model); +} diff --git a/plugins/devtoolsplugin/logdialog.h b/plugins/devtoolsplugin/logdialog.h new file mode 100644 index 0000000..aea06e9 --- /dev/null +++ b/plugins/devtoolsplugin/logdialog.h @@ -0,0 +1,21 @@ +#pragma once + +#include "zeiterfassungdialog.h" + +class QAbstractItemModel; + +namespace Ui { class LogDialog; } + +class LogDialog : public ZeiterfassungDialog +{ + Q_OBJECT + +public: + explicit LogDialog(QWidget *parent = Q_NULLPTR); + ~LogDialog(); + + void setModel(QAbstractItemModel *model); + +private: + Ui::LogDialog *ui; +}; diff --git a/plugins/devtoolsplugin/logdialog.ui b/plugins/devtoolsplugin/logdialog.ui new file mode 100644 index 0000000..583dbcc --- /dev/null +++ b/plugins/devtoolsplugin/logdialog.ui @@ -0,0 +1,67 @@ + + + LogDialog + + + + 0 + 0 + 694 + 300 + + + + Log + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Close + + + + + + + + + buttonBox + accepted() + LogDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + LogDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/plugins/devtoolsplugin/logmodel.cpp b/plugins/devtoolsplugin/logmodel.cpp new file mode 100644 index 0000000..ad71ceb --- /dev/null +++ b/plugins/devtoolsplugin/logmodel.cpp @@ -0,0 +1,80 @@ +#include "logmodel.h" + +LogModel::LogModel(QObject *parent) : + QAbstractListModel(parent) +{ +} + +void LogModel::log(QtMsgType type, const char *fileName, int lineNumber, const char *functionName, const char *categoryName, const QString &message) +{ + beginInsertRows(QModelIndex(), m_entries.count(), m_entries.count()); + m_entries.append(Entry { QDateTime::currentDateTime(), type, fileName, lineNumber, functionName, categoryName, message }); + endInsertRows(); +} + +int LogModel::rowCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent) + return m_entries.count(); +} + +int LogModel::columnCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent) + return 4; +} + +QVariant LogModel::data(const QModelIndex &index, int role) const +{ + Q_ASSERT(index.row() < m_entries.count()); + const auto &entry = m_entries.at(index.row()); + + switch(role) + { + case Qt::DisplayRole: + case Qt::EditRole: + switch(index.column()) + { + case 0: + { + switch(entry.type) + { + case QtDebugMsg: return tr("Debug"); + case QtWarningMsg: return tr("Warning"); + case QtCriticalMsg: return tr("Critical"); + case QtFatalMsg: return tr("Fatal"); + case QtInfoMsg: return tr("Info"); + } + } + case 1: return entry.dateTime.toString(QStringLiteral("dd.MM.yyyy HH:mm:ss.zzz")); + case 2: return entry.functionName; + case 3: return entry.message; + } + } + + return QVariant(); +} + +QVariant LogModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + switch(orientation) + { + case Qt::Horizontal: + switch(role) + { + case Qt::DisplayRole: + case Qt::EditRole: + switch(section) + { + case 0: return tr("Type"); + case 1: return tr("Timestamp"); + case 2: return tr("Function"); + case 3: return tr("Message"); + } + } + default: + qt_noop(); + } + + return QVariant(); +} diff --git a/plugins/devtoolsplugin/logmodel.h b/plugins/devtoolsplugin/logmodel.h new file mode 100644 index 0000000..4312fb5 --- /dev/null +++ b/plugins/devtoolsplugin/logmodel.h @@ -0,0 +1,36 @@ +#pragma once + +#include +#include +#include +#include + +class LogModel : public QAbstractListModel +{ + Q_OBJECT + +public: + explicit LogModel(QObject *parent = Q_NULLPTR); + + void log(QtMsgType type, const char *fileName, int lineNumber, const char *functionName, const char *categoryName, const QString &message); + + // QAbstractItemModel interface + int rowCount(const QModelIndex &parent) const Q_DECL_OVERRIDE; + int columnCount(const QModelIndex &parent) const Q_DECL_OVERRIDE; + QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE; + QVariant headerData(int section, Qt::Orientation orientation, int role) const Q_DECL_OVERRIDE; + +private: + struct Entry + { + QDateTime dateTime; + QtMsgType type; + const char *fileName; + int lineNumber; + const char *functionName; + const char *categoryName; + QString message; + }; + + QList m_entries; +}; diff --git a/plugins/devtoolsplugin/translations/devtoolsplugin_de.ts b/plugins/devtoolsplugin/translations/devtoolsplugin_de.ts new file mode 100644 index 0000000..f0cf20a --- /dev/null +++ b/plugins/devtoolsplugin/translations/devtoolsplugin_de.ts @@ -0,0 +1,57 @@ + + + + + DevToolsPlugin + + Show log + Log anzeigen + + + + LogDialog + + Log + Log + + + + LogModel + + Type + Typ + + + Timestamp + Zeitpunkt + + + Function + Funktion + + + Message + Nachricht + + + Debug + Debug + + + Warning + Warnung + + + Critical + Kritisch + + + Fatal + Fatal + + + Info + Info + + + diff --git a/plugins/devtoolsplugin/translations/devtoolsplugin_en.ts b/plugins/devtoolsplugin/translations/devtoolsplugin_en.ts new file mode 100644 index 0000000..93ffe55 --- /dev/null +++ b/plugins/devtoolsplugin/translations/devtoolsplugin_en.ts @@ -0,0 +1,57 @@ + + + + + DevToolsPlugin + + Show log + + + + + LogDialog + + Log + + + + + LogModel + + Type + + + + Timestamp + + + + Function + + + + Message + + + + Debug + + + + Warning + + + + Critical + + + + Fatal + + + + Info + + + + diff --git a/plugins/lunchmealplugin/lunchmealdialog.cpp b/plugins/lunchmealplugin/lunchmealdialog.cpp index a61dd57..972de57 100644 --- a/plugins/lunchmealplugin/lunchmealdialog.cpp +++ b/plugins/lunchmealplugin/lunchmealdialog.cpp @@ -2,50 +2,18 @@ #include "ui_lunchmealdialog.h" #include -#include -#include -#include -#include "stripswidget.h" -#include "mainwindow.h" -#include "zeiterfassungsettings.h" -#include "zeiterfassungapi.h" - -LunchMealDialog::LunchMealDialog(StripsWidget &stripsWidget) : - QDialog(&stripsWidget.mainWindow()), +LunchMealDialog::LunchMealDialog(const QDate &date, const QString &content, QWidget *parent) : + ZeiterfassungDialog(parent), ui(new Ui::LunchMealDialog) { ui->setupUi(this); - ui->labelTitle->setText(tr("Lunch meal for %0").arg(stripsWidget.date().toString(tr("dd.MM.yyyy")))); - - const auto &settings = stripsWidget.mainWindow().settings(); - - auto url = settings.value(QStringLiteral("LunchMealPlugin/url"), - QStringLiteral("https://brunner.ninja/lunch/%0.txt")).toString() - .arg(stripsWidget.date().toString(settings.value(QStringLiteral("LunchMealPlugin/dateFormat"), - QStringLiteral("yyyy-MM-dd")).toString())); - m_reply = std::unique_ptr(stripsWidget.mainWindow().erfassung().manager()->get(QNetworkRequest(QUrl(url)))); - connect(m_reply.get(), &QNetworkReply::finished, this, &LunchMealDialog::finished); + ui->labelTitle->setText(tr("Lunch meal for %0").arg(date.toString(tr("dd.MM.yyyy")))); + ui->labelLunchMeal->setText(content); } LunchMealDialog::~LunchMealDialog() { delete ui; } - -void LunchMealDialog::finished() -{ - if(m_reply->error() != QNetworkReply::NoError) - { - ui->labelLunchMeal->setText(QStringLiteral("%0\n\n%1") - .arg(m_reply->errorString()) - .arg(QString(m_reply->readAll()))); - goto after; - } - - ui->labelLunchMeal->setText(m_reply->readAll()); - - after: - m_reply = Q_NULLPTR; -} diff --git a/plugins/lunchmealplugin/lunchmealdialog.h b/plugins/lunchmealplugin/lunchmealdialog.h index 9345fcf..f20ceb8 100644 --- a/plugins/lunchmealplugin/lunchmealdialog.h +++ b/plugins/lunchmealplugin/lunchmealdialog.h @@ -1,29 +1,21 @@ -#ifndef LUNCHMEALDIALOG_H -#define LUNCHMEALDIALOG_H +#pragma once -#include +#include "zeiterfassungdialog.h" -#include -#include +class QDate; class StripsWidget; namespace Ui { class LunchMealDialog; } -class LunchMealDialog : public QDialog +class LunchMealDialog : public ZeiterfassungDialog { Q_OBJECT public: - explicit LunchMealDialog(StripsWidget &stripsWidget); + explicit LunchMealDialog(const QDate &date, const QString &content, QWidget *parent = Q_NULLPTR); ~LunchMealDialog(); -private Q_SLOTS: - void finished(); - private: Ui::LunchMealDialog *ui; - std::unique_ptr m_reply; }; - -#endif // LUNCHMEALDIALOG_H diff --git a/plugins/lunchmealplugin/lunchmealplugin.h b/plugins/lunchmealplugin/lunchmealplugin.h index f2a0f7c..8b14f85 100644 --- a/plugins/lunchmealplugin/lunchmealplugin.h +++ b/plugins/lunchmealplugin/lunchmealplugin.h @@ -1,5 +1,4 @@ -#ifndef LUNCHMEALPLUGIN_H -#define LUNCHMEALPLUGIN_H +#pragma once #include #include @@ -23,5 +22,3 @@ public: private: QTranslator m_translator; }; - -#endif // LUNCHMEALPLUGIN_H diff --git a/plugins/lunchmealplugin/lunchmealplugin.pro b/plugins/lunchmealplugin/lunchmealplugin.pro index c3debe5..daf797d 100644 --- a/plugins/lunchmealplugin/lunchmealplugin.pro +++ b/plugins/lunchmealplugin/lunchmealplugin.pro @@ -5,22 +5,24 @@ TEMPLATE = lib CONFIG += shared c++14 -DESTDIR = $${OUT_PWD}/../../bin/plugins/zeiterfassung +PROJECT_ROOT = ../.. -LIBS += -L$$OUT_PWD/../../lib -lzeiterfassunglib +DESTDIR = $${OUT_PWD}/$${PROJECT_ROOT}/bin/plugins/zeiterfassung -INCLUDEPATH += $$PWD/../../zeiterfassunglib -DEPENDPATH += $$PWD/../../zeiterfassunglib +LIBS += -L$${OUT_PWD}/$${PROJECT_ROOT}/bin -lzeiterfassungcorelib -lzeiterfassungguilib + +INCLUDEPATH += $$PWD/$${PROJECT_ROOT}/zeiterfassungcorelib $$PWD/$${PROJECT_ROOT}/zeiterfassungguilib +DEPENDPATH += $$PWD/$${PROJECT_ROOT}/zeiterfassungcorelib $$PWD/$${PROJECT_ROOT}/zeiterfassungguilib DEFINES += QT_DEPRECATED_WARNINGS QT_DISABLE_DEPRECATED_BEFORE=0x060000 QT_MESSAGELOGCONTEXT -HEADERS += lunchmealplugin.h \ - lunchmealwidget.h \ - lunchmealdialog.h +HEADERS += lunchmealdialog.h \ + lunchmealplugin.h \ + lunchmealwidget.h -SOURCES += lunchmealplugin.cpp \ - lunchmealwidget.cpp \ - lunchmealdialog.cpp +SOURCES += lunchmealdialog.cpp \ + lunchmealplugin.cpp \ + lunchmealwidget.cpp FORMS += lunchmealdialog.ui @@ -32,8 +34,3 @@ TRANSLATIONS += translations/lunchmealplugin_en.ts \ OTHER_FILES += lunchmealplugin.json include(../../lrelease.pri) - -COMPILED_TRANSLATIONS += $${OUT_PWD}/translations/lunchmealplugin_en.qm \ - $${OUT_PWD}/translations/lunchmealplugin_de.qm - -include(../copy_translations.pri) diff --git a/plugins/lunchmealplugin/lunchmealwidget.cpp b/plugins/lunchmealplugin/lunchmealwidget.cpp index eacaaf6..47d6649 100644 --- a/plugins/lunchmealplugin/lunchmealwidget.cpp +++ b/plugins/lunchmealplugin/lunchmealwidget.cpp @@ -1,9 +1,15 @@ #include "lunchmealwidget.h" #include +#include +#include +#include +#include +#include #include "stripswidget.h" #include "mainwindow.h" +#include "zeiterfassungsettings.h" #include "zeiterfassungapi.h" #include "lunchmealdialog.h" @@ -16,10 +22,48 @@ LunchMealWidget::LunchMealWidget(StripsWidget &stripsWidget) : setText(tr("Lunch meal")); connect(this, &QAbstractButton::pressed, this, &LunchMealWidget::pressedSlot); + + connect(&m_stripsWidget, &StripsWidget::dateChanged, this, &LunchMealWidget::dateChanged); + dateChanged(m_stripsWidget.date()); } void LunchMealWidget::pressedSlot() { - LunchMealDialog dialog(m_stripsWidget); + LunchMealDialog dialog(m_stripsWidget.date(), m_content, this); dialog.exec(); } + +void LunchMealWidget::dateChanged(const QDate &date) +{ + setEnabled(false); + setVisible(false); + + const auto &settings = m_stripsWidget.mainWindow().settings(); + + auto url = settings.value(QStringLiteral("LunchMealPlugin/url"), + QStringLiteral("https://brunner.ninja/lunch/%0.txt")).toString() + .arg(date.toString(settings.value(QStringLiteral("LunchMealPlugin/dateFormat"), QStringLiteral("yyyy-MM-dd")).toString())); + m_reply = std::unique_ptr(m_stripsWidget.mainWindow().erfassung().manager()->get(QNetworkRequest(QUrl(url)))); + connect(m_reply.get(), &QNetworkReply::finished, this, &LunchMealWidget::finished); +} + +void LunchMealWidget::finished() +{ + if(m_reply->error() != QNetworkReply::NoError && + m_reply->error() != QNetworkReply::ContentNotFoundError) + { + QMessageBox::warning(&m_stripsWidget.mainWindow(), tr("Could not load lunch meal!"), + tr("Could not load lunch meal!") % "\n\n" % m_reply->errorString()); + goto after; + } + + if(m_reply->error() == QNetworkReply::NoError) + { + setEnabled(true); + setVisible(true); + m_content = m_reply->readAll(); + } + + after: + m_reply = Q_NULLPTR; +} diff --git a/plugins/lunchmealplugin/lunchmealwidget.h b/plugins/lunchmealplugin/lunchmealwidget.h index a609ab9..fb7e3c7 100644 --- a/plugins/lunchmealplugin/lunchmealwidget.h +++ b/plugins/lunchmealplugin/lunchmealwidget.h @@ -1,7 +1,9 @@ -#ifndef LUNCHMEALWIDGET_H -#define LUNCHMEALWIDGET_H +#pragma once + +#include #include +#include class StripsWidget; @@ -13,9 +15,11 @@ public: private Q_SLOTS: void pressedSlot(); + void dateChanged(const QDate &date); + void finished(); private: StripsWidget &m_stripsWidget; + std::unique_ptr m_reply; + QString m_content; }; - -#endif // LUNCHMEALWIDGET_H diff --git a/plugins/lunchmealplugin/translations/lunchmealplugin_de.ts b/plugins/lunchmealplugin/translations/lunchmealplugin_de.ts index 0a13bcc..d0f4690 100644 --- a/plugins/lunchmealplugin/translations/lunchmealplugin_de.ts +++ b/plugins/lunchmealplugin/translations/lunchmealplugin_de.ts @@ -14,12 +14,12 @@ Lade... - + Lunch meal for %0 Mittagsmenü vom %0 - + dd.MM.yyyy dd.MM.yyyy @@ -27,9 +27,15 @@ LunchMealWidget - + Lunch meal Mittagsmenü + + + + Could not load lunch meal! + + diff --git a/plugins/lunchmealplugin/translations/lunchmealplugin_en.ts b/plugins/lunchmealplugin/translations/lunchmealplugin_en.ts index ac807ce..5637f62 100644 --- a/plugins/lunchmealplugin/translations/lunchmealplugin_en.ts +++ b/plugins/lunchmealplugin/translations/lunchmealplugin_en.ts @@ -14,12 +14,12 @@ - + Lunch meal for %0 - + dd.MM.yyyy @@ -27,9 +27,15 @@ LunchMealWidget - + Lunch meal + + + + Could not load lunch meal! + + diff --git a/plugins/plugins.pro b/plugins/plugins.pro index f8c26c3..2857a61 100644 --- a/plugins/plugins.pro +++ b/plugins/plugins.pro @@ -1,8 +1,12 @@ TEMPLATE = subdirs -SUBDIRS += advancedviewplugin \ +SUBDIRS += absenceplugin \ + advancedviewplugin \ + devtoolsplugin \ lunchmealplugin \ + profileplugin \ presenceplugin \ reportsplugin \ updaterplugin \ - weatherplugin + weatherplugin \ + webradioplugin diff --git a/plugins/presenceplugin/images/not-present.png b/plugins/presenceplugin/images/not-present.png new file mode 100644 index 0000000..ff9da22 Binary files /dev/null and b/plugins/presenceplugin/images/not-present.png differ diff --git a/plugins/presenceplugin/images/present.png b/plugins/presenceplugin/images/present.png new file mode 100644 index 0000000..21232af Binary files /dev/null and b/plugins/presenceplugin/images/present.png differ diff --git a/plugins/presenceplugin/presenceplugin.cpp b/plugins/presenceplugin/presenceplugin.cpp index 3e5e64d..870f593 100644 --- a/plugins/presenceplugin/presenceplugin.cpp +++ b/plugins/presenceplugin/presenceplugin.cpp @@ -4,6 +4,9 @@ #include #include #include +#include + +#include "mainwindow.h" #include "presencewidget.h" @@ -29,5 +32,5 @@ PresencePlugin::PresencePlugin(QObject *parent) : void PresencePlugin::attachTo(MainWindow &mainWindow) { - new PresenceWidget(mainWindow); + mainWindow.statusBar()->addWidget(new PresenceWidget(mainWindow)); } diff --git a/plugins/presenceplugin/presenceplugin.h b/plugins/presenceplugin/presenceplugin.h index 2fc9f87..2907b7f 100644 --- a/plugins/presenceplugin/presenceplugin.h +++ b/plugins/presenceplugin/presenceplugin.h @@ -1,5 +1,4 @@ -#ifndef PRESENCEPLUGIN_H -#define PRESENCEPLUGIN_H +#pragma once #include #include @@ -23,5 +22,3 @@ public: private: QTranslator m_translator; }; - -#endif // PRESENCEPLUGIN_H diff --git a/plugins/presenceplugin/presenceplugin.pro b/plugins/presenceplugin/presenceplugin.pro index e3e1d82..c4b421b 100644 --- a/plugins/presenceplugin/presenceplugin.pro +++ b/plugins/presenceplugin/presenceplugin.pro @@ -5,12 +5,14 @@ TEMPLATE = lib CONFIG += shared c++14 -DESTDIR = $${OUT_PWD}/../../bin/plugins/zeiterfassung +PROJECT_ROOT = ../.. -LIBS += -L$$OUT_PWD/../../lib -lzeiterfassunglib +DESTDIR = $${OUT_PWD}/$${PROJECT_ROOT}/bin/plugins/zeiterfassung -INCLUDEPATH += $$PWD/../../zeiterfassunglib -DEPENDPATH += $$PWD/../../zeiterfassunglib +LIBS += -L$${OUT_PWD}/$${PROJECT_ROOT}/bin -lzeiterfassungcorelib -lzeiterfassungguilib + +INCLUDEPATH += $$PWD/$${PROJECT_ROOT}/zeiterfassungcorelib $$PWD/$${PROJECT_ROOT}/zeiterfassungguilib +DEPENDPATH += $$PWD/$${PROJECT_ROOT}/zeiterfassungcorelib $$PWD/$${PROJECT_ROOT}/zeiterfassungguilib DEFINES += QT_DEPRECATED_WARNINGS QT_DISABLE_DEPRECATED_BEFORE=0x060000 QT_MESSAGELOGCONTEXT @@ -30,8 +32,3 @@ TRANSLATIONS += translations/presenceplugin_en.ts \ OTHER_FILES += presenceplugin.json include(../../lrelease.pri) - -COMPILED_TRANSLATIONS += $${OUT_PWD}/translations/presenceplugin_en.qm \ - $${OUT_PWD}/translations/presenceplugin_de.qm - -include(../copy_translations.pri) diff --git a/plugins/presenceplugin/presenceplugin_resources.qrc b/plugins/presenceplugin/presenceplugin_resources.qrc index 9eca07d..0e59021 100644 --- a/plugins/presenceplugin/presenceplugin_resources.qrc +++ b/plugins/presenceplugin/presenceplugin_resources.qrc @@ -1,5 +1,7 @@ + images/not-present.png + images/present.png images/refresh.png diff --git a/plugins/presenceplugin/presencewidget.cpp b/plugins/presenceplugin/presencewidget.cpp index cbcbca6..ee7ddbb 100644 --- a/plugins/presenceplugin/presencewidget.cpp +++ b/plugins/presenceplugin/presencewidget.cpp @@ -1,33 +1,30 @@ #include "presencewidget.h" -#include -#include #include +#include #include #include #include +#include + +#include #include "mainwindow.h" #include "zeiterfassungapi.h" PresenceWidget::PresenceWidget(MainWindow &mainWindow) : - QWidget(&mainWindow), + QPushButton(&mainWindow), m_mainWindow(mainWindow) { connect(&m_mainWindow, &MainWindow::refreshEverything, this, &PresenceWidget::refresh); - m_labelAvailable = new QLabel(this); - m_labelAvailable->setFrameShape(QFrame::Panel); - m_labelAvailable->setFrameShadow(QFrame::Sunken); - m_mainWindow.statusBar()->addWidget(m_labelAvailable); + m_menu = new QMenu(this); + setMenu(m_menu); - m_labelNotAvailable = new QLabel(this); - m_labelNotAvailable->setFrameShape(QFrame::Panel); - m_labelNotAvailable->setFrameShadow(QFrame::Sunken); - m_mainWindow.statusBar()->addWidget(m_labelNotAvailable); - - m_action = m_mainWindow.menuView()->addAction(QIcon(QStringLiteral(":zeiterfassung/plugins/presenceplugin/images/refresh.png")), - tr("Refresh presence"), this, &PresenceWidget::refresh); + m_action = new QAction(QIcon(QStringLiteral(":zeiterfassung/plugins/presenceplugin/images/refresh.png")), + tr("Refresh presence"), this); + connect(m_action, &QAction::triggered, this, &PresenceWidget::refresh); + m_mainWindow.menuView()->addAction(m_action); auto timer = new QTimer(this); timer->setInterval(60000); @@ -39,8 +36,8 @@ PresenceWidget::PresenceWidget(MainWindow &mainWindow) : void PresenceWidget::refresh() { - m_labelAvailable->setText(tr("%0: %1").arg(tr("Available")).arg(tr("???"))); - m_labelNotAvailable->setText(tr("%0: %1").arg(tr("Not available")).arg(tr("???"))); + setText(tr("%0 available, %1 not available").arg(tr("???")).arg(tr("???"))); + m_menu->clear(); m_action->setEnabled(false); @@ -58,20 +55,29 @@ void PresenceWidget::finished() } { - int available = 0, - notAvailable = 0; + int present = 0, + notPresent = 0; + for(const auto &status : m_reply->presenceStatuses()) { + QIcon icon; if(status.presence == QStringLiteral("J")) - available++; + { + present++; + icon = QIcon(QStringLiteral(":zeiterfassung/plugins/presenceplugin/images/present.png")); + } else if(status.presence == QStringLiteral("N")) - notAvailable++; + { + notPresent++; + icon = QIcon(QStringLiteral(":zeiterfassung/plugins/presenceplugin/images/not-present.png")); + } else - qWarning() << "unknown presence" << status.firstName << status.lastName << status.presence; + qCritical() << "unknown presence" << status.firstName << status.lastName << status.presence; + + m_menu->addAction(icon, tr("%0 %1").arg(status.firstName).arg(status.lastName)); } - m_labelAvailable->setText(tr("%0: %1").arg(tr("Available")).arg(available)); - m_labelNotAvailable->setText(tr("%0: %1").arg(tr("Not available")).arg(notAvailable)); + setText(tr("%0 available, %1 not available").arg(present).arg(notPresent)); } after: diff --git a/plugins/presenceplugin/presencewidget.h b/plugins/presenceplugin/presencewidget.h index ce7f6dc..e05b230 100644 --- a/plugins/presenceplugin/presencewidget.h +++ b/plugins/presenceplugin/presencewidget.h @@ -1,16 +1,15 @@ -#ifndef PRESENCEWIDGET_H -#define PRESENCEWIDGET_H +#pragma once -#include +#include #include "replies/getpresencestatusreply.h" -class QLabel; +class QMenu; class QAction; class MainWindow; -class PresenceWidget : public QWidget +class PresenceWidget : public QPushButton { Q_OBJECT @@ -24,12 +23,8 @@ private Q_SLOTS: private: MainWindow &m_mainWindow; - QLabel *m_labelAvailable; - QLabel *m_labelNotAvailable; - + QMenu *m_menu; QAction *m_action; std::unique_ptr m_reply; }; - -#endif // PRESENCEWIDGET_H diff --git a/plugins/presenceplugin/translations/presenceplugin_de.ts b/plugins/presenceplugin/translations/presenceplugin_de.ts index 6f9be17..1d34124 100644 --- a/plugins/presenceplugin/translations/presenceplugin_de.ts +++ b/plugins/presenceplugin/translations/presenceplugin_de.ts @@ -4,41 +4,31 @@ PresenceWidget - + Refresh presence Verfügbarkeit aktualisieren - - - - - %0: %1 - %0: %1 - - - - - Available - Verfügbar - - - - + ??? ??? - - - Not available - Nicht verfügbar + + + %0 available, %1 not available + %0 verfügbar, %1 nicht verfügbar - - + + Could not get presence status! Konnte Verfügbarkeit nicht laden! + + + %0 %1 + %0 %1 + diff --git a/plugins/presenceplugin/translations/presenceplugin_en.ts b/plugins/presenceplugin/translations/presenceplugin_en.ts index 924bcb5..7865d10 100644 --- a/plugins/presenceplugin/translations/presenceplugin_en.ts +++ b/plugins/presenceplugin/translations/presenceplugin_en.ts @@ -4,41 +4,31 @@ PresenceWidget - + Refresh presence - - - - - %0: %1 - - - - - - Available - - - - - + ??? - - - Not available + + + %0 available, %1 not available - - + + Could not get presence status! + + + %0 %1 + + diff --git a/zeiterfassunglib/images/user.png b/plugins/profileplugin/images/profile.png similarity index 100% rename from zeiterfassunglib/images/user.png rename to plugins/profileplugin/images/profile.png diff --git a/plugins/profileplugin/profiledialog.cpp b/plugins/profileplugin/profiledialog.cpp new file mode 100644 index 0000000..92bddae --- /dev/null +++ b/plugins/profileplugin/profiledialog.cpp @@ -0,0 +1,32 @@ +#include "profiledialog.h" +#include "ui_profiledialog.h" + +ProfileDialog::ProfileDialog(const GetUserInfoReply::UserInfo &userInfo, QWidget *parent) : + ZeiterfassungDialog(parent), + ui(new Ui::ProfileDialog) +{ + ui->setupUi(this); + + ui->spinBoxUserId->setValue(userInfo.userId); + ui->lineEditEmail->setText(userInfo.email); + ui->lineEditLongUsername->setText(userInfo.longUsername); + ui->lineEditText->setText(userInfo.text); + ui->lineEditUsername->setText(userInfo.username); + ui->lineEditStreet->setText(userInfo.street); + ui->lineEditCity->setText(userInfo.city); + ui->lineEditEmployedSince->setText(userInfo.employedSince.toString(tr("dd.MM.yyyy"))); + ui->lineEditEmployedTill->setText(userInfo.employedTill.toString(tr("dd.MM.yyyy"))); + ui->lineEditPlaceOfBirth->setText(userInfo.placeOfBirth); + ui->lineEditZipcode->setText(userInfo.zipcode); + ui->lineEditReligion->setText(userInfo.religion); + ui->lineEditDepartment->setText(userInfo.department); + ui->lineEditVerwendgr->setText(userInfo.verwendgr); + ui->lineEditTaetig->setText(userInfo.taetig); + ui->lineEditArbverh->setText(userInfo.arbverh); + ui->lineEditBetriebsnr->setText(userInfo.betriebsnr); +} + +ProfileDialog::~ProfileDialog() +{ + delete ui; +} diff --git a/plugins/profileplugin/profiledialog.h b/plugins/profileplugin/profiledialog.h new file mode 100644 index 0000000..3725fd7 --- /dev/null +++ b/plugins/profileplugin/profiledialog.h @@ -0,0 +1,18 @@ +#pragma once + +#include "zeiterfassungdialog.h" +#include "replies/getuserinforeply.h" + +namespace Ui { class ProfileDialog; } + +class ProfileDialog : public ZeiterfassungDialog +{ + Q_OBJECT + +public: + explicit ProfileDialog(const GetUserInfoReply::UserInfo &userInfo, QWidget *parent = Q_NULLPTR); + ~ProfileDialog(); + +private: + Ui::ProfileDialog *ui; +}; diff --git a/plugins/profileplugin/profiledialog.ui b/plugins/profileplugin/profiledialog.ui new file mode 100644 index 0000000..3ce9181 --- /dev/null +++ b/plugins/profileplugin/profiledialog.ui @@ -0,0 +1,320 @@ + + + ProfileDialog + + + + 0 + 0 + 454 + 281 + + + + Profile + + + + + + true + + + + + 0 + 0 + 420 + 540 + + + + + + + User-ID: + + + spinBoxUserId + + + + + + + E-Mail: + + + lineEditEmail + + + + + + + Long username: + + + lineEditLongUsername + + + + + + + Text: + + + lineEditText + + + + + + + Username: + + + lineEditUsername + + + + + + + true + + + 16777215 + + + + + + + true + + + + + + + true + + + + + + + true + + + + + + + true + + + + + + + Street: + + + + + + + City: + + + + + + + Employed since: + + + + + + + Employed till: + + + + + + + Place of birth: + + + + + + + Zipcode: + + + + + + + Religion: + + + + + + + Department: + + + + + + + Verwendgr: + + + + + + + Taetig: + + + + + + + Arbverh: + + + + + + + Betriebsnr: + + + + + + + true + + + + + + + true + + + + + + + true + + + + + + + true + + + + + + + true + + + + + + + true + + + + + + + true + + + + + + + true + + + + + + + true + + + + + + + true + + + + + + + true + + + + + + + true + + + + + + + + + + + QDialogButtonBox::Close + + + + + + + + + buttonBox + rejected() + ProfileDialog + close() + + + 226 + 5 + + + 226 + 0 + + + + + diff --git a/plugins/profileplugin/profileplugin.cpp b/plugins/profileplugin/profileplugin.cpp new file mode 100644 index 0000000..1dc949d --- /dev/null +++ b/plugins/profileplugin/profileplugin.cpp @@ -0,0 +1,39 @@ +#include "profileplugin.h" + +#include +#include +#include +#include +#include +#include + +#include "mainwindow.h" + +#include "profiledialog.h" + +ProfilePlugin::ProfilePlugin(QObject *parent) : + ZeiterfassungPlugin(parent) +{ + qDebug() << "called"; + + static auto dir = QDir(QCoreApplication::applicationDirPath()).absoluteFilePath(QStringLiteral("translations")); + + if(m_translator.load(QLocale(), QStringLiteral("profileplugin"), QStringLiteral("_"), dir)) + { + if(!QCoreApplication::installTranslator(&m_translator)) + { + qWarning() << "could not install translation profileplugin"; + } + } + else + { + qWarning() << "could not load translation profileplugin"; + } +} + +void ProfilePlugin::attachTo(MainWindow &mainWindow) +{ + auto dialog = new ProfileDialog(mainWindow.userInfo(), &mainWindow); + mainWindow.menuTools()->addAction(QIcon(QStringLiteral(":/zeiterfassung/plugins/profileplugin/images/profile.png")), + tr("My profile"), dialog, &QDialog::open); +} diff --git a/plugins/profileplugin/profileplugin.h b/plugins/profileplugin/profileplugin.h new file mode 100644 index 0000000..ee1f67e --- /dev/null +++ b/plugins/profileplugin/profileplugin.h @@ -0,0 +1,24 @@ +#pragma once + +#include +#include + +#include "zeiterfassungplugin.h" + +class MainWindow; + +class Q_DECL_EXPORT ProfilePlugin : public ZeiterfassungPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "dbsoftware.zeiterfassung.plugin/1.0" FILE "profileplugin.json") + Q_INTERFACES(ZeiterfassungPlugin) + +public: + explicit ProfilePlugin(QObject *parent = Q_NULLPTR); + + // ZeiterfassungPlugin interface + void attachTo(MainWindow &mainWindow) Q_DECL_OVERRIDE; + +private: + QTranslator m_translator; +}; diff --git a/plugins/profileplugin/profileplugin.json b/plugins/profileplugin/profileplugin.json new file mode 100644 index 0000000..e69de29 diff --git a/plugins/profileplugin/profileplugin.pro b/plugins/profileplugin/profileplugin.pro new file mode 100644 index 0000000..42cd1c0 --- /dev/null +++ b/plugins/profileplugin/profileplugin.pro @@ -0,0 +1,34 @@ +QT += core network gui widgets + +TARGET = profileplugin +TEMPLATE = lib + +CONFIG += shared c++14 + +PROJECT_ROOT = ../.. + +DESTDIR = $${OUT_PWD}/$${PROJECT_ROOT}/bin/plugins/zeiterfassung + +LIBS += -L$${OUT_PWD}/$${PROJECT_ROOT}/bin -lzeiterfassungcorelib -lzeiterfassungguilib + +INCLUDEPATH += $$PWD/$${PROJECT_ROOT}/zeiterfassungcorelib $$PWD/$${PROJECT_ROOT}/zeiterfassungguilib +DEPENDPATH += $$PWD/$${PROJECT_ROOT}/zeiterfassungcorelib $$PWD/$${PROJECT_ROOT}/zeiterfassungguilib + +DEFINES += QT_DEPRECATED_WARNINGS QT_DISABLE_DEPRECATED_BEFORE=0x060000 QT_MESSAGELOGCONTEXT + +HEADERS += profiledialog.h \ + profileplugin.h + +SOURCES += profiledialog.cpp \ + profileplugin.cpp + +FORMS += profiledialog.ui + +RESOURCES += profileplugin_resources.qrc + +TRANSLATIONS += translations/profileplugin_en.ts \ + translations/profileplugin_de.ts + +OTHER_FILES += profileplugin.json + +include(../../lrelease.pri) diff --git a/plugins/profileplugin/profileplugin_resources.qrc b/plugins/profileplugin/profileplugin_resources.qrc new file mode 100644 index 0000000..d1346b0 --- /dev/null +++ b/plugins/profileplugin/profileplugin_resources.qrc @@ -0,0 +1,5 @@ + + + images/profile.png + + diff --git a/plugins/profileplugin/translations/profileplugin_de.ts b/plugins/profileplugin/translations/profileplugin_de.ts new file mode 100644 index 0000000..87a46c7 --- /dev/null +++ b/plugins/profileplugin/translations/profileplugin_de.ts @@ -0,0 +1,111 @@ + + + + + ProfileDialog + + + Profile + Profil + + + + User-ID: + Benutzer-ID: + + + + E-Mail: + E-Mail: + + + + Long username: + Langer Benutzername: + + + + Text: + Text: + + + + Username: + Benutzername: + + + + Street: + Straße: + + + + City: + Stadt: + + + + Employed since: + Angestellt seit: + + + + Employed till: + Angestellt bis: + + + + Place of birth: + Geburtsort: + + + + Zipcode: + Postleitzahl: + + + + Religion: + Religion: + + + + Department: + Abteilung: + + + + Verwendgr: + Verwendgr: + + + + Taetig: + Taetig: + + + + Arbverh: + Arbverh: + + + + Betriebsnr: + Betriebsnr: + + + + + dd.MM.yyyy + dd.MM.yyyy + + + + ProfilePlugin + + + My profile + Mein Profil + + + diff --git a/plugins/profileplugin/translations/profileplugin_en.ts b/plugins/profileplugin/translations/profileplugin_en.ts new file mode 100644 index 0000000..d4a55e7 --- /dev/null +++ b/plugins/profileplugin/translations/profileplugin_en.ts @@ -0,0 +1,111 @@ + + + + + ProfileDialog + + + Profile + + + + + User-ID: + + + + + E-Mail: + + + + + Long username: + + + + + Text: + + + + + Username: + + + + + Street: + + + + + City: + + + + + Employed since: + + + + + Employed till: + + + + + Place of birth: + + + + + Zipcode: + + + + + Religion: + + + + + Department: + + + + + Verwendgr: + + + + + Taetig: + + + + + Arbverh: + + + + + Betriebsnr: + + + + + + dd.MM.yyyy + + + + + ProfilePlugin + + + My profile + + + + diff --git a/plugins/reportsplugin/reportsplugin.cpp b/plugins/reportsplugin/reportsplugin.cpp index ce4dec0..c629073 100644 --- a/plugins/reportsplugin/reportsplugin.cpp +++ b/plugins/reportsplugin/reportsplugin.cpp @@ -4,6 +4,9 @@ #include #include #include +#include + +#include "mainwindow.h" #include "reportswidget.h" @@ -29,5 +32,5 @@ ReportsPlugin::ReportsPlugin(QObject *parent) : void ReportsPlugin::attachTo(MainWindow &mainWindow) { - new ReportsWidget(mainWindow); + mainWindow.statusBar()->addPermanentWidget(new ReportsWidget(mainWindow)); } diff --git a/plugins/reportsplugin/reportsplugin.h b/plugins/reportsplugin/reportsplugin.h index 469ac83..6f58568 100644 --- a/plugins/reportsplugin/reportsplugin.h +++ b/plugins/reportsplugin/reportsplugin.h @@ -1,5 +1,4 @@ -#ifndef REPORTSPLUGIN_H -#define REPORTSPLUGIN_H +#pragma once #include #include @@ -23,5 +22,3 @@ public: private: QTranslator m_translator; }; - -#endif // REPORTSPLUGIN_H diff --git a/plugins/reportsplugin/reportsplugin.pro b/plugins/reportsplugin/reportsplugin.pro index e5fcadf..002d60b 100644 --- a/plugins/reportsplugin/reportsplugin.pro +++ b/plugins/reportsplugin/reportsplugin.pro @@ -5,20 +5,22 @@ TEMPLATE = lib CONFIG += shared c++14 -DESTDIR = $${OUT_PWD}/../../bin/plugins/zeiterfassung +PROJECT_ROOT = ../.. -LIBS += -L$$OUT_PWD/../../lib -lzeiterfassunglib +DESTDIR = $${OUT_PWD}/$${PROJECT_ROOT}/bin/plugins/zeiterfassung -INCLUDEPATH += $$PWD/../../zeiterfassunglib -DEPENDPATH += $$PWD/../../zeiterfassunglib +LIBS += -L$${OUT_PWD}/$${PROJECT_ROOT}/bin -lzeiterfassungcorelib -lzeiterfassungguilib + +INCLUDEPATH += $$PWD/$${PROJECT_ROOT}/zeiterfassungcorelib $$PWD/$${PROJECT_ROOT}/zeiterfassungguilib +DEPENDPATH += $$PWD/$${PROJECT_ROOT}/zeiterfassungcorelib $$PWD/$${PROJECT_ROOT}/zeiterfassungguilib DEFINES += QT_DEPRECATED_WARNINGS QT_DISABLE_DEPRECATED_BEFORE=0x060000 QT_MESSAGELOGCONTEXT HEADERS += reportsplugin.h \ - reportswidget.h + reportswidget.h SOURCES += reportsplugin.cpp \ - reportswidget.cpp + reportswidget.cpp FORMS += @@ -30,8 +32,3 @@ TRANSLATIONS += translations/reportsplugin_en.ts \ OTHER_FILES += reportsplugin.json include(../../lrelease.pri) - -COMPILED_TRANSLATIONS += $${OUT_PWD}/translations/reportsplugin_en.qm \ - $${OUT_PWD}/translations/reportsplugin_de.qm - -include(../copy_translations.pri) diff --git a/plugins/reportsplugin/reportswidget.cpp b/plugins/reportsplugin/reportswidget.cpp index 1aded66..30eba00 100644 --- a/plugins/reportsplugin/reportswidget.cpp +++ b/plugins/reportsplugin/reportswidget.cpp @@ -1,10 +1,10 @@ #include "reportswidget.h" -#include #include #include #include #include +#include #include #include #include @@ -15,27 +15,25 @@ #include "zeiterfassungapi.h" ReportsWidget::ReportsWidget(MainWindow &mainWindow) : - QWidget(&mainWindow), + QLabel(&mainWindow), m_mainWindow(mainWindow) { connect(&m_mainWindow, &MainWindow::dateChanged, this, &ReportsWidget::dateChanged); connect(&m_mainWindow, &MainWindow::refreshEverything, this, &ReportsWidget::refresh); - m_labelBalance = new QLabel(this); - m_labelBalance->setFrameShape(QFrame::Panel); - m_labelBalance->setFrameShadow(QFrame::Sunken); - m_mainWindow.statusBar()->addPermanentWidget(m_labelBalance); + setFrameShape(QFrame::Panel); + setFrameShadow(QFrame::Sunken); - m_labelHolidays = new QLabel(this); - m_labelHolidays->setFrameShape(QFrame::Panel); - m_labelHolidays->setFrameShadow(QFrame::Sunken); - m_mainWindow.statusBar()->addPermanentWidget(m_labelHolidays); + m_actionRefreshReport = new QAction(QIcon(QStringLiteral(":/zeiterfassung/plugins/reportsplugin/images/refresh.png")), + tr("Refresh report"), this); + connect(m_actionRefreshReport, &QAction::triggered, this, &ReportsWidget::refresh); + m_mainWindow.menuView()->addAction(m_actionRefreshReport); - m_actionRefreshReport = m_mainWindow.menuView()->addAction(QIcon(QStringLiteral(":/zeiterfassung/plugins/reportsplugin/images/refresh.png")), - tr("Refresh report"), this, &ReportsWidget::refresh); + m_actionOpenReport = new QAction(QIcon(QStringLiteral(":/zeiterfassung/plugins/reportsplugin/images/report.png")), + tr("Open report"), this); + connect(m_actionOpenReport, &QAction::triggered, this, &ReportsWidget::openReport); + m_mainWindow.menuTools()->addAction(m_actionOpenReport); - m_actionOpenReport = m_mainWindow.menuTools()->addAction(QIcon(QStringLiteral(":/zeiterfassung/plugins/reportsplugin/images/report.png")), - tr("Open report"), this, &ReportsWidget::openReport); m_mainWindow.toolBar()->addAction(m_actionOpenReport); dateChanged(m_mainWindow.date()); @@ -65,12 +63,11 @@ void ReportsWidget::refresh() return; } + setText(tr("Balance: %0, Holidays: %1").arg(tr("???")).arg(tr("???"))); + m_actionRefreshReport->setEnabled(false); m_actionOpenReport->setEnabled(false); - m_labelBalance->setText(tr("%0: %1").arg(tr("Balance")).arg(tr("???"))); - m_labelHolidays->setText(tr("%0: %1").arg(tr("Holidays")).arg(tr("???"))); - m_reply = m_mainWindow.erfassung().doGetReport(m_mainWindow.userInfo().userId, m_date); connect(m_reply.get(), &ZeiterfassungReply::finished, this, &ReportsWidget::finished); } @@ -87,38 +84,43 @@ void ReportsWidget::finished() { auto content = m_reply->content(); + QString balance; + { static QRegularExpression regex(QStringLiteral("Gleitzeit +([0-9]+\\:[0-9]+\\-?) +([0-9]+\\:[0-9]+\\-?)")); auto match = regex.match(content); if(match.hasMatch()) { - auto balance = match.captured(2); + balance = match.captured(2); if(balance.endsWith(QChar('-'))) { balance.chop(1); balance = QChar('-') % balance; } - m_labelBalance->setText(tr("%0: %1").arg(tr("Balance")).arg(tr("%0h").arg(balance))); } else { - m_labelBalance->setText(tr("%0: %1").arg(tr("Balance")).arg(tr("n/a"))); + balance = tr("n/a"); qWarning() << "balance not found in PDF"; } } + QString holidays; + { - static QRegularExpression regex(QStringLiteral("Urlaubsanspruch +([0-9]+\\.[0-9]+\\-?) +([0-9]+\\.[0-9]+\\-?)")); + static QRegularExpression regex(QStringLiteral("Urlaubsanspruch +(\\-?[0-9]+\\.[0-9]+) +(\\-?[0-9]+\\.[0-9]+)")); auto match = regex.match(content); if(match.hasMatch()) - m_labelHolidays->setText(tr("%0: %1").arg(tr("Holidays")).arg(match.captured(2))); + holidays = match.captured(2); else { - m_labelHolidays->setText(tr("%0: %1").arg(tr("Holidays")).arg(tr("n/a"))); + holidays = tr("n/a"); qWarning() << "holidays not found in PDF"; } } + setText(tr("Balance: %0, Holidays: %1").arg(balance).arg(holidays)); + { QTemporaryFile file(QDir::temp().absoluteFilePath(QStringLiteral("reportXXXXXX.pdf"))); file.setAutoRemove(false); diff --git a/plugins/reportsplugin/reportswidget.h b/plugins/reportsplugin/reportswidget.h index 9adcfe7..46ad7d9 100644 --- a/plugins/reportsplugin/reportswidget.h +++ b/plugins/reportsplugin/reportswidget.h @@ -1,18 +1,16 @@ -#ifndef REPORTSWIDGET_H -#define REPORTSWIDGET_H +#pragma once -#include +#include #include #include #include "replies/getreportreply.h" -class QLabel; class QAction; class MainWindow; -class ReportsWidget : public QWidget +class ReportsWidget : public QLabel { Q_OBJECT @@ -28,9 +26,6 @@ private Q_SLOTS: private: MainWindow &m_mainWindow; - QLabel *m_labelBalance; - QLabel *m_labelHolidays; - QAction *m_actionOpenReport; QAction *m_actionRefreshReport; @@ -39,5 +34,3 @@ private: std::unique_ptr m_reply; }; - -#endif // REPORTSWIDGET_H diff --git a/plugins/reportsplugin/translations/reportsplugin_de.ts b/plugins/reportsplugin/translations/reportsplugin_de.ts index fdca085..20c4d29 100644 --- a/plugins/reportsplugin/translations/reportsplugin_de.ts +++ b/plugins/reportsplugin/translations/reportsplugin_de.ts @@ -4,68 +4,44 @@ ReportsWidget - + Refresh report Auswertung aktualisieren - + Open report Auswertung öffnen - - - - - - - %0: %1 - %0: %1 - - - - - - Balance - Gleitzeit - - - - + ??? ??? - - - - Holidays - Urlaub + + + Balance: %0, Holidays: %1 + Gleitzeit: %0, Urlaub: %1 - + Could not load report! Konnte Auswertung nicht laden! - - %0h - %0h - - - - + + n/a n/v - + Could not write report! Konnte Auswertung nicht abspeichern! - + Could not launch your default PDF viewer! Konnte Standard-PDF-Viewer nicht öffnen! diff --git a/plugins/reportsplugin/translations/reportsplugin_en.ts b/plugins/reportsplugin/translations/reportsplugin_en.ts index 03ce2d6..0dc51dd 100644 --- a/plugins/reportsplugin/translations/reportsplugin_en.ts +++ b/plugins/reportsplugin/translations/reportsplugin_en.ts @@ -4,68 +4,44 @@ ReportsWidget - + Refresh report - + Open report - - - - - - - %0: %1 - - - - - - - Balance - - - - - + ??? - - - - Holidays + + + Balance: %0, Holidays: %1 - + Could not load report! - - %0h - - - - - + + n/a - + Could not write report! - + Could not launch your default PDF viewer! diff --git a/plugins/updaterplugin/translations/updaterplugin_de.ts b/plugins/updaterplugin/translations/updaterplugin_de.ts index 0fd56e0..d07c870 100644 --- a/plugins/updaterplugin/translations/updaterplugin_de.ts +++ b/plugins/updaterplugin/translations/updaterplugin_de.ts @@ -20,7 +20,7 @@ Heute nicht mehr anzeigen - + Could not open default webbrowser! Konnte Standard-Browser nicht öffnen! diff --git a/plugins/updaterplugin/translations/updaterplugin_en.ts b/plugins/updaterplugin/translations/updaterplugin_en.ts index fd1099e..0da5318 100644 --- a/plugins/updaterplugin/translations/updaterplugin_en.ts +++ b/plugins/updaterplugin/translations/updaterplugin_en.ts @@ -20,7 +20,7 @@ - + Could not open default webbrowser! diff --git a/plugins/updaterplugin/updaterdialog.cpp b/plugins/updaterplugin/updaterdialog.cpp index 55f5bdb..61b3b62 100644 --- a/plugins/updaterplugin/updaterdialog.cpp +++ b/plugins/updaterplugin/updaterdialog.cpp @@ -19,7 +19,7 @@ #include "zeiterfassungapi.h" UpdaterDialog::UpdaterDialog(MainWindow &mainWindow) : - QDialog(&mainWindow), + ZeiterfassungDialog(&mainWindow), ui(new Ui::UpdaterDialog), m_mainWindow(mainWindow) { @@ -31,8 +31,8 @@ UpdaterDialog::UpdaterDialog(MainWindow &mainWindow) : connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &UpdaterDialog::rejectedSlot); auto url = m_mainWindow.settings().value(QStringLiteral("UpdaterPlugin/url"), - QUrl(QStringLiteral("https://api.github.com/repos/0xFEEDC0DE64/QtZeiterfassung/releases"))).toUrl(); - m_reply = m_mainWindow.erfassung().manager()->get(QNetworkRequest(url)); + QStringLiteral("https://api.github.com/repos/0xFEEDC0DE64/QtZeiterfassung/releases")).toString(); + m_reply = m_mainWindow.erfassung().manager()->get(QNetworkRequest(QUrl(url))); connect(m_reply, &QNetworkReply::finished, this, &UpdaterDialog::finished); } diff --git a/plugins/updaterplugin/updaterdialog.h b/plugins/updaterplugin/updaterdialog.h index c714506..2ea7560 100644 --- a/plugins/updaterplugin/updaterdialog.h +++ b/plugins/updaterplugin/updaterdialog.h @@ -1,15 +1,15 @@ -#ifndef UPDATERDIALOG_H -#define UPDATERDIALOG_H +#pragma once -#include #include +#include "zeiterfassungdialog.h" + class QNetworkReply; namespace Ui { class UpdaterDialog; } class MainWindow; -class UpdaterDialog : public QDialog +class UpdaterDialog : public ZeiterfassungDialog { Q_OBJECT @@ -29,5 +29,3 @@ private: QUrl m_url; }; - -#endif // UPDATERDIALOG_H diff --git a/plugins/updaterplugin/updaterplugin.h b/plugins/updaterplugin/updaterplugin.h index 51311b2..7cefe30 100644 --- a/plugins/updaterplugin/updaterplugin.h +++ b/plugins/updaterplugin/updaterplugin.h @@ -1,5 +1,4 @@ -#ifndef UPDATERPLUGIN_H -#define UPDATERPLUGIN_H +#pragma once #include #include @@ -23,5 +22,3 @@ public: private: QTranslator m_translator; }; - -#endif // UPDATERPLUGIN_H diff --git a/plugins/updaterplugin/updaterplugin.pro b/plugins/updaterplugin/updaterplugin.pro index 0e6f1ce..ec3d037 100644 --- a/plugins/updaterplugin/updaterplugin.pro +++ b/plugins/updaterplugin/updaterplugin.pro @@ -5,12 +5,14 @@ TEMPLATE = lib CONFIG += shared c++14 -DESTDIR = $${OUT_PWD}/../../bin/plugins/zeiterfassung +PROJECT_ROOT = ../.. -LIBS += -L$$OUT_PWD/../../lib -lzeiterfassunglib +DESTDIR = $${OUT_PWD}/$${PROJECT_ROOT}/bin/plugins/zeiterfassung -INCLUDEPATH += $$PWD/../../zeiterfassunglib -DEPENDPATH += $$PWD/../../zeiterfassunglib +LIBS += -L$${OUT_PWD}/$${PROJECT_ROOT}/bin -lzeiterfassungcorelib -lzeiterfassungguilib + +INCLUDEPATH += $$PWD/$${PROJECT_ROOT}/zeiterfassungcorelib $$PWD/$${PROJECT_ROOT}/zeiterfassungguilib +DEPENDPATH += $$PWD/$${PROJECT_ROOT}/zeiterfassungcorelib $$PWD/$${PROJECT_ROOT}/zeiterfassungguilib DEFINES += QT_DEPRECATED_WARNINGS QT_DISABLE_DEPRECATED_BEFORE=0x060000 QT_MESSAGELOGCONTEXT @@ -30,8 +32,3 @@ TRANSLATIONS += translations/updaterplugin_en.ts \ OTHER_FILES += updaterplugin.json include(../../lrelease.pri) - -COMPILED_TRANSLATIONS += $${OUT_PWD}/translations/updaterplugin_en.qm \ - $${OUT_PWD}/translations/updaterplugin_de.qm - -include(../copy_translations.pri) diff --git a/plugins/weatherplugin/translations/weatherplugin_de.ts b/plugins/weatherplugin/translations/weatherplugin_de.ts index 40f7555..c7baf36 100644 --- a/plugins/weatherplugin/translations/weatherplugin_de.ts +++ b/plugins/weatherplugin/translations/weatherplugin_de.ts @@ -23,6 +23,16 @@ Not an json obj Kein json obj + + + No weather found + Kein weather gefunden + + + + No main found + Kein main gefunden + %0 (%1°C) diff --git a/plugins/weatherplugin/translations/weatherplugin_en.ts b/plugins/weatherplugin/translations/weatherplugin_en.ts index c4bb548..fd63ccf 100644 --- a/plugins/weatherplugin/translations/weatherplugin_en.ts +++ b/plugins/weatherplugin/translations/weatherplugin_en.ts @@ -23,6 +23,16 @@ Not an json obj + + + No weather found + + + + + No main found + + %0 (%1°C) diff --git a/plugins/weatherplugin/weatherplugin.h b/plugins/weatherplugin/weatherplugin.h index c4dc84f..07f4f68 100644 --- a/plugins/weatherplugin/weatherplugin.h +++ b/plugins/weatherplugin/weatherplugin.h @@ -1,5 +1,4 @@ -#ifndef WEATHERPLUGIN_H -#define WEATHERPLUGIN_H +#pragma once #include #include @@ -21,5 +20,3 @@ public: private: QTranslator m_translator; }; - -#endif // WEATHERPLUGIN_H diff --git a/plugins/weatherplugin/weatherplugin.pro b/plugins/weatherplugin/weatherplugin.pro index 43118e3..02016bc 100644 --- a/plugins/weatherplugin/weatherplugin.pro +++ b/plugins/weatherplugin/weatherplugin.pro @@ -5,12 +5,14 @@ TEMPLATE = lib CONFIG += shared c++14 -DESTDIR = $${OUT_PWD}/../../bin/plugins/zeiterfassung +PROJECT_ROOT = ../.. -LIBS += -L$$OUT_PWD/../../lib -lzeiterfassunglib +DESTDIR = $${OUT_PWD}/$${PROJECT_ROOT}/bin/plugins/zeiterfassung -INCLUDEPATH += $$PWD/../../zeiterfassunglib -DEPENDPATH += $$PWD/../../zeiterfassunglib +LIBS += -L$${OUT_PWD}/$${PROJECT_ROOT}/bin -lzeiterfassungcorelib -lzeiterfassungguilib + +INCLUDEPATH += $$PWD/$${PROJECT_ROOT}/zeiterfassungcorelib $$PWD/$${PROJECT_ROOT}/zeiterfassungguilib +DEPENDPATH += $$PWD/$${PROJECT_ROOT}/zeiterfassungcorelib $$PWD/$${PROJECT_ROOT}/zeiterfassungguilib DEFINES += QT_DEPRECATED_WARNINGS QT_DISABLE_DEPRECATED_BEFORE=0x060000 QT_MESSAGELOGCONTEXT @@ -30,8 +32,3 @@ TRANSLATIONS += translations/weatherplugin_en.ts \ OTHER_FILES += weatherplugin.json include(../../lrelease.pri) - -COMPILED_TRANSLATIONS += $${OUT_PWD}/translations/weatherplugin_en.qm \ - $${OUT_PWD}/translations/weatherplugin_de.qm - -include(../copy_translations.pri) diff --git a/plugins/weatherplugin/weatherwidget.cpp b/plugins/weatherplugin/weatherwidget.cpp index 76efa1a..764bf99 100644 --- a/plugins/weatherplugin/weatherwidget.cpp +++ b/plugins/weatherplugin/weatherwidget.cpp @@ -3,8 +3,7 @@ #include #include #include -#include -#include +#include #include #include #include @@ -69,14 +68,14 @@ void WeatherWidget::finished() if(!obj.contains(QStringLiteral("weather"))) { qWarning() << "no weather" << obj; - setText("No weater found"); + setText(tr("No weather found")); goto after; } if(!obj.contains(QStringLiteral("main"))) { qWarning() << "no main" << obj; - setText("No main found"); + setText(tr("No main found")); goto after; } diff --git a/plugins/weatherplugin/weatherwidget.h b/plugins/weatherplugin/weatherwidget.h index 17532c5..8a3a2f7 100644 --- a/plugins/weatherplugin/weatherwidget.h +++ b/plugins/weatherplugin/weatherwidget.h @@ -1,5 +1,4 @@ -#ifndef WEATHERWIDGET_H -#define WEATHERWIDGET_H +#pragma once #include @@ -24,5 +23,3 @@ private: std::unique_ptr m_reply; }; - -#endif // WEATHERWIDGET_H diff --git a/plugins/webradioplugin/images/web-radio.png b/plugins/webradioplugin/images/web-radio.png new file mode 100644 index 0000000..c68d7c1 Binary files /dev/null and b/plugins/webradioplugin/images/web-radio.png differ diff --git a/plugins/webradioplugin/translations/webradioplugin_de.ts b/plugins/webradioplugin/translations/webradioplugin_de.ts new file mode 100644 index 0000000..039b33f --- /dev/null +++ b/plugins/webradioplugin/translations/webradioplugin_de.ts @@ -0,0 +1,101 @@ + + + + + WebRadioDialog + + + Radio + Radio + + + + Play + Abspielen + + + + Pause + Pause + + + + Stop + Stop + + + + Stopped + Gestoppt + + + + Playing + Wird abgespielt + + + + Paused + Pausiert + + + + + Unknown + Unbekannt + + + + Unknown media + Unbekanntes Medium + + + + No media + Kein Medium + + + + Loading media... + Lade Medium... + + + + Loaded media + Medium geladen + + + + Stalled media + Medium angehalten + + + + Buffering media + Puffere Medium + + + + Buffered media + Medium gepuffert + + + + End of media + Ende des Mediums + + + + Invalid media + Ungültiges Medium + + + + WebRadioPlugin + + + Play webradio + Webradio spielen + + + diff --git a/plugins/webradioplugin/translations/webradioplugin_en.ts b/plugins/webradioplugin/translations/webradioplugin_en.ts new file mode 100644 index 0000000..77f91eb --- /dev/null +++ b/plugins/webradioplugin/translations/webradioplugin_en.ts @@ -0,0 +1,101 @@ + + + + + WebRadioDialog + + + Radio + + + + + Play + + + + + Pause + + + + + Stop + + + + + Stopped + + + + + Playing + + + + + Paused + + + + + + Unknown + + + + + Unknown media + + + + + No media + + + + + Loading media... + + + + + Loaded media + + + + + Stalled media + + + + + Buffering media + + + + + Buffered media + + + + + End of media + + + + + Invalid media + + + + + WebRadioPlugin + + + Play webradio + + + + diff --git a/plugins/webradioplugin/webradiodialog.cpp b/plugins/webradioplugin/webradiodialog.cpp new file mode 100644 index 0000000..fd5e855 --- /dev/null +++ b/plugins/webradioplugin/webradiodialog.cpp @@ -0,0 +1,141 @@ +#include "webradiodialog.h" +#include "ui_webradiodialog.h" + +#include "mainwindow.h" +#include "zeiterfassungsettings.h" + +WebRadioDialog::WebRadioDialog(MainWindow &mainWindow) : + ZeiterfassungDialog(&mainWindow), + ui(new Ui::WebRadioDialog), + m_mainWindow(mainWindow) +{ + ui->setupUi(this); + + m_player = new QMediaPlayer(this); + connect(m_player, &QMediaPlayer::stateChanged, this, &WebRadioDialog::stateChanged); + connect(m_player, &QMediaPlayer::stateChanged, this, &WebRadioDialog::updateWidgets); + connect(m_player, &QMediaPlayer::mediaStatusChanged, this, &WebRadioDialog::mediaStatusChanged); + connect(m_player, &QMediaPlayer::mediaStatusChanged, this, &WebRadioDialog::updateWidgets); + connect(m_player, static_cast(&QMediaPlayer::error), this, &WebRadioDialog::error); + + for(const auto &url : m_mainWindow.settings().value(QStringLiteral("WebRadioPlugin/urls"), QStringList { + QStringLiteral("http://stream.drumandbass.fm:9002"), + QStringLiteral("http://stream.trap.fm:6002"), + QStringLiteral("http://stream.dubbase.fm:7002"), + QStringLiteral("http://lw1.mp3.tb-group.fm/hb.mp3"), + QStringLiteral("http://lw1.mp3.tb-group.fm/tb.mp3"), + QStringLiteral("http://lw1.mp3.tb-group.fm/tt.mp3"), + QStringLiteral("http://lw1.mp3.tb-group.fm/ht.mp3"), + QStringLiteral("http://lw1.mp3.tb-group.fm/trb.mp3"), + QStringLiteral("http://lw1.mp3.tb-group.fm/ct.mp3"), + QStringLiteral("http://lw1.mp3.tb-group.fm/clt.mp3"), + QStringLiteral("https://live.helsinki.at:8088/live160.ogg") + }).toStringList()) + { + ui->comboBox->addItem(url, url); + } + + ui->comboBox->setCurrentIndex(ui->comboBox->findData(m_mainWindow.settings().value(QStringLiteral("WebRadioPlugin/lastUrl")).toString())); + + connect(ui->comboBox, static_cast(&QComboBox::currentIndexChanged), + this, &WebRadioDialog::currentIndexChanged); + + connect(ui->comboBox, static_cast(&QComboBox::currentIndexChanged), + this, &WebRadioDialog::updateWidgets); + + connect(ui->pushButtonPlay, &QAbstractButton::pressed, this, &WebRadioDialog::play); + connect(ui->pushButtonPause, &QAbstractButton::pressed, m_player, &QMediaPlayer::pause); + connect(ui->pushButtonStop, &QAbstractButton::pressed, m_player, &QMediaPlayer::stop); + + m_player->setVolume(m_mainWindow.settings().value(QStringLiteral("WebRadioPlugin/volume"), 100).toInt()); + ui->horizontalSlider->setValue(m_player->volume()); + connect(ui->horizontalSlider, &QAbstractSlider::valueChanged, this, &WebRadioDialog::volumeChanged); + + stateChanged(m_player->state()); + mediaStatusChanged(m_player->mediaStatus()); + currentIndexChanged(ui->comboBox->currentIndex()); + updateWidgets(); +} + +WebRadioDialog::~WebRadioDialog() +{ + // To avoid crash on app close + disconnect(m_player, &QMediaPlayer::stateChanged, this, &WebRadioDialog::stateChanged); + disconnect(m_player, &QMediaPlayer::stateChanged, this, &WebRadioDialog::updateWidgets); + disconnect(m_player, &QMediaPlayer::mediaStatusChanged, this, &WebRadioDialog::mediaStatusChanged); + disconnect(m_player, &QMediaPlayer::mediaStatusChanged, this, &WebRadioDialog::updateWidgets); + disconnect(m_player, static_cast(&QMediaPlayer::error), this, &WebRadioDialog::error); + + delete ui; +} + +void WebRadioDialog::stateChanged(QMediaPlayer::State newState) +{ + switch(newState) + { + case QMediaPlayer::StoppedState: ui->labelState->setText(tr("Stopped")); break; + case QMediaPlayer::PlayingState: ui->labelState->setText(tr("Playing")); break; + case QMediaPlayer::PausedState: ui->labelState->setText(tr("Paused")); break; + default: + qWarning() << "unknown state" << newState; + ui->labelState->setText(tr("Unknown")); + } +} + +void WebRadioDialog::mediaStatusChanged(QMediaPlayer::MediaStatus status) +{ + switch(status) + { + case QMediaPlayer::UnknownMediaStatus: ui->labelMediaStatus->setText(tr("Unknown media")); break; + case QMediaPlayer::NoMedia: ui->labelMediaStatus->setText(tr("No media")); break; + case QMediaPlayer::LoadingMedia: ui->labelMediaStatus->setText(tr("Loading media...")); break; + case QMediaPlayer::LoadedMedia: ui->labelMediaStatus->setText(tr("Loaded media")); break; + case QMediaPlayer::StalledMedia: ui->labelMediaStatus->setText(tr("Stalled media")); break; + case QMediaPlayer::BufferingMedia: ui->labelMediaStatus->setText(tr("Buffering media")); break; + case QMediaPlayer::BufferedMedia: ui->labelMediaStatus->setText(tr("Buffered media")); break; + case QMediaPlayer::EndOfMedia: ui->labelMediaStatus->setText(tr("End of media")); break; + case QMediaPlayer::InvalidMedia: ui->labelMediaStatus->setText(tr("Invalid media")); break; + default: + qWarning() << "unknown mediaStatus" << status; + ui->labelMediaStatus->setText(tr("Unknown")); + } +} + +void WebRadioDialog::error(QMediaPlayer::Error error) +{ + qWarning() << error; +} + +void WebRadioDialog::currentIndexChanged(int index) +{ + if(index == -1) + m_player->setMedia(QMediaContent()); + else + m_player->setMedia(QMediaContent(QUrl(ui->comboBox->currentData().toString()))); +} + +void WebRadioDialog::play() +{ + if(ui->comboBox->currentIndex() == -1) + return; + + m_mainWindow.settings().setValue(QStringLiteral("WebRadioPlugin/lastUrl"), ui->comboBox->currentData().toString()); + + m_player->play(); +} + +void WebRadioDialog::updateWidgets() +{ + ui->comboBox->setEnabled(m_player->state() != QMediaPlayer::PlayingState); + ui->pushButtonPlay->setEnabled(ui->comboBox->currentIndex() > -1 && + (m_player->state() == QMediaPlayer::StoppedState || m_player->state() == QMediaPlayer::PausedState) && + (m_player->mediaStatus() == QMediaPlayer::LoadedMedia || m_player->mediaStatus() == QMediaPlayer::BufferedMedia)); + ui->pushButtonPause->setEnabled(m_player->state() == QMediaPlayer::PlayingState || m_player->state() == QMediaPlayer::PausedState); + ui->pushButtonStop->setEnabled(m_player->state() == QMediaPlayer::PlayingState || m_player->state() == QMediaPlayer::PausedState); +} + +void WebRadioDialog::volumeChanged(int volume) +{ + m_mainWindow.settings().setValue(QStringLiteral("WebRadioPlugin/volume"), volume); + m_player->setVolume(volume); +} diff --git a/plugins/webradioplugin/webradiodialog.h b/plugins/webradioplugin/webradiodialog.h new file mode 100644 index 0000000..6dbda8d --- /dev/null +++ b/plugins/webradioplugin/webradiodialog.h @@ -0,0 +1,34 @@ +#pragma once + +#include + +#include "zeiterfassungdialog.h" + +class MainWindow; + +namespace Ui { class WebRadioDialog; } + +class WebRadioDialog : public ZeiterfassungDialog +{ + Q_OBJECT + +public: + explicit WebRadioDialog(MainWindow &mainWindow); + ~WebRadioDialog(); + +private Q_SLOTS: + void stateChanged(QMediaPlayer::State newState); + void mediaStatusChanged(QMediaPlayer::MediaStatus status); + void error(QMediaPlayer::Error error); + void currentIndexChanged(int index); + void volumeChanged(int volume); + void play(); + +private: + void updateWidgets(); + + Ui::WebRadioDialog *ui; + + MainWindow &m_mainWindow; + QMediaPlayer *m_player; +}; diff --git a/plugins/webradioplugin/webradiodialog.ui b/plugins/webradioplugin/webradiodialog.ui new file mode 100644 index 0000000..5758e10 --- /dev/null +++ b/plugins/webradioplugin/webradiodialog.ui @@ -0,0 +1,135 @@ + + + WebRadioDialog + + + + 0 + 0 + 494 + 155 + + + + Radio + + + + + + + + + + + + 0 + 50 + + + + Play + + + + + + + + 0 + 50 + + + + Pause + + + + + + + + 0 + 50 + + + + Stop + + + + + + + Qt::Horizontal + + + + + + + + + + + state + + + + + + + mediaStatus + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Close + + + + + + + + + buttonBox + accepted() + WebRadioDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + WebRadioDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/plugins/webradioplugin/webradioplugin.cpp b/plugins/webradioplugin/webradioplugin.cpp new file mode 100644 index 0000000..9a749d7 --- /dev/null +++ b/plugins/webradioplugin/webradioplugin.cpp @@ -0,0 +1,39 @@ +#include "webradioplugin.h" + +#include +#include +#include +#include +#include +#include + +#include "mainwindow.h" + +#include "webradiodialog.h" + +WebRadioPlugin::WebRadioPlugin(QObject *parent) : + ZeiterfassungPlugin(parent) +{ + qDebug() << "called"; + + static auto dir = QDir(QCoreApplication::applicationDirPath()).absoluteFilePath(QStringLiteral("translations")); + + if(m_translator.load(QLocale(), QStringLiteral("webradioplugin"), QStringLiteral("_"), dir)) + { + if(!QCoreApplication::installTranslator(&m_translator)) + { + qWarning() << "could not install translation webradioplugin"; + } + } + else + { + qWarning() << "could not load translation webradioplugin"; + } +} + +void WebRadioPlugin::attachTo(MainWindow &mainWindow) +{ + auto dialog = new WebRadioDialog(mainWindow); + mainWindow.menuTools()->addAction(QIcon(QStringLiteral(":/zeiterfassung/plugins/webradioplugin/images/web-radio.png")), + tr("Play webradio"), dialog, &QWidget::show); +} diff --git a/plugins/webradioplugin/webradioplugin.h b/plugins/webradioplugin/webradioplugin.h new file mode 100644 index 0000000..e11932d --- /dev/null +++ b/plugins/webradioplugin/webradioplugin.h @@ -0,0 +1,22 @@ +#pragma once + +#include +#include + +#include "zeiterfassungplugin.h" + +class Q_DECL_EXPORT WebRadioPlugin : public ZeiterfassungPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "dbsoftware.zeiterfassung.plugin/1.0" FILE "webradioplugin.json") + Q_INTERFACES(ZeiterfassungPlugin) + +public: + explicit WebRadioPlugin(QObject *parent = Q_NULLPTR); + + // ZeiterfassungPlugin interface + void attachTo(MainWindow &mainWindow) Q_DECL_OVERRIDE; + +private: + QTranslator m_translator; +}; diff --git a/plugins/webradioplugin/webradioplugin.json b/plugins/webradioplugin/webradioplugin.json new file mode 100644 index 0000000..e69de29 diff --git a/plugins/webradioplugin/webradioplugin.pro b/plugins/webradioplugin/webradioplugin.pro new file mode 100644 index 0000000..1024a95 --- /dev/null +++ b/plugins/webradioplugin/webradioplugin.pro @@ -0,0 +1,34 @@ +QT += core network gui widgets multimedia + +TARGET = webradioplugin +TEMPLATE = lib + +CONFIG += shared c++14 + +PROJECT_ROOT = ../.. + +DESTDIR = $${OUT_PWD}/$${PROJECT_ROOT}/bin/plugins/zeiterfassung + +LIBS += -L$${OUT_PWD}/$${PROJECT_ROOT}/bin -lzeiterfassungcorelib -lzeiterfassungguilib + +INCLUDEPATH += $$PWD/$${PROJECT_ROOT}/zeiterfassungcorelib $$PWD/$${PROJECT_ROOT}/zeiterfassungguilib +DEPENDPATH += $$PWD/$${PROJECT_ROOT}/zeiterfassungcorelib $$PWD/$${PROJECT_ROOT}/zeiterfassungguilib + +DEFINES += QT_DEPRECATED_WARNINGS QT_DISABLE_DEPRECATED_BEFORE=0x060000 QT_MESSAGELOGCONTEXT + +HEADERS += webradiodialog.h \ + webradioplugin.h + +SOURCES += webradiodialog.cpp \ + webradioplugin.cpp + +FORMS += webradiodialog.ui + +RESOURCES += webradioplugin_resources.qrc + +TRANSLATIONS += translations/webradioplugin_en.ts \ + translations/webradioplugin_de.ts + +OTHER_FILES += webradioplugin.json + +include(../../lrelease.pri) diff --git a/plugins/webradioplugin/webradioplugin_resources.qrc b/plugins/webradioplugin/webradioplugin_resources.qrc new file mode 100644 index 0000000..f7b12b5 --- /dev/null +++ b/plugins/webradioplugin/webradioplugin_resources.qrc @@ -0,0 +1,5 @@ + + + images/web-radio.png + + diff --git a/win32/Qt.conf b/win32/Qt.conf new file mode 100644 index 0000000..e69de29 diff --git a/zeiterfassung.pro b/zeiterfassung.pro deleted file mode 100644 index 337265b..0000000 --- a/zeiterfassung.pro +++ /dev/null @@ -1,8 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS += plugins \ - zeiterfassung \ - zeiterfassunglib - -plugins.depends += zeiterfassunglib -zeiterfassung.depends += zeiterfassunglib diff --git a/zeiterfassung/images/splash.png b/zeiterfassung/images/splash.png new file mode 100644 index 0000000..7140cd2 Binary files /dev/null and b/zeiterfassung/images/splash.png differ diff --git a/zeiterfassung/installs.pri b/zeiterfassung/installs.pri index 7782a92..ec42827 100644 --- a/zeiterfassung/installs.pri +++ b/zeiterfassung/installs.pri @@ -1,32 +1,8 @@ -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.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 @@ -74,7 +50,7 @@ DARK_THEME_RESOURCES += themes/dark_theme/checkbox_indeterminate_disabled.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.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 @@ -85,7 +61,7 @@ STRIPLAYOUTS += strips/bookingstartstrip.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.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 index c8dd1f2..26f2133 100644 --- a/zeiterfassung/installs_unix.pri +++ b/zeiterfassung/installs_unix.pri @@ -1,8 +1,3 @@ -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 +scriptsInstall.path = $${DESTDIR} +scriptsInstall.files = unix/zeiterfassung.sh +INSTALLS += scriptsInstall diff --git a/zeiterfassung/installs_win32.pri b/zeiterfassung/installs_win32.pri deleted file mode 100644 index a953930..0000000 --- a/zeiterfassung/installs_win32.pri +++ /dev/null @@ -1,44 +0,0 @@ -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/zeiterfassung/main.cpp b/zeiterfassung/main.cpp index 42c2855..2d5eb51 100755 --- a/zeiterfassung/main.cpp +++ b/zeiterfassung/main.cpp @@ -1,3 +1,5 @@ +#include + #include #include #include @@ -29,10 +31,10 @@ struct { QTranslator qtTranslator; QTranslator zeiterfassungTranslator; - QTranslator zeiterfassunglibTranslator; + QTranslator zeiterfassungguilibTranslator; } translators; -QVector plugins; +QVector > pluginLoaders; bool loadAndInstallTranslator(QTranslator &translator, const QString &filename) { @@ -80,7 +82,7 @@ bool loadTranslations(QSplashScreen &splashScreen, ZeiterfassungSettings &settin loadAndInstallTranslator(translators.qtTranslator, QStringLiteral("qt")); loadAndInstallTranslator(translators.zeiterfassungTranslator, QStringLiteral("zeiterfassung")); - loadAndInstallTranslator(translators.zeiterfassunglibTranslator, QStringLiteral("zeiterfassunglib")); + loadAndInstallTranslator(translators.zeiterfassungguilibTranslator, QStringLiteral("zeiterfassungguilib")); return true; } @@ -270,44 +272,25 @@ bool loadPlugins(QSplashScreen &splashScreen) ).absoluteFilePath(QStringLiteral("zeiterfassung")) ); - for(const auto &fileInfo : dir.entryInfoList(QDir::Files)) + for(const auto &fileInfo : dir.entryInfoList(QDir::Files | QDir::NoSymLinks)) { - if(fileInfo.isSymLink()) - { - qWarning() << "skipping" << fileInfo.fileName() << "because symlink"; - continue; // to skip unix so symlinks - } - if(!QLibrary::isLibrary(fileInfo.filePath())) { qWarning() << "skipping" << fileInfo.fileName() << "because no QLibrary"; continue; // to skip windows junk files } - qDebug() << "loading" << fileInfo.fileName(); - - QPluginLoader loader(fileInfo.filePath()); - if(!loader.load()) + auto pluginLoader = std::make_shared(fileInfo.filePath()); + if(!pluginLoader->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()); + "\n\n" % pluginLoader->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); + pluginLoaders.append(pluginLoader); } return ok; @@ -333,7 +316,7 @@ int main(int argc, char *argv[]) QCoreApplication::setApplicationName(QStringLiteral("zeiterfassung")); QCoreApplication::setApplicationVersion(QStringLiteral("1.5")); - QSplashScreen splashScreen(QPixmap(QStringLiteral(":/zeiterfassunglib/images/splash.png"))); + QSplashScreen splashScreen(QPixmap(QStringLiteral(":/zeiterfassung/images/splash.png"))); splashScreen.showMessage(QCoreApplication::translate("main", "Loading settings...")); splashScreen.show(); @@ -370,8 +353,13 @@ int main(int argc, char *argv[]) MainWindow mainWindow(settings, erfassung, userInfo, stripFactory); splashScreen.finish(&mainWindow); - for(auto plugin : plugins) - plugin->attachTo(mainWindow); + for(auto &pluginLoader : pluginLoaders) + if(auto plugin = qobject_cast(pluginLoader->instance())) + plugin->attachTo(mainWindow); + else + QMessageBox::warning(&splashScreen, QCoreApplication::translate("main", "Plugin not valid %0!"), + QCoreApplication::translate("main", "Plugin not valid %0!").arg(pluginLoader->fileName()) % + "\n\n" % pluginLoader->errorString()); mainWindow.show(); diff --git a/zeiterfassung/strips/bookingendstrip.ui b/zeiterfassung/strips/bookingendstrip.ui index 0116a4f..e901bb5 100644 --- a/zeiterfassung/strips/bookingendstrip.ui +++ b/zeiterfassung/strips/bookingendstrip.ui @@ -19,7 +19,7 @@ QFrame::Raised - + 10 @@ -73,6 +73,16 @@ + + + + background-color: rgba(0,0,0,30); + + + 9:99h + + + diff --git a/zeiterfassung/translations/zeiterfassung_de.ts b/zeiterfassung/translations/zeiterfassung_de.ts index 777228f..a5213e5 100644 --- a/zeiterfassung/translations/zeiterfassung_de.ts +++ b/zeiterfassung/translations/zeiterfassung_de.ts @@ -20,113 +20,113 @@ 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 index 0229025..f881ea3 100644 --- a/zeiterfassung/translations/zeiterfassung_en.ts +++ b/zeiterfassung/translations/zeiterfassung_en.ts @@ -20,113 +20,113 @@ 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 deleted file mode 100755 index b3c1ca6..0000000 --- a/zeiterfassung/unix/start.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -cd "${0%/*}" -LD_LIBRARY_PATH=../lib ./zeiterfassung diff --git a/zeiterfassung/unix/zeiterfassung.sh b/zeiterfassung/unix/zeiterfassung.sh new file mode 100755 index 0000000..29ab530 --- /dev/null +++ b/zeiterfassung/unix/zeiterfassung.sh @@ -0,0 +1,3 @@ +#!/bin/bash +cd "${0%/*}" +LD_LIBRARY_PATH=. ./zeiterfassung diff --git a/zeiterfassung/zeiterfassung.pro b/zeiterfassung/zeiterfassung.pro index 23b76b5..506e989 100755 --- a/zeiterfassung/zeiterfassung.pro +++ b/zeiterfassung/zeiterfassung.pro @@ -6,12 +6,14 @@ TEMPLATE = app CONFIG += c++14 CONFIG -= app_bundle -DESTDIR = $${OUT_PWD}/../bin +PROJECT_ROOT = .. -LIBS += -L$$OUT_PWD/../lib -lzeiterfassunglib +DESTDIR = $${OUT_PWD}/$${PROJECT_ROOT}/bin -INCLUDEPATH += $$PWD/../zeiterfassunglib -DEPENDPATH += $$PWD/../zeiterfassunglib +LIBS += -L$${OUT_PWD}/$${PROJECT_ROOT}/bin -lzeiterfassungcorelib -lzeiterfassungguilib + +INCLUDEPATH += $$PWD/$${PROJECT_ROOT}/zeiterfassungcorelib $$PWD/$${PROJECT_ROOT}/zeiterfassungguilib +DEPENDPATH += $$PWD/$${PROJECT_ROOT}/zeiterfassungcorelib $$PWD/$${PROJECT_ROOT}/zeiterfassungguilib DEFINES += QT_DEPRECATED_WARNINGS QT_DISABLE_DEPRECATED_BEFORE=0x060000 QT_MESSAGELOGCONTEXT @@ -25,13 +27,12 @@ FORMS += strips/bookingstartstrip.ui \ strips/bookingendstrip.ui \ strips/timeassignmentstrip.ui -RESOURCES += +RESOURCES += zeiterfassung_resources.qrc TRANSLATIONS += translations/zeiterfassung_en.ts \ translations/zeiterfassung_de.ts -include(../lrelease.pri) +include($${PROJECT_ROOT}/lrelease.pri) include(installs.pri) unix: include(installs_unix.pri) -win32: include(installs_win32.pri) diff --git a/zeiterfassung/zeiterfassung_resources.qrc b/zeiterfassung/zeiterfassung_resources.qrc new file mode 100644 index 0000000..e5e1897 --- /dev/null +++ b/zeiterfassung/zeiterfassung_resources.qrc @@ -0,0 +1,5 @@ + + + images/splash.png + + diff --git a/zeiterfassunglib/cpp14polyfills.h b/zeiterfassungcorelib/cpp14polyfills.h similarity index 85% rename from zeiterfassunglib/cpp14polyfills.h rename to zeiterfassungcorelib/cpp14polyfills.h index 1c482e9..2fcbe50 100644 --- a/zeiterfassunglib/cpp14polyfills.h +++ b/zeiterfassungcorelib/cpp14polyfills.h @@ -1,8 +1,4 @@ -#ifndef CPP14POLYFILLS_H -#define CPP14POLYFILLS_H - -#ifndef CPP14POLYFILLS_INCLUDED -#define CPP14POLYFILLS_INCLUDED +#pragma once #if __cplusplus < 201402L @@ -45,7 +41,3 @@ namespace std { } #endif // __cplusplus < 201402L - -#endif // CPP14POLYFILLS_INCLUDED - -#endif // CPP14POLYFILLS_H diff --git a/zeiterfassungcorelib/replies/createbookingreply.cpp b/zeiterfassungcorelib/replies/createbookingreply.cpp new file mode 100644 index 0000000..0b73d39 --- /dev/null +++ b/zeiterfassungcorelib/replies/createbookingreply.cpp @@ -0,0 +1,26 @@ +#include "createbookingreply.h" + +CreateBookingReply::CreateBookingReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung) : + ZeiterfassungReply(zeiterfassung), + m_reply(std::move(reply)) +{ + connect(m_reply.get(), &QNetworkReply::finished, this, &CreateBookingReply::requestFinished); +} + +void CreateBookingReply::requestFinished() +{ + if(m_reply->error() != QNetworkReply::NoError) + { + setSuccess(false); + setMessage(tr("Request error occured: %0").arg(m_reply->errorString())); + goto end; + } + + // empty response so nothing to check + setSuccess(true); + + end: + m_reply = Q_NULLPTR; + + Q_EMIT finished(); +} diff --git a/zeiterfassungcorelib/replies/createbookingreply.h b/zeiterfassungcorelib/replies/createbookingreply.h new file mode 100644 index 0000000..263f099 --- /dev/null +++ b/zeiterfassungcorelib/replies/createbookingreply.h @@ -0,0 +1,22 @@ +#pragma once + +#include + +#include + +#include "zeiterfassungcorelib_global.h" +#include "zeiterfassungreply.h" + +class ZEITERFASSUNGCORELIBSHARED_EXPORT CreateBookingReply : public ZeiterfassungReply +{ + Q_OBJECT + +public: + explicit CreateBookingReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung); + +private Q_SLOTS: + void requestFinished(); + +private: + std::unique_ptr m_reply; +}; diff --git a/zeiterfassunglib/replies/createtimeassignmentreply.cpp b/zeiterfassungcorelib/replies/createtimeassignmentreply.cpp similarity index 99% rename from zeiterfassunglib/replies/createtimeassignmentreply.cpp rename to zeiterfassungcorelib/replies/createtimeassignmentreply.cpp index 51c3a62..68c6e7f 100644 --- a/zeiterfassunglib/replies/createtimeassignmentreply.cpp +++ b/zeiterfassungcorelib/replies/createtimeassignmentreply.cpp @@ -23,7 +23,7 @@ void CreateTimeAssignmentReply::requestFinished() if(m_reply->error() != QNetworkReply::NoError) { setSuccess(false); - setMessage(tr("Request error occured: %0").arg(m_reply->error())); + setMessage(tr("Request error occured: %0").arg(m_reply->errorString())); goto end; } diff --git a/zeiterfassungcorelib/replies/createtimeassignmentreply.h b/zeiterfassungcorelib/replies/createtimeassignmentreply.h new file mode 100644 index 0000000..f81e1be --- /dev/null +++ b/zeiterfassungcorelib/replies/createtimeassignmentreply.h @@ -0,0 +1,25 @@ +#pragma once + +#include + +#include + +#include "zeiterfassungcorelib_global.h" +#include "zeiterfassungreply.h" + +class ZEITERFASSUNGCORELIBSHARED_EXPORT CreateTimeAssignmentReply : public ZeiterfassungReply +{ + Q_OBJECT + +public: + explicit CreateTimeAssignmentReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung); + + int timeAssignmentId() const; + +private Q_SLOTS: + void requestFinished(); + +private: + std::unique_ptr m_reply; + int m_timeAssignmentId; +}; diff --git a/zeiterfassunglib/replies/deletebookingreply.cpp b/zeiterfassungcorelib/replies/deletebookingreply.cpp similarity index 97% rename from zeiterfassunglib/replies/deletebookingreply.cpp rename to zeiterfassungcorelib/replies/deletebookingreply.cpp index 5549f32..f16916c 100644 --- a/zeiterfassunglib/replies/deletebookingreply.cpp +++ b/zeiterfassungcorelib/replies/deletebookingreply.cpp @@ -12,7 +12,7 @@ void DeleteBookingReply::requestFinished() if(m_reply->error() != QNetworkReply::NoError) { setSuccess(false); - setMessage(tr("Request error occured: %0").arg(m_reply->error())); + setMessage(tr("Request error occured: %0").arg(m_reply->errorString())); goto end; } diff --git a/zeiterfassungcorelib/replies/deletebookingreply.h b/zeiterfassungcorelib/replies/deletebookingreply.h new file mode 100644 index 0000000..6807669 --- /dev/null +++ b/zeiterfassungcorelib/replies/deletebookingreply.h @@ -0,0 +1,22 @@ +#pragma once + +#include + +#include + +#include "zeiterfassungcorelib_global.h" +#include "zeiterfassungreply.h" + +class ZEITERFASSUNGCORELIBSHARED_EXPORT DeleteBookingReply : public ZeiterfassungReply +{ + Q_OBJECT + +public: + explicit DeleteBookingReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung); + +private Q_SLOTS: + void requestFinished(); + +private: + std::unique_ptr m_reply; +}; diff --git a/zeiterfassunglib/replies/deletetimeassignmentreply.cpp b/zeiterfassungcorelib/replies/deletetimeassignmentreply.cpp similarity index 97% rename from zeiterfassunglib/replies/deletetimeassignmentreply.cpp rename to zeiterfassungcorelib/replies/deletetimeassignmentreply.cpp index 5c3ea75..2b54ddc 100644 --- a/zeiterfassunglib/replies/deletetimeassignmentreply.cpp +++ b/zeiterfassungcorelib/replies/deletetimeassignmentreply.cpp @@ -12,7 +12,7 @@ void DeleteTimeAssignmentReply::requestFinished() if(m_reply->error() != QNetworkReply::NoError) { setSuccess(false); - setMessage(tr("Request error occured: %0").arg(m_reply->error())); + setMessage(tr("Request error occured: %0").arg(m_reply->errorString())); goto end; } diff --git a/zeiterfassungcorelib/replies/deletetimeassignmentreply.h b/zeiterfassungcorelib/replies/deletetimeassignmentreply.h new file mode 100644 index 0000000..9353ba6 --- /dev/null +++ b/zeiterfassungcorelib/replies/deletetimeassignmentreply.h @@ -0,0 +1,22 @@ +#pragma once + +#include + +#include + +#include "zeiterfassungcorelib_global.h" +#include "zeiterfassungreply.h" + +class ZEITERFASSUNGCORELIBSHARED_EXPORT DeleteTimeAssignmentReply : public ZeiterfassungReply +{ + Q_OBJECT + +public: + explicit DeleteTimeAssignmentReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung); + +private Q_SLOTS: + void requestFinished(); + +private: + std::unique_ptr m_reply; +}; diff --git a/zeiterfassungcorelib/replies/getabsencesreply.cpp b/zeiterfassungcorelib/replies/getabsencesreply.cpp new file mode 100644 index 0000000..107adc6 --- /dev/null +++ b/zeiterfassungcorelib/replies/getabsencesreply.cpp @@ -0,0 +1,77 @@ +#include "getabsencesreply.h" + +#include +#include +#include +#include +#include +#include + +#include "zeiterfassungapi.h" + +GetAbsencesReply::GetAbsencesReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung) : + ZeiterfassungReply(zeiterfassung), + m_reply(std::move(reply)) +{ + connect(m_reply.get(), &QNetworkReply::finished, this, &GetAbsencesReply::requestFinished); +} + +const QVector &GetAbsencesReply::absences() const +{ + return m_absences; +} + +void GetAbsencesReply::requestFinished() +{ + if(m_reply->error() != QNetworkReply::NoError) + { + setSuccess(false); + setMessage(tr("Request error occured: %0").arg(m_reply->errorString())); + goto end; + } + + { + QJsonParseError error; + QJsonDocument document = QJsonDocument::fromJson(m_reply->readAll(), &error); + if(error.error != QJsonParseError::NoError) + { + setSuccess(false); + setMessage(tr("Parsing JSON failed: %0").arg(error.errorString())); + goto end; + } + + if(!document.isArray()) + { + setSuccess(false); + setMessage(tr("JSON document is not an array!")); + goto end; + } + + auto arr = document.array(); + + setSuccess(true); + m_absences.clear(); + m_absences.reserve(arr.count()); + for(const auto &val : arr) + { + auto obj = val.toObject(); + + m_absences.append({ + obj.value(QStringLiteral("altRepresentative")).toInt(), + obj.value(QStringLiteral("compositeId")).toString(), + QDate::fromString(QString::number(obj.value(QStringLiteral("end")).toInt()), QStringLiteral("yyyyMMdd")), + obj.value(QStringLiteral("hourCategory")).toString(), + obj.value(QStringLiteral("openMarking")).toString(), + obj.value(QStringLiteral("persNr")).toInt(), + obj.value(QStringLiteral("representative")).toInt(), + QDate::fromString(QString::number(obj.value(QStringLiteral("start")).toInt()), QStringLiteral("yyyyMMdd")), + obj.value(QStringLiteral("text")).toString() + }); + } + } + + end: + m_reply = Q_NULLPTR; + + Q_EMIT finished(); +} diff --git a/zeiterfassungcorelib/replies/getabsencesreply.h b/zeiterfassungcorelib/replies/getabsencesreply.h new file mode 100644 index 0000000..1a8cbf4 --- /dev/null +++ b/zeiterfassungcorelib/replies/getabsencesreply.h @@ -0,0 +1,43 @@ +#pragma once + +#include + +#include +#include +#include +#include + +#include "zeiterfassungcorelib_global.h" +#include "zeiterfassungreply.h" + +class ZeiterfassungApi; + +class ZEITERFASSUNGCORELIBSHARED_EXPORT GetAbsencesReply : public ZeiterfassungReply +{ + Q_OBJECT + +public: + explicit GetAbsencesReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung); + + struct Absence + { + int altRepresentative; + QString compositeId; + QDate end; + QString hourCategory; + QString openMarking; + int persNr; + int representative; + QDate start; + QString text; + }; + + const QVector &absences() const; + +private Q_SLOTS: + void requestFinished(); + +private: + std::unique_ptr m_reply; + QVector m_absences; +}; diff --git a/zeiterfassunglib/replies/getbookingsreply.cpp b/zeiterfassungcorelib/replies/getbookingsreply.cpp similarity index 99% rename from zeiterfassunglib/replies/getbookingsreply.cpp rename to zeiterfassungcorelib/replies/getbookingsreply.cpp index b7941fa..b286cae 100644 --- a/zeiterfassunglib/replies/getbookingsreply.cpp +++ b/zeiterfassungcorelib/replies/getbookingsreply.cpp @@ -25,7 +25,7 @@ void GetBookingsReply::requestFinished() if(m_reply->error() != QNetworkReply::NoError) { setSuccess(false); - setMessage(tr("Request error occured: %0").arg(m_reply->error())); + setMessage(tr("Request error occured: %0").arg(m_reply->errorString())); goto end; } diff --git a/zeiterfassunglib/replies/getbookingsreply.h b/zeiterfassungcorelib/replies/getbookingsreply.h similarity index 62% rename from zeiterfassunglib/replies/getbookingsreply.h rename to zeiterfassungcorelib/replies/getbookingsreply.h index 59344b9..e6f240e 100644 --- a/zeiterfassunglib/replies/getbookingsreply.h +++ b/zeiterfassungcorelib/replies/getbookingsreply.h @@ -1,22 +1,22 @@ -#ifndef GETBOOKINGSREPLY_H -#define GETBOOKINGSREPLY_H +#pragma once #include +#include #include #include -#include "zeiterfassunglib_global.h" +#include "zeiterfassungcorelib_global.h" #include "zeiterfassungreply.h" class ZeiterfassungApi; -class ZEITERFASSUNGLIBSHARED_EXPORT GetBookingsReply : public ZeiterfassungReply +class ZEITERFASSUNGCORELIBSHARED_EXPORT GetBookingsReply : public ZeiterfassungReply { Q_OBJECT public: - GetBookingsReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung); + explicit GetBookingsReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung); struct Booking { @@ -37,5 +37,3 @@ private: std::unique_ptr m_reply; QVector m_bookings; }; - -#endif // GETBOOKINGSREPLY_H diff --git a/zeiterfassunglib/replies/getpresencestatusreply.cpp b/zeiterfassungcorelib/replies/getpresencestatusreply.cpp similarity index 99% rename from zeiterfassunglib/replies/getpresencestatusreply.cpp rename to zeiterfassungcorelib/replies/getpresencestatusreply.cpp index 5ee41db..8dca891 100644 --- a/zeiterfassunglib/replies/getpresencestatusreply.cpp +++ b/zeiterfassungcorelib/replies/getpresencestatusreply.cpp @@ -25,7 +25,7 @@ void GetPresenceStatusReply::requestFinished() if(m_reply->error() != QNetworkReply::NoError) { setSuccess(false); - setMessage(tr("Request error occured: %0").arg(m_reply->error())); + setMessage(tr("Request error occured: %0").arg(m_reply->errorString())); goto end; } diff --git a/zeiterfassunglib/replies/getpresencestatusreply.h b/zeiterfassungcorelib/replies/getpresencestatusreply.h similarity index 72% rename from zeiterfassunglib/replies/getpresencestatusreply.h rename to zeiterfassungcorelib/replies/getpresencestatusreply.h index e220379..91e86b0 100644 --- a/zeiterfassunglib/replies/getpresencestatusreply.h +++ b/zeiterfassungcorelib/replies/getpresencestatusreply.h @@ -1,16 +1,15 @@ -#ifndef GETPRESENCESTATUSREPLY_H -#define GETPRESENCESTATUSREPLY_H +#pragma once #include #include -#include "zeiterfassunglib_global.h" +#include "zeiterfassungcorelib_global.h" #include "zeiterfassungreply.h" class ZeiterfassungApi; -class ZEITERFASSUNGLIBSHARED_EXPORT GetPresenceStatusReply : public ZeiterfassungReply +class ZEITERFASSUNGCORELIBSHARED_EXPORT GetPresenceStatusReply : public ZeiterfassungReply { Q_OBJECT @@ -34,5 +33,3 @@ private: std::unique_ptr m_reply; QVector m_presenceStatuses; }; - -#endif // GETPRESENCESTATUSREPLY_H diff --git a/zeiterfassunglib/replies/getprojectsreply.cpp b/zeiterfassungcorelib/replies/getprojectsreply.cpp similarity index 99% rename from zeiterfassunglib/replies/getprojectsreply.cpp rename to zeiterfassungcorelib/replies/getprojectsreply.cpp index 1800d10..58b47d4 100644 --- a/zeiterfassunglib/replies/getprojectsreply.cpp +++ b/zeiterfassungcorelib/replies/getprojectsreply.cpp @@ -25,7 +25,7 @@ void GetProjectsReply::requestFinished() if(m_reply->error() != QNetworkReply::NoError) { setSuccess(false); - setMessage(tr("Request error occured: %0").arg(m_reply->error())); + setMessage(tr("Request error occured: %0").arg(m_reply->errorString())); goto end; } diff --git a/zeiterfassunglib/replies/getprojectsreply.h b/zeiterfassungcorelib/replies/getprojectsreply.h similarity index 57% rename from zeiterfassunglib/replies/getprojectsreply.h rename to zeiterfassungcorelib/replies/getprojectsreply.h index 576728a..293b592 100644 --- a/zeiterfassunglib/replies/getprojectsreply.h +++ b/zeiterfassungcorelib/replies/getprojectsreply.h @@ -1,22 +1,21 @@ -#ifndef GETPROJECTSREPLY_H -#define GETPROJECTSREPLY_H +#pragma once #include #include #include -#include "zeiterfassunglib_global.h" +#include "zeiterfassungcorelib_global.h" #include "zeiterfassungreply.h" class ZeiterfassungApi; -class ZEITERFASSUNGLIBSHARED_EXPORT GetProjectsReply : public ZeiterfassungReply +class ZEITERFASSUNGCORELIBSHARED_EXPORT GetProjectsReply : public ZeiterfassungReply { Q_OBJECT public: - GetProjectsReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung); + explicit GetProjectsReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung); struct Project { @@ -33,5 +32,3 @@ private: std::unique_ptr m_reply; QVector m_projects; }; - -#endif // GETPROJECTSREPLY_H diff --git a/zeiterfassunglib/replies/getreportreply.cpp b/zeiterfassungcorelib/replies/getreportreply.cpp similarity index 97% rename from zeiterfassunglib/replies/getreportreply.cpp rename to zeiterfassungcorelib/replies/getreportreply.cpp index b63f91f..41e004b 100644 --- a/zeiterfassunglib/replies/getreportreply.cpp +++ b/zeiterfassungcorelib/replies/getreportreply.cpp @@ -19,7 +19,7 @@ void GetReportReply::request0Finished() if(m_reply->error() != QNetworkReply::NoError) { setSuccess(false); - setMessage(tr("Request error occured: %0").arg(m_reply->error())); + setMessage(tr("Request error occured: %0").arg(m_reply->errorString())); m_reply = Q_NULLPTR; Q_EMIT finished(); return; @@ -37,7 +37,7 @@ void GetReportReply::request1Finished() if(m_reply->error() != QNetworkReply::NoError) { setSuccess(false); - setMessage(tr("Request error occured: %0").arg(m_reply->error())); + setMessage(tr("Request error occured: %0").arg(m_reply->errorString())); goto end; } diff --git a/zeiterfassunglib/replies/getreportreply.h b/zeiterfassungcorelib/replies/getreportreply.h similarity index 53% rename from zeiterfassunglib/replies/getreportreply.h rename to zeiterfassungcorelib/replies/getreportreply.h index 1590681..6b0bc75 100644 --- a/zeiterfassunglib/replies/getreportreply.h +++ b/zeiterfassungcorelib/replies/getreportreply.h @@ -1,20 +1,19 @@ -#ifndef GETREPORTREPLY_H -#define GETREPORTREPLY_H +#pragma once #include #include #include -#include "zeiterfassunglib_global.h" +#include "zeiterfassungcorelib_global.h" #include "zeiterfassungreply.h" -class ZEITERFASSUNGLIBSHARED_EXPORT GetReportReply : public ZeiterfassungReply +class ZEITERFASSUNGCORELIBSHARED_EXPORT GetReportReply : public ZeiterfassungReply { Q_OBJECT public: - GetReportReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung); + explicit GetReportReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung); const QByteArray &content() const; @@ -26,5 +25,3 @@ private: std::unique_ptr m_reply; QByteArray m_content; }; - -#endif // GETREPORTREPLY_H diff --git a/zeiterfassunglib/replies/gettimeassignmentsreply.cpp b/zeiterfassungcorelib/replies/gettimeassignmentsreply.cpp similarity index 99% rename from zeiterfassunglib/replies/gettimeassignmentsreply.cpp rename to zeiterfassungcorelib/replies/gettimeassignmentsreply.cpp index a4b62ef..2f13cd1 100644 --- a/zeiterfassunglib/replies/gettimeassignmentsreply.cpp +++ b/zeiterfassungcorelib/replies/gettimeassignmentsreply.cpp @@ -26,7 +26,7 @@ void GetTimeAssignmentsReply::requestFinished() if(m_reply->error() != QNetworkReply::NoError) { setSuccess(false); - setMessage(tr("Request error occured: %0").arg(m_reply->error())); + setMessage(tr("Request error occured: %0").arg(m_reply->errorString())); goto end; } diff --git a/zeiterfassunglib/replies/gettimeassignmentsreply.h b/zeiterfassungcorelib/replies/gettimeassignmentsreply.h similarity index 63% rename from zeiterfassunglib/replies/gettimeassignmentsreply.h rename to zeiterfassungcorelib/replies/gettimeassignmentsreply.h index a335a70..bba728b 100644 --- a/zeiterfassunglib/replies/gettimeassignmentsreply.h +++ b/zeiterfassungcorelib/replies/gettimeassignmentsreply.h @@ -1,22 +1,23 @@ -#ifndef GETTIMEASSIGNMENTSREPLY_H -#define GETTIMEASSIGNMENTSREPLY_H +#pragma once #include +#include +#include #include #include -#include "zeiterfassunglib_global.h" +#include "zeiterfassungcorelib_global.h" #include "zeiterfassungreply.h" class ZeiterfassungApi; -class ZEITERFASSUNGLIBSHARED_EXPORT GetTimeAssignmentsReply : public ZeiterfassungReply +class ZEITERFASSUNGCORELIBSHARED_EXPORT GetTimeAssignmentsReply : public ZeiterfassungReply { Q_OBJECT public: - GetTimeAssignmentsReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung); + explicit GetTimeAssignmentsReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung); struct TimeAssignment { @@ -39,5 +40,3 @@ private: std::unique_ptr m_reply; QVector m_timeAssignments; }; - -#endif // GETTIMEASSIGNMENTSREPLY_H diff --git a/zeiterfassungcorelib/replies/getuserinforeply.cpp b/zeiterfassungcorelib/replies/getuserinforeply.cpp new file mode 100644 index 0000000..e07dc18 --- /dev/null +++ b/zeiterfassungcorelib/replies/getuserinforeply.cpp @@ -0,0 +1,170 @@ +#include "getuserinforeply.h" + +#include +#include +#include +#include +#include + +#include "zeiterfassungapi.h" + +GetUserInfoReply::GetUserInfoReply(std::unique_ptr &&reply0, std::unique_ptr &&reply1, + ZeiterfassungApi *zeiterfassung) : + ZeiterfassungReply(zeiterfassung), + m_reply0(std::move(reply0)), + m_reply1(std::move(reply1)) +{ + Q_ASSERT(m_reply0 != Q_NULLPTR); + Q_ASSERT(m_reply1 != Q_NULLPTR); + + connect(m_reply0.get(), &QNetworkReply::finished, this, &GetUserInfoReply::request0Finished); + connect(m_reply1.get(), &QNetworkReply::finished, this, &GetUserInfoReply::request1Finished); +} + +const GetUserInfoReply::UserInfo &GetUserInfoReply::userInfo() const +{ + return m_userInfo; +} + +void GetUserInfoReply::request0Finished() +{ + if(m_reply0->error() != QNetworkReply::NoError) + { + setSuccess(false); + setMessage(tr("Request 0 error occured: %0").arg(m_reply0->errorString())); + m_reply1 = Q_NULLPTR; + goto end; + } + + { + QJsonParseError error; + auto document = QJsonDocument::fromJson(m_reply0->readAll(), &error); + if(error.error != QJsonParseError::NoError) + { + setSuccess(false); + setMessage(tr("Parsing JSON 0 failed: %0").arg(error.errorString())); + m_reply1 = Q_NULLPTR; + goto end; + } + + if(!document.isObject()) + { + setSuccess(false); + setMessage(tr("JSON document 0 is not an object!")); + m_reply1 = Q_NULLPTR; + goto end; + } + + auto rootObj = document.object(); + + if(!rootObj.contains(QStringLiteral("evoAppsUser"))) + { + setSuccess(false); + setMessage(tr("JSON 0 does not contain evoAppsUser!")); + m_reply1 = Q_NULLPTR; + goto end; + } + + auto evoAppsUser = rootObj.value(QStringLiteral("evoAppsUser")); + + if(!evoAppsUser.isObject()) + { + setSuccess(false); + setMessage(tr("evoAppsUser is not an object!")); + m_reply1 = Q_NULLPTR; + goto end; + } + + auto evoAppsUserObj = evoAppsUser.toObject(); + + if(!m_reply1) + setSuccess(true); + + m_userInfo.userId = evoAppsUserObj.value(QStringLiteral("persNr")).toInt(); + m_userInfo.email = evoAppsUserObj.value(QStringLiteral("email")).toString(); + m_userInfo.longUsername = evoAppsUserObj.value(QStringLiteral("longUsername")).toString(); + m_userInfo.text = evoAppsUserObj.value(QStringLiteral("text")).toString(); + m_userInfo.username = evoAppsUserObj.value(QStringLiteral("username")).toString(); + } + + end: + m_reply0 = Q_NULLPTR; + + if(!m_reply1) + Q_EMIT finished(); +} + +void GetUserInfoReply::request1Finished() +{ + if(m_reply1->error() != QNetworkReply::NoError) + { + setSuccess(false); + setMessage(tr("Request 1 error occured: %0").arg(m_reply0->errorString())); + m_reply0 = Q_NULLPTR; + goto end; + } + + { + QJsonParseError error; + auto document = QJsonDocument::fromJson(m_reply1->readAll(), &error); + if(error.error != QJsonParseError::NoError) + { + setSuccess(false); + setMessage(tr("Parsing JSON 1 failed: %0").arg(error.errorString())); + m_reply0 = Q_NULLPTR; + goto end; + } + + if(!document.isArray()) + { + setSuccess(false); + setMessage(tr("JSON document 1 is not an array!")); + m_reply0 = Q_NULLPTR; + goto end; + } + + auto arr = document.array(); + + if(arr.isEmpty()) + { + setSuccess(false); + setMessage(tr("JSON array 1 is empty!")); + m_reply0 = Q_NULLPTR; + goto end; + } + + auto first = arr.first(); + + if(!first.isObject()) + { + setSuccess(false); + setMessage(tr("JSON array value is not an object!")); + m_reply0 = Q_NULLPTR; + goto end; + } + + auto obj = first.toObject(); + + if(!m_reply0) + setSuccess(true); + + m_userInfo.street = obj.value(QStringLiteral("gemeinde")).toString(); + m_userInfo.city = obj.value(QStringLiteral("ort")).toString(); + m_userInfo.employedSince = QDate::fromString(QString::number(obj.value(QStringLiteral("angFrom")).toInt()), QStringLiteral("yyyyMMdd")); + m_userInfo.employedTill = QDate::fromString(QString::number(obj.value(QStringLiteral("angTill")).toInt()), QStringLiteral("yyyyMMdd")); + m_userInfo.placeOfBirth = obj.value(QStringLiteral("gebOrt")).toString(); + m_userInfo.zipcode = obj.value(QStringLiteral("plz")).toString(); + m_userInfo.religion = obj.value(QStringLiteral("religion")).toString(); + m_userInfo.department = obj.value(QStringLiteral("bereich")).toString(); + m_userInfo.verwendgr = obj.value(QStringLiteral("verwendgr")).toString(); + m_userInfo.taetig = obj.value(QStringLiteral("taetig")).toString(); + m_userInfo.arbverh = obj.value(QStringLiteral("arbverh")).toString(); + m_userInfo.betriebsnr = obj.value(QStringLiteral("betriebsnr")).toString(); + } + + end: + m_reply1 = Q_NULLPTR; + + if(!m_reply0) + Q_EMIT finished(); +} diff --git a/zeiterfassungcorelib/replies/getuserinforeply.h b/zeiterfassungcorelib/replies/getuserinforeply.h new file mode 100644 index 0000000..fef7b52 --- /dev/null +++ b/zeiterfassungcorelib/replies/getuserinforeply.h @@ -0,0 +1,53 @@ +#pragma once + +#include + +#include +#include +#include + +#include "zeiterfassungcorelib_global.h" +#include "zeiterfassungreply.h" + +class ZeiterfassungApi; + +class ZEITERFASSUNGCORELIBSHARED_EXPORT GetUserInfoReply : public ZeiterfassungReply +{ + Q_OBJECT + +public: + explicit GetUserInfoReply(std::unique_ptr &&reply0, std::unique_ptr &&reply1, + ZeiterfassungApi *zeiterfassung); + + struct UserInfo + { + int userId; + QString email; + QString longUsername; + QString text; + QString username; + QString street; + QString city; + QDate employedSince; + QDate employedTill; + QString placeOfBirth; + QString zipcode; + QString religion; + QString department; + QString verwendgr; + QString taetig; + QString arbverh; + QString betriebsnr; + }; + + const UserInfo &userInfo() const; + +private Q_SLOTS: + void request0Finished(); + void request1Finished(); + +private: + std::unique_ptr m_reply0; + std::unique_ptr m_reply1; + UserInfo m_userInfo; +}; diff --git a/zeiterfassunglib/replies/loginpagereply.cpp b/zeiterfassungcorelib/replies/loginpagereply.cpp similarity index 98% rename from zeiterfassunglib/replies/loginpagereply.cpp rename to zeiterfassungcorelib/replies/loginpagereply.cpp index f05f60e..1157581 100644 --- a/zeiterfassunglib/replies/loginpagereply.cpp +++ b/zeiterfassungcorelib/replies/loginpagereply.cpp @@ -14,7 +14,7 @@ void LoginPageReply::requestFinished() if(m_reply->error() != QNetworkReply::NoError) { setSuccess(false); - setMessage(tr("Request error occured: %0").arg(m_reply->error())); + setMessage(tr("Request error occured: %0").arg(m_reply->errorString())); goto end; } diff --git a/zeiterfassungcorelib/replies/loginpagereply.h b/zeiterfassungcorelib/replies/loginpagereply.h new file mode 100644 index 0000000..d050555 --- /dev/null +++ b/zeiterfassungcorelib/replies/loginpagereply.h @@ -0,0 +1,22 @@ +#pragma once + +#include + +#include + +#include "zeiterfassungcorelib_global.h" +#include "zeiterfassungreply.h" + +class ZEITERFASSUNGCORELIBSHARED_EXPORT LoginPageReply : public ZeiterfassungReply +{ + Q_OBJECT + +public: + explicit LoginPageReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung); + +private Q_SLOTS: + void requestFinished(); + +private: + std::unique_ptr m_reply; +}; diff --git a/zeiterfassunglib/replies/loginreply.cpp b/zeiterfassungcorelib/replies/loginreply.cpp similarity index 98% rename from zeiterfassunglib/replies/loginreply.cpp rename to zeiterfassungcorelib/replies/loginreply.cpp index a81971b..abc64ca 100644 --- a/zeiterfassunglib/replies/loginreply.cpp +++ b/zeiterfassungcorelib/replies/loginreply.cpp @@ -14,7 +14,7 @@ void LoginReply::requestFinished() if(m_reply->error() != QNetworkReply::NoError) { setSuccess(false); - setMessage(tr("Request error occured: %0").arg(m_reply->error())); + setMessage(tr("Request error occured: %0").arg(m_reply->errorString())); goto end; } diff --git a/zeiterfassungcorelib/replies/loginreply.h b/zeiterfassungcorelib/replies/loginreply.h new file mode 100644 index 0000000..a0a21e2 --- /dev/null +++ b/zeiterfassungcorelib/replies/loginreply.h @@ -0,0 +1,22 @@ +#pragma once + +#include + +#include + +#include "zeiterfassungcorelib_global.h" +#include "zeiterfassungreply.h" + +class ZEITERFASSUNGCORELIBSHARED_EXPORT LoginReply : public ZeiterfassungReply +{ + Q_OBJECT + +public: + explicit LoginReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung); + +private Q_SLOTS: + void requestFinished(); + +private: + std::unique_ptr m_reply; +}; diff --git a/zeiterfassunglib/replies/updatebookingreply.cpp b/zeiterfassungcorelib/replies/updatebookingreply.cpp similarity index 98% rename from zeiterfassunglib/replies/updatebookingreply.cpp rename to zeiterfassungcorelib/replies/updatebookingreply.cpp index 8feb6c9..5386d22 100644 --- a/zeiterfassunglib/replies/updatebookingreply.cpp +++ b/zeiterfassungcorelib/replies/updatebookingreply.cpp @@ -18,7 +18,7 @@ void UpdateBookingReply::requestFinished() if(m_reply->error() != QNetworkReply::NoError) { setSuccess(false); - setMessage(tr("Request error occured: %0").arg(m_reply->error())); + setMessage(tr("Request error occured: %0").arg(m_reply->errorString())); goto end; } diff --git a/zeiterfassungcorelib/replies/updatebookingreply.h b/zeiterfassungcorelib/replies/updatebookingreply.h new file mode 100644 index 0000000..8c37de3 --- /dev/null +++ b/zeiterfassungcorelib/replies/updatebookingreply.h @@ -0,0 +1,23 @@ +#pragma once + +#include + +#include + +#include "zeiterfassungcorelib_global.h" +#include "zeiterfassungreply.h" + +class ZEITERFASSUNGCORELIBSHARED_EXPORT UpdateBookingReply : public ZeiterfassungReply +{ + Q_OBJECT + +public: + explicit UpdateBookingReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung); + +private Q_SLOTS: + void requestFinished(); + +private: + std::unique_ptr m_reply; + int m_bookingId; +}; diff --git a/zeiterfassunglib/replies/updatetimeassignmentreply.cpp b/zeiterfassungcorelib/replies/updatetimeassignmentreply.cpp similarity index 99% rename from zeiterfassunglib/replies/updatetimeassignmentreply.cpp rename to zeiterfassungcorelib/replies/updatetimeassignmentreply.cpp index 6a08740..100981d 100644 --- a/zeiterfassunglib/replies/updatetimeassignmentreply.cpp +++ b/zeiterfassungcorelib/replies/updatetimeassignmentreply.cpp @@ -23,7 +23,7 @@ void UpdateTimeAssignmentReply::requestFinished() if(m_reply->error() != QNetworkReply::NoError) { setSuccess(false); - setMessage(tr("Request error occured: %0").arg(m_reply->error())); + setMessage(tr("Request error occured: %0").arg(m_reply->errorString())); goto end; } diff --git a/zeiterfassungcorelib/replies/updatetimeassignmentreply.h b/zeiterfassungcorelib/replies/updatetimeassignmentreply.h new file mode 100644 index 0000000..5dd3d32 --- /dev/null +++ b/zeiterfassungcorelib/replies/updatetimeassignmentreply.h @@ -0,0 +1,25 @@ +#pragma once + +#include + +#include + +#include "zeiterfassungcorelib_global.h" +#include "zeiterfassungreply.h" + +class ZEITERFASSUNGCORELIBSHARED_EXPORT UpdateTimeAssignmentReply : public ZeiterfassungReply +{ + Q_OBJECT + +public: + explicit UpdateTimeAssignmentReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung); + + int timeAssignmentId() const; + +private Q_SLOTS: + void requestFinished(); + +private: + std::unique_ptr m_reply; + int m_timeAssignmentId; +}; diff --git a/zeiterfassunglib/replies/zeiterfassungreply.cpp b/zeiterfassungcorelib/replies/zeiterfassungreply.cpp similarity index 100% rename from zeiterfassunglib/replies/zeiterfassungreply.cpp rename to zeiterfassungcorelib/replies/zeiterfassungreply.cpp diff --git a/zeiterfassunglib/replies/zeiterfassungreply.h b/zeiterfassungcorelib/replies/zeiterfassungreply.h similarity index 71% rename from zeiterfassunglib/replies/zeiterfassungreply.h rename to zeiterfassungcorelib/replies/zeiterfassungreply.h index 05187e3..11b535d 100644 --- a/zeiterfassunglib/replies/zeiterfassungreply.h +++ b/zeiterfassungcorelib/replies/zeiterfassungreply.h @@ -1,13 +1,12 @@ -#ifndef ZEITERFASSUNGREPLY_H -#define ZEITERFASSUNGREPLY_H +#pragma once #include -#include "zeiterfassunglib_global.h" +#include "zeiterfassungcorelib_global.h" class ZeiterfassungApi; -class ZEITERFASSUNGLIBSHARED_EXPORT ZeiterfassungReply : public QObject +class ZEITERFASSUNGCORELIBSHARED_EXPORT ZeiterfassungReply : public QObject { Q_OBJECT @@ -32,5 +31,3 @@ private: bool m_success; QString m_message; }; - -#endif // ZEITERFASSUNGREPLY_H diff --git a/zeiterfassunglib/timeutils.cpp b/zeiterfassungcorelib/timeutils.cpp similarity index 100% rename from zeiterfassunglib/timeutils.cpp rename to zeiterfassungcorelib/timeutils.cpp diff --git a/zeiterfassungcorelib/timeutils.h b/zeiterfassungcorelib/timeutils.h new file mode 100644 index 0000000..3544299 --- /dev/null +++ b/zeiterfassungcorelib/timeutils.h @@ -0,0 +1,10 @@ +#pragma once + +#include + +#include "zeiterfassungcorelib_global.h" + +int ZEITERFASSUNGCORELIBSHARED_EXPORT timeToSeconds(const QTime &time); +QTime ZEITERFASSUNGCORELIBSHARED_EXPORT timeBetween(const QTime &l, const QTime &r); +QTime ZEITERFASSUNGCORELIBSHARED_EXPORT timeAdd(const QTime &l, const QTime &r); +QTime ZEITERFASSUNGCORELIBSHARED_EXPORT timeNormalise(const QTime &time); diff --git a/zeiterfassungcorelib/translations/zeiterfassungcorelib_de.ts b/zeiterfassungcorelib/translations/zeiterfassungcorelib_de.ts new file mode 100644 index 0000000..b624ce5 --- /dev/null +++ b/zeiterfassungcorelib/translations/zeiterfassungcorelib_de.ts @@ -0,0 +1,277 @@ + + + + + CreateBookingReply + + + Request error occured: %0 + + + + + CreateTimeAssignmentReply + + + Request error occured: %0 + + + + + Parsing JSON failed: %0 + + + + + JSON document is not an object! + + + + + JSON does not contain bookingNr! + + + + + DeleteBookingReply + + + Request error occured: %0 + + + + + DeleteTimeAssignmentReply + + + Request error occured: %0 + + + + + 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! + + + + + 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! + + + + + GetReportReply + + + + Request error occured: %0 + + + + + GetTimeAssignmentsReply + + + Request error occured: %0 + + + + + Parsing JSON failed: %0 + + + + + JSON document is not an array! + + + + + GetUserInfoReply + + + Request 0 error occured: %0 + + + + + Parsing JSON 0 failed: %0 + + + + + JSON document 0 is not an object! + + + + + JSON 0 does not contain evoAppsUser! + + + + + evoAppsUser is not an object! + + + + + Request 1 error occured: %0 + + + + + Parsing JSON 1 failed: %0 + + + + + JSON document 1 is not an array! + + + + + JSON array 1 is empty! + + + + + JSON array value is not an object! + + + + + LoginPageReply + + + Request error occured: %0 + + + + + Could not find necessary keywords in login page! + + + + + LoginReply + + + Request error occured: %0 + + + + + Response did not contain a Location header. + + + + + Authentication failure. Please check username and password. + + + + + An unknown authentication failure occured. Redirected to: %0 + + + + + UpdateBookingReply + + + Request error occured: %0 + + + + + Parsing JSON failed: %0 + + + + + JSON document is not an object! + + + + + JSON does not contain bookingNr! + + + + + UpdateTimeAssignmentReply + + + Request error occured: %0 + + + + + Parsing JSON failed: %0 + + + + + JSON document is not an object! + + + + + JSON does not contain bookingNr! + + + + diff --git a/zeiterfassungcorelib/translations/zeiterfassungcorelib_en.ts b/zeiterfassungcorelib/translations/zeiterfassungcorelib_en.ts new file mode 100644 index 0000000..747f7a7 --- /dev/null +++ b/zeiterfassungcorelib/translations/zeiterfassungcorelib_en.ts @@ -0,0 +1,277 @@ + + + + + CreateBookingReply + + + Request error occured: %0 + + + + + CreateTimeAssignmentReply + + + Request error occured: %0 + + + + + Parsing JSON failed: %0 + + + + + JSON document is not an object! + + + + + JSON does not contain bookingNr! + + + + + DeleteBookingReply + + + Request error occured: %0 + + + + + DeleteTimeAssignmentReply + + + Request error occured: %0 + + + + + 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! + + + + + 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! + + + + + GetReportReply + + + + Request error occured: %0 + + + + + GetTimeAssignmentsReply + + + Request error occured: %0 + + + + + Parsing JSON failed: %0 + + + + + JSON document is not an array! + + + + + GetUserInfoReply + + + Request 0 error occured: %0 + + + + + Parsing JSON 0 failed: %0 + + + + + JSON document 0 is not an object! + + + + + JSON 0 does not contain evoAppsUser! + + + + + evoAppsUser is not an object! + + + + + Request 1 error occured: %0 + + + + + Parsing JSON 1 failed: %0 + + + + + JSON document 1 is not an array! + + + + + JSON array 1 is empty! + + + + + JSON array value is not an object! + + + + + LoginPageReply + + + Request error occured: %0 + + + + + Could not find necessary keywords in login page! + + + + + LoginReply + + + Request error occured: %0 + + + + + Response did not contain a Location header. + + + + + Authentication failure. Please check username and password. + + + + + An unknown authentication failure occured. Redirected to: %0 + + + + + UpdateBookingReply + + + Request error occured: %0 + + + + + Parsing JSON failed: %0 + + + + + JSON document is not an object! + + + + + JSON does not contain bookingNr! + + + + + UpdateTimeAssignmentReply + + + Request error occured: %0 + + + + + Parsing JSON failed: %0 + + + + + JSON document is not an object! + + + + + JSON does not contain bookingNr! + + + + diff --git a/zeiterfassunglib/zeiterfassungapi.cpp b/zeiterfassungcorelib/zeiterfassungapi.cpp similarity index 80% rename from zeiterfassunglib/zeiterfassungapi.cpp rename to zeiterfassungcorelib/zeiterfassungapi.cpp index ffdfa24..16d0a02 100644 --- a/zeiterfassunglib/zeiterfassungapi.cpp +++ b/zeiterfassungcorelib/zeiterfassungapi.cpp @@ -9,20 +9,21 @@ #include #include -#include "replies/createbookingreply.h" -#include "replies/createtimeassignmentreply.h" -#include "replies/deletebookingreply.h" -#include "replies/deletetimeassignmentreply.h" -#include "replies/getreportreply.h" -#include "replies/getbookingsreply.h" -#include "replies/getpresencestatusreply.h" -#include "replies/getprojectsreply.h" -#include "replies/gettimeassignmentsreply.h" #include "replies/loginpagereply.h" #include "replies/loginreply.h" -#include "replies/updatebookingreply.h" -#include "replies/updatetimeassignmentreply.h" #include "replies/getuserinforeply.h" +#include "replies/getbookingsreply.h" +#include "replies/createbookingreply.h" +#include "replies/updatebookingreply.h" +#include "replies/deletebookingreply.h" +#include "replies/gettimeassignmentsreply.h" +#include "replies/createtimeassignmentreply.h" +#include "replies/updatetimeassignmentreply.h" +#include "replies/deletetimeassignmentreply.h" +#include "replies/getprojectsreply.h" +#include "replies/getreportreply.h" +#include "replies/getpresencestatusreply.h" +#include "replies/getabsencesreply.h" //add support for pre cpp14 compilers #include "cpp14polyfills.h" @@ -53,9 +54,7 @@ std::unique_ptr ZeiterfassungApi::doLoginPage() { QNetworkRequest request(QUrl(m_url % "pages/login.jsp")); - auto reply = std::unique_ptr(m_manager->get(request)); - - return std::make_unique(std::move(reply), this); + return std::make_unique(std::unique_ptr(m_manager->get(request)), this); } std::unique_ptr ZeiterfassungApi::doLogin(const QString &username, const QString &password) @@ -66,19 +65,19 @@ std::unique_ptr ZeiterfassungApi::doLogin(const QString &username, c auto data = QStringLiteral("j_username=%0&j_password=%1&login=Anmelden").arg(username).arg(password).toUtf8(); - auto reply = std::unique_ptr(m_manager->post(request, data)); - - return std::make_unique(std::move(reply), this); + return std::make_unique(std::unique_ptr(m_manager->post(request, data)), this); } std::unique_ptr ZeiterfassungApi::doUserInfo() { - QNetworkRequest request(QUrl(m_url % "json/evoAppsUserInfoDialogController/load-EvoAppsUserInfoTO")); - request.setRawHeader(QByteArrayLiteral("sisAppName"), QByteArrayLiteral("home")); + QNetworkRequest request0(QUrl(m_url % "json/evoAppsUserInfoDialogController/load-EvoAppsUserInfoTO")); + request0.setRawHeader(QByteArrayLiteral("sisAppName"), QByteArrayLiteral("home")); - auto reply = std::unique_ptr(m_manager->get(request)); + QNetworkRequest request1(QUrl(m_url % "json/persons")); + request1.setRawHeader(QByteArrayLiteral("sisAppName"), QByteArrayLiteral("bookingCalendar")); - return std::make_unique(std::move(reply), this); + return std::make_unique(std::unique_ptr(m_manager->get(request0)), + std::unique_ptr(m_manager->get(request1)), this); } std::unique_ptr ZeiterfassungApi::doGetBookings(int userId, const QDate &start, const QDate &end) @@ -90,9 +89,7 @@ std::unique_ptr ZeiterfassungApi::doGetBookings(int userId, co .arg(userId))); request.setRawHeader(QByteArrayLiteral("sisAppName"), QByteArrayLiteral("bookingCalendar")); - auto reply = std::unique_ptr(m_manager->get(request)); - - return std::make_unique(std::move(reply), this); + return std::make_unique(std::unique_ptr(m_manager->get(request)), this); } std::unique_ptr ZeiterfassungApi::doCreateBooking(int userId, const QDate &date, const QTime &time, const QTime ×pan, @@ -113,9 +110,9 @@ std::unique_ptr ZeiterfassungApi::doCreateBooking(int userId obj[QStringLiteral("bewEinh")] = QStringLiteral(""); obj[QStringLiteral("text")] = text; - auto reply = std::unique_ptr(m_manager->post(request, QJsonDocument(obj).toJson())); + auto data = QJsonDocument(obj).toJson(); - return std::make_unique(std::move(reply), this); + return std::make_unique(std::unique_ptr(m_manager->post(request, data)), this); } std::unique_ptr ZeiterfassungApi::doUpdateBooking(int bookingId, int userId, const QDate &date, const QTime &time, @@ -139,9 +136,7 @@ std::unique_ptr ZeiterfassungApi::doUpdateBooking(int bookin auto data = QJsonDocument(obj).toJson(); - auto reply = std::unique_ptr(m_manager->put(request, data)); - - return std::make_unique(std::move(reply), this); + return std::make_unique(std::unique_ptr(m_manager->put(request, data)), this); } std::unique_ptr ZeiterfassungApi::doDeleteBooking(int bookingId) @@ -151,9 +146,7 @@ std::unique_ptr ZeiterfassungApi::doDeleteBooking(int bookin .arg(bookingId))); request.setRawHeader(QByteArrayLiteral("sisAppName"), QByteArrayLiteral("bookingCalendar")); - auto reply = std::unique_ptr(m_manager->deleteResource(request)); - - return std::make_unique(std::move(reply), this); + return std::make_unique(std::unique_ptr(m_manager->deleteResource(request)), this); } std::unique_ptr ZeiterfassungApi::doGetTimeAssignments(int userId, const QDate &start, const QDate &end) @@ -165,9 +158,7 @@ std::unique_ptr ZeiterfassungApi::doGetTimeAssignments( .arg(userId))); request.setRawHeader(QByteArrayLiteral("sisAppName"), QByteArrayLiteral("bookingCalendar")); - auto reply = std::unique_ptr(m_manager->get(request)); - - return std::make_unique(std::move(reply), this); + return std::make_unique(std::unique_ptr(m_manager->get(request)), this); } std::unique_ptr ZeiterfassungApi::doCreateTimeAssignment(int userId, const QDate &date, const QTime &time, @@ -208,9 +199,7 @@ std::unique_ptr ZeiterfassungApi::doCreateTimeAssignm auto data = QJsonDocument(obj).toJson(); - auto reply = std::unique_ptr(m_manager->post(request, data)); - - return std::make_unique(std::move(reply), this); + return std::make_unique(std::unique_ptr(m_manager->post(request, data)), this); } std::unique_ptr ZeiterfassungApi::doUpdateTimeAssignment(int timeAssignmentId, int userId, const QDate &date, @@ -256,9 +245,7 @@ std::unique_ptr ZeiterfassungApi::doUpdateTimeAssignm auto data = QJsonDocument(obj).toJson(); - auto reply = std::unique_ptr(m_manager->put(request, data)); - - return std::make_unique(std::move(reply), this); + return std::make_unique(std::unique_ptr(m_manager->put(request, data)), this); } std::unique_ptr ZeiterfassungApi::doDeleteTimeAssignment(int timeAssignmentId) @@ -268,9 +255,7 @@ std::unique_ptr ZeiterfassungApi::doDeleteTimeAssignm .arg(timeAssignmentId))); request.setRawHeader(QByteArrayLiteral("sisAppName"), QByteArrayLiteral("bookingCalendar")); - auto reply = std::unique_ptr(m_manager->deleteResource(request)); - - return std::make_unique(std::move(reply), this); + return std::make_unique(std::unique_ptr(m_manager->deleteResource(request)), this); } std::unique_ptr ZeiterfassungApi::doGetProjects(int userId, const QDate &date) @@ -281,9 +266,7 @@ std::unique_ptr ZeiterfassungApi::doGetProjects(int userId, co .arg(date.toString(QStringLiteral("yyyyMMdd"))))); request.setRawHeader(QByteArrayLiteral("sisAppName"), QByteArrayLiteral("bookingCalendar")); - auto reply = std::unique_ptr(m_manager->get(request)); - - return std::make_unique(std::move(reply), this); + return std::make_unique(std::unique_ptr(m_manager->get(request)), this); } std::unique_ptr ZeiterfassungApi::doGetReport(int userId, const QDate &date) @@ -294,9 +277,7 @@ std::unique_ptr ZeiterfassungApi::doGetReport(int userId, const .arg(date.toString(QStringLiteral("yyyyMMdd"))))); request.setRawHeader(QByteArrayLiteral("sisAppName"), QByteArrayLiteral("bookingCalendar")); - auto reply = std::unique_ptr(m_manager->get(request)); - - return std::make_unique(std::move(reply), this); + return std::make_unique(std::unique_ptr(m_manager->get(request)), this); } std::unique_ptr ZeiterfassungApi::doGetPresenceStatus() @@ -304,7 +285,17 @@ std::unique_ptr ZeiterfassungApi::doGetPresenceStatus() QNetworkRequest request(QUrl(m_url % "json/presencestatus")); request.setRawHeader(QByteArrayLiteral("sisAppName"), QByteArrayLiteral("presenceStatus")); - auto reply = std::unique_ptr(m_manager->get(request)); - - return std::make_unique(std::move(reply), this); + return std::make_unique(std::unique_ptr(m_manager->get(request)), this); +} + +std::unique_ptr ZeiterfassungApi::doGetAbsences(int userId, const QDate &start, const QDate &end) +{ + QNetworkRequest request(QUrl(QStringLiteral("%0json/fulldayAbsences?start=%1&end=%2&pnrLst=%3") + .arg(m_url) + .arg(start.toString(QStringLiteral("yyyyMMdd"))) + .arg(end.toString(QStringLiteral("yyyyMMdd"))) + .arg(userId))); + request.setRawHeader(QByteArrayLiteral("sisAppName"), QByteArrayLiteral("bookingCalendar")); + + return std::make_unique(std::unique_ptr(m_manager->get(request)), this); } diff --git a/zeiterfassunglib/zeiterfassungapi.h b/zeiterfassungcorelib/zeiterfassungapi.h similarity index 92% rename from zeiterfassunglib/zeiterfassungapi.h rename to zeiterfassungcorelib/zeiterfassungapi.h index e978094..8af9b71 100644 --- a/zeiterfassunglib/zeiterfassungapi.h +++ b/zeiterfassungcorelib/zeiterfassungapi.h @@ -1,5 +1,4 @@ -#ifndef ZEITERFASSUNGAPI_H -#define ZEITERFASSUNGAPI_H +#pragma once #include @@ -8,7 +7,7 @@ #include #include -#include "zeiterfassunglib_global.h" +#include "zeiterfassungcorelib_global.h" class QNetworkAccessManager; @@ -26,8 +25,9 @@ class DeleteTimeAssignmentReply; class GetProjectsReply; class GetReportReply; class GetPresenceStatusReply; +class GetAbsencesReply; -class ZEITERFASSUNGLIBSHARED_EXPORT ZeiterfassungApi : public QObject +class ZEITERFASSUNGCORELIBSHARED_EXPORT ZeiterfassungApi : public QObject { Q_OBJECT @@ -64,10 +64,9 @@ public: std::unique_ptr doGetProjects(int userId, const QDate &date); std::unique_ptr doGetReport(int userId, const QDate &date); std::unique_ptr doGetPresenceStatus(); + std::unique_ptr doGetAbsences(int userId, const QDate &start, const QDate &end); private: QString m_url; QNetworkAccessManager *m_manager; }; - -#endif // ZEITERFASSUNGAPI_H diff --git a/zeiterfassunglib/zeiterfassunglib.pro b/zeiterfassungcorelib/zeiterfassungcorelib.pro similarity index 52% rename from zeiterfassunglib/zeiterfassunglib.pro rename to zeiterfassungcorelib/zeiterfassungcorelib.pro index e58e448..9ba114a 100644 --- a/zeiterfassunglib/zeiterfassunglib.pro +++ b/zeiterfassungcorelib/zeiterfassungcorelib.pro @@ -1,85 +1,65 @@ -QT += core network gui widgets uitools +QT += core network +QT -= gui widgets -TARGET = zeiterfassunglib +TARGET = zeiterfassungcorelib TEMPLATE = lib CONFIG += c++14 -DESTDIR = $${OUT_PWD}/../lib +PROJECT_ROOT = .. + +DESTDIR = $${OUT_PWD}/$${PROJECT_ROOT}/bin DEFINES += QT_DEPRECATED_WARNINGS QT_DISABLE_DEPRECATED_BEFORE=0x060000 QT_MESSAGELOGCONTEXT -DEFINES += ZEITERFASSUNGLIB_LIBRARY +DEFINES += ZEITERFASSUNGCORELIB_LIBRARY -SOURCES += mainwindow.cpp \ - stripfactory.cpp \ - stripswidget.cpp \ - timeutils.cpp \ +SOURCES += timeutils.cpp \ zeiterfassungapi.cpp \ - zeiterfassungplugin.cpp \ zeiterfassungsettings.cpp \ - dialogs/aboutmedialog.cpp \ - dialogs/authenticationdialog.cpp \ - dialogs/languageselectiondialog.cpp \ - dialogs/settingsdialog.cpp \ replies/createbookingreply.cpp \ replies/createtimeassignmentreply.cpp \ replies/deletebookingreply.cpp \ replies/deletetimeassignmentreply.cpp \ + replies/getabsencesreply.cpp \ replies/getbookingsreply.cpp \ replies/getpresencestatusreply.cpp \ replies/getprojectsreply.cpp \ + replies/getreportreply.cpp \ replies/gettimeassignmentsreply.cpp \ + replies/getuserinforeply.cpp \ replies/loginpagereply.cpp \ replies/loginreply.cpp \ replies/updatebookingreply.cpp \ replies/updatetimeassignmentreply.cpp \ - replies/zeiterfassungreply.cpp \ - replies/getuserinforeply.cpp \ - replies/getreportreply.cpp + replies/zeiterfassungreply.cpp HEADERS += cpp14polyfills.h \ - mainwindow.h \ - stripfactory.h \ - stripswidget.h \ timeutils.h \ zeiterfassungapi.h \ - zeiterfassunglib_global.h \ - zeiterfassungplugin.h \ + zeiterfassungcorelib_global.h \ zeiterfassungsettings.h \ - dialogs/aboutmedialog.h \ - dialogs/authenticationdialog.h \ - dialogs/languageselectiondialog.h \ - dialogs/settingsdialog.h \ replies/createbookingreply.h \ replies/createtimeassignmentreply.h \ replies/deletebookingreply.h \ replies/deletetimeassignmentreply.h \ + replies/getabsencesreply.h \ replies/getbookingsreply.h \ replies/getpresencestatusreply.h \ replies/getprojectsreply.h \ + replies/getreportreply.h \ replies/gettimeassignmentsreply.h \ + replies/getuserinforeply.h \ replies/loginpagereply.h \ replies/loginreply.h \ replies/updatebookingreply.h \ replies/updatetimeassignmentreply.h \ - replies/zeiterfassungreply.h \ - replies/getuserinforeply.h \ - replies/getreportreply.h + replies/zeiterfassungreply.h -FORMS += mainwindow.ui \ - dialogs/settingsdialog.ui \ - dialogs/languageselectiondialog.ui \ - dialogs/authenticationdialog.ui \ - dialogs/aboutmedialog.ui +FORMS += -RESOURCES += resources.qrc +RESOURCES += -TRANSLATIONS += translations/zeiterfassunglib_en.ts \ - translations/zeiterfassunglib_de.ts +TRANSLATIONS += translations/zeiterfassungcorelib_en.ts \ + translations/zeiterfassungcorelib_de.ts -include(../lrelease.pri) - -# unix { -# target.path = /usr/lib -# INSTALLS += target -# } +include($${PROJECT_ROOT}/lrelease.pri) diff --git a/zeiterfassungcorelib/zeiterfassungcorelib_global.h b/zeiterfassungcorelib/zeiterfassungcorelib_global.h new file mode 100644 index 0000000..334fcf9 --- /dev/null +++ b/zeiterfassungcorelib/zeiterfassungcorelib_global.h @@ -0,0 +1,9 @@ +#pragma once + +#include + +#if defined(ZEITERFASSUNGCORELIB_LIBRARY) +# define ZEITERFASSUNGCORELIBSHARED_EXPORT Q_DECL_EXPORT +#else +# define ZEITERFASSUNGCORELIBSHARED_EXPORT Q_DECL_IMPORT +#endif diff --git a/zeiterfassunglib/zeiterfassungsettings.cpp b/zeiterfassungcorelib/zeiterfassungsettings.cpp similarity index 100% rename from zeiterfassunglib/zeiterfassungsettings.cpp rename to zeiterfassungcorelib/zeiterfassungsettings.cpp diff --git a/zeiterfassunglib/zeiterfassungsettings.h b/zeiterfassungcorelib/zeiterfassungsettings.h similarity index 89% rename from zeiterfassunglib/zeiterfassungsettings.h rename to zeiterfassungcorelib/zeiterfassungsettings.h index 0a56adf..843ea9c 100644 --- a/zeiterfassunglib/zeiterfassungsettings.h +++ b/zeiterfassungcorelib/zeiterfassungsettings.h @@ -1,5 +1,4 @@ -#ifndef ZEITERFASSUNGSETTINGS_H -#define ZEITERFASSUNGSETTINGS_H +#pragma once #include #include @@ -7,9 +6,9 @@ #include #include -#include "zeiterfassunglib_global.h" +#include "zeiterfassungcorelib_global.h" -class ZEITERFASSUNGLIBSHARED_EXPORT ZeiterfassungSettings : public QSettings +class ZEITERFASSUNGCORELIBSHARED_EXPORT ZeiterfassungSettings : public QSettings { Q_OBJECT @@ -57,5 +56,3 @@ public: private: void prependItem(const QString &name, const QString &item); }; - -#endif // ZEITERFASSUNGSETTINGS_H diff --git a/zeiterfassunglib/dialogs/authenticationdialog.cpp b/zeiterfassungguilib/dialogs/authenticationdialog.cpp similarity index 95% rename from zeiterfassunglib/dialogs/authenticationdialog.cpp rename to zeiterfassungguilib/dialogs/authenticationdialog.cpp index 5de7cf2..d4dbfd2 100644 --- a/zeiterfassunglib/dialogs/authenticationdialog.cpp +++ b/zeiterfassungguilib/dialogs/authenticationdialog.cpp @@ -2,7 +2,7 @@ #include "ui_authenticationdialog.h" AuthenticationDialog::AuthenticationDialog(QWidget *parent) : - QDialog(parent), + ZeiterfassungDialog(parent), ui(new Ui::AuthenticationDialog) { ui->setupUi(this); diff --git a/zeiterfassunglib/dialogs/authenticationdialog.h b/zeiterfassungguilib/dialogs/authenticationdialog.h similarity index 54% rename from zeiterfassunglib/dialogs/authenticationdialog.h rename to zeiterfassungguilib/dialogs/authenticationdialog.h index 712059c..af0e49f 100644 --- a/zeiterfassunglib/dialogs/authenticationdialog.h +++ b/zeiterfassungguilib/dialogs/authenticationdialog.h @@ -1,15 +1,11 @@ -#ifndef AUTHENTICATIONDIALOG_H -#define AUTHENTICATIONDIALOG_H +#pragma once -#include +#include "zeiterfassungguilib_global.h" +#include "zeiterfassungdialog.h" -#include "zeiterfassunglib_global.h" +namespace Ui { class AuthenticationDialog; } -namespace Ui { -class AuthenticationDialog; -} - -class ZEITERFASSUNGLIBSHARED_EXPORT AuthenticationDialog : public QDialog +class ZEITERFASSUNGGUILIBSHARED_EXPORT AuthenticationDialog : public ZeiterfassungDialog { Q_OBJECT @@ -26,5 +22,3 @@ public: private: Ui::AuthenticationDialog *ui; }; - -#endif // AUTHENTICATIONDIALOG_H diff --git a/zeiterfassunglib/dialogs/authenticationdialog.ui b/zeiterfassungguilib/dialogs/authenticationdialog.ui similarity index 95% rename from zeiterfassunglib/dialogs/authenticationdialog.ui rename to zeiterfassungguilib/dialogs/authenticationdialog.ui index cbb43c6..e68034f 100644 --- a/zeiterfassunglib/dialogs/authenticationdialog.ui +++ b/zeiterfassungguilib/dialogs/authenticationdialog.ui @@ -37,7 +37,7 @@ - :/zeiterfassunglib/images/authentication.png + :/zeiterfassungguilib/images/authentication.png true @@ -105,7 +105,7 @@ - + diff --git a/zeiterfassunglib/dialogs/languageselectiondialog.cpp b/zeiterfassungguilib/dialogs/languageselectiondialog.cpp similarity index 95% rename from zeiterfassunglib/dialogs/languageselectiondialog.cpp rename to zeiterfassungguilib/dialogs/languageselectiondialog.cpp index 3cf0c6a..c39f5bc 100644 --- a/zeiterfassunglib/dialogs/languageselectiondialog.cpp +++ b/zeiterfassungguilib/dialogs/languageselectiondialog.cpp @@ -2,7 +2,7 @@ #include "ui_languageselectiondialog.h" LanguageSelectionDialog::LanguageSelectionDialog(QWidget *parent) : - QDialog(parent), + ZeiterfassungDialog(parent), ui(new Ui::LanguageSelectionDialog) { ui->setupUi(this); diff --git a/zeiterfassunglib/dialogs/languageselectiondialog.h b/zeiterfassungguilib/dialogs/languageselectiondialog.h similarity index 58% rename from zeiterfassunglib/dialogs/languageselectiondialog.h rename to zeiterfassungguilib/dialogs/languageselectiondialog.h index e28b883..f2d01c9 100644 --- a/zeiterfassunglib/dialogs/languageselectiondialog.h +++ b/zeiterfassungguilib/dialogs/languageselectiondialog.h @@ -1,14 +1,13 @@ -#ifndef LANGUAGESELECTIONDIALOG_H -#define LANGUAGESELECTIONDIALOG_H +#pragma once -#include #include -#include "zeiterfassunglib_global.h" +#include "zeiterfassungguilib_global.h" +#include "zeiterfassungdialog.h" namespace Ui { class LanguageSelectionDialog; } -class ZEITERFASSUNGLIBSHARED_EXPORT LanguageSelectionDialog : public QDialog +class ZEITERFASSUNGGUILIBSHARED_EXPORT LanguageSelectionDialog : public ZeiterfassungDialog { Q_OBJECT @@ -22,5 +21,3 @@ public: private: Ui::LanguageSelectionDialog *ui; }; - -#endif // LANGUAGESELECTIONDIALOG_H diff --git a/zeiterfassunglib/dialogs/languageselectiondialog.ui b/zeiterfassungguilib/dialogs/languageselectiondialog.ui similarity index 100% rename from zeiterfassunglib/dialogs/languageselectiondialog.ui rename to zeiterfassungguilib/dialogs/languageselectiondialog.ui diff --git a/zeiterfassunglib/dialogs/settingsdialog.cpp b/zeiterfassungguilib/dialogs/settingsdialog.cpp similarity index 99% rename from zeiterfassunglib/dialogs/settingsdialog.cpp rename to zeiterfassungguilib/dialogs/settingsdialog.cpp index 0532c8a..ea84650 100644 --- a/zeiterfassunglib/dialogs/settingsdialog.cpp +++ b/zeiterfassungguilib/dialogs/settingsdialog.cpp @@ -11,7 +11,7 @@ #include "zeiterfassungsettings.h" SettingsDialog::SettingsDialog(ZeiterfassungSettings &settings, QWidget *parent) : - QDialog(parent), + ZeiterfassungDialog(parent), ui(new Ui::SettingsDialog), m_settings(settings) { diff --git a/zeiterfassunglib/dialogs/settingsdialog.h b/zeiterfassungguilib/dialogs/settingsdialog.h similarity index 61% rename from zeiterfassunglib/dialogs/settingsdialog.h rename to zeiterfassungguilib/dialogs/settingsdialog.h index 5cafed2..3315276 100644 --- a/zeiterfassunglib/dialogs/settingsdialog.h +++ b/zeiterfassungguilib/dialogs/settingsdialog.h @@ -1,14 +1,12 @@ -#ifndef SETTINGSDIALOG_H -#define SETTINGSDIALOG_H +#pragma once -#include - -#include "zeiterfassunglib_global.h" +#include "zeiterfassungguilib_global.h" +#include "zeiterfassungdialog.h" class ZeiterfassungSettings; namespace Ui { class SettingsDialog; } -class ZEITERFASSUNGLIBSHARED_EXPORT SettingsDialog : public QDialog +class ZEITERFASSUNGGUILIBSHARED_EXPORT SettingsDialog : public ZeiterfassungDialog { Q_OBJECT @@ -23,5 +21,3 @@ private: Ui::SettingsDialog *ui; ZeiterfassungSettings &m_settings; }; - -#endif // SETTINGSDIALOG_H diff --git a/zeiterfassunglib/dialogs/settingsdialog.ui b/zeiterfassungguilib/dialogs/settingsdialog.ui similarity index 100% rename from zeiterfassunglib/dialogs/settingsdialog.ui rename to zeiterfassungguilib/dialogs/settingsdialog.ui diff --git a/zeiterfassunglib/images/about.png b/zeiterfassungguilib/images/about.png similarity index 100% rename from zeiterfassunglib/images/about.png rename to zeiterfassungguilib/images/about.png diff --git a/zeiterfassunglib/images/authentication.png b/zeiterfassungguilib/images/authentication.png similarity index 100% rename from zeiterfassunglib/images/authentication.png rename to zeiterfassungguilib/images/authentication.png diff --git a/zeiterfassunglib/images/help.png b/zeiterfassungguilib/images/help.png similarity index 100% rename from zeiterfassunglib/images/help.png rename to zeiterfassungguilib/images/help.png diff --git a/zeiterfassunglib/images/icon.png b/zeiterfassungguilib/images/icon.png similarity index 100% rename from zeiterfassunglib/images/icon.png rename to zeiterfassungguilib/images/icon.png diff --git a/zeiterfassunglib/images/next.png b/zeiterfassungguilib/images/next.png similarity index 100% rename from zeiterfassunglib/images/next.png rename to zeiterfassungguilib/images/next.png diff --git a/zeiterfassunglib/images/now.png b/zeiterfassungguilib/images/now.png similarity index 100% rename from zeiterfassunglib/images/now.png rename to zeiterfassungguilib/images/now.png diff --git a/zeiterfassunglib/images/previous.png b/zeiterfassungguilib/images/previous.png similarity index 100% rename from zeiterfassunglib/images/previous.png rename to zeiterfassungguilib/images/previous.png diff --git a/zeiterfassungguilib/images/qt.png b/zeiterfassungguilib/images/qt.png new file mode 100644 index 0000000..f0088ac Binary files /dev/null and b/zeiterfassungguilib/images/qt.png differ diff --git a/zeiterfassunglib/images/quit.png b/zeiterfassungguilib/images/quit.png similarity index 100% rename from zeiterfassunglib/images/quit.png rename to zeiterfassungguilib/images/quit.png diff --git a/zeiterfassunglib/images/refresh.png b/zeiterfassungguilib/images/refresh.png similarity index 100% rename from zeiterfassunglib/images/refresh.png rename to zeiterfassungguilib/images/refresh.png diff --git a/zeiterfassunglib/images/settings.png b/zeiterfassungguilib/images/settings.png similarity index 100% rename from zeiterfassunglib/images/settings.png rename to zeiterfassungguilib/images/settings.png diff --git a/zeiterfassunglib/images/today.png b/zeiterfassungguilib/images/today.png similarity index 100% rename from zeiterfassunglib/images/today.png rename to zeiterfassungguilib/images/today.png diff --git a/zeiterfassungguilib/images/user.png b/zeiterfassungguilib/images/user.png new file mode 100644 index 0000000..e6e955f Binary files /dev/null and b/zeiterfassungguilib/images/user.png differ diff --git a/zeiterfassunglib/mainwindow.cpp b/zeiterfassungguilib/mainwindow.cpp similarity index 96% rename from zeiterfassunglib/mainwindow.cpp rename to zeiterfassungguilib/mainwindow.cpp index 29abb46..845ea44 100644 --- a/zeiterfassunglib/mainwindow.cpp +++ b/zeiterfassungguilib/mainwindow.cpp @@ -19,7 +19,6 @@ #include "zeiterfassungsettings.h" #include "stripfactory.h" #include "stripswidget.h" -#include "dialogs/aboutmedialog.h" #include "dialogs/settingsdialog.h" #include "replies/getprojectsreply.h" #include "replies/createbookingreply.h" @@ -47,7 +46,6 @@ MainWindow::MainWindow(ZeiterfassungSettings &settings, ZeiterfassungApi &erfass ui->actionRefresh->setShortcut(QKeySequence::Refresh); connect(ui->actionRefresh, &QAction::triggered, this, &MainWindow::refreshEverything); - connect(ui->actionAboutMe, &QAction::triggered, [=](){ AboutMeDialog(userInfo, this).exec(); }); connect(ui->actionSettings, &QAction::triggered, [=](){ SettingsDialog(m_settings, this).exec(); }); ui->actionHelp->setShortcut(QKeySequence::HelpContents); @@ -254,12 +252,6 @@ void MainWindow::pushButtonStartPressed() } else m_currentStripWidget->refreshTimeAssignments(); - - ui->actionToday->setEnabled(false); - ui->actionRefresh->setEnabled(false); - ui->dateEditDate->setReadOnly(true); - ui->pushButtonPrev->setEnabled(false); - ui->pushButtonNext->setEnabled(false); } void MainWindow::pushButtonEndPressed() @@ -302,12 +294,6 @@ void MainWindow::pushButtonEndPressed() m_currentStripWidget->refresh(); //refreshReport(); - - ui->actionToday->setEnabled(false); - ui->actionRefresh->setEnabled(false); - ui->dateEditDate->setReadOnly(true); - ui->pushButtonPrev->setEnabled(false); - ui->pushButtonNext->setEnabled(false); } void MainWindow::dateChangedSlot(const QDate &date) diff --git a/zeiterfassunglib/mainwindow.h b/zeiterfassungguilib/mainwindow.h similarity index 91% rename from zeiterfassunglib/mainwindow.h rename to zeiterfassungguilib/mainwindow.h index b9d88de..a6e5a5b 100644 --- a/zeiterfassunglib/mainwindow.h +++ b/zeiterfassungguilib/mainwindow.h @@ -1,12 +1,11 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H +#pragma once #include #include #include -#include "zeiterfassunglib_global.h" +#include "zeiterfassungguilib_global.h" #include "replies/getuserinforeply.h" #include "replies/getprojectsreply.h" #include "replies/getpresencestatusreply.h" @@ -21,7 +20,7 @@ class ZeiterfassungSettings; class StripFactory; class StripsWidget; -class ZEITERFASSUNGLIBSHARED_EXPORT MainWindow : public QMainWindow +class ZEITERFASSUNGGUILIBSHARED_EXPORT MainWindow : public QMainWindow { Q_OBJECT @@ -77,5 +76,3 @@ private: std::array m_stripsWidgets; StripsWidget *m_currentStripWidget; }; - -#endif // MAINWINDOW_H diff --git a/zeiterfassunglib/mainwindow.ui b/zeiterfassungguilib/mainwindow.ui similarity index 78% rename from zeiterfassunglib/mainwindow.ui rename to zeiterfassungguilib/mainwindow.ui index ebc7280..c96c07d 100644 --- a/zeiterfassunglib/mainwindow.ui +++ b/zeiterfassungguilib/mainwindow.ui @@ -11,8 +11,8 @@ - - :/zeiterfassunglib/images/icon.png:/zeiterfassunglib/images/icon.png + + :/zeiterfassungguilib/images/icon.png:/zeiterfassungguilib/images/icon.png @@ -30,8 +30,8 @@ - - :/zeiterfassunglib/images/previous.png:/zeiterfassunglib/images/previous.png + + :/zeiterfassungguilib/images/previous.png:/zeiterfassungguilib/images/previous.png @@ -44,8 +44,8 @@ - - :/zeiterfassunglib/images/next.png:/zeiterfassunglib/images/next.png + + :/zeiterfassungguilib/images/next.png:/zeiterfassungguilib/images/next.png @@ -74,8 +74,8 @@ - - :/zeiterfassunglib/images/now.png:/zeiterfassunglib/images/now.png + + :/zeiterfassungguilib/images/now.png:/zeiterfassungguilib/images/now.png @@ -211,7 +211,6 @@ &About - @@ -248,8 +247,8 @@ - - :/zeiterfassunglib/images/quit.png:/zeiterfassunglib/images/quit.png + + :/zeiterfassungguilib/images/quit.png:/zeiterfassungguilib/images/quit.png &Quit @@ -257,8 +256,8 @@ - - :/zeiterfassunglib/images/user.png:/zeiterfassunglib/images/user.png + + :/zeiterfassungguilib/images/user.png:/zeiterfassungguilib/images/user.png About &Me @@ -266,22 +265,26 @@ - - :/zeiterfassunglib/images/about.png:/zeiterfassunglib/images/about.png + + :/zeiterfassungguilib/images/about.png:/zeiterfassungguilib/images/about.png About &zeiterfassung + + + :/zeiterfassungguilib/images/qt.png:/zeiterfassungguilib/images/qt.png + About &Qt - - :/zeiterfassunglib/images/today.png:/zeiterfassunglib/images/today.png + + :/zeiterfassungguilib/images/today.png:/zeiterfassungguilib/images/today.png &Today @@ -289,8 +292,8 @@ - - :/zeiterfassunglib/images/refresh.png:/zeiterfassunglib/images/refresh.png + + :/zeiterfassungguilib/images/refresh.png:/zeiterfassungguilib/images/refresh.png &Refresh everything @@ -298,8 +301,8 @@ - - :/zeiterfassunglib/images/settings.png:/zeiterfassunglib/images/settings.png + + :/zeiterfassungguilib/images/settings.png:/zeiterfassungguilib/images/settings.png &Settings @@ -307,8 +310,8 @@ - - :/zeiterfassunglib/images/help.png:/zeiterfassunglib/images/help.png + + :/zeiterfassungguilib/images/help.png:/zeiterfassungguilib/images/help.png Help @@ -316,7 +319,7 @@ - + diff --git a/zeiterfassunglib/stripfactory.cpp b/zeiterfassungguilib/stripfactory.cpp similarity index 100% rename from zeiterfassunglib/stripfactory.cpp rename to zeiterfassungguilib/stripfactory.cpp diff --git a/zeiterfassunglib/stripfactory.h b/zeiterfassungguilib/stripfactory.h similarity index 79% rename from zeiterfassunglib/stripfactory.h rename to zeiterfassungguilib/stripfactory.h index af3e1d3..8a8deef 100644 --- a/zeiterfassunglib/stripfactory.h +++ b/zeiterfassungguilib/stripfactory.h @@ -1,17 +1,16 @@ -#ifndef STRIPFACTORY_H -#define STRIPFACTORY_H +#pragma once #include #include #include -#include "zeiterfassunglib_global.h" +#include "zeiterfassungguilib_global.h" class QUiLoader; class QByteArray; -class ZEITERFASSUNGLIBSHARED_EXPORT StripFactory : public QObject +class ZEITERFASSUNGGUILIBSHARED_EXPORT StripFactory : public QObject { Q_OBJECT @@ -34,5 +33,3 @@ private: QByteArray m_bookingEndStrip; QByteArray m_timeAssignmentStrip; }; - -#endif // STRIPFACTORY_H diff --git a/zeiterfassunglib/stripswidget.cpp b/zeiterfassungguilib/stripswidget.cpp similarity index 92% rename from zeiterfassunglib/stripswidget.cpp rename to zeiterfassungguilib/stripswidget.cpp index 34f41a8..ab0e37c 100644 --- a/zeiterfassunglib/stripswidget.cpp +++ b/zeiterfassungguilib/stripswidget.cpp @@ -270,14 +270,6 @@ bool StripsWidget::createStrips() } auto timeAssignment = *timeAssignmentsIter++; - if(timeAssignment.time != timeAssignmentTime) - { - errorMessage = tr("Expected %0 but received %1 in time assignment.\nTime assignment ID: %2") - .arg(timeAssignmentTime.toString(tr("HH:mm:ss"))) - .arg(timeAssignment.time.toString(tr("HH:mm:ss"))) - .arg(timeAssignment.id); - goto after; - } appendTimeAssignmentStrip(timeAssignment.id, timeAssignment.timespan, buildProjectString(timeAssignment.project), timeAssignment.subproject, timeAssignment.workpackage, timeAssignment.text); @@ -321,14 +313,6 @@ bool StripsWidget::createStrips() } timeAssignment = *timeAssignmentsIter++; - if(timeAssignment.time != timeAssignmentTime) - { - errorMessage = tr("Expected %0 but received %1 in time assignment.\nTime assignment ID: %2") - .arg(timeAssignmentTime.toString(tr("HH:mm:ss"))) - .arg(timeAssignment.time.toString(tr("HH:mm:ss"))) - .arg(timeAssignment.id); - goto after; - } appendTimeAssignmentStrip(timeAssignment.id, timeAssignment.timespan, buildProjectString(timeAssignment.project), timeAssignment.subproject, timeAssignment.workpackage, timeAssignment.text); @@ -368,7 +352,8 @@ bool StripsWidget::createStrips() lastBooking = &endBooking; - bookingTimespan = timeAdd(bookingTimespan, timeBetween(startBooking.time, endBooking.time)); + auto currBookingDuration = timeBetween(startBooking.time, endBooking.time); + bookingTimespan = timeAdd(bookingTimespan, currBookingDuration); minimumTime = timeAdd(endBooking.time, QTime(0, 1)); while(timeAssignmentTime < bookingTimespan) @@ -378,20 +363,12 @@ bool StripsWidget::createStrips() errorMessage = tr("Missing time assignment! Missing: %0") .arg(tr("%0h").arg(timeBetween(timeAssignmentTime, bookingTimespan).toString(tr("HH:mm:ss")))); - appendBookingEndStrip(endBooking.id, endBooking.time); + appendBookingEndStrip(endBooking.id, endBooking.time, currBookingDuration); goto after; } timeAssignment = *timeAssignmentsIter++; - if(timeAssignment.time != timeAssignmentTime) - { - errorMessage = tr("Expected %0 but received %1 in time assignment.\nTime assignment ID: %2") - .arg(timeAssignmentTime.toString(tr("HH:mm:ss"))) - .arg(timeAssignment.time.toString(tr("HH:mm:ss"))) - .arg(timeAssignment.id); - goto after; - } appendTimeAssignmentStrip(timeAssignment.id, timeAssignment.timespan, buildProjectString(timeAssignment.project), timeAssignment.subproject, timeAssignment.workpackage, timeAssignment.text); @@ -432,7 +409,7 @@ bool StripsWidget::createStrips() .arg(bookingTimespan.toString(tr("HH:mm:ss"))); } - appendBookingEndStrip(endBooking.id, endBooking.time); + appendBookingEndStrip(endBooking.id, endBooking.time, currBookingDuration); if(timeAssignmentTime > bookingTimespan) goto after; @@ -461,7 +438,7 @@ bool StripsWidget::createStrips() auto label = new QLabel(tr("Strip rendering aborted due error.\n" "Your bookings and time assignments for this day are in an illegal state!") % "\n" % errorMessage, this); - label->setStyleSheet("color: red;"); + label->setStyleSheet(QStringLiteral("color: red;")); m_stripsLayout->addWidget(label); } @@ -576,7 +553,7 @@ QWidget *StripsWidget::appendBookingStartStrip(int id, const QTime &time) return widget; } -QWidget *StripsWidget::appendBookingEndStrip(int id, const QTime &time) +QWidget *StripsWidget::appendBookingEndStrip(int id, const QTime &time, const QTime &duration) { auto widget = m_mainWindow.stripFactory().createBookingEndStrip(this).release(); @@ -585,6 +562,11 @@ QWidget *StripsWidget::appendBookingEndStrip(int id, const QTime &time) else qWarning() << "no labelTime found!"; + if(auto labelDuration = widget->findChild(QStringLiteral("labelDuration"))) + labelDuration->setProperty("text", tr("%0h").arg(duration.toString(tr("HH:mm")))); + else + qWarning() << "no labelDuration found!"; + if(auto labelId = widget->findChild(QStringLiteral("labelId"))) labelId->setProperty("text", QString::number(id)); else diff --git a/zeiterfassunglib/stripswidget.h b/zeiterfassungguilib/stripswidget.h similarity index 92% rename from zeiterfassunglib/stripswidget.h rename to zeiterfassungguilib/stripswidget.h index 76e48d7..38f1b61 100644 --- a/zeiterfassunglib/stripswidget.h +++ b/zeiterfassungguilib/stripswidget.h @@ -1,12 +1,11 @@ -#ifndef STRIPSWIDGET_H -#define STRIPSWIDGET_H +#pragma once #include #include #include -#include "zeiterfassunglib_global.h" +#include "zeiterfassungguilib_global.h" #include "replies/getbookingsreply.h" #include "replies/gettimeassignmentsreply.h" @@ -16,7 +15,7 @@ template class QVector; class MainWindow; -class ZEITERFASSUNGLIBSHARED_EXPORT StripsWidget : public QWidget +class ZEITERFASSUNGGUILIBSHARED_EXPORT StripsWidget : public QWidget { Q_OBJECT @@ -75,7 +74,7 @@ private: QString buildProjectString(const QString &project) const; QWidget *appendBookingStartStrip(int id, const QTime &time); - QWidget *appendBookingEndStrip(int id, const QTime &time); + QWidget *appendBookingEndStrip(int id, const QTime &time, const QTime &duration); QWidget *appendTimeAssignmentStrip(int id, const QTime &duration, const QString &project, const QString &subproject, const QString &workpackage, const QString &text); @@ -103,5 +102,3 @@ private: std::unique_ptr m_getBookingsReply; std::unique_ptr m_getTimeAssignmentsReply; }; - -#endif // STRIPSWIDGET_H diff --git a/zeiterfassungguilib/translations/zeiterfassungguilib_de.ts b/zeiterfassungguilib/translations/zeiterfassungguilib_de.ts new file mode 100644 index 0000000..c069490 --- /dev/null +++ b/zeiterfassungguilib/translations/zeiterfassungguilib_de.ts @@ -0,0 +1,443 @@ + + + + + AuthenticationDialog + + + + Authentication + Authentifizierung + + + + Username: + Benutzername: + + + + Password: + Passwort: + + + + LanguageSelectionDialog + + + + Language selection + Sprachauswahl + + + + Please select a language: + Bitte wählen Sie eine Sprache: + + + + Language: + Sprache: + + + + English + Englisch + + + + German + Deutsch + + + + MainWindow + + + Previous day + Vorheriger Tag + + + + Next day + Nächster Tag + + + + Now + Jetzt + + + + + + Start + Kommen + + + + End + Gehen + + + + &File + &Datei + + + + &About + &Über + + + + &View + &Ansicht + + + + &Tools + &Werkzeuge + + + + &Quit + &Beenden + + + + About &Me + Über &mich + + + + About &zeiterfassung + Über &zeiterfassung + + + + About &Qt + Über &Qt + + + + &Today + &Heute + + + + &Refresh everything + Alles &neu laden + + + + &Settings + &Einstellungen + + + + Help + Hilfe + + + + Zeiterfassung - %0 (%1) + Zeiterfassung - %0 (%1) + + + + Subproject + Subprojekt + + + + Workpackage + Arbeitspaket + + + + Text + Text + + + + + Could not load bookings! + Konnte Buchungen nicht laden! + + + + + Could not create booking! + Konnte Buchung nicht erstellen! + + + + + Could not edit time assignment! + Konnte Kontierung nicht bearbeiten! + + + + + %0 (%1) + %0 (%1) + + + + Could not create time assignment! + Konnte Kontierung nicht erstellen! + + + + + Switch + Wechseln + + + + SettingsDialog + + + + Settings + Einstellungen + + + + Language: + Sprache: + + + + Theme: + Aussehen: + + + + English + Englisch + + + + German + Deutsch + + + + + + Invalid settings! + Ungültige Einstellungen! + + + + Unknown language! + Unbekannte Sprache! + + + + Default + Standard + + + + Unknown theme! + Unbekanntes Aussehen! + + + + Please fill all options with valid values! + Bitte füllen Sie alle Felder mit gültigen Werten! + + + + + Could not load theme! + Konnte Aussehen nicht laden! + + + + Theme file does not exist! + Aussehen-Datei existiert nicht! + + + + Restart required! + Neustart erforderlich! + + + + To apply the new settings a restart is required! + Um die neuen Einstellungen zu übernehmen, ist ein Neustart erforderlich! + + + + 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! + + + + + + 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 + + + diff --git a/zeiterfassungguilib/translations/zeiterfassungguilib_en.ts b/zeiterfassungguilib/translations/zeiterfassungguilib_en.ts new file mode 100644 index 0000000..77fe691 --- /dev/null +++ b/zeiterfassungguilib/translations/zeiterfassungguilib_en.ts @@ -0,0 +1,443 @@ + + + + + AuthenticationDialog + + + + Authentication + + + + + Username: + + + + + Password: + + + + + LanguageSelectionDialog + + + + Language selection + + + + + Please select a language: + + + + + Language: + + + + + English + + + + + German + + + + + MainWindow + + + Previous day + + + + + Next day + + + + + Now + + + + + + + Start + + + + + End + + + + + &File + + + + + &About + + + + + &View + + + + + &Tools + + + + + &Quit + + + + + About &Me + + + + + About &zeiterfassung + + + + + About &Qt + + + + + &Today + + + + + &Refresh everything + + + + + &Settings + + + + + Help + + + + + Zeiterfassung - %0 (%1) + + + + + Subproject + + + + + Workpackage + + + + + Text + + + + + + Could not load bookings! + + + + + + Could not create booking! + + + + + Could not create time assignment! + + + + + + Could not edit time assignment! + + + + + + Switch + + + + + + %0 (%1) + + + + + SettingsDialog + + + + Settings + + + + + Language: + + + + + Theme: + + + + + English + + + + + German + + + + + + + Invalid settings! + + + + + Unknown language! + + + + + Default + + + + + Unknown theme! + + + + + Please fill all options with valid values! + + + + + + Could not load theme! + + + + + Theme file does not exist! + + + + + Restart required! + + + + + To apply the new settings a restart is required! + + + + + StripsWidget + + + + + Loading... + + + + + Missing booking! + + + + + Expected start booking, instead got type %0 +Booking ID: %1 + + + + + + %0: %1 + + + + + Break + + + + + + + + %0h + + + + + + + + + + HH:mm + + + + + Missing time assignment! + + + + + + + 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 + + + + + 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 + + + + diff --git a/zeiterfassungguilib/zeiterfassungdialog.cpp b/zeiterfassungguilib/zeiterfassungdialog.cpp new file mode 100644 index 0000000..3b68510 --- /dev/null +++ b/zeiterfassungguilib/zeiterfassungdialog.cpp @@ -0,0 +1,13 @@ +#include "zeiterfassungdialog.h" + +#include + +ZeiterfassungDialog::ZeiterfassungDialog(QWidget *parent) : + QDialog(parent) +{ +#if (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)) + setWindowFlag(Qt::WindowContextHelpButtonHint, false); +#else + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); +#endif +} diff --git a/zeiterfassungguilib/zeiterfassungdialog.h b/zeiterfassungguilib/zeiterfassungdialog.h new file mode 100644 index 0000000..30132e0 --- /dev/null +++ b/zeiterfassungguilib/zeiterfassungdialog.h @@ -0,0 +1,13 @@ +#pragma once + +#include + +#include "zeiterfassungguilib_global.h" + +class ZEITERFASSUNGGUILIBSHARED_EXPORT ZeiterfassungDialog : public QDialog +{ + Q_OBJECT + +public: + explicit ZeiterfassungDialog(QWidget *parent = Q_NULLPTR); +}; diff --git a/zeiterfassungguilib/zeiterfassungguilib.pro b/zeiterfassungguilib/zeiterfassungguilib.pro new file mode 100644 index 0000000..a3e9a2d --- /dev/null +++ b/zeiterfassungguilib/zeiterfassungguilib.pro @@ -0,0 +1,49 @@ +QT += core network gui widgets uitools + +TARGET = zeiterfassungguilib +TEMPLATE = lib + +CONFIG += c++14 + +PROJECT_ROOT = .. + +DESTDIR = $${OUT_PWD}/$${PROJECT_ROOT}/bin + +LIBS += -L$$DESTDIR -lzeiterfassungcorelib + +INCLUDEPATH += $$PWD/$${PROJECT_ROOT}/zeiterfassungcorelib $$PWD/$${PROJECT_ROOT}/zeiterfassungguilib +DEPENDPATH += $$PWD/$${PROJECT_ROOT}/zeiterfassungcorelib $$PWD/$${PROJECT_ROOT}/zeiterfassungguilib + +DEFINES += QT_DEPRECATED_WARNINGS QT_DISABLE_DEPRECATED_BEFORE=0x060000 QT_MESSAGELOGCONTEXT +DEFINES += ZEITERFASSUNGGUILIB_LIBRARY + +SOURCES += mainwindow.cpp \ + stripfactory.cpp \ + stripswidget.cpp \ + zeiterfassungdialog.cpp \ + zeiterfassungplugin.cpp \ + dialogs/authenticationdialog.cpp \ + dialogs/languageselectiondialog.cpp \ + dialogs/settingsdialog.cpp + +HEADERS += mainwindow.h \ + stripfactory.h \ + stripswidget.h \ + zeiterfassungguilib_global.h \ + zeiterfassungdialog.h \ + zeiterfassungplugin.h \ + dialogs/authenticationdialog.h \ + dialogs/languageselectiondialog.h \ + dialogs/settingsdialog.h + +FORMS += mainwindow.ui \ + dialogs/settingsdialog.ui \ + dialogs/languageselectiondialog.ui \ + dialogs/authenticationdialog.ui + +RESOURCES += zeiterfassungguilib_resources.qrc + +TRANSLATIONS += translations/zeiterfassungguilib_en.ts \ + translations/zeiterfassungguilib_de.ts + +include($${PROJECT_ROOT}/lrelease.pri) diff --git a/zeiterfassungguilib/zeiterfassungguilib_global.h b/zeiterfassungguilib/zeiterfassungguilib_global.h new file mode 100644 index 0000000..3da52d5 --- /dev/null +++ b/zeiterfassungguilib/zeiterfassungguilib_global.h @@ -0,0 +1,9 @@ +#pragma once + +#include + +#if defined(ZEITERFASSUNGGUILIB_LIBRARY) +# define ZEITERFASSUNGGUILIBSHARED_EXPORT Q_DECL_EXPORT +#else +# define ZEITERFASSUNGGUILIBSHARED_EXPORT Q_DECL_IMPORT +#endif diff --git a/zeiterfassunglib/resources.qrc b/zeiterfassungguilib/zeiterfassungguilib_resources.qrc similarity index 85% rename from zeiterfassunglib/resources.qrc rename to zeiterfassungguilib/zeiterfassungguilib_resources.qrc index 252e452..2baf83f 100644 --- a/zeiterfassunglib/resources.qrc +++ b/zeiterfassungguilib/zeiterfassungguilib_resources.qrc @@ -1,5 +1,5 @@ - + images/about.png images/authentication.png images/help.png @@ -7,10 +7,10 @@ images/next.png images/now.png images/previous.png + images/qt.png images/quit.png images/refresh.png images/settings.png - images/splash.png images/today.png images/user.png diff --git a/zeiterfassunglib/zeiterfassungplugin.cpp b/zeiterfassungguilib/zeiterfassungplugin.cpp similarity index 100% rename from zeiterfassunglib/zeiterfassungplugin.cpp rename to zeiterfassungguilib/zeiterfassungplugin.cpp diff --git a/zeiterfassunglib/zeiterfassungplugin.h b/zeiterfassungguilib/zeiterfassungplugin.h similarity index 60% rename from zeiterfassunglib/zeiterfassungplugin.h rename to zeiterfassungguilib/zeiterfassungplugin.h index 1b170c0..ed50fb2 100644 --- a/zeiterfassunglib/zeiterfassungplugin.h +++ b/zeiterfassungguilib/zeiterfassungplugin.h @@ -1,14 +1,13 @@ -#ifndef ZEITERFASSUNGPLUGIN_H -#define ZEITERFASSUNGPLUGIN_H +#pragma once #include -#include "zeiterfassunglib_global.h" +#include "zeiterfassungguilib_global.h" class MainWindow; class StripsWidget; -class ZEITERFASSUNGLIBSHARED_EXPORT ZeiterfassungPlugin : public QObject +class ZEITERFASSUNGGUILIBSHARED_EXPORT ZeiterfassungPlugin : public QObject { Q_OBJECT @@ -19,5 +18,3 @@ public: }; Q_DECLARE_INTERFACE(ZeiterfassungPlugin, "dbsoftware.zeiterfassung.plugin/1.0") - -#endif // ZEITERFASSUNGPLUGIN_H diff --git a/zeiterfassunglib/dialogs/aboutmedialog.cpp b/zeiterfassunglib/dialogs/aboutmedialog.cpp deleted file mode 100644 index 338a67b..0000000 --- a/zeiterfassunglib/dialogs/aboutmedialog.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "aboutmedialog.h" -#include "ui_aboutmedialog.h" - -AboutMeDialog::AboutMeDialog(const GetUserInfoReply::UserInfo &userInfo, QWidget *parent) : - QDialog(parent), - ui(new Ui::AboutMeDialog) -{ - ui->setupUi(this); - - ui->spinBoxUserId->setValue(userInfo.userId); - ui->lineEditEmail->setText(userInfo.email); - ui->lineEditLongUsername->setText(userInfo.longUsername); - ui->lineEditText->setText(userInfo.text); - ui->lineEditUsername->setText(userInfo.username); -} - -AboutMeDialog::~AboutMeDialog() -{ - delete ui; -} diff --git a/zeiterfassunglib/dialogs/aboutmedialog.h b/zeiterfassunglib/dialogs/aboutmedialog.h deleted file mode 100644 index d33fbd4..0000000 --- a/zeiterfassunglib/dialogs/aboutmedialog.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef ABOUTMEDIALOG_H -#define ABOUTMEDIALOG_H - -#include - -#include "zeiterfassunglib_global.h" -#include "replies/getuserinforeply.h" - -namespace Ui { class AboutMeDialog; } - -class ZEITERFASSUNGLIBSHARED_EXPORT AboutMeDialog : public QDialog -{ - Q_OBJECT - -public: - explicit AboutMeDialog(const GetUserInfoReply::UserInfo &userInfo, QWidget *parent = Q_NULLPTR); - ~AboutMeDialog(); - -private: - Ui::AboutMeDialog *ui; -}; - -#endif // ABOUTMEDIALOG_H diff --git a/zeiterfassunglib/dialogs/aboutmedialog.ui b/zeiterfassunglib/dialogs/aboutmedialog.ui deleted file mode 100644 index 3564b77..0000000 --- a/zeiterfassunglib/dialogs/aboutmedialog.ui +++ /dev/null @@ -1,155 +0,0 @@ - - - AboutMeDialog - - - - 0 - 0 - 454 - 0 - - - - - 16777215 - 0 - - - - About me - - - - - - - 20 - - - - About me - - - - - - - - - User-ID: - - - spinBoxUserId - - - - - - - E-Mail: - - - lineEditEmail - - - - - - - Long username: - - - lineEditLongUsername - - - - - - - Text: - - - lineEditText - - - - - - - Username: - - - lineEditUsername - - - - - - - true - - - 16777215 - - - - - - - true - - - - - - - true - - - - - - - true - - - - - - - true - - - - - - - - - QDialogButtonBox::Close - - - - - - - - - buttonBox - rejected() - AboutMeDialog - close() - - - 226 - 5 - - - 226 - 0 - - - - - diff --git a/zeiterfassunglib/images/splash.png b/zeiterfassunglib/images/splash.png deleted file mode 100644 index cc66e5f..0000000 Binary files a/zeiterfassunglib/images/splash.png and /dev/null differ diff --git a/zeiterfassunglib/replies/createbookingreply.cpp b/zeiterfassunglib/replies/createbookingreply.cpp deleted file mode 100644 index 07cd2c3..0000000 --- a/zeiterfassunglib/replies/createbookingreply.cpp +++ /dev/null @@ -1,64 +0,0 @@ -#include "createbookingreply.h" - -#include -#include -#include -#include - -CreateBookingReply::CreateBookingReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung) : - ZeiterfassungReply(zeiterfassung), - m_reply(std::move(reply)), - m_bookingId(-1) -{ - connect(m_reply.get(), &QNetworkReply::finished, this, &CreateBookingReply::requestFinished); -} - -int CreateBookingReply::bookingId() const -{ - return m_bookingId; -} - -void CreateBookingReply::requestFinished() -{ - if(m_reply->error() != QNetworkReply::NoError) - { - setSuccess(false); - setMessage(tr("Request error occured: %0").arg(m_reply->error())); - goto end; - } - - { - QJsonParseError error; - QJsonDocument document = QJsonDocument::fromJson(m_reply->readAll(), &error); - if(error.error != QJsonParseError::NoError) - { - setSuccess(false); - setMessage(tr("Parsing JSON failed: %0").arg(error.errorString())); - goto end; - } - - if(!document.isObject()) - { - setSuccess(false); - setMessage(tr("JSON document is not an object!")); - goto end; - } - - auto obj = document.object(); - - if(!obj.contains(QStringLiteral("bookingNr"))) - { - setSuccess(false); - setMessage(tr("JSON does not contain bookingNr!")); - goto end; - } - - setSuccess(true); - m_bookingId = obj.value(QStringLiteral("bookingNr")).toInt(); - } - - end: - m_reply = Q_NULLPTR; - - Q_EMIT finished(); -} diff --git a/zeiterfassunglib/replies/createbookingreply.h b/zeiterfassunglib/replies/createbookingreply.h deleted file mode 100644 index 7111181..0000000 --- a/zeiterfassunglib/replies/createbookingreply.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef CREATEBOOKINGREPLY_H -#define CREATEBOOKINGREPLY_H - -#include - -#include - -#include "zeiterfassunglib_global.h" -#include "zeiterfassungreply.h" - -class ZEITERFASSUNGLIBSHARED_EXPORT CreateBookingReply : public ZeiterfassungReply -{ - Q_OBJECT - -public: - CreateBookingReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung); - - int bookingId() const; - -private Q_SLOTS: - void requestFinished(); - -private: - std::unique_ptr m_reply; - int m_bookingId; -}; - -#endif // CREATEBOOKINGREPLY_H diff --git a/zeiterfassunglib/replies/createtimeassignmentreply.h b/zeiterfassunglib/replies/createtimeassignmentreply.h deleted file mode 100644 index 0224410..0000000 --- a/zeiterfassunglib/replies/createtimeassignmentreply.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef CREATETIMEASSIGNMENTREPLY_H -#define CREATETIMEASSIGNMENTREPLY_H - -#include - -#include - -#include "zeiterfassunglib_global.h" -#include "zeiterfassungreply.h" - -class ZEITERFASSUNGLIBSHARED_EXPORT CreateTimeAssignmentReply : public ZeiterfassungReply -{ - Q_OBJECT - -public: - CreateTimeAssignmentReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung); - - int timeAssignmentId() const; - -private Q_SLOTS: - void requestFinished(); - -private: - std::unique_ptr m_reply; - int m_timeAssignmentId; -}; - -#endif // CREATETIMEASSIGNMENTREPLY_H diff --git a/zeiterfassunglib/replies/deletebookingreply.h b/zeiterfassunglib/replies/deletebookingreply.h deleted file mode 100644 index 6e701fa..0000000 --- a/zeiterfassunglib/replies/deletebookingreply.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef DELETEBOOKINGREPLY_H -#define DELETEBOOKINGREPLY_H - -#include - -#include - -#include "zeiterfassunglib_global.h" -#include "zeiterfassungreply.h" - -class ZEITERFASSUNGLIBSHARED_EXPORT DeleteBookingReply : public ZeiterfassungReply -{ - Q_OBJECT - -public: - DeleteBookingReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung); - -private Q_SLOTS: - void requestFinished(); - -private: - std::unique_ptr m_reply; -}; - -#endif // DELETEBOOKINGREPLY_H diff --git a/zeiterfassunglib/replies/deletetimeassignmentreply.h b/zeiterfassunglib/replies/deletetimeassignmentreply.h deleted file mode 100644 index ec7a4d0..0000000 --- a/zeiterfassunglib/replies/deletetimeassignmentreply.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef DELETETIMEASSIGNMENT_H -#define DELETETIMEASSIGNMENT_H - -#include - -#include - -#include "zeiterfassunglib_global.h" -#include "zeiterfassungreply.h" - -class ZEITERFASSUNGLIBSHARED_EXPORT DeleteTimeAssignmentReply : public ZeiterfassungReply -{ - Q_OBJECT - -public: - DeleteTimeAssignmentReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung); - -private Q_SLOTS: - void requestFinished(); - -private: - std::unique_ptr m_reply; -}; - -#endif // DELETETIMEASSIGNMENT_H diff --git a/zeiterfassunglib/replies/getuserinforeply.cpp b/zeiterfassunglib/replies/getuserinforeply.cpp deleted file mode 100644 index 73d751b..0000000 --- a/zeiterfassunglib/replies/getuserinforeply.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#include "getuserinforeply.h" - -#include -#include -#include -#include - -#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, &GetUserInfoReply::requestFinished); -} - -const GetUserInfoReply::UserInfo &GetUserInfoReply::userInfo() const -{ - return m_userInfo; -} - -void GetUserInfoReply::requestFinished() -{ - if(m_reply->error() != QNetworkReply::NoError) - { - setSuccess(false); - setMessage(tr("Request error occured: %0").arg(m_reply->error())); - goto end; - } - - { - QJsonParseError error; - auto document = QJsonDocument::fromJson(m_reply->readAll(), &error); - if(error.error != QJsonParseError::NoError) - { - setSuccess(false); - setMessage(tr("Parsing JSON failed: %0").arg(error.errorString())); - goto end; - } - - if(!document.isObject()) - { - setSuccess(false); - setMessage(tr("JSON document is not an object!")); - goto end; - } - - auto rootObj = document.object(); - - if(!rootObj.contains(QStringLiteral("evoAppsUser"))) - { - setSuccess(false); - setMessage(tr("JSON does not contain evoAppsUser!")); - goto end; - } - - auto evoAppsUser = rootObj.value(QStringLiteral("evoAppsUser")); - - if(!evoAppsUser.isObject()) - { - setSuccess(false); - setMessage(tr("evoAppsUser is not an object!")); - goto end; - } - - auto evoAppsUserObj = evoAppsUser.toObject(); - - setSuccess(true); - m_userInfo = { - evoAppsUserObj.value(QStringLiteral("persNr")).toInt(), - evoAppsUserObj.value(QStringLiteral("email")).toString(), - evoAppsUserObj.value(QStringLiteral("longUsername")).toString(), - evoAppsUserObj.value(QStringLiteral("text")).toString(), - evoAppsUserObj.value(QStringLiteral("username")).toString() - }; - } - - end: - m_reply = Q_NULLPTR; - - Q_EMIT finished(); -} diff --git a/zeiterfassunglib/replies/getuserinforeply.h b/zeiterfassunglib/replies/getuserinforeply.h deleted file mode 100644 index 30e2579..0000000 --- a/zeiterfassunglib/replies/getuserinforeply.h +++ /dev/null @@ -1,39 +0,0 @@ -#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/zeiterfassunglib/replies/loginpagereply.h b/zeiterfassunglib/replies/loginpagereply.h deleted file mode 100644 index daf0f44..0000000 --- a/zeiterfassunglib/replies/loginpagereply.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef LOGINPAGEREPLY_H -#define LOGINPAGEREPLY_H - -#include - -#include - -#include "zeiterfassunglib_global.h" -#include "zeiterfassungreply.h" - -class ZEITERFASSUNGLIBSHARED_EXPORT LoginPageReply : public ZeiterfassungReply -{ - Q_OBJECT - -public: - LoginPageReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung); - -private Q_SLOTS: - void requestFinished(); - -private: - std::unique_ptr m_reply; -}; - -#endif // LOGINPAGEREPLY_H diff --git a/zeiterfassunglib/replies/loginreply.h b/zeiterfassunglib/replies/loginreply.h deleted file mode 100644 index 2626d7a..0000000 --- a/zeiterfassunglib/replies/loginreply.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef LOGINREPLY_H -#define LOGINREPLY_H - -#include - -#include - -#include "zeiterfassunglib_global.h" -#include "zeiterfassungreply.h" - -class ZEITERFASSUNGLIBSHARED_EXPORT LoginReply : public ZeiterfassungReply -{ - Q_OBJECT - -public: - LoginReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung); - -private Q_SLOTS: - void requestFinished(); - -private: - std::unique_ptr m_reply; -}; - -#endif // LOGINREPLY_H diff --git a/zeiterfassunglib/replies/updatebookingreply.h b/zeiterfassunglib/replies/updatebookingreply.h deleted file mode 100644 index c948485..0000000 --- a/zeiterfassunglib/replies/updatebookingreply.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef UPDATEBOOKINGREPLY_H -#define UPDATEBOOKINGREPLY_H - -#include - -#include - -#include "zeiterfassunglib_global.h" -#include "zeiterfassungreply.h" - -class ZEITERFASSUNGLIBSHARED_EXPORT UpdateBookingReply : public ZeiterfassungReply -{ - Q_OBJECT - -public: - UpdateBookingReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung); - -private Q_SLOTS: - void requestFinished(); - -private: - std::unique_ptr m_reply; - int m_bookingId; -}; - -#endif // UPDATEBOOKINGREPLY_H diff --git a/zeiterfassunglib/replies/updatetimeassignmentreply.h b/zeiterfassunglib/replies/updatetimeassignmentreply.h deleted file mode 100644 index ea9977a..0000000 --- a/zeiterfassunglib/replies/updatetimeassignmentreply.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef UPDATETIMEASSIGNMENTREPLY_H -#define UPDATETIMEASSIGNMENTREPLY_H - -#include - -#include - -#include "zeiterfassunglib_global.h" -#include "zeiterfassungreply.h" - -class ZEITERFASSUNGLIBSHARED_EXPORT UpdateTimeAssignmentReply : public ZeiterfassungReply -{ - Q_OBJECT - -public: - UpdateTimeAssignmentReply(std::unique_ptr &&reply, ZeiterfassungApi *zeiterfassung); - - int timeAssignmentId() const; - -private Q_SLOTS: - void requestFinished(); - -private: - std::unique_ptr m_reply; - int m_timeAssignmentId; -}; - -#endif // UPDATETIMEASSIGNMENTREPLY_H diff --git a/zeiterfassunglib/timeutils.h b/zeiterfassunglib/timeutils.h deleted file mode 100644 index 0bc866a..0000000 --- a/zeiterfassunglib/timeutils.h +++ /dev/null @@ -1,13 +0,0 @@ -#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/zeiterfassunglib/translations/zeiterfassunglib_de.ts b/zeiterfassunglib/translations/zeiterfassunglib_de.ts deleted file mode 100644 index 873a88d..0000000 --- a/zeiterfassunglib/translations/zeiterfassunglib_de.ts +++ /dev/null @@ -1,752 +0,0 @@ - - - - - AboutMeDialog - - - - About me - Über mich - - - - User-ID: - Benutzer-ID: - - - - E-Mail: - E-Mail: - - - - Long username: - Langer Benutzername: - - - - Text: - Text: - - - - Username: - Benutzername: - - - - AuthenticationDialog - - - - Authentication - Authentifizierung - - - - Username: - Benutzername: - - - - Password: - Passwort: - - - - CreateBookingReply - - - Request error occured: %0 - - - - - Parsing JSON failed: %0 - - - - - JSON document is not an object! - - - - - JSON does not contain bookingNr! - - - - - CreateTimeAssignmentReply - - - Request error occured: %0 - - - - - Parsing JSON failed: %0 - - - - - JSON document is not an object! - - - - - JSON does not contain bookingNr! - - - - - DeleteBookingReply - - - Request error occured: %0 - - - - - DeleteTimeAssignmentReply - - - Request error occured: %0 - - - - - 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! - - - - - 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! - - - - - GetReportReply - - - - Request error occured: %0 - - - - - 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 - - - - Language selection - Sprachauswahl - - - - Please select a language: - Bitte wählen Sie eine Sprache: - - - - Language: - Sprache: - - - - English - Englisch - - - - German - Deutsch - - - - LoginPageReply - - - Request error occured: %0 - - - - - Could not find necessary keywords in login page! - - - - - LoginReply - - - Request error occured: %0 - - - - - Response did not contain a Location header. - - - - - Authentication failure. Please check username and password. - - - - - An unknown authentication failure occured. Redirected to: %0 - - - - - MainWindow - - - Previous day - Vorheriger Tag - - - - Next day - Nächster Tag - - - - Now - Jetzt - - - - - - Start - Kommen - - - - End - Gehen - - - - &File - &Datei - - - - &About - &Über - - - - &View - &Ansicht - - - - &Tools - &Werkzeuge - - - - &Quit - &Beenden - - - - About &Me - Über &mich - - - - About &zeiterfassung - Über &zeiterfassung - - - - About &Qt - Über &Qt - - - - &Today - &Heute - - - - &Refresh everything - Alles &neu laden - - - - &Settings - &Einstellungen - - - - Help - Hilfe - - - - Zeiterfassung - %0 (%1) - Zeiterfassung - %0 (%1) - - - - Subproject - Subprojekt - - - - Workpackage - Arbeitspaket - - - - Text - Text - - - - - Could not load bookings! - Konnte Buchungen nicht laden! - - - - - Could not create booking! - Konnte Buchung nicht erstellen! - - - - - Could not edit time assignment! - Konnte Kontierung nicht bearbeiten! - - - - - %0 (%1) - %0 (%1) - - - - Could not create time assignment! - Konnte Kontierung nicht erstellen! - - - - - Switch - Wechseln - - - - SettingsDialog - - - - Settings - Einstellungen - - - - Language: - Sprache: - - - - Theme: - Aussehen: - - - - English - Englisch - - - - German - Deutsch - - - - - - Invalid settings! - Ungültige Einstellungen! - - - - Unknown language! - Unbekannte Sprache! - - - - Default - Standard - - - - Unknown theme! - Unbekanntes Aussehen! - - - - Please fill all options with valid values! - Bitte füllen Sie alle Felder mit gültigen Werten! - - - - - Could not load theme! - Konnte Aussehen nicht laden! - - - - Theme file does not exist! - Aussehen-Datei existiert nicht! - - - - Restart required! - Neustart erforderlich! - - - - To apply the new settings a restart is required! - Um die neuen Einstellungen zu übernehmen, ist ein Neustart erforderlich! - - - - 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 - - - - UpdateBookingReply - - - Request error occured: %0 - - - - - Parsing JSON failed: %0 - - - - - JSON document is not an object! - - - - - JSON does not contain bookingNr! - - - - - UpdateTimeAssignmentReply - - - Request error occured: %0 - - - - - Parsing JSON failed: %0 - - - - - JSON document is not an object! - - - - - JSON does not contain bookingNr! - - - - diff --git a/zeiterfassunglib/translations/zeiterfassunglib_en.ts b/zeiterfassunglib/translations/zeiterfassunglib_en.ts deleted file mode 100644 index 2e4ce17..0000000 --- a/zeiterfassunglib/translations/zeiterfassunglib_en.ts +++ /dev/null @@ -1,752 +0,0 @@ - - - - - AboutMeDialog - - - - About me - - - - - User-ID: - - - - - E-Mail: - - - - - Long username: - - - - - Text: - - - - - Username: - - - - - AuthenticationDialog - - - - Authentication - - - - - Username: - - - - - Password: - - - - - CreateBookingReply - - - Request error occured: %0 - - - - - Parsing JSON failed: %0 - - - - - JSON document is not an object! - - - - - JSON does not contain bookingNr! - - - - - CreateTimeAssignmentReply - - - Request error occured: %0 - - - - - Parsing JSON failed: %0 - - - - - JSON document is not an object! - - - - - JSON does not contain bookingNr! - - - - - DeleteBookingReply - - - Request error occured: %0 - - - - - DeleteTimeAssignmentReply - - - Request error occured: %0 - - - - - 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! - - - - - 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! - - - - - GetReportReply - - - - Request error occured: %0 - - - - - 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 - - - - Language selection - - - - - Please select a language: - - - - - Language: - - - - - English - - - - - German - - - - - LoginPageReply - - - Request error occured: %0 - - - - - Could not find necessary keywords in login page! - - - - - LoginReply - - - Request error occured: %0 - - - - - Response did not contain a Location header. - - - - - Authentication failure. Please check username and password. - - - - - An unknown authentication failure occured. Redirected to: %0 - - - - - MainWindow - - - Previous day - - - - - Next day - - - - - Now - - - - - - - Start - - - - - End - - - - - &File - - - - - &About - - - - - &View - - - - - &Tools - - - - - &Quit - - - - - About &Me - - - - - About &zeiterfassung - - - - - About &Qt - - - - - &Today - - - - - &Refresh everything - - - - - &Settings - - - - - Help - - - - - Zeiterfassung - %0 (%1) - - - - - Subproject - - - - - Workpackage - - - - - Text - - - - - - Could not load bookings! - - - - - - Could not create booking! - - - - - Could not create time assignment! - - - - - - Could not edit time assignment! - - - - - - Switch - - - - - - %0 (%1) - - - - - SettingsDialog - - - - Settings - - - - - Language: - - - - - Theme: - - - - - English - - - - - German - - - - - - - Invalid settings! - - - - - Unknown language! - - - - - Default - - - - - Unknown theme! - - - - - Please fill all options with valid values! - - - - - - Could not load theme! - - - - - Theme file does not exist! - - - - - Restart required! - - - - - To apply the new settings a restart is required! - - - - - 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 - - - - - 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 - - - - - UpdateBookingReply - - - Request error occured: %0 - - - - - Parsing JSON failed: %0 - - - - - JSON document is not an object! - - - - - JSON does not contain bookingNr! - - - - - UpdateTimeAssignmentReply - - - Request error occured: %0 - - - - - Parsing JSON failed: %0 - - - - - JSON document is not an object! - - - - - JSON does not contain bookingNr! - - - - diff --git a/zeiterfassunglib/zeiterfassunglib_global.h b/zeiterfassunglib/zeiterfassunglib_global.h deleted file mode 100644 index bfb9534..0000000 --- a/zeiterfassunglib/zeiterfassunglib_global.h +++ /dev/null @@ -1,12 +0,0 @@ -#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