-
Notifications
You must be signed in to change notification settings - Fork 0
/
chatwidget.cpp
62 lines (50 loc) · 1.14 KB
/
chatwidget.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
#include "chatwidget.h"
#include "ui_chatwidget.h"
#include "newtab.h"
#include <QDebug>
#include <QSettings>
ChatWidget::ChatWidget(QWidget *parent) :
QTabWidget(parent),
ui(new Ui::ChatWidget)
{
ui->setupUi(this);
connect(this,SIGNAL(currentChanged(int)),this,SLOT(changedTab(int)));
connect(this,SIGNAL(tabCloseRequested(int)),this,SLOT(closeTab(int)));
}
ChatWidget::~ChatWidget()
{
delete ui;
}
void ChatWidget::changedTab(int i)
{
qDebug() << "Changed to Tab Nr." << i;
}
void ChatWidget::tabInserted(int index)
{
qDebug() << "Yay a new Tab. Index: " << index;
newTab *tab = (newTab*)widget(index);
QSettings s;
tab->setFriend(tabText(index));
tab->setUser(s.value("UserEmail").toString());
this->setCurrentIndex(index);
}
void ChatWidget::closeTab(int index)
{
qDebug() << "Tab No." << index << " should closed now";
removeTab(index);
if(count() == 0)
{
this->close();
}
}
bool ChatWidget::existTab(QString tabname)
{
for(int i = 0; i < count(); i++)
{
if(tabText(i) == tabname)
{
return true;
}
}
return false;
}