PeriodicUpdateView.cpp
Go to the documentation of this file.
2
3#include <cmath>
4
5#include <QCheckBox>
6#include <QDoubleSpinBox>
7#include <QHBoxLayout>
8#include <QPushButton>
9#include <QLabel>
10#include <QMovie>
11#include <QFontMetrics>
12
14{
15
17 {
18 setSizePolicy(QSizePolicy::Policy::Preferred, QSizePolicy::Policy::Fixed);
19
20 QLayout* vlayout = new QVBoxLayout();
21 QLayout* hlayout = new QHBoxLayout();
22 this->setLayout(vlayout);
23
24 const int margin = 0;
25 hlayout->setContentsMargins(margin, margin, margin, margin);
26 hlayout->setSpacing(6);
27
28 _updateButton = new QPushButton("Update", this);
29 _autoCheckBox = new QCheckBox("Auto Update", this);
30 _frequencySpinBox = new QDoubleSpinBox(this);
31 _collapseAllButton = new QPushButton("Collapse all", this);
32 _splitBoxButton = new QPushButton("Hide Queries, Predictions and Commits", this);
33 _loadingGifLabel = new QLabel(this);
34 _loadingGif = new QMovie(":/armem_gui/resources/loadingSpinner.gif");
35
36 _loadingGifLabel->setScaledContents(true);
37 QFontMetrics fm(font());
38 _loadingGifLabel->setFixedSize(fm.height(), fm.height());
39
40 _frequencySpinBox->setValue(2.0);
41 _frequencySpinBox->setMinimum(0);
42 _frequencySpinBox->setMaximum(60);
43 _frequencySpinBox->setSingleStep(0.5);
44 _frequencySpinBox->setSuffix(" Hz");
45
46 hlayout->addWidget(_updateButton);
47 hlayout->addWidget(_autoCheckBox);
48 hlayout->addWidget(_frequencySpinBox);
49
50 hlayout->addWidget(_collapseAllButton);
51 hlayout->addWidget(_splitBoxButton);
52 hlayout->addWidget(_loadingGifLabel);
53 vlayout->addItem(hlayout);
54
56
57 _frequencySpinBox->setEnabled(_autoCheckBox->isChecked());
58
59 // Private connections.
60 connect(_autoCheckBox, &QCheckBox::toggled, this, &This::toggleAutoUpdates);
61 connect(_frequencySpinBox,
62 &QDoubleSpinBox::editingFinished,
63 this,
65
66 // Public connections.
67 connect(_updateButton, &QPushButton::pressed, this, &This::update);
68 connect(_collapseAllButton, &QPushButton::pressed, this, &This::collapseAll);
69 connect(_splitBoxButton, &QPushButton::pressed, this, &This::splitBox);
70
71 }
72
73 void
75 {
76 _loadingGifLabel->setMovie(_loadingGif);
77 _loadingGif->start();
78 }
79
80 void
82 {
83 _loadingGif->stop();
84 _loadingGifLabel->clear();
85 }
86
87 void
89 {
90 if (_splitBoxButton->text() == "Hide Queries, Predictions and Commits") {
91 _splitBoxButton->setText("Show Queries, Predictions and Commits");
92 }
93 else {
94 _splitBoxButton->setText("Hide Queries, Predictions and Commits");
95 }
96 }
97
98 QPushButton*
100 {
101 return _updateButton;
102 }
103
104 QPushButton*
106 {
107 return _collapseAllButton;
108 }
109
110 QPushButton*
112 {
113 return _splitBoxButton;
114 }
115
116 bool
118 {
119 return _autoCheckBox->isChecked();
120 }
121
122 int
124 {
125 return static_cast<int>(std::round(1000 / _frequencySpinBox->value()));
126 }
127
128 QCheckBox*
130 {
131 return _autoCheckBox;
132 }
133
134 QDoubleSpinBox*
136 {
137 return _frequencySpinBox;
138 }
139
140} // namespace armarx::armem::gui::view