-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.cpp
105 lines (94 loc) · 2.71 KB
/
mainwindow.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
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "frmalumnos.h"
#include "frmproductos.h"
#include "frmsysoptions.h"
#include "frmventas.h"
#include "frmcompras.h"
#include "dlglogin.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
QLocale::setDefault(QLocale(QLocale::Spanish, QLocale::Peru));
ui->setupUi(this);
QPixmap userIcon(tr(":/images/maintoolbar/user.png"));
QLabel *lblUserIcon= new QLabel();
lblUserIcon->setPixmap(userIcon);
this->lblUsuario= new QLabel(tr("Usuario"));
qDebug() << lblUsuario->winId();
QWidget *userArea = new QWidget(this);
QHBoxLayout *userAreaLayout = new QHBoxLayout(this);
userAreaLayout->addWidget(lblUserIcon);
userAreaLayout->addWidget(lblUsuario);
userArea->setLayout(userAreaLayout);
userArea->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::MinimumExpanding);
ui->toolBarUser->addWidget(userArea);
this->addToolBar(Qt::TopToolBarArea, ui->toolBarUser);
this->addToolBar(Qt::LeftToolBarArea, ui->toolBar);
DlgLogin *loginDialog=new DlgLogin(this);
loginDialog->show();
}
void MainWindow::setUserName(QString user)
{
this->lblUsuario->setText(user);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_actionAlumnos_triggered()
{
FrmAlumnos* frmAlumnos=new FrmAlumnos();
ui->mdiArea->addSubWindow(frmAlumnos);
frmAlumnos->show();
}
void MainWindow::on_actionProductos_triggered()
{
//QList<QMdiSubWindow *> lista= ui->mdiArea->subWindowList(QMdiArea::CreationOrder);
bool canAdd = TRUE;
foreach (QMdiSubWindow *window, ui->mdiArea->subWindowList()){
if (window->windowTitle()=="Productos"){
canAdd=FALSE;
}
}
if (canAdd==TRUE){
frmproductos* frm=new frmproductos();
ui->mdiArea->addSubWindow(frm);
frm->show();
}
}
void MainWindow::on_actionSistema_triggered()
{
FrmSysOptions *frm=new FrmSysOptions();
ui->mdiArea->addSubWindow(frm);
frm->show();
}
void MainWindow::on_actionVentas_triggered()
{
bool canAdd = TRUE;
foreach (QMdiSubWindow *window, ui->mdiArea->subWindowList()){
if (window->windowTitle()=="Ventas"){
canAdd=FALSE;
}
}
if (canAdd==TRUE){
FrmVentas *frm=new FrmVentas();
ui->mdiArea->addSubWindow(frm);
frm->show();
}
}
void MainWindow::on_actionCompras_triggered()
{
bool canAdd = TRUE;
foreach (QMdiSubWindow *window, ui->mdiArea->subWindowList()){
if (window->windowTitle()=="Compras"){
canAdd=FALSE;
}
}
if (canAdd==TRUE){
FrmCompras *frm=new FrmCompras();
ui->mdiArea->addSubWindow(frm);
frm->show();
}
}