change layout and styling, window now hides instead of segfaulting
This commit is contained in:
@@ -1,8 +1,7 @@
|
|||||||
# include "LoginFrame.hpp"
|
# include "LoginFrame.hpp"
|
||||||
|
|
||||||
LoginFrame::LoginFrame(QWidget* parent)
|
LoginFrame::LoginFrame(QWidget* parent)
|
||||||
:QFrame(parent)
|
:QFrame(parent) {
|
||||||
{
|
|
||||||
//configure LoginFrame
|
//configure LoginFrame
|
||||||
setObjectName("LoginFrame");
|
setObjectName("LoginFrame");
|
||||||
setStyleSheet(R"(
|
setStyleSheet(R"(
|
||||||
@@ -17,7 +16,6 @@ LoginFrame::LoginFrame(QWidget* parent)
|
|||||||
//create QWidgets and add LoginFrame as parent
|
//create QWidgets and add LoginFrame as parent
|
||||||
header_m = new QLabel("Einsatzplan", this);
|
header_m = new QLabel("Einsatzplan", this);
|
||||||
header_m->setFrameStyle(QFrame::Box);
|
header_m->setFrameStyle(QFrame::Box);
|
||||||
header_m->setAlignment(Qt::AlignCenter);
|
|
||||||
header_m->setObjectName("Header");
|
header_m->setObjectName("Header");
|
||||||
header_m->setStyleSheet(R"(
|
header_m->setStyleSheet(R"(
|
||||||
#Header{
|
#Header{
|
||||||
@@ -33,14 +31,15 @@ LoginFrame::LoginFrame(QWidget* parent)
|
|||||||
id_m = new QLineEdit(this);
|
id_m = new QLineEdit(this);
|
||||||
id_m->setPlaceholderText("ID...");
|
id_m->setPlaceholderText("ID...");
|
||||||
id_m->setObjectName("ID");
|
id_m->setObjectName("ID");
|
||||||
|
id_m->setFixedSize(300, 40);
|
||||||
id_m->setStyleSheet(R"(
|
id_m->setStyleSheet(R"(
|
||||||
#ID{
|
#ID{
|
||||||
color: #333333;
|
color: #DADADA;
|
||||||
font-size: 25px;
|
font-size: 16px;
|
||||||
font-weight: bold;
|
background-color: #313131;
|
||||||
background-color: #444444;
|
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
|
border: 2px solid #414141;
|
||||||
}
|
}
|
||||||
)");
|
)");
|
||||||
id_m->show( );
|
id_m->show( );
|
||||||
@@ -49,52 +48,45 @@ LoginFrame::LoginFrame(QWidget* parent)
|
|||||||
password_m = new QLineEdit(this);
|
password_m = new QLineEdit(this);
|
||||||
password_m->setPlaceholderText("Passwort...");
|
password_m->setPlaceholderText("Passwort...");
|
||||||
password_m->setObjectName("Password");
|
password_m->setObjectName("Password");
|
||||||
|
password_m->setEchoMode(QLineEdit::Password);
|
||||||
|
password_m->setFixedSize(300, 40);
|
||||||
password_m->setStyleSheet(R"(
|
password_m->setStyleSheet(R"(
|
||||||
#Password{
|
#Password{
|
||||||
color: #333333;
|
color: #DADADA;
|
||||||
font-size: 25px;
|
font-size: 16px;
|
||||||
font-weight: bold;
|
background-color: #313131;
|
||||||
background-color: #444444;
|
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
padding: 5px;
|
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->setObjectName("loginButton");
|
||||||
|
loginButton_m->setFixedSize(QSize(150, 50));
|
||||||
loginButton_m->setStyleSheet(R"(
|
loginButton_m->setStyleSheet(R"(
|
||||||
#loginButton{
|
#loginButton{
|
||||||
color: #212121;
|
color: #212121;
|
||||||
font-size: 30px;
|
font-size: 24px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
background-color: #00C800;
|
background-color: #53EC87;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
}
|
}
|
||||||
#loginButton:pressed {
|
#loginButton:pressed {
|
||||||
background-color: #00A800;
|
background-color: #43DC77;
|
||||||
}
|
}
|
||||||
)");
|
)");
|
||||||
loginButton_m->show( );
|
loginButton_m->show( );
|
||||||
|
|
||||||
|
|
||||||
//create layout
|
//create layout
|
||||||
QVBoxLayout* layout = new QVBoxLayout( );
|
QVBoxLayout* layout = new QVBoxLayout( );
|
||||||
|
|
||||||
layout->setContentsMargins(50, 20, 50, 20);
|
//layout->setContentsMargins(50, 20, 50, 20);
|
||||||
|
layout->addWidget(header_m, 3, Qt::AlignCenter);
|
||||||
layout->addStretch(1);
|
layout->addWidget(id_m, 1, Qt::AlignCenter);
|
||||||
layout->addWidget(header_m);
|
layout->addWidget(password_m, 1, Qt::AlignCenter);
|
||||||
header_m->setAlignment(Qt::AlignHCenter);
|
layout->addWidget(loginButton_m, 3, Qt::AlignCenter);
|
||||||
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
|
//add Layout to LoginFrame
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
@@ -111,14 +103,13 @@ void LoginFrame::loginButtonClicked(){
|
|||||||
//check if Contents Valid
|
//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.");
|
QMessageBox::warning(this, "Error", "Bitte füllen Sie sowohl die ID als auch das Passwort aus.");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
LoginFrameController* controller = new LoginFrameController( );
|
LoginFrameController* controller = new LoginFrameController( );
|
||||||
if (!controller->tryLogin(id, password)) {
|
if (!controller->tryLogin(id, password)) {
|
||||||
QMessageBox::warning(this, "Error", "ID und Passwort stimmen nicht überein!");
|
QMessageBox::warning(this, "Error", "ID und Passwort stimmen nicht überein!");
|
||||||
}
|
} else {
|
||||||
else{
|
((QWidget*)(this->parent( )))->hide( );
|
||||||
this->~LoginFrame();
|
//TODO: Create new window
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user