14
src/Controller/LoginFrameController/LoginFrameController.cpp
Normal file
14
src/Controller/LoginFrameController/LoginFrameController.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include "LoginFrameController.hpp"
|
||||
|
||||
LoginFrameController::LoginFrameController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool LoginFrameController::tryLogin(QString id, QString password){
|
||||
//DatabaseHandler dbHandler = new Databasehandler();
|
||||
//dbHandler.CheckValidLogin();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
10
src/Controller/LoginFrameController/LoginFrameController.hpp
Normal file
10
src/Controller/LoginFrameController/LoginFrameController.hpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
#include <iostream>
|
||||
#include <QString>
|
||||
|
||||
class LoginFrameController{
|
||||
private:
|
||||
public:
|
||||
LoginFrameController();
|
||||
bool tryLogin(QString id, QString password);
|
||||
};
|
||||
123
src/View/LoginFrame/LoginFrame.cpp
Normal file
123
src/View/LoginFrame/LoginFrame.cpp
Normal 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
|
||||
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( );
|
||||
}
|
||||
26
src/View/LoginFrame/LoginFrame.hpp
Normal file
26
src/View/LoginFrame/LoginFrame.hpp
Normal file
@@ -0,0 +1,26 @@
|
||||
# pragma once
|
||||
# include <QFrame>
|
||||
# include <QWidget>
|
||||
# include <QPushButton>
|
||||
# include <QInputDialog>
|
||||
# include <QLabel>
|
||||
# include <QVBoxLayout>
|
||||
# include <QMessageBox>
|
||||
# include <QMainWindow>
|
||||
# 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();
|
||||
};
|
||||
9
src/View/LoginWindow/LoginWindow.cpp
Normal file
9
src/View/LoginWindow/LoginWindow.cpp
Normal file
@@ -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());
|
||||
}
|
||||
13
src/View/LoginWindow/LoginWindow.hpp
Normal file
13
src/View/LoginWindow/LoginWindow.hpp
Normal file
@@ -0,0 +1,13 @@
|
||||
# pragma once
|
||||
#include <QMainWindow>
|
||||
#include "../LoginFrame/LoginFrame.hpp"
|
||||
|
||||
class LoginWindow : public QMainWindow{
|
||||
Q_OBJECT
|
||||
private:
|
||||
LoginFrame* frame_m;
|
||||
|
||||
|
||||
public:
|
||||
LoginWindow(QWidget* parent = nullptr);
|
||||
};
|
||||
13
src/main.cpp
13
src/main.cpp
@@ -1,9 +1,10 @@
|
||||
# include <QApplication>
|
||||
# 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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user