From b6d27666578db524f45bdb1b979cd37a13a0e218 Mon Sep 17 00:00:00 2001 From: AJ Date: Tue, 18 Jun 2024 22:12:18 +0200 Subject: [PATCH 1/9] Beginnings --- .gitignore | 2 ++ CMakeLists.txt | 5 ++--- src/View/LoginFrame/LoginFrame.cpp | 7 +++++++ src/View/LoginFrame/LoginFrame.hpp | 14 ++++++++++++++ src/View/LoginWindow/LoginWindow.cpp | 7 +++++++ src/View/LoginWindow/LoginWindow.hpp | 11 +++++++++++ src/main.cpp | 9 +++++++++ 7 files changed, 52 insertions(+), 3 deletions(-) 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/main.cpp diff --git a/.gitignore b/.gitignore index 7f4826b..55d0973 100644 --- a/.gitignore +++ b/.gitignore @@ -52,3 +52,5 @@ compile_commands.json *creator.user* *_qmlcache.qrc + +build/ \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index a615213..6015eb1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,8 +9,8 @@ set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) -find_package(QT NAMES Qt6 REQUIRED COMPONENTS Widgets Qml Svg Core Sql) -find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Qml Svg Core Sql) +find_package(QT NAMES Qt6 REQUIRED COMPONENTS Widgets Svg Core Sql) +find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Svg Core Sql) file(GLOB_RECURSE PROJECT_SOURCES src/*.cpp) file(GLOB_RECURSE PROJECT_HEADERS src/*.hpp) @@ -24,7 +24,6 @@ add_executable(EinsatzplanQT target_link_libraries(EinsatzplanQT PRIVATE Qt${QT_VERSION_MAJOR}::Widgets - Qt${QT_VERSION_MAJOR}::Qml Qt${QT_VERSION_MAJOR}::Svg Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Sql diff --git a/src/View/LoginFrame/LoginFrame.cpp b/src/View/LoginFrame/LoginFrame.cpp new file mode 100644 index 0000000..6fc510c --- /dev/null +++ b/src/View/LoginFrame/LoginFrame.cpp @@ -0,0 +1,7 @@ +# include "LoginFrame.hpp" + +LoginFrame::LoginFrame(QWidget* parent) +:QFrame(parent) +{ + +} \ No newline at end of file diff --git a/src/View/LoginFrame/LoginFrame.hpp b/src/View/LoginFrame/LoginFrame.hpp new file mode 100644 index 0000000..d5a64c6 --- /dev/null +++ b/src/View/LoginFrame/LoginFrame.hpp @@ -0,0 +1,14 @@ +# pragma once +# include +# include +# include +# include +# include + +class LoginFrame : public QFrame{ + Q_OBJECT +private: + +public: +LoginFrame(QWidget* parent = nullptr); +}; \ 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..cd2381d --- /dev/null +++ b/src/View/LoginWindow/LoginWindow.cpp @@ -0,0 +1,7 @@ +#include "LoginWindow.hpp" + +LoginWindow::LoginWindow(QWidget* parent) +:QMainWindow(parent) +{ + +} \ 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..732d5e2 --- /dev/null +++ b/src/View/LoginWindow/LoginWindow.hpp @@ -0,0 +1,11 @@ +# pragma once +#include + +class LoginWindow : public QMainWindow{ + Q_OBJECT +private: + +public: +LoginWindow(QWidget* parent = nullptr); + +}; \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..7e239ab --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,9 @@ +# 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(); +} \ No newline at end of file From f0b68699901ddbfb05cc05491352fc657d7d7f49 Mon Sep 17 00:00:00 2001 From: AJ Date: Wed, 19 Jun 2024 14:20:22 +0200 Subject: [PATCH 2/9] =?UTF-8?q?Frame=20Ger=C3=BCst?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/View/LoginFrame/LoginFrame.cpp | 19 +++++++++++++++++++ src/View/LoginFrame/LoginFrame.hpp | 6 +++++- src/View/LoginWindow/LoginWindow.cpp | 4 +++- src/View/LoginWindow/LoginWindow.hpp | 8 +++++--- 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/View/LoginFrame/LoginFrame.cpp b/src/View/LoginFrame/LoginFrame.cpp index 6fc510c..5282492 100644 --- a/src/View/LoginFrame/LoginFrame.cpp +++ b/src/View/LoginFrame/LoginFrame.cpp @@ -3,5 +3,24 @@ LoginFrame::LoginFrame(QWidget* parent) :QFrame(parent) { + header_m = new QLabel("Login", this); + header_m->setFrameStyle(QFrame::Box); + header_m->setGeometry(100,100,200,50); + header_m->show(); + + id_m = new QLineEdit("ID...", this); + id_m->setGeometry(100,200,200,50); + id_m->show(); + password_m = new QLineEdit("Passwort...",this); + password_m->setGeometry(100,300,200,50); + password_m->show(); + + loginButton_m = new QPushButton("Login",this); + loginButton_m->setGeometry(100,400,200,50); + loginButton_m->show(); + + setFrameStyle(QFrame::Box | QFrame::Plain); + setLineWidth(5); + } \ No newline at end of file diff --git a/src/View/LoginFrame/LoginFrame.hpp b/src/View/LoginFrame/LoginFrame.hpp index d5a64c6..17d845a 100644 --- a/src/View/LoginFrame/LoginFrame.hpp +++ b/src/View/LoginFrame/LoginFrame.hpp @@ -8,7 +8,11 @@ class LoginFrame : public QFrame{ Q_OBJECT private: + QLabel* header_m; + QLineEdit* id_m; + QLineEdit* password_m; + QPushButton* loginButton_m; public: -LoginFrame(QWidget* parent = nullptr); + LoginFrame(QWidget* parent = nullptr); }; \ No newline at end of file diff --git a/src/View/LoginWindow/LoginWindow.cpp b/src/View/LoginWindow/LoginWindow.cpp index cd2381d..1328487 100644 --- a/src/View/LoginWindow/LoginWindow.cpp +++ b/src/View/LoginWindow/LoginWindow.cpp @@ -3,5 +3,7 @@ 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 index 732d5e2..e274033 100644 --- a/src/View/LoginWindow/LoginWindow.hpp +++ b/src/View/LoginWindow/LoginWindow.hpp @@ -1,11 +1,13 @@ # pragma once #include +#include "../LoginFrame/LoginFrame.hpp" class LoginWindow : public QMainWindow{ Q_OBJECT private: - -public: -LoginWindow(QWidget* parent = nullptr); + LoginFrame* frame_m; + +public: + LoginWindow(QWidget* parent = nullptr); }; \ No newline at end of file From d38da91903020feafacb9b496b6d5ff79d98a61a Mon Sep 17 00:00:00 2001 From: AJ Date: Wed, 19 Jun 2024 16:35:59 +0200 Subject: [PATCH 3/9] LoginFrameController Base --- .../LoginFrameController/LoginFrameController.cpp | 7 +++++++ .../LoginFrameController/LoginFrameController.hpp | 11 +++++++++++ 2 files changed, 18 insertions(+) create mode 100644 src/Controller/LoginFrameController/LoginFrameController.cpp create mode 100644 src/Controller/LoginFrameController/LoginFrameController.hpp diff --git a/src/Controller/LoginFrameController/LoginFrameController.cpp b/src/Controller/LoginFrameController/LoginFrameController.cpp new file mode 100644 index 0000000..1d4c8fd --- /dev/null +++ b/src/Controller/LoginFrameController/LoginFrameController.cpp @@ -0,0 +1,7 @@ +#include "LoginFrameController.hpp" + +LoginFrameController::LoginFrameController(std::string id, std::string password) +:id_m(id), passwort_m(password) +{ + //try Login +} \ 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..372db99 --- /dev/null +++ b/src/Controller/LoginFrameController/LoginFrameController.hpp @@ -0,0 +1,11 @@ +#pragma once +#include + +class LoginFrameController{ +private: + std::string id_m; + std::string passwort_m; + +public: + LoginFrameController(std::string id, std::string password); +}; \ No newline at end of file From ff7f4e1177063b1466bf2d460f22781505ef3987 Mon Sep 17 00:00:00 2001 From: AJ Date: Thu, 20 Jun 2024 16:15:40 +0200 Subject: [PATCH 4/9] Style Beginnings --- .../LoginFrameController.cpp | 3 +- src/View/LoginFrame/LoginFrame.cpp | 77 +++++++++++++++++-- src/View/LoginFrame/LoginFrame.hpp | 1 + 3 files changed, 73 insertions(+), 8 deletions(-) diff --git a/src/Controller/LoginFrameController/LoginFrameController.cpp b/src/Controller/LoginFrameController/LoginFrameController.cpp index 1d4c8fd..877f989 100644 --- a/src/Controller/LoginFrameController/LoginFrameController.cpp +++ b/src/Controller/LoginFrameController/LoginFrameController.cpp @@ -3,5 +3,6 @@ LoginFrameController::LoginFrameController(std::string id, std::string password) :id_m(id), passwort_m(password) { - //try Login + //DatabaseHandler dbHandler = new Databasehandler(); + //dbHandler.CheckValidLogin(); } \ No newline at end of file diff --git a/src/View/LoginFrame/LoginFrame.cpp b/src/View/LoginFrame/LoginFrame.cpp index 5282492..3132dd6 100644 --- a/src/View/LoginFrame/LoginFrame.cpp +++ b/src/View/LoginFrame/LoginFrame.cpp @@ -3,24 +3,87 @@ LoginFrame::LoginFrame(QWidget* parent) :QFrame(parent) { - header_m = new QLabel("Login", this); + //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->setGeometry(100,100,200,50); + header_m->setAlignment(Qt::AlignCenter); + 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("ID...", this); - id_m->setGeometry(100,200,200,50); + id_m->setObjectName("ID"); + id_m->setStyleSheet(R"( + #ID{ + color: #93F8FF; + font-size: 25px; + font-weight: bold; + border: none; + } + )"); id_m->show(); + password_m = new QLineEdit("Passwort...",this); - password_m->setGeometry(100,300,200,50); + password_m->setObjectName("Password"); + password_m->setStyleSheet(R"( + #Password{ + color: #93F8FF; + font-size: 25px; + font-weight: bold; + border: none; + } + )"); password_m->show(); loginButton_m = new QPushButton("Login",this); - loginButton_m->setGeometry(100,400,200,50); + loginButton_m->setObjectName("loginButton"); + loginButton_m->setStyleSheet(R"( + #loginButton{ + color: #212121; + font-size: 30px; + font-weight: bold; + background-color: #00C800; + } + )"); loginButton_m->show(); - setFrameStyle(QFrame::Box | QFrame::Plain); - setLineWidth(5); + //create layout + QVBoxLayout* layout = new QVBoxLayout(); + + layout->addStretch(1); + layout->addWidget(header_m); + header_m->setAlignment(Qt::AlignHCenter); + layout->addStretch(2); + layout->addWidget(id_m); + id_m->setAlignment(Qt::AlignHCenter); + layout->addStretch(1); + layout->addWidget(password_m); + password_m->setAlignment(Qt::AlignHCenter); + layout->addStretch(2); + layout->addWidget(loginButton_m); + layout->addStretch(1); + + //add Layout to LoginFrame + setLayout(layout); } \ No newline at end of file diff --git a/src/View/LoginFrame/LoginFrame.hpp b/src/View/LoginFrame/LoginFrame.hpp index 17d845a..39b7729 100644 --- a/src/View/LoginFrame/LoginFrame.hpp +++ b/src/View/LoginFrame/LoginFrame.hpp @@ -4,6 +4,7 @@ # include # include # include +# include class LoginFrame : public QFrame{ Q_OBJECT From bcca19116d59931fe719f23a7fcd44fd8e6d47ea Mon Sep 17 00:00:00 2001 From: AJ Date: Fri, 21 Jun 2024 13:53:07 +0200 Subject: [PATCH 5/9] Update --- src/View/LoginFrame/LoginFrame.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/View/LoginFrame/LoginFrame.cpp b/src/View/LoginFrame/LoginFrame.cpp index 3132dd6..8f35e38 100644 --- a/src/View/LoginFrame/LoginFrame.cpp +++ b/src/View/LoginFrame/LoginFrame.cpp @@ -34,10 +34,11 @@ LoginFrame::LoginFrame(QWidget* parent) id_m->setObjectName("ID"); id_m->setStyleSheet(R"( #ID{ - color: #93F8FF; + color: #333333; font-size: 25px; font-weight: bold; border: none; + background-color: #444444; } )"); id_m->show(); @@ -47,10 +48,11 @@ LoginFrame::LoginFrame(QWidget* parent) password_m->setObjectName("Password"); password_m->setStyleSheet(R"( #Password{ - color: #93F8FF; + color: #333333; font-size: 25px; font-weight: bold; border: none; + background-color: #444444; } )"); password_m->show(); From ce1f26168705cc9dad046fd77cf76868ea8e933a Mon Sep 17 00:00:00 2001 From: AJ Date: Sun, 23 Jun 2024 17:01:12 +0200 Subject: [PATCH 6/9] Update --- .../LoginFrameController.cpp | 7 +++- .../LoginFrameController.hpp | 6 +-- src/View/LoginFrame/LoginFrame.cpp | 37 +++++++++++++++++-- src/View/LoginFrame/LoginFrame.hpp | 6 ++- 4 files changed, 45 insertions(+), 11 deletions(-) diff --git a/src/Controller/LoginFrameController/LoginFrameController.cpp b/src/Controller/LoginFrameController/LoginFrameController.cpp index 877f989..84892ce 100644 --- a/src/Controller/LoginFrameController/LoginFrameController.cpp +++ b/src/Controller/LoginFrameController/LoginFrameController.cpp @@ -1,8 +1,11 @@ #include "LoginFrameController.hpp" -LoginFrameController::LoginFrameController(std::string id, std::string password) -:id_m(id), passwort_m(password) +LoginFrameController::LoginFrameController() { + +} + +bool LoginFrameController::tryLogin(std::string id, std::string password){ //DatabaseHandler dbHandler = new Databasehandler(); //dbHandler.CheckValidLogin(); } \ No newline at end of file diff --git a/src/Controller/LoginFrameController/LoginFrameController.hpp b/src/Controller/LoginFrameController/LoginFrameController.hpp index 372db99..73537f8 100644 --- a/src/Controller/LoginFrameController/LoginFrameController.hpp +++ b/src/Controller/LoginFrameController/LoginFrameController.hpp @@ -3,9 +3,7 @@ class LoginFrameController{ private: - std::string id_m; - std::string passwort_m; - public: - LoginFrameController(std::string id, std::string password); + LoginFrameController(); + bool tryLogin(std::string id, std::string password); }; \ No newline at end of file diff --git a/src/View/LoginFrame/LoginFrame.cpp b/src/View/LoginFrame/LoginFrame.cpp index 8f35e38..9a3c7b7 100644 --- a/src/View/LoginFrame/LoginFrame.cpp +++ b/src/View/LoginFrame/LoginFrame.cpp @@ -30,29 +30,33 @@ LoginFrame::LoginFrame(QWidget* parent) header_m->show(); - id_m = new QLineEdit("ID...", this); + id_m = new QLineEdit( this); + id_m->setPlaceholderText("ID..."); id_m->setObjectName("ID"); id_m->setStyleSheet(R"( #ID{ color: #333333; font-size: 25px; font-weight: bold; - border: none; background-color: #444444; + border-radius: 10px; + padding: 5px; } )"); id_m->show(); - password_m = new QLineEdit("Passwort...",this); + password_m = new QLineEdit(this); + password_m->setPlaceholderText("Passwort..."); password_m->setObjectName("Password"); password_m->setStyleSheet(R"( #Password{ color: #333333; font-size: 25px; font-weight: bold; - border: none; background-color: #444444; + border-radius: 10px; + padding: 5px; } )"); password_m->show(); @@ -65,6 +69,10 @@ LoginFrame::LoginFrame(QWidget* parent) font-size: 30px; font-weight: bold; background-color: #00C800; + border-radius: 10px; + } + #loginButton:pressed { + background-color: #00A800; } )"); loginButton_m->show(); @@ -73,6 +81,8 @@ LoginFrame::LoginFrame(QWidget* parent) //create layout QVBoxLayout* layout = new QVBoxLayout(); + layout->setContentsMargins(50, 20, 50, 20); + layout->addStretch(1); layout->addWidget(header_m); header_m->setAlignment(Qt::AlignHCenter); @@ -88,4 +98,23 @@ LoginFrame::LoginFrame(QWidget* parent) //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, "Fehler", "Bitte füllen Sie sowohl die ID als auch das Passwort aus."); + } + else { + LoginFrameController* controller = new LoginFrameController(); + bool valid = controller->tryLogin(id.toStdString(), password.toStdString()); + } + } \ No newline at end of file diff --git a/src/View/LoginFrame/LoginFrame.hpp b/src/View/LoginFrame/LoginFrame.hpp index 39b7729..735ee34 100644 --- a/src/View/LoginFrame/LoginFrame.hpp +++ b/src/View/LoginFrame/LoginFrame.hpp @@ -5,15 +5,19 @@ # include # include # include +# include +# include "../../Controller/LoginFrameController/LoginFrameController.hpp" class LoginFrame : public QFrame{ Q_OBJECT -private: +protected: QLabel* header_m; QLineEdit* id_m; QLineEdit* password_m; QPushButton* loginButton_m; + void loginButtonClicked(); + public: LoginFrame(QWidget* parent = nullptr); }; \ No newline at end of file From 63249f711090406b2cf620296c8009f1c282af39 Mon Sep 17 00:00:00 2001 From: AJ Date: Sun, 23 Jun 2024 17:28:09 +0200 Subject: [PATCH 7/9] Destruction added --- .../LoginFrameController.cpp | 2 ++ src/View/LoginFrame/LoginFrame.cpp | 16 ++++++++++++++-- src/View/LoginFrame/LoginFrame.hpp | 3 +++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/Controller/LoginFrameController/LoginFrameController.cpp b/src/Controller/LoginFrameController/LoginFrameController.cpp index 84892ce..95a1910 100644 --- a/src/Controller/LoginFrameController/LoginFrameController.cpp +++ b/src/Controller/LoginFrameController/LoginFrameController.cpp @@ -8,4 +8,6 @@ LoginFrameController::LoginFrameController() bool LoginFrameController::tryLogin(std::string id, std::string password){ //DatabaseHandler dbHandler = new Databasehandler(); //dbHandler.CheckValidLogin(); + + return true; } \ No newline at end of file diff --git a/src/View/LoginFrame/LoginFrame.cpp b/src/View/LoginFrame/LoginFrame.cpp index 9a3c7b7..9a350b2 100644 --- a/src/View/LoginFrame/LoginFrame.cpp +++ b/src/View/LoginFrame/LoginFrame.cpp @@ -110,11 +110,23 @@ void LoginFrame::loginButtonClicked(){ //check if Contents Valid if (id.isEmpty() || password.isEmpty()){ - QMessageBox::warning(this, "Fehler", "Bitte füllen Sie sowohl die ID als auch das Passwort aus."); + QMessageBox::warning(this, "Error", "Bitte füllen Sie sowohl die ID als auch das Passwort aus."); } else { LoginFrameController* controller = new LoginFrameController(); - bool valid = controller->tryLogin(id.toStdString(), password.toStdString()); + if (!controller->tryLogin(id.toStdString(), password.toStdString())){ + QMessageBox:: warning(this, "Error", "ID und Passwort stimmen nicht überein!"); + } + else{ + this->~LoginFrame(); + } } +} +LoginFrame::~LoginFrame(){ + header_m->~QLabel(); + id_m->~QLineEdit(); + password_m->~QLineEdit(); + loginButton_m->~QPushButton(); + parent_m->~QMainWindow(); } \ No newline at end of file diff --git a/src/View/LoginFrame/LoginFrame.hpp b/src/View/LoginFrame/LoginFrame.hpp index 735ee34..f0f527a 100644 --- a/src/View/LoginFrame/LoginFrame.hpp +++ b/src/View/LoginFrame/LoginFrame.hpp @@ -6,11 +6,13 @@ # 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; @@ -20,4 +22,5 @@ protected: public: LoginFrame(QWidget* parent = nullptr); + ~LoginFrame(); }; \ No newline at end of file From ccee4c7df102fb444ce65bac3a10f722cd01c134 Mon Sep 17 00:00:00 2001 From: AJ Date: Sun, 23 Jun 2024 18:15:36 +0200 Subject: [PATCH 8/9] Update --- src/Controller/LoginFrameController/LoginFrameController.cpp | 5 +++-- src/Controller/LoginFrameController/LoginFrameController.hpp | 3 ++- src/View/LoginFrame/LoginFrame.cpp | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Controller/LoginFrameController/LoginFrameController.cpp b/src/Controller/LoginFrameController/LoginFrameController.cpp index 95a1910..ae79222 100644 --- a/src/Controller/LoginFrameController/LoginFrameController.cpp +++ b/src/Controller/LoginFrameController/LoginFrameController.cpp @@ -5,9 +5,10 @@ LoginFrameController::LoginFrameController() } -bool LoginFrameController::tryLogin(std::string id, std::string password){ +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 index 73537f8..dab79a9 100644 --- a/src/Controller/LoginFrameController/LoginFrameController.hpp +++ b/src/Controller/LoginFrameController/LoginFrameController.hpp @@ -1,9 +1,10 @@ #pragma once #include +#include class LoginFrameController{ private: public: LoginFrameController(); - bool tryLogin(std::string id, std::string password); + 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 index 9a350b2..25cfeac 100644 --- a/src/View/LoginFrame/LoginFrame.cpp +++ b/src/View/LoginFrame/LoginFrame.cpp @@ -114,7 +114,7 @@ void LoginFrame::loginButtonClicked(){ } else { LoginFrameController* controller = new LoginFrameController(); - if (!controller->tryLogin(id.toStdString(), password.toStdString())){ + if (!controller->tryLogin(id, password)){ QMessageBox:: warning(this, "Error", "ID und Passwort stimmen nicht überein!"); } else{ From 558eceee19d933feb399ae3f58e7539c18edb9b9 Mon Sep 17 00:00:00 2001 From: Crylia Date: Mon, 24 Jun 2024 08:40:36 +0200 Subject: [PATCH 9/9] change layout and styling, window now hides instead of segfaulting --- src/View/LoginFrame/LoginFrame.cpp | 107 +++++++++++++---------------- 1 file changed, 49 insertions(+), 58 deletions(-) diff --git a/src/View/LoginFrame/LoginFrame.cpp b/src/View/LoginFrame/LoginFrame.cpp index 25cfeac..b1b3da4 100644 --- a/src/View/LoginFrame/LoginFrame.cpp +++ b/src/View/LoginFrame/LoginFrame.cpp @@ -1,8 +1,7 @@ # include "LoginFrame.hpp" LoginFrame::LoginFrame(QWidget* parent) -:QFrame(parent) -{ + :QFrame(parent) { //configure LoginFrame setObjectName("LoginFrame"); setStyleSheet(R"( @@ -13,11 +12,10 @@ LoginFrame::LoginFrame(QWidget* parent) )"); setFrameStyle(QFrame::Box); - + //create QWidgets and add LoginFrame as parent header_m = new QLabel("Einsatzplan", this); header_m->setFrameStyle(QFrame::Box); - header_m->setAlignment(Qt::AlignCenter); header_m->setObjectName("Header"); header_m->setStyleSheet(R"( #Header{ @@ -27,74 +25,68 @@ LoginFrame::LoginFrame(QWidget* parent) border: none; } )"); - header_m->show(); - + header_m->show( ); - id_m = new QLineEdit( this); + + id_m = new QLineEdit(this); id_m->setPlaceholderText("ID..."); id_m->setObjectName("ID"); + id_m->setFixedSize(300, 40); id_m->setStyleSheet(R"( #ID{ - color: #333333; - font-size: 25px; - font-weight: bold; - background-color: #444444; + color: #DADADA; + font-size: 16px; + background-color: #313131; border-radius: 10px; padding: 5px; + border: 2px solid #414141; } )"); - id_m->show(); + 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: #333333; - font-size: 25px; - font-weight: bold; - background-color: #444444; + color: #DADADA; + font-size: 16px; + background-color: #313131; border-radius: 10px; padding: 5px; + border: 2px solid #414141; } )"); - password_m->show(); + password_m->show( ); - loginButton_m = new QPushButton("Login",this); + 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: 30px; + font-size: 24px; font-weight: bold; - background-color: #00C800; + background-color: #53EC87; border-radius: 10px; } #loginButton:pressed { - background-color: #00A800; + background-color: #43DC77; } )"); - loginButton_m->show(); + loginButton_m->show( ); - //create layout - QVBoxLayout* layout = new QVBoxLayout(); + QVBoxLayout* layout = new QVBoxLayout( ); - layout->setContentsMargins(50, 20, 50, 20); - - layout->addStretch(1); - layout->addWidget(header_m); - header_m->setAlignment(Qt::AlignHCenter); - layout->addStretch(2); - layout->addWidget(id_m); - id_m->setAlignment(Qt::AlignHCenter); - layout->addStretch(1); - layout->addWidget(password_m); - password_m->setAlignment(Qt::AlignHCenter); - layout->addStretch(2); - layout->addWidget(loginButton_m); - layout->addStretch(1); + //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); @@ -103,30 +95,29 @@ LoginFrame::LoginFrame(QWidget* parent) 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(); +//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()){ + 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{ - this->~LoginFrame(); + } 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(); -} \ No newline at end of file +LoginFrame::~LoginFrame( ) { + header_m->~QLabel( ); + id_m->~QLineEdit( ); + password_m->~QLineEdit( ); + loginButton_m->~QPushButton( ); + parent_m->~QMainWindow( ); +}