diff options
author | Simon Rettberg | 2018-08-03 15:30:22 +0200 |
---|---|---|
committer | Simon Rettberg | 2018-08-03 15:30:22 +0200 |
commit | 2c8b79b680568a9d104e23b2fad55ef24819ebcc (patch) | |
tree | 24dc4bc2f80c4dbc470dd9cd4413d998bffb3e08 /src/server | |
parent | [server] Make "reload room" window look less idiotic (diff) | |
download | pvs2-2c8b79b680568a9d104e23b2fad55ef24819ebcc.tar.gz pvs2-2c8b79b680568a9d104e23b2fad55ef24819ebcc.tar.xz pvs2-2c8b79b680568a9d104e23b2fad55ef24819ebcc.zip |
[server] Get rid of broken help window ui, generate programatically
Diffstat (limited to 'src/server')
-rw-r--r-- | src/server/helpwindow/helpwindow.cpp | 56 | ||||
-rw-r--r-- | src/server/helpwindow/helpwindow.h | 16 | ||||
-rw-r--r-- | src/server/mainwindow/mainwindow.cpp | 3 |
3 files changed, 40 insertions, 35 deletions
diff --git a/src/server/helpwindow/helpwindow.cpp b/src/server/helpwindow/helpwindow.cpp index bc04d30..2ae47ee 100644 --- a/src/server/helpwindow/helpwindow.cpp +++ b/src/server/helpwindow/helpwindow.cpp @@ -1,23 +1,43 @@ #include "helpwindow.h" -#include "ui_help.h" -HelpWindow::HelpWindow(QWidget *parent) : - QDialog(parent), ui(new Ui::Help) -{ - ui->setupUi(this); - connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(onButtonCancel())); -} - -HelpWindow::~HelpWindow() -{ - delete ui; -} - -/* - * Slots - */ +#include <QPushButton> +#include <QBoxLayout> +#include <QAction> +#include <QLabel> -void HelpWindow::onButtonCancel() +HelpWindow::HelpWindow(const QList<QAction*> &actions, QWidget *parent) : + QDialog(parent) { - this->hide(); + 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); } diff --git a/src/server/helpwindow/helpwindow.h b/src/server/helpwindow/helpwindow.h index 528a4d3..2f0cdcb 100644 --- a/src/server/helpwindow/helpwindow.h +++ b/src/server/helpwindow/helpwindow.h @@ -3,26 +3,12 @@ #include <QDialog> -namespace Ui -{ -class Help; -} - class HelpWindow : public QDialog { Q_OBJECT public: - explicit HelpWindow(QWidget *parent = 0); - ~HelpWindow(); - Ui::Help *ui; - - // void show(); - -private: - -private slots: - void onButtonCancel(); + explicit HelpWindow(const QList<QAction*> &actions, QWidget *parent = nullptr); }; #endif diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp index 6ff8fc3..17bfdb2 100644 --- a/src/server/mainwindow/mainwindow.cpp +++ b/src/server/mainwindow/mainwindow.cpp @@ -78,8 +78,6 @@ MainWindow::MainWindow(QWidget* parent) : _virtRows = 0; _sessionNameWindow = new SessionNameWindow(this); - _helpWindow = new HelpWindow(this); - _helpWindow->setWindowTitle(tr("Help")); _reloadWindow = new ReloadRoomWindow(this); _reloadWindow->setWindowTitle(tr("Reload Room")); ui->setupUi(this); @@ -111,6 +109,7 @@ MainWindow::MainWindow(QWidget* parent) : _dropMarker = new QLabel(ui->frmRoom); _dropMarker->setStyleSheet("background-color: #448; border-radius: 2px;"); _dropMarker->hide(); + _helpWindow = new HelpWindow(ui->toolBar->actions(), this); serverApp->setExam(false); |