Files
comaps/qt/info_dialog.cpp
Konstantin Pastbin e3e4a1985a Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run:
  git remote add om-historic [om-historic.git repo url]
  git fetch --tags om-historic
  git replace squashed-history historic-commits
2025-05-08 21:10:51 +07:00

66 lines
1.8 KiB
C++

#include "qt/info_dialog.hpp"
#include "base/assert.hpp"
#include <QtGui/QIcon>
#include <QtWidgets/QTextBrowser>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QVBoxLayout>
#include <QtWidgets/QLabel>
namespace qt
{
InfoDialog::InfoDialog(QString const & title, QString const & text, QWidget * parent,
QStringList const & buttons)
: QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint)
{
QIcon icon(":/ui/logo.png");
setWindowIcon(icon);
setWindowTitle(title);
setFocusPolicy(Qt::StrongFocus);
setWindowModality(Qt::WindowModal);
QVBoxLayout * vBox = new QVBoxLayout();
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(static_cast<int>(browser->width() / 4 * (3.5 - buttons.size())));
for (int i = 0; i < buttons.size(); ++i)
{
QPushButton * button = new QPushButton(buttons[i], this);
switch (i)
{
case 0: connect(button, &QAbstractButton::clicked, this, &InfoDialog::OnButtonClick1); break;
case 1: connect(button, &QAbstractButton::clicked, this, &InfoDialog::OnButtonClick2); break;
case 2: connect(button, &QAbstractButton::clicked, this, &InfoDialog::OnButtonClick3); break;
default:
ASSERT(false, ("Only 3 buttons are currently supported in info dialog"));
}
hBox->addWidget(button);
}
vBox->addLayout(hBox);
setLayout(vBox);
}
void InfoDialog::OnButtonClick1()
{
done(1);
}
void InfoDialog::OnButtonClick2()
{
done(2);
}
void InfoDialog::OnButtonClick3()
{
done(3);
}
}