summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2018-09-03 13:35:39 +0200
committerSimon Rettberg2018-09-03 13:35:39 +0200
commit78346191063fd4e35c1575d6a715d9f2e574034c (patch)
treeea4a5d9079e5e88c85e6e29d8da01955d418c3e3
parent[*] Add log message if loading translations fails (diff)
downloadpvs2-78346191063fd4e35c1575d6a715d9f2e574034c.tar.gz
pvs2-78346191063fd4e35c1575d6a715d9f2e574034c.tar.xz
pvs2-78346191063fd4e35c1575d6a715d9f2e574034c.zip
[server] Pimp help window
Closes #3409
-rw-r--r--src/server/helpwindow/helpwindow.cpp56
-rw-r--r--src/server/helpwindow/helpwindow.h2
2 files changed, 43 insertions, 15 deletions
diff --git a/src/server/helpwindow/helpwindow.cpp b/src/server/helpwindow/helpwindow.cpp
index 2ae47ee..152cf0d 100644
--- a/src/server/helpwindow/helpwindow.cpp
+++ b/src/server/helpwindow/helpwindow.cpp
@@ -1,43 +1,69 @@
#include "helpwindow.h"
#include <QPushButton>
-#include <QBoxLayout>
+#include <QGridLayout>
#include <QAction>
#include <QLabel>
+#include <QDebug>
+#include <QApplication>
+#include <QScreen>
+
+#define ICON_SIZE (50)
+#define ICON_SIZE_SMALL (32)
HelpWindow::HelpWindow(const QList<QAction*> &actions, QWidget *parent) :
QDialog(parent)
{
- QBoxLayout *layout = new QBoxLayout(QBoxLayout::TopToBottom, this);
- layout->setMargin(3);
+ setWindowTitle(tr("Help"));
+ int iconSize = ICON_SIZE;
+ for (auto screen : qApp->screens()) {
+ if (screen->geometry().height() < 900) {
+ iconSize = ICON_SIZE_SMALL;
+ break;
+ }
+ }
+ QGridLayout *layout = new QGridLayout(this);
+ layout->setSpacing(2);
+ QSizePolicy sizePol(QSizePolicy::Minimum, QSizePolicy::Preferred);
+ QList<QLabel*> wrapLabels;
// Add help items
+ int row = 0;
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);
+ icon->setPixmap(action->icon().pixmap(iconSize, iconSize, QIcon::Normal, QIcon::Off));
+ icon->setMinimumSize(iconSize + 5, iconSize + 2);
+ layout->addWidget(icon, row, 0, 3, 1, Qt::AlignTop | Qt::AlignLeft);
QLabel *headline = new QLabel(action->toolTip(), this);
QFont boldFont = headline->font();
boldFont.setBold(true);
headline->setFont(boldFont);
- textLayout->addWidget(headline);
+ headline->setAlignment(Qt::AlignTop | Qt::AlignLeft);
+ layout->addWidget(headline, row, 1, Qt::AlignTop);
QLabel *description = new QLabel(action->text(), this);
description->setWordWrap(true);
- textLayout->addWidget(description);
- textLayout->addStretch(1);
- rowLayout->addLayout(textLayout, 1);
- layout->addLayout(rowLayout);
+ description->setAlignment(Qt::AlignTop | Qt::AlignLeft);
+ description->setSizePolicy(sizePol);
+ wrapLabels.append(description);
+ layout->addWidget(description, row + 1, 1, Qt::AlignTop);
+ layout->setRowStretch(row + 2, 1);
+ QFrame *line = new QFrame();
+ line->setFrameShape(QFrame::HLine);
+ line->setFrameShadow(QFrame::Sunken);
+ layout->addWidget(line, row + 3, 0, 1, 2);
+ row += 4;
}
+ layout->setColumnStretch(1, 1);
// Add close button
+ layout->setRowStretch(row++, 1000);
QPushButton *close = new QPushButton(tr("Close"), this);
QFont bigFont = close->font();
bigFont.setPointSize(20);
close->setFont(bigFont);
+ close->setDefault(true);
connect(close, SIGNAL(clicked()), this, SLOT(hide()));
- layout->addStretch(1);
- layout->addWidget(close);
- this->setMinimumSize(600, 600);
+ layout->addWidget(close, row++, 0, 1, 2);
+ this->setFixedWidth(600);
+ this->setSizePolicy(sizePol);
}
diff --git a/src/server/helpwindow/helpwindow.h b/src/server/helpwindow/helpwindow.h
index 2f0cdcb..56bfe24 100644
--- a/src/server/helpwindow/helpwindow.h
+++ b/src/server/helpwindow/helpwindow.h
@@ -3,6 +3,8 @@
#include <QDialog>
+class QShowEvent;
+
class HelpWindow : public QDialog
{
Q_OBJECT