From b8512190b763dedab8b12d7d684240dd2a662bc9 Mon Sep 17 00:00:00 2001 From: AJ Date: Tue, 9 Jul 2024 00:14:27 +0200 Subject: [PATCH] evert "Update" This reverts commit c42edb9b6c585848a94c6e20f5ae11ab03582f3e. --- .../PlanGridController/PlanGridController.cpp | 61 +++----- src/Core/config/config.hpp | 37 +++++ .../Dialogs/CreateMember/CreateMember.cpp | 137 +++++++++++++++++ .../Dialogs/CreateMember/CreateMember.hpp | 26 ++++ .../CreateVeranstaltung.cpp | 141 ++++++++++++++++++ .../CreateVeranstaltung.hpp | 28 ++++ .../Dialogs/Krankmelden/Krankmelden.cpp | 62 ++++++++ .../Dialogs/Krankmelden/Krankmelden.hpp | 16 ++ .../EinsatzplanFrame/EinsatzplanFrame.hpp | 47 ++++++ .../EinsatzplanWindow/EinsatzplanWindow.cpp | 8 + .../EinsatzplanWindow/EinsatzplanWindow.hpp | 12 ++ src/View/LoginFrame/LoginFrame.cpp | 123 +++++++++++++++ src/View/LoginFrame/LoginFrame.hpp | 29 ++++ src/View/LoginWindow/LoginWindow.cpp | 8 + src/View/LoginWindow/LoginWindow.hpp | 14 ++ src/View/PlanGrid/PlanGrid.hpp | 34 +++++ src/main.cpp | 10 ++ 17 files changed, 751 insertions(+), 42 deletions(-) create mode 100644 src/Core/config/config.hpp create mode 100644 src/View/EinsatzplanFrame/Dialogs/CreateMember/CreateMember.cpp create mode 100644 src/View/EinsatzplanFrame/Dialogs/CreateMember/CreateMember.hpp create mode 100644 src/View/EinsatzplanFrame/Dialogs/CreateVeranstaltung/CreateVeranstaltung.cpp create mode 100644 src/View/EinsatzplanFrame/Dialogs/CreateVeranstaltung/CreateVeranstaltung.hpp create mode 100644 src/View/EinsatzplanFrame/Dialogs/Krankmelden/Krankmelden.cpp create mode 100644 src/View/EinsatzplanFrame/Dialogs/Krankmelden/Krankmelden.hpp create mode 100644 src/View/EinsatzplanFrame/EinsatzplanFrame.hpp create mode 100644 src/View/EinsatzplanWindow/EinsatzplanWindow.cpp create mode 100644 src/View/EinsatzplanWindow/EinsatzplanWindow.hpp create mode 100644 src/View/LoginFrame/LoginFrame.cpp create mode 100644 src/View/LoginFrame/LoginFrame.hpp create mode 100644 src/View/LoginWindow/LoginWindow.cpp create mode 100644 src/View/LoginWindow/LoginWindow.hpp create mode 100644 src/View/PlanGrid/PlanGrid.hpp create mode 100644 src/main.cpp diff --git a/src/Controller/PlanGridController/PlanGridController.cpp b/src/Controller/PlanGridController/PlanGridController.cpp index d9b675d..01957d5 100644 --- a/src/Controller/PlanGridController/PlanGridController.cpp +++ b/src/Controller/PlanGridController/PlanGridController.cpp @@ -116,53 +116,30 @@ QMap, QWidget*>* PlanGridController::getVeranstaltungen( )")); container->setFixedSize(240, 100); - if (infoVector.at(8) == "4") { - QFrame* container2 = new QFrame( ); - - container2->setObjectName("container2"); - container2->setStyleSheet(R"( - #container2{ - background-color: #313131; - } - )"); - auto layout2 = new QVBoxLayout(container2); - container2->setLayout(layout2); - - QPushButton* widget2 = new QPushButton(QString::fromStdString(infoVector.at(4) + " - " + infoVector.at(5) + "\n" + infoVector.at(3) + infoVector.at(6))); - layout2->addWidget(widget2); - widget2->setProperty("MitarbeiterName", QString::fromStdString(infoVector.at(5))); - widget2->setProperty("MitarbeiterID", QString::fromStdString(infoVector.at(7))); - widget2->setObjectName("eintragung2"); - widget2->setFixedSize(210, 70); - widget2->setToolTip(QString::fromStdString(infoVector.at(7))); - widget2->setCursor(Qt::PointingHandCursor); - layout2->setAlignment(Qt::AlignCenter); - - widget2->setStyleSheet(QString::fromStdString(R"( - #eintragung2{ - border: 0px solid #313131; - background-color: )" + color + R"(; - color: #212121; - font-weight: 900; - font-size: 18px; - border-radius: 8px; - } - )")); - - container2->setFixedSize(240, 100); - - planMap->insert(qMakePair( - weekdays[std::stoi(infoVector.at(0)) - 1], - QString::fromStdString(infoVector.at(2).erase(5, 8))), - container2); - } - planMap->insert(qMakePair( weekdays[std::stoi(infoVector.at(0)) - 1], QString::fromStdString(infoVector.at(1).erase(5, 8))), container); - + + std::string originalString = infoVector.at(1); + if (originalString.length( ) >= 2) { + char secondChar = originalString[1]; + secondChar += 2; + originalString[1] = secondChar; + } + + planMap->insert(qMakePair( + weekdays[std::stoi(infoVector.at(0)) - 1], + QString::fromStdString(originalString)), + container); + } else { + + planMap->insert(qMakePair( + weekdays[std::stoi(infoVector.at(0)) - 1], + QString::fromStdString(infoVector.at(1).erase(5, 8))), + container); + } } return planMap; diff --git a/src/Core/config/config.hpp b/src/Core/config/config.hpp new file mode 100644 index 0000000..d833151 --- /dev/null +++ b/src/Core/config/config.hpp @@ -0,0 +1,37 @@ +#pragma once + +#include +#include +#include +#include + +inline static const std::map& load_config( ) { + static std::map config; + static bool is_loaded{ false }; + static std::string fn{ "" }; + +#if defined(_WIN32) || defined(_WIN64) + std::string filename = std::string(std::getenv("USER")) + "\\config.cfg"; +#elif defined(__unix__) || defined(__APPLE__) + std::string filename = std::string(std::getenv("HOME")) + "/Dokumente/git/EinsatzplanQT/config.cfg"; +#endif + + if (!is_loaded || fn != filename) { + std::ifstream file(filename); + std::string line; + + while (std::getline(file, line)) { + std::istringstream line_stream(line); + std::string key; + if (std::getline(line_stream, key, '=')) { + std::string value; + if (std::getline(line_stream, value)) + config[key] = value; + } + } + + is_loaded = true; + fn = filename; + } + return config; +} diff --git a/src/View/EinsatzplanFrame/Dialogs/CreateMember/CreateMember.cpp b/src/View/EinsatzplanFrame/Dialogs/CreateMember/CreateMember.cpp new file mode 100644 index 0000000..f53fa09 --- /dev/null +++ b/src/View/EinsatzplanFrame/Dialogs/CreateMember/CreateMember.cpp @@ -0,0 +1,137 @@ +#include "CreateMember.hpp" + +CreateMemDialog::CreateMemDialog(QWidget* parent) + :QDialog(parent) { + setWindowTitle("Mitarbeiter Hinzufügen"); + setFixedSize(300, 400); + setObjectName("CreateMemDialog"); + setStyleSheet(R"( + #CreateMemDialog{ + background-color: #212121; + border: none; + } + )"); + + m_name = new QLineEdit(this); + m_name->setPlaceholderText("Name"); + m_name->setFixedSize(220, 40); + m_name->setObjectName("name"); + m_name->setStyleSheet(R"( + #name{ + color: #DADADA; + font-size: 16px; + background-color: #313131; + border-radius: 10px; + padding: 5px; + border: 2px solid #414141; + } + )"); + m_name->show( ); + + + m_email = new QLineEdit(this); + m_email->setPlaceholderText("Email"); + m_email->setFixedSize(220, 40); + m_email->setObjectName("email"); + m_email->setStyleSheet(R"( + #email{ + color: #DADADA; + font-size: 16px; + background-color: #313131; + border-radius: 10px; + padding: 5px; + border: 2px solid #414141; + } + )"); + m_email->show( ); + + m_password = new QLineEdit(this); + m_password->setPlaceholderText("Passwort"); + m_password->setEchoMode(QLineEdit::Password); + m_password->setFixedSize(220, 40); + m_password->setObjectName("password"); + m_password->setStyleSheet(R"( + #password{ + color: #DADADA; + font-size: 16px; + background-color: #313131; + border-radius: 10px; + padding: 5px; + border: 2px solid #414141; + } + )"); + m_password->show( ); + + m_admin = new QCheckBox("Admin", this); + m_admin->setFixedSize(220, 40); + m_admin->setObjectName("admin"); + m_admin->setStyleSheet(R"( + #admin{ + color: #DADADA; + font-size: 20px; + border: none; + } + )"); + m_admin->show( ); + + QVBoxLayout* layout = new QVBoxLayout(this); + + layout->setContentsMargins(30, 30, 30, 30); + + layout->addWidget(m_name, 1, Qt::AlignCenter); + layout->addWidget(m_email, 1, Qt::AlignCenter); + layout->addWidget(m_password, 1, Qt::AlignCenter); + layout->addWidget(m_admin, 1, Qt::AlignCenter); + + QHBoxLayout* buttonLayout = new QHBoxLayout( ); + + m_okButton = new QPushButton("OK", this); + m_okButton->setFixedSize(110, 40); + m_okButton->setObjectName("okButton"); + m_okButton->setStyleSheet(R"( + #okButton{ + color: #212121; + font-size: 16px; + font-weight: bold; + background-color: #A5D6A7; + border-radius: 10px; + } + )"); + + m_cancelButton = new QPushButton("Abbrechen", this); + m_cancelButton->setFixedSize(110, 40); + m_cancelButton->setObjectName("cancelButton"); + m_cancelButton->setStyleSheet(R"( + #cancelButton{ + color: #212121; + font-size: 16px; + font-weight: bold; + background-color: #EF9A9A; + border-radius: 10px; + } + )"); + + buttonLayout->addWidget(m_okButton, 1, Qt::AlignCenter); + buttonLayout->addWidget(m_cancelButton, 1, Qt::AlignCenter); + + layout->addLayout(buttonLayout); + + connect(m_okButton, &QPushButton::clicked, this, &QDialog::accept); + connect(m_cancelButton, &QPushButton::clicked, this, &QDialog::reject); +} + +QString CreateMemDialog::getName( ) const { + return m_name->text( ); +} + +QString CreateMemDialog::getEmail( ) const { + return m_email->text( ); +} + +QString CreateMemDialog::getPassword( ) const { + return m_password->text( ); +} + +bool CreateMemDialog::isAdmin( ) const { + return m_admin->isChecked( ); +} diff --git a/src/View/EinsatzplanFrame/Dialogs/CreateMember/CreateMember.hpp b/src/View/EinsatzplanFrame/Dialogs/CreateMember/CreateMember.hpp new file mode 100644 index 0000000..182f836 --- /dev/null +++ b/src/View/EinsatzplanFrame/Dialogs/CreateMember/CreateMember.hpp @@ -0,0 +1,26 @@ +#pragma once + +#include +#include +#include +#include +#include + +class CreateMemDialog : public QDialog { + Q_OBJECT +protected: + QLineEdit* m_name; + QLineEdit* m_email; + QLineEdit* m_password; + QCheckBox* m_admin; + QPushButton* m_okButton; + QPushButton* m_cancelButton; + +public: + CreateMemDialog(QWidget* parent = nullptr); + + QString getName( ) const; + QString getEmail( ) const; + QString getPassword( ) const; + bool isAdmin( ) const; +}; diff --git a/src/View/EinsatzplanFrame/Dialogs/CreateVeranstaltung/CreateVeranstaltung.cpp b/src/View/EinsatzplanFrame/Dialogs/CreateVeranstaltung/CreateVeranstaltung.cpp new file mode 100644 index 0000000..2a7a143 --- /dev/null +++ b/src/View/EinsatzplanFrame/Dialogs/CreateVeranstaltung/CreateVeranstaltung.cpp @@ -0,0 +1,141 @@ +#include "CreateVeranstaltung.hpp" + +CreateVerDialog::CreateVerDialog(QWidget* parent) + : QDialog(parent) { + setWindowTitle("Veranstaltung Hinzufügen"); + setFixedSize(300, 400); + setObjectName("createMemDialog"); + setStyleSheet(R"( + #createMemDialog{ + background-color: #212121; + border: none; + } + )"); + + QVBoxLayout* layout = new QVBoxLayout(this); + layout->setContentsMargins(30, 30, 30, 30); + + m_name = new QLineEdit(this); + m_name->setPlaceholderText("Veranstaltungskürzel"); + m_name->setFixedSize(220, 40); + m_name->setObjectName("name"); + m_name->setStyleSheet(R"( + #name{ + color: #DADADA; + font-size: 16px; + background-color: #313131; + border-radius: 10px; + padding: 5px; + border: 2px solid #414141; + } + )"); + layout->addWidget(m_name, 1, Qt::AlignCenter); + + m_raum = new QLineEdit(this); + m_raum->setPlaceholderText("Raum"); + m_raum->setFixedSize(220, 40); + m_raum->setObjectName("raum"); + m_raum->setStyleSheet(R"( + #raum{ + color: #DADADA; + font-size: 16px; + background-color: #313131; + border-radius: 10px; + padding: 5px; + border: 2px solid #414141; + } + )"); + layout->addWidget(m_raum, 1, Qt::AlignCenter); + + m_campus = new QComboBox(this); + m_campus->addItem("Campus A"); + m_campus->addItem("Campus B"); + m_campus->setFixedSize(220, 40); + m_campus->setObjectName("campus"); + m_campus->setStyleSheet(R"( + #campus{ + color: #DADADA; + font-size: 16px; + background-color: #313131; + border-radius: 10px; + padding: 5px; + } + #campus::Item{ + color: #DADADA; + background-color: #313131; + } + )"); + layout->addWidget(m_campus, 1, Qt::AlignCenter); + + m_time = new QComboBox(this); + m_time->addItem("2h"); + m_time->addItem("4h"); + m_time->setFixedSize(220, 40); + m_time->setObjectName("time"); + m_time->setStyleSheet(R"( + #time{ + color: #DADADA; + font-size: 16px; + background-color: #313131; + border-radius: 10px; + padding: 5px; + } + #time::Item{ + color: #DADADA; + background-color: #313131; + } + )"); + layout->addWidget(m_time, 1, Qt::AlignCenter); + + QHBoxLayout* buttonLayout = new QHBoxLayout( ); + + m_okButton = new QPushButton("OK", this); + m_okButton->setFixedSize(110, 40); + m_okButton->setObjectName("okButton"); + m_okButton->setStyleSheet(R"( + #okButton{ + color: #212121; + font-size: 16px; + font-weight: bold; + background-color: #53EC87; + border-radius: 10px; + } + )"); + + m_cancelButton = new QPushButton("Abbrechen", this); + m_cancelButton->setFixedSize(110, 40); + m_cancelButton->setObjectName("cancelButton"); + m_cancelButton->setStyleSheet(R"( + #cancelButton{ + color: #212121; + font-size: 16px; + font-weight: bold; + background-color: #FF5555; + border-radius: 10px; + } + )"); + + buttonLayout->addWidget(m_okButton, 1, Qt::AlignCenter); + buttonLayout->addWidget(m_cancelButton, 1, Qt::AlignCenter); + + layout->addLayout(buttonLayout, 1); + + connect(m_okButton, &QPushButton::clicked, this, &QDialog::accept); + connect(m_cancelButton, &QPushButton::clicked, this, &QDialog::reject); +} + +QString CreateVerDialog::getName( ) const { + return m_name->text( ); +} + +QString CreateVerDialog::getRaum( ) const { + return m_raum->text( ); +} + +QString CreateVerDialog::getCampus( ) const { + return m_campus->currentText( ); +} + +QString CreateVerDialog::getTime( ) const { + return m_time->currentText( ); +} diff --git a/src/View/EinsatzplanFrame/Dialogs/CreateVeranstaltung/CreateVeranstaltung.hpp b/src/View/EinsatzplanFrame/Dialogs/CreateVeranstaltung/CreateVeranstaltung.hpp new file mode 100644 index 0000000..50e666a --- /dev/null +++ b/src/View/EinsatzplanFrame/Dialogs/CreateVeranstaltung/CreateVeranstaltung.hpp @@ -0,0 +1,28 @@ +#pragma once + +#include +#include +#include +#include +#include + +class CreateVerDialog : public QDialog { + Q_OBJECT +protected: + QLineEdit* m_name; + QLineEdit* m_raum; + + QComboBox* m_campus; + QComboBox* m_time; + + QPushButton* m_okButton; + QPushButton* m_cancelButton; + +public: + CreateVerDialog(QWidget* parent = nullptr); + + QString getName( ) const; + QString getRaum( ) const; + QString getCampus( ) const; + QString getTime( ) const; +}; diff --git a/src/View/EinsatzplanFrame/Dialogs/Krankmelden/Krankmelden.cpp b/src/View/EinsatzplanFrame/Dialogs/Krankmelden/Krankmelden.cpp new file mode 100644 index 0000000..3442058 --- /dev/null +++ b/src/View/EinsatzplanFrame/Dialogs/Krankmelden/Krankmelden.cpp @@ -0,0 +1,62 @@ +#include "Krankmelden.hpp" + +Krankmelden::Krankmelden(const QString& mitarbeiterName, QWidget* parent) : + QDialog(parent), + m_text(new QLabel(QString::fromStdString(mitarbeiterName.toStdString( ) + " krankmelden?"))) { + setWindowTitle("Mitarbeiter Krankmelden?"); + setFixedSize(350, 150); + setObjectName("Krankmelden"); + setStyleSheet(R"( + #Krankmelden{ + background-color: #212121; + border: none; + } + )"); + + m_accept = new QPushButton("Ja", this); + m_accept->setFixedSize(110, 40); + m_accept->setObjectName("acceptButton"); + m_accept->setStyleSheet(R"( + #acceptButton{ + color: #212121; + font-size: 16px; + font-weight: bold; + background-color: #A5D6A7; + border-radius: 10px; + } + )"); + m_decline = new QPushButton("Nein", this); + m_decline->setFixedSize(110, 40); + m_decline->setObjectName("declineButton"); + m_decline->setStyleSheet(R"( + #declineButton{ + color: #212121; + font-size: 16px; + font-weight: bold; + background-color: #EF9A9A; + border-radius: 10px; + } + )"); + + m_text->setObjectName("mitarbeiterName"); + m_text->setStyleSheet(R"( + #mitarbeiterName{ + background-color: none; + border:none; + color: #D8D8D8; + font-size:18px; + } + )"); + + QVBoxLayout* mainLayout = new QVBoxLayout(this); + mainLayout->addWidget(m_text, 0, Qt::AlignCenter); + + QHBoxLayout* layout = new QHBoxLayout( ); + mainLayout->addLayout(layout, 1); + + layout->addWidget(m_accept, 1, Qt::AlignCenter); + layout->addWidget(m_decline, 1, Qt::AlignCenter); + + connect(m_accept, &QPushButton::clicked, this, &QDialog::accept); + connect(m_decline, &QPushButton::clicked, this, &QDialog::reject); +} diff --git a/src/View/EinsatzplanFrame/Dialogs/Krankmelden/Krankmelden.hpp b/src/View/EinsatzplanFrame/Dialogs/Krankmelden/Krankmelden.hpp new file mode 100644 index 0000000..b747b5a --- /dev/null +++ b/src/View/EinsatzplanFrame/Dialogs/Krankmelden/Krankmelden.hpp @@ -0,0 +1,16 @@ +#pragma once + +#include +#include +#include +#include + +class Krankmelden : public QDialog { + Q_OBJECT +protected: + QPushButton* m_accept; + QPushButton* m_decline; + QLabel* m_text; +public: + Krankmelden(const QString& mitarbeiterName, QWidget* parent = nullptr); +}; diff --git a/src/View/EinsatzplanFrame/EinsatzplanFrame.hpp b/src/View/EinsatzplanFrame/EinsatzplanFrame.hpp new file mode 100644 index 0000000..3c93a4a --- /dev/null +++ b/src/View/EinsatzplanFrame/EinsatzplanFrame.hpp @@ -0,0 +1,47 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../PlanGrid/PlanGrid.hpp" +#include "../../Controller/EinsatzplanFrameController/EinsatzplanFrameController.hpp" +#include "Dialogs/CreateMember/CreateMember.hpp" +#include "Dialogs/CreateVeranstaltung/CreateVeranstaltung.hpp" + +class EinsatzplanFrame : public QFrame { + Q_OBJECT +protected: + EinsatzplanFrameController* m_controller; + + QLabel* m_profileImg; + QLabel* m_id; + QLabel* m_einsatzplanLabel; + + PlanGrid* m_planGrid; + + QPushButton* m_abmeldenButton; + QPushButton* m_createMemberButton; + QPushButton* m_deleteMemberButton; + QPushButton* m_createVeranstaltungButton; + QPushButton* m_deleteVeranstaltungButton; + +public: + EinsatzplanFrame(QWidget* parent = nullptr, QString id = "0000000", bool admin = true); + +private slots: + void abmelden( ); + void deleteVeranstaltung( ); + void createVeranstaltung( ); + void deleteMember( ); + void createMember( ); +}; diff --git a/src/View/EinsatzplanWindow/EinsatzplanWindow.cpp b/src/View/EinsatzplanWindow/EinsatzplanWindow.cpp new file mode 100644 index 0000000..f4296a9 --- /dev/null +++ b/src/View/EinsatzplanWindow/EinsatzplanWindow.cpp @@ -0,0 +1,8 @@ +#include "EinsatzplanWindow.hpp" + +EinsatzplanWindow::EinsatzplanWindow(QWidget* parent, QString id, bool admin) + :QMainWindow(parent) { + m_frame = new EinsatzplanFrame(this, id, admin); + setFixedSize(1400, 800); + m_frame->setFixedSize(size( )); +} diff --git a/src/View/EinsatzplanWindow/EinsatzplanWindow.hpp b/src/View/EinsatzplanWindow/EinsatzplanWindow.hpp new file mode 100644 index 0000000..0e88b96 --- /dev/null +++ b/src/View/EinsatzplanWindow/EinsatzplanWindow.hpp @@ -0,0 +1,12 @@ +# pragma once +# include +# include "../EinsatzplanFrame/EinsatzplanFrame.hpp" + +class EinsatzplanWindow : public QMainWindow { + Q_OBJECT +private: + EinsatzplanFrame* m_frame; + +public: + EinsatzplanWindow(QWidget* parent = nullptr, QString id = "0000000", bool admin = true); +}; diff --git a/src/View/LoginFrame/LoginFrame.cpp b/src/View/LoginFrame/LoginFrame.cpp new file mode 100644 index 0000000..cf5e46b --- /dev/null +++ b/src/View/LoginFrame/LoginFrame.cpp @@ -0,0 +1,123 @@ +#include "LoginFrame.hpp" + +LoginFrame::LoginFrame(QWidget* parent) + :QFrame(parent) { + //configure LoginFrame + setObjectName("LoginFrame"); + setStyleSheet(R"( + #LoginFrame{ + background-color: #212121; + border: none; + } + )"); + setFrameStyle(QFrame::Box); + + //create QWidgets and add LoginFrame as parent + m_header = new QLabel("Einsatzplan", this); + m_header->setFrameStyle(QFrame::Box); + m_header->setObjectName("Header"); + m_header->setStyleSheet(R"( + #Header{ + color: #93F8FF; + font-size: 36px; + font-weight: bold; + border: none; + } + )"); + m_header->show( ); + + m_id = new QLineEdit(this); + m_id->setPlaceholderText("ID..."); + m_id->setObjectName("ID"); + m_id->setFixedSize(300, 40); + m_id->setStyleSheet(R"( + #ID{ + color: #DADADA; + font-size: 16px; + background-color: #313131; + border-radius: 10px; + padding: 5px; + border: 2px solid #414141; + } + )"); + m_id->show( ); + + m_password = new QLineEdit(this); + m_password->setPlaceholderText("Passwort..."); + m_password->setObjectName("Password"); + m_password->setEchoMode(QLineEdit::Password); + m_password->setFixedSize(300, 40); + m_password->setStyleSheet(R"( + #Password{ + color: #DADADA; + font-size: 16px; + background-color: #313131; + border-radius: 10px; + padding: 5px; + border: 2px solid #414141; + } + )"); + m_password->show( ); + + m_loginButton = new QPushButton("Login", this); + m_loginButton->setObjectName("loginButton"); + m_loginButton->setFixedSize(QSize(150, 50)); + m_loginButton->setStyleSheet(R"( + #loginButton{ + color: #212121; + font-size: 24px; + font-weight: bold; + background-color: #53EC87; + border-radius: 10px; + } + #loginButton:pressed { + background-color: #43DC77; + } + )"); + m_loginButton->show( ); + + //create layout + QVBoxLayout* layout = new QVBoxLayout( ); + + //layout->setContentsMargins(50, 20, 50, 20); + layout->addWidget(m_header, 3, Qt::AlignCenter); + layout->addWidget(m_id, 1, Qt::AlignCenter); + layout->addWidget(m_password, 1, Qt::AlignCenter); + layout->addWidget(m_loginButton, 3, Qt::AlignCenter); + + //add Layout to LoginFrame + setLayout(layout); + + //connect loginButton with function + connect(m_loginButton, &QPushButton::clicked, this, &LoginFrame::loginButtonClicked); +} + +//try Login if Button clicked +void LoginFrame::loginButtonClicked( ) { + QString id = m_id->text( ); + QString password = m_password->text( ); + + //check if Contents Valid + if (id.isEmpty( ) || password.isEmpty( )) { + QMessageBox::warning(this, "Error", "Bitte füllen Sie sowohl die ID als auch das Passwort aus."); + } else { + LoginFrameController* controller = new LoginFrameController( ); + int res = controller->tryLogin(id, password); + if (res == -1) { + QMessageBox::warning(this, "Error", "ID und Passwort stimmen nicht überein!"); + } else { + ((QWidget*)(this->parent( )))->hide( ); + EinsatzplanWindow* win = new EinsatzplanWindow(nullptr, id, res); + win->show( ); + return; + } + } +} + +LoginFrame::~LoginFrame( ) { + m_header->~QLabel( ); + m_id->~QLineEdit( ); + m_password->~QLineEdit( ); + m_loginButton->~QPushButton( ); + m_parent->~QMainWindow( ); +} diff --git a/src/View/LoginFrame/LoginFrame.hpp b/src/View/LoginFrame/LoginFrame.hpp new file mode 100644 index 0000000..7c339c6 --- /dev/null +++ b/src/View/LoginFrame/LoginFrame.hpp @@ -0,0 +1,29 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../../Controller/LoginFrameController/LoginFrameController.hpp" +#include "../../View/EinsatzplanWindow/EinsatzplanWindow.hpp" + +class LoginFrame : public QFrame { + Q_OBJECT +protected: + QMainWindow* m_parent; + QLabel* m_header; + QLineEdit* m_id; + QLineEdit* m_password; + QPushButton* m_loginButton; + + void loginButtonClicked( ); + +public: + LoginFrame(QWidget* parent = nullptr); + ~LoginFrame( ); +}; diff --git a/src/View/LoginWindow/LoginWindow.cpp b/src/View/LoginWindow/LoginWindow.cpp new file mode 100644 index 0000000..a649dff --- /dev/null +++ b/src/View/LoginWindow/LoginWindow.cpp @@ -0,0 +1,8 @@ +#include "LoginWindow.hpp" + +LoginWindow::LoginWindow(QWidget* parent) + :QMainWindow(parent) { + m_frame = new LoginFrame(this); + setFixedSize(400, 550); + m_frame->setFixedSize(size( )); +} diff --git a/src/View/LoginWindow/LoginWindow.hpp b/src/View/LoginWindow/LoginWindow.hpp new file mode 100644 index 0000000..3fc2003 --- /dev/null +++ b/src/View/LoginWindow/LoginWindow.hpp @@ -0,0 +1,14 @@ +#pragma once + +#include + +#include "../LoginFrame/LoginFrame.hpp" + +class LoginWindow : public QMainWindow { + Q_OBJECT +private: + LoginFrame* m_frame; + +public: + LoginWindow(QWidget* parent = nullptr); +}; diff --git a/src/View/PlanGrid/PlanGrid.hpp b/src/View/PlanGrid/PlanGrid.hpp new file mode 100644 index 0000000..cdde752 --- /dev/null +++ b/src/View/PlanGrid/PlanGrid.hpp @@ -0,0 +1,34 @@ +#pragma once + +#include +#include +#include +#include + +#include "../../Controller/PlanGridController/PlanGridController.hpp" +#include "../EinsatzplanFrame/Dialogs/Krankmelden/Krankmelden.hpp" +#include "../EinsatzplanFrame/Dialogs/CreateMember/CreateMember.hpp" + +class PlanGrid : public QWidget { + Q_OBJECT +private: + QString m_weekdays[5]; + QString m_times[6]; + +protected: + QGridLayout* gridLayout; + QMap, QWidget*>* planMap; + + void KrankmeldenDialog( ); + +public: + PlanGrid(QWidget* parent = nullptr); + + PlanGridController* planGridController; + + void populateGrid( ); + + inline void setPlanMap(QMap, QWidget*>* planMap) { + this->planMap = planMap; + } +}; diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..2b8750c --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,10 @@ +#include + +#include "View/LoginWindow/LoginWindow.hpp" + +int main(int argc, char* argv[]) { + QApplication app(argc, argv); + LoginWindow* loginWindow = new LoginWindow( ); + loginWindow->show( ); + return app.exec( ); +}