summaryrefslogtreecommitdiffstats
path: root/src/server/helpwindow/helpwindow.cpp
blob: 2ae47ee1132e04d4e39a5880461913725cba55af (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "helpwindow.h"

#include <QPushButton>
#include <QBoxLayout>
#include <QAction>
#include <QLabel>

HelpWindow::HelpWindow(const QList<QAction*> &actions, QWidget *parent) :
	QDialog(parent)
{
	QBoxLayout *layout = new QBoxLayout(QBoxLayout::TopToBottom, this);
	layout->setMargin(3);
	// Add help items
	for (QAction *action : actions) {
		if (action->icon().isNull() || action->text().isEmpty())
			continue;
		QBoxLayout *rowLayout = new QBoxLayout(QBoxLayout::LeftToRight, nullptr);
		QLabel *icon = new QLabel(this);
		icon->setPixmap(action->icon().pixmap(55, 55, QIcon::Normal, QIcon::Off));
		rowLayout->addWidget(icon);
		QBoxLayout *textLayout = new QBoxLayout(QBoxLayout::TopToBottom, nullptr);
		QLabel *headline = new QLabel(action->toolTip(), this);
		QFont boldFont = headline->font();
		boldFont.setBold(true);
		headline->setFont(boldFont);
		textLayout->addWidget(headline);
		QLabel *description = new QLabel(action->text(), this);
		description->setWordWrap(true);
		textLayout->addWidget(description);
		textLayout->addStretch(1);
		rowLayout->addLayout(textLayout, 1);
		layout->addLayout(rowLayout);
	}
	// Add close button
	QPushButton *close = new QPushButton(tr("Close"), this);
	QFont bigFont = close->font();
	bigFont.setPointSize(20);
	close->setFont(bigFont);
	connect(close, SIGNAL(clicked()), this, SLOT(hide()));
	layout->addStretch(1);
	layout->addWidget(close);
	this->setMinimumSize(600, 600);
}