-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlightman.cpp
More file actions
82 lines (59 loc) · 1.76 KB
/
lightman.cpp
File metadata and controls
82 lines (59 loc) · 1.76 KB
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
#include "lightman.h"
#include "ui_lightman.h"
#include "QResizeEvent"
#include <QDebug>
#include "iostream"
#include "newrequestscreen.h"
#include "newserverscreen.h"
#include "nameatabdialog.h"
LightMan::LightMan(QWidget *parent)
: QWidget(parent)
, ui(new Ui::LightMan)
{
ui->setupUi(this);
init();
}
LightMan::~LightMan()
{
delete ui;
qDebug() <<" LIGMAN DELETED";
}
void LightMan::resizeEvent(QResizeEvent *event) {
QWidget::resizeEvent(event);
}
void LightMan::init() {
const std::function<void(QString&,bool)> clickCallback = [&](QString &tabName,bool tabTypeIsServer) {
onNameATabDialogDismiss(tabName,tabTypeIsServer);
};
nameATabDialog = new NameATabDialog(clickCallback,this);
ui->tabWidget->setAttribute(Qt::WA_DeleteOnClose, true);
connect(ui->newRequestButton,&QPushButton::clicked,this,&LightMan::onNewRequestButtonClicked);
connect(ui->newServerButton,&QPushButton::clicked,this,&LightMan::onNewServerButtonClicked);
//todo will be working on it later..
ui->newServerButton->setVisible(false);
}
void LightMan::on_tabWidget_tabCloseRequested(int index)
{
ui->tabWidget->removeTab(index);
}
void LightMan::on_tabWidget_tabBarClicked(int index)
{
}
void LightMan::onNewServerButtonClicked()
{
nameATabDialog->showDialog(true);
}
void LightMan::onNewRequestButtonClicked()
{
nameATabDialog->showDialog(false);
}
void LightMan::onNameATabDialogDismiss(QString& tabName,bool tabTypeIsServer) {
int tabIndex = -1;
if(tabTypeIsServer) {
tabIndex = ui->tabWidget->addTab(new NewServerScreen(),tabName);
} else {
tabIndex = ui->tabWidget->addTab(new NewRequestScreen(), tabName);
}
ui->tabWidget->setCurrentIndex(tabIndex);
ui->tabWidget->update();
}