| 19 | #include <QtWidgets/QVBoxLayout> |
| 20 | |
| 21 | AboutDialog::AboutDialog(QWidget * parent) |
| 22 | : QDialog(parent, |
| 23 | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint) |
| 24 | { |
| 25 | QIcon icon(":/ui/logo.png"); |
| 26 | setWindowIcon(icon); |
| 27 | setWindowTitle(QMenuBar::tr("About")); |
| 28 | |
| 29 | QLabel * labelIcon = new QLabel(); |
| 30 | labelIcon->setPixmap(icon.pixmap(128)); |
| 31 | |
| 32 | Platform & platform = GetPlatform(); |
| 33 | |
| 34 | QVBoxLayout * versionBox = new QVBoxLayout(); |
| 35 | versionBox->addWidget(new QLabel(QCoreApplication::applicationName())); |
| 36 | QLabel * versionLabel = new QLabel("Version: " + QString::fromStdString(platform.Version())); |
| 37 | versionLabel->setTextInteractionFlags(Qt::TextSelectableByMouse); |
| 38 | versionBox->addWidget(versionLabel); |
| 39 | // TODO: insert maps data version. |
| 40 | // versionBox->addWidget(new QLabel(QString("Data: ") + DESIGNER_DATA_VERSION)); |
| 41 | |
| 42 | QHBoxLayout * hBox = new QHBoxLayout(); |
| 43 | hBox->addWidget(labelIcon); |
| 44 | hBox->addLayout(versionBox); |
| 45 | |
| 46 | std::string aboutText; |
| 47 | try |
| 48 | { |
| 49 | ReaderPtr<Reader> reader = platform.GetReader("copyright.html"); |
| 50 | reader.ReadAsString(aboutText); |
| 51 | } |
| 52 | catch (RootException const & ex) |
| 53 | { |
| 54 | LOG(LWARNING, ("About text error: ", ex.Msg())); |
| 55 | } |
| 56 | |
| 57 | if (!aboutText.empty()) |
| 58 | { |
| 59 | QTextBrowser * aboutTextBrowser = new QTextBrowser(); |
| 60 | aboutTextBrowser->setReadOnly(true); |
| 61 | aboutTextBrowser->setOpenLinks(true); |
| 62 | aboutTextBrowser->setOpenExternalLinks(true); |
| 63 | RemovePTagsWithNonMatchedLanguages(languages::GetCurrentTwine(), aboutText); |
| 64 | aboutTextBrowser->setText(aboutText.c_str()); |
| 65 | |
| 66 | QVBoxLayout * vBox = new QVBoxLayout(); |
| 67 | vBox->addLayout(hBox); |
| 68 | vBox->addWidget(aboutTextBrowser); |
| 69 | setLayout(vBox); |
| 70 | } |
| 71 | else |
| 72 | setLayout(hBox); |
| 73 | |
| 74 | adjustSize(); |
| 75 | } |
nothing calls this directly
no test coverage detected