PageRenderTime 60ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/ground/gcs/src/plugins/coreplugin/aboutdialog.cpp

https://gitlab.com/sonium/librepilot
C++ | 97 lines | 64 code | 11 blank | 22 comment | 0 complexity | e5a5ae5e614889869797c604e024c962 MD5 | raw file
  1. /**
  2. ******************************************************************************
  3. *
  4. * @file aboutdialog.h
  5. * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
  6. * Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
  7. *****************************************************************************/
  8. /*
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  16. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  17. * for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License along
  20. * with this program; if not, write to the Free Software Foundation, Inc.,
  21. * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. */
  23. #include "aboutdialog.h"
  24. #include "version_info/version_info.h"
  25. #include "coreconstants.h"
  26. #include "icore.h"
  27. #include <QtCore/QDate>
  28. #include <QtCore/QFile>
  29. #include <QtCore/QSysInfo>
  30. #include <QDesktopServices>
  31. #include <QLayout>
  32. #include <QVBoxLayout>
  33. #include <QtQuick>
  34. #include <QQuickView>
  35. #include <QQmlEngine>
  36. #include <QQmlContext>
  37. using namespace Core::Constants;
  38. AboutDialog::AboutDialog(QWidget *parent) :
  39. QDialog(parent)
  40. {
  41. setWindowIcon(QIcon(":/core/images/librepilot_logo_32.png"));
  42. setWindowTitle(tr("About %1").arg(ORG_BIG_NAME));
  43. setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
  44. setMinimumSize(600, 400);
  45. setMaximumSize(800, 600);
  46. const QString description = tr(
  47. "Revision: <b>%1</b><br/>"
  48. "UAVO Hash: <b>%2</b><br/>"
  49. "<br/>"
  50. "Built from %3<br/>"
  51. "Built on %4 at %5<br/>"
  52. "Based on Qt %6 (%7 bit)<br/>"
  53. "<br/>"
  54. "&copy; The %8 Project, %9. All rights reserved.<br/>"
  55. "&copy; The OpenPilot Project 2010-2015. All rights reserved.<br/>"
  56. ).arg(
  57. VersionInfo::revision().left(60), // %1
  58. VersionInfo::uavoHash().left(8), // %2
  59. VersionInfo::origin(), // $3
  60. QLatin1String(__DATE__), // %4
  61. QLatin1String(__TIME__), // %5
  62. QLatin1String(QT_VERSION_STR), // %6
  63. QString::number(QSysInfo::WordSize), // %7
  64. QLatin1String(ORG_BIG_NAME), // %8
  65. VersionInfo::year() // %9
  66. );
  67. QQuickView *view = new QQuickView();
  68. view->rootContext()->setContextProperty("dialog", this);
  69. view->rootContext()->setContextProperty("version", description);
  70. view->setResizeMode(QQuickView::SizeRootObjectToView);
  71. view->setSource(QUrl("qrc:/core/qml/AboutDialog.qml"));
  72. QWidget *container = QWidget::createWindowContainer(view);
  73. container->setMinimumSize(600, 400);
  74. container->setMaximumSize(800, 600);
  75. container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
  76. QVBoxLayout *lay = new QVBoxLayout();
  77. lay->setContentsMargins(0, 0, 0, 0);
  78. setLayout(lay);
  79. layout()->addWidget(container);
  80. }
  81. void AboutDialog::openUrl(const QString &url)
  82. {
  83. QDesktopServices::openUrl(QUrl(url));
  84. }
  85. AboutDialog::~AboutDialog()
  86. {}