@@ -18,24 +18,36 VisualizationWidget::VisualizationWidget(QWidget *parent) | |||||
18 | auto addTabViewButton = new QToolButton{ui->tabWidget}; |
|
18 | auto addTabViewButton = new QToolButton{ui->tabWidget}; | |
19 | addTabViewButton->setText(tr("Add View")); |
|
19 | addTabViewButton->setText(tr("Add View")); | |
20 | addTabViewButton->setCursor(Qt::ArrowCursor); |
|
20 | addTabViewButton->setCursor(Qt::ArrowCursor); | |
21 | addTabViewButton->setAutoRaise(true); |
|
|||
22 | ui->tabWidget->setCornerWidget(addTabViewButton, Qt::TopRightCorner); |
|
21 | ui->tabWidget->setCornerWidget(addTabViewButton, Qt::TopRightCorner); | |
23 | auto width = ui->tabWidget->cornerWidget()->width(); |
|
22 | ||
24 | auto height = ui->tabWidget->cornerWidget()->height(); |
|
23 | auto enableMinimunCornerWidgetSize = [this](bool enable) { | |
25 | addTabViewButton->setMinimumHeight(height); |
|
24 | ||
26 | addTabViewButton->setMinimumWidth(width); |
|
25 | auto tabViewCornerWidget = ui->tabWidget->cornerWidget(); | |
27 | ui->tabWidget->setMinimumHeight(height); |
|
26 | auto width = enable ? tabViewCornerWidget->width() : 0; | |
28 | ui->tabWidget->setMinimumWidth(width); |
|
27 | auto height = enable ? tabViewCornerWidget->height() : 0; | |
29 |
|
28 | tabViewCornerWidget->setMinimumHeight(height); | ||
30 | auto addTabView = [&]() { |
|
29 | tabViewCornerWidget->setMinimumWidth(width); | |
|
30 | ui->tabWidget->setMinimumHeight(height); | |||
|
31 | ui->tabWidget->setMinimumWidth(width); | |||
|
32 | }; | |||
|
33 | ||||
|
34 | auto addTabView = [this, enableMinimunCornerWidgetSize]() { | |||
31 | auto index = ui->tabWidget->addTab(new VisualizationTabWidget(ui->tabWidget), |
|
35 | auto index = ui->tabWidget->addTab(new VisualizationTabWidget(ui->tabWidget), | |
32 | QString("View %1").arg(ui->tabWidget->count() + 1)); |
|
36 | QString("View %1").arg(ui->tabWidget->count() + 1)); | |
|
37 | if (ui->tabWidget->count() > 0) { | |||
|
38 | enableMinimunCornerWidgetSize(false); | |||
|
39 | } | |||
33 | qCInfo(LOG_VisualizationWidget()) << tr("add the tab of index %1").arg(index); |
|
40 | qCInfo(LOG_VisualizationWidget()) << tr("add the tab of index %1").arg(index); | |
34 | }; |
|
41 | }; | |
35 |
|
42 | |||
36 |
auto removeTabView = [ |
|
43 | auto removeTabView = [this, enableMinimunCornerWidgetSize](int index) { | |
|
44 | if (ui->tabWidget->count() == 1) { | |||
|
45 | enableMinimunCornerWidgetSize(true); | |||
|
46 | } | |||
|
47 | ||||
37 | ui->tabWidget->removeTab(index); |
|
48 | ui->tabWidget->removeTab(index); | |
38 | qCInfo(LOG_VisualizationWidget()) << tr("remove the tab of index %1").arg(index); |
|
49 | qCInfo(LOG_VisualizationWidget()) << tr("remove the tab of index %1").arg(index); | |
|
50 | ||||
39 | }; |
|
51 | }; | |
40 |
|
52 | |||
41 | ui->tabWidget->setTabsClosable(true); |
|
53 | ui->tabWidget->setTabsClosable(true); |
@@ -14,14 +14,32 | |||||
14 | <string>Form</string> |
|
14 | <string>Form</string> | |
15 | </property> |
|
15 | </property> | |
16 | <layout class="QVBoxLayout" name="verticalLayout_2"> |
|
16 | <layout class="QVBoxLayout" name="verticalLayout_2"> | |
|
17 | <property name="spacing"> | |||
|
18 | <number>3</number> | |||
|
19 | </property> | |||
|
20 | <property name="leftMargin"> | |||
|
21 | <number>0</number> | |||
|
22 | </property> | |||
|
23 | <property name="topMargin"> | |||
|
24 | <number>0</number> | |||
|
25 | </property> | |||
|
26 | <property name="rightMargin"> | |||
|
27 | <number>0</number> | |||
|
28 | </property> | |||
|
29 | <property name="bottomMargin"> | |||
|
30 | <number>0</number> | |||
|
31 | </property> | |||
17 | <item> |
|
32 | <item> | |
18 | <widget class="QFrame" name="visualizationZoneFrame"> |
|
33 | <widget class="QFrame" name="visualizationZoneFrame"> | |
19 | <property name="frameShape"> |
|
34 | <property name="frameShape"> | |
20 |
<enum>QFrame:: |
|
35 | <enum>QFrame::Box</enum> | |
21 | </property> |
|
36 | </property> | |
22 | <property name="frameShadow"> |
|
37 | <property name="frameShadow"> | |
23 | <enum>QFrame::Raised</enum> |
|
38 | <enum>QFrame::Raised</enum> | |
24 | </property> |
|
39 | </property> | |
|
40 | <property name="lineWidth"> | |||
|
41 | <number>1</number> | |||
|
42 | </property> | |||
25 | <layout class="QVBoxLayout" name="verticalLayout"/> |
|
43 | <layout class="QVBoxLayout" name="verticalLayout"/> | |
26 | </widget> |
|
44 | </widget> | |
27 | </item> |
|
45 | </item> |
General Comments 0
You need to be logged in to leave comments.
Login now