evert "Update"

This reverts commit c42edb9b6c.
This commit is contained in:
AJ
2024-07-09 00:14:27 +02:00
parent c42edb9b6c
commit b8512190b7
17 changed files with 751 additions and 42 deletions

View File

@@ -116,53 +116,30 @@ QMap<QPair<QString, QString>, QWidget*>* PlanGridController::getVeranstaltungen(
)")); )"));
container->setFixedSize(240, 100); container->setFixedSize(240, 100);
if (infoVector.at(8) == "4") { 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( planMap->insert(qMakePair(
weekdays[std::stoi(infoVector.at(0)) - 1], weekdays[std::stoi(infoVector.at(0)) - 1],
QString::fromStdString(infoVector.at(1).erase(5, 8))), QString::fromStdString(infoVector.at(1).erase(5, 8))),
container); 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; return planMap;

View File

@@ -0,0 +1,37 @@
#pragma once
#include <fstream>
#include <string>
#include <sstream>
#include <map>
inline static const std::map<std::string, std::string>& load_config( ) {
static std::map<std::string, std::string> 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;
}

View File

@@ -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( );
}

View File

@@ -0,0 +1,26 @@
#pragma once
#include <QDialog>
#include <QCheckBox>
#include <QPushButton>
#include <QLineEdit>
#include <QVBoxLayout>
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;
};

View File

@@ -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( );
}

View File

@@ -0,0 +1,28 @@
#pragma once
#include <QDialog>
#include <QLineEdit>
#include <QComboBox>
#include <QPushButton>
#include <QVBoxLayout>
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;
};

View File

@@ -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);
}

View File

@@ -0,0 +1,16 @@
#pragma once
#include <QDialog>
#include <QHBoxLayout>
#include <QPushButton>
#include <QLabel>
class Krankmelden : public QDialog {
Q_OBJECT
protected:
QPushButton* m_accept;
QPushButton* m_decline;
QLabel* m_text;
public:
Krankmelden(const QString& mitarbeiterName, QWidget* parent = nullptr);
};

View File

@@ -0,0 +1,47 @@
#pragma once
#include <QFrame>
#include <QLabel>
#include <QPushButton>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QMainWindow>
#include <QApplication>
#include <QMessageBox>
#include <QInputDialog>
#include <QCheckBox>
#include <QComboBox>
#include <QProcess>
#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( );
};

View File

@@ -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( ));
}

View File

@@ -0,0 +1,12 @@
# pragma once
# include <QMainWindow>
# 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);
};

View File

@@ -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( );
}

View File

@@ -0,0 +1,29 @@
#pragma once
#include <QFrame>
#include <QWidget>
#include <QPushButton>
#include <QInputDialog>
#include <QLabel>
#include <QVBoxLayout>
#include <QMessageBox>
#include <QMainWindow>
#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( );
};

View File

@@ -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( ));
}

View File

@@ -0,0 +1,14 @@
#pragma once
#include <QMainWindow>
#include "../LoginFrame/LoginFrame.hpp"
class LoginWindow : public QMainWindow {
Q_OBJECT
private:
LoginFrame* m_frame;
public:
LoginWindow(QWidget* parent = nullptr);
};

View File

@@ -0,0 +1,34 @@
#pragma once
#include <QGridLayout>
#include <QWidget>
#include <QLabel>
#include <QDateTime>
#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<QPair<QString, QString>, QWidget*>* planMap;
void KrankmeldenDialog( );
public:
PlanGrid(QWidget* parent = nullptr);
PlanGridController* planGridController;
void populateGrid( );
inline void setPlanMap(QMap<QPair<QString, QString>, QWidget*>* planMap) {
this->planMap = planMap;
}
};

10
src/main.cpp Normal file
View File

@@ -0,0 +1,10 @@
#include <QApplication>
#include "View/LoginWindow/LoginWindow.hpp"
int main(int argc, char* argv[]) {
QApplication app(argc, argv);
LoginWindow* loginWindow = new LoginWindow( );
loginWindow->show( );
return app.exec( );
}