Merge pull request #38 from sophiekovalevsky/full-screen-plots
gui: set individual plot as full screen when double clicked
This commit is contained in:
commit
14e2794826
@ -13,13 +13,17 @@ TileWidget::TileWidget(TraceModel &model, QWidget *parent) :
|
|||||||
child1(0),
|
child1(0),
|
||||||
child2(0),
|
child2(0),
|
||||||
hasContent(false),
|
hasContent(false),
|
||||||
|
isFullScreen(false),
|
||||||
content(0),
|
content(0),
|
||||||
model(model)
|
model(model)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
auto layout = new QGridLayout;
|
auto layout = new QGridLayout;
|
||||||
layout->setContentsMargins(0,0,0,0);
|
layout->setContentsMargins(0,0,0,0);
|
||||||
|
auto fsLayout = new QGridLayout;
|
||||||
|
fsLayout->setContentsMargins(0,0,0,0);
|
||||||
ui->ContentPage->setLayout(layout);
|
ui->ContentPage->setLayout(layout);
|
||||||
|
ui->ContentFullScreenMode->setLayout(fsLayout);
|
||||||
ui->bClose->setVisible(false);
|
ui->bClose->setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,6 +192,49 @@ void TileWidget::setContent(TracePlot *plot)
|
|||||||
ui->ContentPage->layout()->addWidget(plot);
|
ui->ContentPage->layout()->addWidget(plot);
|
||||||
ui->stack->setCurrentWidget(ui->ContentPage);
|
ui->stack->setCurrentWidget(ui->ContentPage);
|
||||||
connect(content, &TracePlot::deleted, this, &TileWidget::traceDeleted);
|
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()
|
void TileWidget::on_bSmithchart_clicked()
|
||||||
@ -204,6 +251,13 @@ void TileWidget::on_bXYplot_clicked()
|
|||||||
|
|
||||||
void TileWidget::traceDeleted(TracePlot *)
|
void TileWidget::traceDeleted(TracePlot *)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (isFullScreen)
|
||||||
|
{
|
||||||
|
auto rootTile = findRootTile();
|
||||||
|
rootTile->ui->stack->setCurrentWidget(rootTile->ui->ContentPage);
|
||||||
|
}
|
||||||
|
|
||||||
ui->stack->setCurrentWidget(ui->TilePage);
|
ui->stack->setCurrentWidget(ui->TilePage);
|
||||||
hasContent = false;
|
hasContent = false;
|
||||||
content = nullptr;
|
content = nullptr;
|
||||||
|
@ -36,6 +36,7 @@ public slots:
|
|||||||
private slots:
|
private slots:
|
||||||
void on_bSmithchart_clicked();
|
void on_bSmithchart_clicked();
|
||||||
void on_bXYplot_clicked();
|
void on_bXYplot_clicked();
|
||||||
|
void on_plotDoubleClicked();
|
||||||
void traceDeleted(TracePlot *t);
|
void traceDeleted(TracePlot *t);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -43,12 +44,16 @@ private:
|
|||||||
void split();
|
void split();
|
||||||
void setContent(TracePlot *plot);
|
void setContent(TracePlot *plot);
|
||||||
void setChild();
|
void setChild();
|
||||||
|
TileWidget* findRootTile();
|
||||||
|
void setFullScreen();
|
||||||
|
TracePlot *fullScreenPlot;
|
||||||
Ui::TileWidget *ui;
|
Ui::TileWidget *ui;
|
||||||
QSplitter *splitter;
|
QSplitter *splitter;
|
||||||
bool isSplit;
|
bool isSplit;
|
||||||
TileWidget *parent;
|
TileWidget *parent;
|
||||||
TileWidget *child1, *child2;
|
TileWidget *child1, *child2;
|
||||||
bool hasContent;
|
bool hasContent;
|
||||||
|
bool isFullScreen;
|
||||||
TracePlot *content;
|
TracePlot *content;
|
||||||
TraceModel &model;
|
TraceModel &model;
|
||||||
};
|
};
|
||||||
|
@ -200,6 +200,7 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QWidget" name="ContentFullScreenMode"/>
|
||||||
<widget class="QWidget" name="ContentPage"/>
|
<widget class="QWidget" name="ContentPage"/>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
Loading…
Reference in New Issue
Block a user