diff --git a/qt/info_dialog.cpp b/qt/info_dialog.cpp index a93b83ee86..4ee9c6c243 100644 --- a/qt/info_dialog.cpp +++ b/qt/info_dialog.cpp @@ -1,7 +1,9 @@ #include "info_dialog.hpp" +#include "../base/assert.hpp" + #include -#include +#include #include #include #include @@ -20,17 +22,27 @@ namespace qt setWindowModality(Qt::WindowModal); QVBoxLayout * vBox = new QVBoxLayout(); - QLabel * label = new QLabel(text); - label->setOpenExternalLinks(true); - vBox->addWidget(label); + QTextBrowser * browser = new QTextBrowser(); + browser->setReadOnly(true); + browser->setOpenLinks(true); + browser->setOpenExternalLinks(true); + browser->setText(text); + vBox->addWidget(browser); // this horizontal layout is for buttons QHBoxLayout * hBox = new QHBoxLayout(); - hBox->addSpacing(label->width() / 4 * (3.5 - buttons.size())); + hBox->addSpacing(browser->width() / 4 * (3.5 - buttons.size())); for (int i = 0; i < buttons.size(); ++i) { QPushButton * button = new QPushButton(buttons[i], this); - connect(button, SIGNAL(clicked()), this, SLOT(OnButtonClick())); + switch (i) + { + case 0: connect(button, SIGNAL(clicked()), this, SLOT(OnButtonClick1())); break; + case 1: connect(button, SIGNAL(clicked()), this, SLOT(OnButtonClick2())); break; + case 2: connect(button, SIGNAL(clicked()), this, SLOT(OnButtonClick3())); break; + default: + ASSERT(false, ("Only 3 buttons are currently supported in info dialog")); + } hBox->addWidget(button); } @@ -38,9 +50,16 @@ namespace qt setLayout(vBox); } - void InfoDialog::OnButtonClick() + void InfoDialog::OnButtonClick1() { - // @TODO determine which button is pressed - done(0); + done(1); + } + void InfoDialog::OnButtonClick2() + { + done(2); + } + void InfoDialog::OnButtonClick3() + { + done(3); } } diff --git a/qt/info_dialog.hpp b/qt/info_dialog.hpp index 501412f594..06b6f479b4 100644 --- a/qt/info_dialog.hpp +++ b/qt/info_dialog.hpp @@ -5,6 +5,7 @@ namespace qt { /// Simple information dialog with scrollable html content + /// @note exec() returns 0 if dialog was closed or [1..buttons_count] for any button pressed class InfoDialog : public QDialog { Q_OBJECT @@ -13,6 +14,8 @@ namespace qt explicit InfoDialog(QString const & title, QString const & text, QWidget * parent, QStringList const & buttons = QStringList()); public Q_SLOTS: - void OnButtonClick(); + void OnButtonClick1(); + void OnButtonClick2(); + void OnButtonClick3(); }; }