diff --git a/.gitignore b/.gitignore index 22fd58a..188f5c9 100644 --- a/.gitignore +++ b/.gitignore @@ -55,4 +55,4 @@ compile_commands.json build debug -config.cfg +config.cfg \ No newline at end of file diff --git a/src/Controller/LoginFrameController/LoginFrameController.cpp b/src/Controller/LoginFrameController/LoginFrameController.cpp new file mode 100644 index 0000000..ae79222 --- /dev/null +++ b/src/Controller/LoginFrameController/LoginFrameController.cpp @@ -0,0 +1,14 @@ +#include "LoginFrameController.hpp" + +LoginFrameController::LoginFrameController() +{ + +} + +bool LoginFrameController::tryLogin(QString id, QString password){ + //DatabaseHandler dbHandler = new Databasehandler(); + //dbHandler.CheckValidLogin(); + + + return true; +} \ No newline at end of file diff --git a/src/Controller/LoginFrameController/LoginFrameController.hpp b/src/Controller/LoginFrameController/LoginFrameController.hpp new file mode 100644 index 0000000..dab79a9 --- /dev/null +++ b/src/Controller/LoginFrameController/LoginFrameController.hpp @@ -0,0 +1,10 @@ +#pragma once +#include +#include + +class LoginFrameController{ +private: +public: + LoginFrameController(); + bool tryLogin(QString id, QString password); +}; \ No newline at end of file diff --git a/src/View/LoginFrame/LoginFrame.cpp b/src/View/LoginFrame/LoginFrame.cpp new file mode 100644 index 0000000..b1b3da4 --- /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 + header_m = new QLabel("Einsatzplan", this); + header_m->setFrameStyle(QFrame::Box); + header_m->setObjectName("Header"); + header_m->setStyleSheet(R"( + #Header{ + color: #93F8FF; + font-size: 36px; + font-weight: bold; + border: none; + } + )"); + header_m->show( ); + + + id_m = new QLineEdit(this); + id_m->setPlaceholderText("ID..."); + id_m->setObjectName("ID"); + id_m->setFixedSize(300, 40); + id_m->setStyleSheet(R"( + #ID{ + color: #DADADA; + font-size: 16px; + background-color: #313131; + border-radius: 10px; + padding: 5px; + border: 2px solid #414141; + } + )"); + id_m->show( ); + + + password_m = new QLineEdit(this); + password_m->setPlaceholderText("Passwort..."); + password_m->setObjectName("Password"); + password_m->setEchoMode(QLineEdit::Password); + password_m->setFixedSize(300, 40); + password_m->setStyleSheet(R"( + #Password{ + color: #DADADA; + font-size: 16px; + background-color: #313131; + border-radius: 10px; + padding: 5px; + border: 2px solid #414141; + } + )"); + password_m->show( ); + + loginButton_m = new QPushButton("Login", this); + loginButton_m->setObjectName("loginButton"); + loginButton_m->setFixedSize(QSize(150, 50)); + loginButton_m->setStyleSheet(R"( + #loginButton{ + color: #212121; + font-size: 24px; + font-weight: bold; + background-color: #53EC87; + border-radius: 10px; + } + #loginButton:pressed { + background-color: #43DC77; + } + )"); + loginButton_m->show( ); + + //create layout + QVBoxLayout* layout = new QVBoxLayout( ); + + //layout->setContentsMargins(50, 20, 50, 20); + layout->addWidget(header_m, 3, Qt::AlignCenter); + layout->addWidget(id_m, 1, Qt::AlignCenter); + layout->addWidget(password_m, 1, Qt::AlignCenter); + layout->addWidget(loginButton_m, 3, Qt::AlignCenter); + + //add Layout to LoginFrame + setLayout(layout); + + //connect loginButton with function + connect(loginButton_m, &QPushButton::clicked, this, &LoginFrame::loginButtonClicked); +} + +//try Login if Button clicked +void LoginFrame::loginButtonClicked( ) { + QString id = id_m->text( ); + QString password = password_m->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( ); + if (!controller->tryLogin(id, password)) { + QMessageBox::warning(this, "Error", "ID und Passwort stimmen nicht überein!"); + } else { + ((QWidget*)(this->parent( )))->hide( ); + //TODO: Create new window + } + } +} + +LoginFrame::~LoginFrame( ) { + header_m->~QLabel( ); + id_m->~QLineEdit( ); + password_m->~QLineEdit( ); + loginButton_m->~QPushButton( ); + parent_m->~QMainWindow( ); +} diff --git a/src/View/LoginFrame/LoginFrame.hpp b/src/View/LoginFrame/LoginFrame.hpp new file mode 100644 index 0000000..f0f527a --- /dev/null +++ b/src/View/LoginFrame/LoginFrame.hpp @@ -0,0 +1,26 @@ +# pragma once +# include +# include +# include +# include +# include +# include +# include +# include +# include "../../Controller/LoginFrameController/LoginFrameController.hpp" + +class LoginFrame : public QFrame{ + Q_OBJECT +protected: + QMainWindow* parent_m; + QLabel* header_m; + QLineEdit* id_m; + QLineEdit* password_m; + QPushButton* loginButton_m; + + void loginButtonClicked(); + +public: + LoginFrame(QWidget* parent = nullptr); + ~LoginFrame(); +}; \ No newline at end of file diff --git a/src/View/LoginWindow/LoginWindow.cpp b/src/View/LoginWindow/LoginWindow.cpp new file mode 100644 index 0000000..1328487 --- /dev/null +++ b/src/View/LoginWindow/LoginWindow.cpp @@ -0,0 +1,9 @@ +#include "LoginWindow.hpp" + +LoginWindow::LoginWindow(QWidget* parent) +:QMainWindow(parent) +{ + frame_m = new LoginFrame(this); + setFixedSize(400,550); + frame_m->setFixedSize(size()); +} \ No newline at end of file diff --git a/src/View/LoginWindow/LoginWindow.hpp b/src/View/LoginWindow/LoginWindow.hpp new file mode 100644 index 0000000..e274033 --- /dev/null +++ b/src/View/LoginWindow/LoginWindow.hpp @@ -0,0 +1,13 @@ +# pragma once +#include +#include "../LoginFrame/LoginFrame.hpp" + +class LoginWindow : public QMainWindow{ + Q_OBJECT +private: + LoginFrame* frame_m; + + +public: + LoginWindow(QWidget* parent = nullptr); +}; \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index f81378c..313560f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,9 +1,10 @@ # include -# include "View/EinsatzplanWindow/EinsatzplanWindow.hpp" -int main(int argc, char* argv[]) { - QApplication app(argc, argv); - EinsatzplanWindow* einsatzplanWindow = new EinsatzplanWindow( ); - einsatzplanWindow->show( ); - return app.exec( ); +# include "View/LoginWindow/LoginWindow.hpp" + +int main(int argc, char* argv[]){ + QApplication app(argc,argv); + LoginWindow* loginWindow = new LoginWindow(); + loginWindow->show(); + return app.exec(); }