Pool Video Switch v2
Software video switch for distributed remote display in a lecture environment
helpwindow.cpp
Go to the documentation of this file.
1 #include "helpwindow.h"
2 
3 #include <QPushButton>
4 #include <QGridLayout>
5 #include <QAction>
6 #include <QLabel>
7 #include <QDebug>
8 #include <QApplication>
9 #include <QScreen>
10 
11 #define ICON_SIZE (50)
12 #define ICON_SIZE_SMALL (32)
13 
14 HelpWindow::HelpWindow(const QList<QAction*> &actions, QWidget *parent) :
15  QDialog(parent)
16 {
17  setWindowTitle(tr("Help"));
18  int iconSize = ICON_SIZE;
19  for (auto screen : qApp->screens()) {
20  if (screen->geometry().height() < 900) {
21  iconSize = ICON_SIZE_SMALL;
22  break;
23  }
24  }
25  auto *layout = new QGridLayout(this);
26  layout->setSpacing(2);
27  QSizePolicy sizePol(QSizePolicy::Minimum, QSizePolicy::Preferred);
28  QList<QLabel*> wrapLabels;
29  // Add help items
30  int row = 0;
31  for (QAction *action : actions) {
32  if (action->icon().isNull() || action->text().isEmpty())
33  continue;
34  auto *icon = new QLabel(this);
35  icon->setPixmap(action->icon().pixmap(iconSize, iconSize, QIcon::Normal, QIcon::Off));
36  icon->setMinimumSize(iconSize + 5, iconSize + 2);
37  layout->addWidget(icon, row, 0, 3, 1, Qt::AlignTop | Qt::AlignLeft);
38  auto *headline = new QLabel(action->toolTip(), this);
39  QFont boldFont = headline->font();
40  boldFont.setBold(true);
41  headline->setFont(boldFont);
42  headline->setAlignment(Qt::AlignTop | Qt::AlignLeft);
43  layout->addWidget(headline, row, 1, Qt::AlignTop);
44  auto *description = new QLabel(action->text(), this);
45  description->setWordWrap(true);
46  description->setAlignment(Qt::AlignTop | Qt::AlignLeft);
47  description->setSizePolicy(sizePol);
48  wrapLabels.append(description);
49  layout->addWidget(description, row + 1, 1, Qt::AlignTop);
50  layout->setRowStretch(row + 2, 1);
51  auto *line = new QFrame();
52  line->setFrameShape(QFrame::HLine);
53  line->setFrameShadow(QFrame::Sunken);
54  layout->addWidget(line, row + 3, 0, 1, 2);
55  row += 4;
56  }
57  layout->setColumnStretch(1, 1);
58  // Add close button
59  layout->setRowStretch(row++, 1000);
60  auto *close = new QPushButton(tr("Close"), this);
61  QFont bigFont = close->font();
62  bigFont.setPointSize(20);
63  close->setFont(bigFont);
64  close->setDefault(true);
65  connect(close, &QPushButton::clicked, this, &HelpWindow::hide);
66  layout->addWidget(close, row++, 0, 1, 2);
67  this->setFixedWidth(600);
68  this->setSizePolicy(sizePol);
69 }
HelpWindow(const QList< QAction * > &actions, QWidget *parent=nullptr)
Definition: helpwindow.cpp:14
#define ICON_SIZE
Definition: helpwindow.cpp:11
#define ICON_SIZE_SMALL
Definition: helpwindow.cpp:12