From 0b2cd5bdc5308f7119db8dc581a7e6ac9ce2260a Mon Sep 17 00:00:00 2001 From: Kiara Navarro Date: Thu, 1 Jul 2021 22:11:38 -0300 Subject: [PATCH] gui: set individual plot as full screen when double clicked The following commit features to set specific plot as full screen if double clicked event is triggered while mouse is over that particular plot. This becomes handy if you are interested in a particular traces over that plot and want to inspect it in more detail. --- .../CustomWidgets/tilewidget.cpp | 54 +++++++++++++++++++ .../PC_Application/CustomWidgets/tilewidget.h | 5 ++ .../CustomWidgets/tilewidget.ui | 1 + 3 files changed, 60 insertions(+) diff --git a/Software/PC_Application/CustomWidgets/tilewidget.cpp b/Software/PC_Application/CustomWidgets/tilewidget.cpp index bb4c02f..8d66da9 100644 --- a/Software/PC_Application/CustomWidgets/tilewidget.cpp +++ b/Software/PC_Application/CustomWidgets/tilewidget.cpp @@ -13,13 +13,17 @@ TileWidget::TileWidget(TraceModel &model, QWidget *parent) : child1(0), child2(0), hasContent(false), + isFullScreen(false), content(0), model(model) { ui->setupUi(this); auto layout = new QGridLayout; layout->setContentsMargins(0,0,0,0); + auto fsLayout = new QGridLayout; + fsLayout->setContentsMargins(0,0,0,0); ui->ContentPage->setLayout(layout); + ui->ContentFullScreenMode->setLayout(fsLayout); ui->bClose->setVisible(false); } @@ -188,6 +192,49 @@ void TileWidget::setContent(TracePlot *plot) ui->ContentPage->layout()->addWidget(plot); ui->stack->setCurrentWidget(ui->ContentPage); connect(content, &TracePlot::deleted, this, &TileWidget::traceDeleted); + connect(content, &TracePlot::doubleClicked, this, &TileWidget::on_plotDoubleClicked); +} + +void TileWidget::on_plotDoubleClicked() +{ + setFullScreen(); +} + +void TileWidget::setFullScreen(void) +{ + auto clickedTile = this; + + if(!clickedTile->parent) { + // Toplevel tile is already in full screen + return; + } + + auto rootTile = findRootTile(); + + rootTile->fullScreenPlot = clickedTile->content; + + if (isFullScreen == false) + { + ui->ContentPage->layout()->removeWidget(clickedTile->content); + rootTile->ui->ContentFullScreenMode->layout()->addWidget(rootTile->fullScreenPlot); + rootTile->ui->stack->setCurrentWidget(rootTile->ui->ContentFullScreenMode); + isFullScreen = true; + } + else { + rootTile->ui->stack->setCurrentWidget(rootTile->ui->ContentPage); + rootTile->ui->ContentFullScreenMode->layout()->removeWidget(rootTile->fullScreenPlot); + ui->ContentPage->layout()->addWidget(clickedTile->content); + isFullScreen = false; + } +} + +TileWidget* TileWidget::findRootTile(void) +{ + auto node = this; + while (node->parent != nullptr) { // root tile should nullptr + node = node->parent; + } + return node; } void TileWidget::on_bSmithchart_clicked() @@ -204,6 +251,13 @@ void TileWidget::on_bXYplot_clicked() void TileWidget::traceDeleted(TracePlot *) { + + if (isFullScreen) + { + auto rootTile = findRootTile(); + rootTile->ui->stack->setCurrentWidget(rootTile->ui->ContentPage); + } + ui->stack->setCurrentWidget(ui->TilePage); hasContent = false; content = nullptr; diff --git a/Software/PC_Application/CustomWidgets/tilewidget.h b/Software/PC_Application/CustomWidgets/tilewidget.h index 357974e..27780cc 100644 --- a/Software/PC_Application/CustomWidgets/tilewidget.h +++ b/Software/PC_Application/CustomWidgets/tilewidget.h @@ -36,6 +36,7 @@ public slots: private slots: void on_bSmithchart_clicked(); void on_bXYplot_clicked(); + void on_plotDoubleClicked(); void traceDeleted(TracePlot *t); private: @@ -43,12 +44,16 @@ private: void split(); void setContent(TracePlot *plot); void setChild(); + TileWidget* findRootTile(); + void setFullScreen(); + TracePlot *fullScreenPlot; Ui::TileWidget *ui; QSplitter *splitter; bool isSplit; TileWidget *parent; TileWidget *child1, *child2; bool hasContent; + bool isFullScreen; TracePlot *content; TraceModel &model; }; diff --git a/Software/PC_Application/CustomWidgets/tilewidget.ui b/Software/PC_Application/CustomWidgets/tilewidget.ui index 67d7e08..2219e23 100644 --- a/Software/PC_Application/CustomWidgets/tilewidget.ui +++ b/Software/PC_Application/CustomWidgets/tilewidget.ui @@ -200,6 +200,7 @@ +