PageRenderTime 45ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/src/tiled/newversiondialog.cpp

http://github.com/bjorn/tiled
C++ | 70 lines | 40 code | 11 blank | 19 comment | 2 complexity | 566e2e3523ece1d5c3cf0678fad84b9f MD5 | raw file
Possible License(s): Apache-2.0, GPL-2.0, LGPL-2.1, AGPL-1.0
  1. /*
  2. * newversiondialog.cpp
  3. * Copyright 2019, Thorbjørn Lindeijer <bjorn@lindeijer.nl>
  4. *
  5. * This file is part of Tiled.
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the Free
  9. * Software Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful, but WITHOUT
  13. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  15. * more details.
  16. *
  17. * You should have received a copy of the GNU General Public License along with
  18. * this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #include "newversiondialog.h"
  21. #include "ui_newversiondialog.h"
  22. #include "tiledproxystyle.h"
  23. #include "utils.h"
  24. #include <QDesktopServices>
  25. #include <QGuiApplication>
  26. namespace Tiled {
  27. NewVersionDialog::NewVersionDialog(const NewVersionChecker::VersionInfo &versionInfo,
  28. QWidget *parent)
  29. : QDialog(parent)
  30. , ui(new Ui::NewVersionDialog)
  31. , mVersionInfo(versionInfo)
  32. {
  33. ui->setupUi(this);
  34. if (auto *style = qobject_cast<TiledProxyStyle*>(QApplication::style()))
  35. if (style->isDark())
  36. ui->logo->setPixmap(QPixmap(QString::fromUtf8(":/images/about-tiled-logo-white.png")));
  37. QSize logoSize = Utils::dpiScaled(QSize(210, 114));
  38. ui->logo->setFixedSize(logoSize);
  39. ui->label->setFixedWidth(ui->logo->minimumWidth());
  40. ui->label->setText(tr("<p><b>%1 %2</b> is available!<br/><br/>Current version is %1 %3.</p>")
  41. .arg(QGuiApplication::applicationDisplayName(),
  42. versionInfo.version,
  43. QGuiApplication::applicationVersion()));
  44. ui->downloadButton->setVisible(!mVersionInfo.downloadUrl.isEmpty());
  45. connect(ui->downloadButton, &QPushButton::clicked, this, [this] {
  46. QDesktopServices::openUrl(mVersionInfo.downloadUrl);
  47. close();
  48. });
  49. ui->releaseNotesButton->setVisible(!mVersionInfo.releaseNotesUrl.isEmpty());
  50. connect(ui->releaseNotesButton, &QPushButton::clicked, this, [this] {
  51. QDesktopServices::openUrl(mVersionInfo.releaseNotesUrl);
  52. close();
  53. });
  54. }
  55. NewVersionDialog::~NewVersionDialog()
  56. {
  57. delete ui;
  58. }
  59. } // namespace Tiled