From 2c8b79b680568a9d104e23b2fad55ef24819ebcc Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 3 Aug 2018 15:30:22 +0200 Subject: [server] Get rid of broken help window ui, generate programatically --- src/server/helpwindow/helpwindow.cpp | 56 ++++++++++++++++++++++++------------ src/server/helpwindow/helpwindow.h | 16 +---------- src/server/mainwindow/mainwindow.cpp | 3 +- 3 files changed, 40 insertions(+), 35 deletions(-) (limited to 'src') 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 +#include +#include +#include -void HelpWindow::onButtonCancel() +HelpWindow::HelpWindow(const QList &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 -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 &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); -- cgit v1.2.3-55-g7522