YODAU 1.0
YEAR OF THE DEPEND ADULT UNDERGARMENT
Loading...
Searching...
No Matches
board.cpp
Go to the documentation of this file.
1#include "widgets/board.hpp"
2
3#include <QVBoxLayout>
4
5#include "widgets/grid_view.hpp"
6#include "widgets/stream_cell.hpp"
7
8board::board(QWidget* parent)
9 : QWidget(parent)
10 , grid(new grid_view(this))
11 , active_container(new QWidget(this))
12 , active_layout(new QVBoxLayout(active_container))
13 , active_tile(nullptr) {
14 active_layout->setContentsMargins(6, 6, 6, 6);
15 active_layout->setSpacing(6);
16 active_container->setLayout(active_layout);
17
18 auto* outer = new QVBoxLayout(this);
19 outer->setContentsMargins(0, 0, 0, 0);
20 outer->setSpacing(6);
21
22 outer->addWidget(active_container, 3);
23
24 outer->addWidget(grid, 1);
25
26 setLayout(outer);
27 active_container->hide();
28}
29
30grid_view* board::grid_mode() const { return grid; }
31
33
34void board::set_active_stream(const QString& name) {
35 if (!grid || name.isEmpty()) {
36 return;
37 }
38 if (active_tile && active_tile->get_name() == name) {
39 return;
40 }
41
42 if (active_tile) {
43 active_layout->removeWidget(active_tile);
46 active_tile = nullptr;
47 }
48
50 if (!cell) {
51 return;
52 }
53 active_container->show();
54
55 cell->setParent(active_container);
56 cell->set_active(true);
57
58 cell->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
59 cell->show();
60 active_layout->addWidget(cell);
61 active_tile = cell;
62
63 active_container->updateGeometry();
64}
65
67 if (!active_tile || !grid) {
68 return;
69 }
70 active_layout->removeWidget(active_tile);
73 // active_tile->deleteLater();
74 active_tile = nullptr;
75
76 active_container->hide();
77 active_container->updateGeometry();
78}
79
81 if (!active_tile) {
82 return nullptr;
83 }
84
85 active_layout->removeWidget(active_tile);
87
88 active_container->hide();
89 active_container->updateGeometry();
90
92 active_tile = nullptr;
93 return out;
94}
void clear_active()
Clear active mode and return the active cell to the grid.
Definition board.cpp:66
board(QWidget *parent=nullptr)
Construct the board widget.
Definition board.cpp:8
void set_active_stream(const QString &name)
Make a stream active by name.
Definition board.cpp:34
stream_cell * active_cell() const
Get the currently active (focused) stream cell, if any.
Definition board.cpp:32
QVBoxLayout * active_layout
Layout inside active_container.
Definition board.hpp:111
grid_view * grid_mode() const
Access the grid view (thumbnail mode).
Definition board.cpp:30
stream_cell * take_active_cell()
Detach and return the active cell without putting it back to grid.
Definition board.cpp:80
stream_cell * active_tile
Currently active stream cell (reparented into active container).
Definition board.hpp:115
grid_view * grid
Grid view holding all non-active stream cells.
Definition board.hpp:105
grid_view(QWidget *parent=nullptr)
Construct an empty grid view.
Definition grid_view.cpp:13
stream_cell * take_stream_cell(const QString &name)
Detach a stream cell from the grid without deleting it.
Definition grid_view.cpp:75
void put_stream_cell(stream_cell *cell)
Return a previously taken cell back into the grid.
Definition grid_view.cpp:91
void set_active(bool val)
Set active (focused) state.
const QString & get_name() const
Get logical name of this stream cell.
Instance of a persistent (saved) line to be rendered on the stream.