-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathClientTabWidget.cpp
69 lines (50 loc) · 2.06 KB
/
ClientTabWidget.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
#include "ClientTabWidget.h"
#include <QLabel>
#include <QTabBar>
#include <QMenu>
#include "DesktopControlWidget.h"
#include <QDebug>
CilentTabWidget::CilentTabWidget(QWidget *parent) : QTabWidget(parent)
{
QString tab_qss = "QTabWidget::pane{} \
QTabBar::tab {color:rgb(0,0,0);font-size:14px;min-width:110px;height:30px;margin:2px;} \
QTabBar::tab:!selected {background:rgb(255,255,255);border:1px solid rgb(233,233,233);} \
QTabBar::tab:hover{background:rgba(255,255,255,0.8);} \
QTabBar::tab:selected {background:rgb(219,228,241);}";
setStyleSheet(tab_qss);
QTabBar *tabBar = this->tabBar();
tabBar->setTabsClosable(true);
tabBar->setSelectionBehaviorOnRemove(QTabBar::SelectPreviousTab);
tabBar->setMovable(true);
tabBar->setContextMenuPolicy(Qt::CustomContextMenu);
// connect(tabBar, &QTabBar::customContextMenuRequested, this, &CilentTabWidget::onHandleContextMenuRequested);
connect(tabBar, &QTabBar::tabCloseRequested, this, &CilentTabWidget::onCloseTab);
setDocumentMode(true);
// setElideMode(Qt::ElideRight);
}
void CilentTabWidget::addDesktopTab(){
DesktopControlWidget *desktop = new DesktopControlWidget(this);
addTab(desktop,tr("首页"));
setCurrentWidget(desktop);
// connect(desktop,&PageIndex::notifyCreateCustomTask,this,[this](const QString &address){
// createPageCustomTask(address);
// });
}
void CilentTabWidget::onCloseTab(int index){
QWidget *cw = widget(index);
if("PageIndex"==QString(cw->metaObject()->className())){
}else{
removeTab(index);
cw->deleteLater();
// delete currentWidget;
// if (WebView *view = webView(index)) {
// bool hasFocus = view->hasFocus();
// removeTab(index);
// if (hasFocus && count() > 0)
// currentWebView()->setFocus();
// if (count() == 0)
// createTab();
// view->deleteLater();
// }
}
}