-
Notifications
You must be signed in to change notification settings - Fork 0
/
homepage.cpp
117 lines (87 loc) · 3.11 KB
/
homepage.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#include "homepage.h"
#include "inscription.h"
#include "emprunter.h"
#include <QWidget>
#include <QLabel>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QPushButton>
#include <QPixmap>
#include <QGridLayout>
#include <QInputDialog>
#include <QString>
#include <QSqlDatabase>
#include <QSqlQuery>
#include "livre.h"
/*
* library to connect QT to databse myqsl
*/
homepage::homepage(QWidget *parent) : QDialog(parent)
{
this->setMinimumSize(QSize(1000, 600));
main_page();
}
//Main page of my program
void homepage::main_page() {
//MINIMUN DIMENSION OF ELEMENT AND SETTING OF WINDOW
this->setPalette(Qt::white);
this->setStyleSheet("QPushButton {color: black;}");
//QGridLayout is used to manage layout
QPixmap imageMain(QSize(250,250));
imageMain.load("/home/innovator/Bibliotheque/image/book.jpg");
QLabel *title = new QLabel(tr("Bienvenu a la bibliotheque Esatic"));
title->setAlignment(Qt::AlignCenter);
QLabel *image = new QLabel();
image->setPixmap(imageMain);
main_vlayout = new QVBoxLayout();
QHBoxLayout *title_hlayout = new QHBoxLayout();
QVBoxLayout *button_vlayout = new QVBoxLayout();
center_hlayout = new QHBoxLayout();
QPushButton *bt_inscription = new QPushButton(tr("Inscription"));
QPushButton *bt_ouvrage = new QPushButton(tr("Oeuvres && examplaires"));
QPushButton *bt_emprunter = new QPushButton(tr("Emprunt && reservation"));
QPushButton *bt_deconnecter = new QPushButton(tr("Deconnecter"));
//INSERTION IN LAYOUT FOR GOOD SEE
title_hlayout->addWidget(title);
button_vlayout->addWidget(bt_inscription);
button_vlayout->addWidget(bt_ouvrage);
button_vlayout->addWidget(bt_emprunter);
button_vlayout->addWidget(bt_deconnecter);
//INSERTION IN GRIDLAYOUT
center_hlayout->addLayout(button_vlayout);
center_hlayout->addWidget(image);
//INSERTION IN GRIDLAYOUT
main_vlayout->addLayout(title_hlayout);
main_vlayout->addLayout(center_hlayout);
//CONNECTION TO DB
this->setLayout(main_vlayout);
//Connexion
connect(bt_inscription,SIGNAL(clicked(bool)),this,SLOT(click_inscription()));
connect(bt_ouvrage,SIGNAL(clicked(bool)),this,SLOT(click_ouvrage()));
connect(bt_emprunter,SIGNAL(clicked(bool)),this,SLOT(click_emprunter()));
connect(bt_deconnecter,&QPushButton::clicked,this,&homepage::accept);
}
//PAGE OF INSCRIPTION
void homepage::inscription_page(){
class inscription *page_inscription = new class inscription(this);
page_inscription->exec();
}
//DEFINITIONS OF SLOTS
void homepage::click_inscription(){
//QString donnee = QInputDialog::getMultiLineText(this, "Inscription etudiant", "Etudiant");
inscription_page();
}
void homepage::click_ouvrage(){
livre *page_login = new livre(this);
page_login->exec();
}
void homepage::click_emprunter(){
emprunter *page_login = new emprunter(this);
page_login->exec();
}
void connection_db(){
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName("/home/innovator/Bibliotheque/bibliotheque.db");
bool ok = db.open();
qDebug()<<ok;
}