VisualizationWidget.cpp
43 lines
| 1.4 KiB
| text/x-c
|
CppLexer
r95 | #include "Visualization/VisualizationWidget.h" | |||
#include "Visualization/VisualizationTabWidget.h" | ||||
r58 | #include "ui_VisualizationWidget.h" | |||
r88 | ||||
#include <QDebug> | ||||
#include <QToolButton> | ||||
#include "iostream" | ||||
Q_LOGGING_CATEGORY(LOG_VisualizationWidget, "VisualizationWidget") | ||||
r58 | ||||
VisualizationWidget::VisualizationWidget(QWidget *parent) | ||||
r91 | : QWidget{parent}, ui{new Ui::VisualizationWidget} | |||
r58 | { | |||
ui->setupUi(this); | ||||
r88 | ||||
r91 | auto addTabViewButton = new QToolButton{ui->tabWidget}; | |||
addTabViewButton->setText(tr("Add View")); | ||||
r88 | addTabViewButton->setCursor(Qt::ArrowCursor); | |||
addTabViewButton->setAutoRaise(true); | ||||
ui->tabWidget->setCornerWidget(addTabViewButton, Qt::TopRightCorner); | ||||
r101 | auto addTabView = [&]() { | |||
r88 | auto index = ui->tabWidget->addTab(new VisualizationTabWidget(ui->tabWidget), | |||
QString("View %1").arg(ui->tabWidget->count() + 1)); | ||||
qCInfo(LOG_VisualizationWidget()) << tr("add the tab of index %1").arg(index); | ||||
}; | ||||
auto removeTabView = [&](int index) { | ||||
ui->tabWidget->removeTab(index); | ||||
qCInfo(LOG_VisualizationWidget()) << tr("remove the tab of index %1").arg(index); | ||||
}; | ||||
ui->tabWidget->setTabsClosable(true); | ||||
connect(addTabViewButton, &QToolButton::clicked, addTabView); | ||||
connect(ui->tabWidget, &QTabWidget::tabCloseRequested, removeTabView); | ||||
r58 | } | |||
VisualizationWidget::~VisualizationWidget() | ||||
{ | ||||
delete ui; | ||||
} | ||||