-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnameatabdialog.cpp
46 lines (37 loc) · 1.2 KB
/
nameatabdialog.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
#include "nameatabdialog.h"
#include "ui_nameatabdialog.h"
#include "QtDebug"
NameATabDialog::NameATabDialog(const std::function<void(QString&,bool)> callback,QWidget *parent) :
QDialog(parent),
ui(new Ui::NameATabDialog),clickCallback{callback},requestTabCounter{new Counter{1}},serverTabCounter {new Counter{1}}
{
ui->setupUi(this);
}
NameATabDialog::~NameATabDialog()
{
delete ui;
delete requestTabCounter;
delete serverTabCounter;
qDebug() <<"NAME A TAB DIALOG DELETED";
}
void NameATabDialog::on_buttonBox_accepted()
{
QString text = ui->textEdit->toPlainText().replace("\n", " ");;
if(text.isEmpty() || text.isNull()) {
int tabCounter = tabTypeIsServer ? serverTabCounter->getAndIncrement() : requestTabCounter->getAndIncrement();
QString tabTitle = tabTypeIsServer ? QString("Server") : QString("Request");
text = tabTitle.append(tr(" - %1")).arg(tabCounter);
}
(clickCallback)(text,tabTypeIsServer);
}
void NameATabDialog::on_buttonBox_rejected()
{
//todo implement something.
}
void NameATabDialog::showEvent(QShowEvent *event) {
ui->textEdit->clear();
}
void NameATabDialog::showDialog(bool server) {
tabTypeIsServer = server;
this->show();
}