Merge pull request #38 from sophiekovalevsky/full-screen-plots

gui: set individual plot as full screen when double clicked
This commit is contained in:
jankae 2021-07-03 22:15:09 +02:00 committed by GitHub
commit 14e2794826
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 60 additions and 0 deletions

View File

@ -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;

View File

@ -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;
};

View File

@ -200,6 +200,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="ContentFullScreenMode"/>
<widget class="QWidget" name="ContentPage"/>
</widget>
</item>