From 300888e8b125ce008c7b8f68af4562a1d0ed4407 Mon Sep 17 00:00:00 2001 From: m_thread Date: Fri, 15 Nov 2013 11:58:59 +0100 Subject: [PATCH] OP-1107 Implements the new About dialog in QtQuick 2.0. --- .../src/plugins/coreplugin/aboutdialog.cpp | 62 ++++++------ .../src/plugins/coreplugin/aboutdialog.h | 9 +- .../src/plugins/coreplugin/aboutdialog.ui | 36 ------- .../src/plugins/coreplugin/coreplugin.pro | 6 +- .../plugins/coreplugin/qml/AboutDialog.qml | 98 +++++++++++++------ 5 files changed, 103 insertions(+), 108 deletions(-) delete mode 100644 ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.ui diff --git a/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.cpp b/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.cpp index b6a9016a0..9f6077a97 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.cpp @@ -31,56 +31,33 @@ #include #include #include +#include -#include +#include +#include +#include #include using namespace Core::Constants; AboutDialog::AboutDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::AboutDialog) + QDialog(parent) { - ui->setupUi(this); - setWindowIcon(QIcon(":/core/images/openpilot_logo_32.png")); setWindowTitle(tr("About OpenPilot")); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); - - // This loads a QML doc - QQuickView *view = new QQuickView(); - QWidget *container = QWidget::createWindowContainer(view, this); - view->setSource(QUrl("qrc:/core/qml/AboutDialog.qml")); - - ui->verticalLayout->addWidget(container); - - QString version = QLatin1String(GCS_VERSION_LONG); - version += QDate(2007, 25, 10).toString(Qt::SystemLocaleDate); - - QString ideRev; - - // : This gets conditionally inserted as argument %8 into the description string. - ideRev = tr("From revision %1
").arg(VersionInfo::revision().left(10)); + setMinimumSize(600, 400); + setMaximumSize(800, 600); const QString description = tr( - "

OpenPilot Ground Control Station

" - "GCS Revision: %1
" + "Revision: %1
" "UAVO Hash: %2
" "
" "Built from %3
" "Built on %4 at %5
" "Based on Qt %6 (%7 bit)
" "
" - "© %8, 2010-%9. All rights reserved.
" - "
" - "This program is free software; you can redistribute it and/or modify
" - "it under the terms of the GNU General Public License as published by
" - "the Free Software Foundation; either version 3 of the License, or
" - "(at your option) any later version.
" - "
" - "The program is provided AS IS with NO WARRANTY OF ANY KIND, " - "INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A " - "PARTICULAR PURPOSE.
" + "© %8, 2010-%9. All rights reserved.
" ).arg( VersionInfo::revision().left(60), // %1 VersionInfo::uavoHash().left(8), // %2 @@ -92,11 +69,28 @@ AboutDialog::AboutDialog(QWidget *parent) : QLatin1String(GCS_AUTHOR), // %8 VersionInfo::year() // %9 ); - // Expose the version description to the QML doc + + QQuickView *view = new QQuickView(); + view->rootContext()->setContextProperty("dialog", this); view->rootContext()->setContextProperty("version", description); + view->setResizeMode(QQuickView::SizeRootObjectToView); + view->setSource(QUrl("qrc:/core/qml/AboutDialog.qml")); + + QWidget * container = QWidget::createWindowContainer(view); + container->setMinimumSize(600, 400); + container->setMaximumSize(800, 600); + container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + QVBoxLayout *lay = new QVBoxLayout(); + lay->setContentsMargins(0,0,0,0); + setLayout(lay); + layout()->addWidget(container); +} + +void AboutDialog::openUrl(const QString &url) +{ + QDesktopServices::openUrl(QUrl(url)); } AboutDialog::~AboutDialog() { - delete ui; } diff --git a/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.h b/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.h index d9d97f1eb..6bce8d24b 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.h +++ b/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.h @@ -26,10 +26,6 @@ #include -namespace Ui { -class AboutDialog; -} - class AboutDialog : public QDialog { Q_OBJECT @@ -38,8 +34,9 @@ public: explicit AboutDialog(QWidget *parent = 0); ~AboutDialog(); -private: - Ui::AboutDialog *ui; +public slots: + void openUrl(const QString &url); + }; #endif // ABOUTDIALOG_H diff --git a/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.ui b/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.ui deleted file mode 100644 index 6e50a77c3..000000000 --- a/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.ui +++ /dev/null @@ -1,36 +0,0 @@ - - - AboutDialog - - - - 0 - 0 - 400 - 300 - - - - Dialog - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - diff --git a/ground/openpilotgcs/src/plugins/coreplugin/coreplugin.pro b/ground/openpilotgcs/src/plugins/coreplugin/coreplugin.pro index 312fc2acb..f566a71e0 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/coreplugin.pro +++ b/ground/openpilotgcs/src/plugins/coreplugin/coreplugin.pro @@ -2,7 +2,8 @@ TEMPLATE = lib TARGET = Core DEFINES += CORE_LIBRARY -QT += quick \ +QT += qml \ + quick \ xml \ network \ script \ @@ -137,8 +138,7 @@ FORMS += dialogs/settingsdialog.ui \ dialogs/shortcutsettings.ui \ generalsettings.ui \ uavgadgetoptionspage.ui \ - workspacesettings.ui \ - aboutdialog.ui + workspacesettings.ui RESOURCES += core.qrc \ fancyactionbar.qrc diff --git a/ground/openpilotgcs/src/plugins/coreplugin/qml/AboutDialog.qml b/ground/openpilotgcs/src/plugins/coreplugin/qml/AboutDialog.qml index b6e7b7299..bd3d9c9e6 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/qml/AboutDialog.qml +++ b/ground/openpilotgcs/src/plugins/coreplugin/qml/AboutDialog.qml @@ -2,8 +2,8 @@ ****************************************************************************** * * @file aboutdialog.qml - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009. + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2013. + * *****************************************************************************/ /* * This program is free software; you can redistribute it and/or modify @@ -20,20 +20,24 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -import QtQuick 2.0 +import QtQuick 2.1 import QtQuick.Layouts 1.0 import QtQuick.Controls 1.0 -GridLayout { +Rectangle { + id: container width: 600 height: 400 + + property AuthorsModel authors: AuthorsModel {} + ColumnLayout { id: columnLayout1 anchors.fill: parent spacing: 10 RowLayout { id: rowLayout1 + opacity: 1 Image { id: logo anchors.left: parent.left @@ -43,58 +47,94 @@ GridLayout { source: "../images/openpilot_logo_128.png" z: 100 fillMode: Image.PreserveAspectFit + MouseArea { + id: mouseArea + anchors.fill: parent + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + onClicked: { + dialog.openUrl("http://www.openpilot.org") + } + } } - TabView { - id: tabs + + Rectangle { anchors.left: logo.right - anchors.leftMargin: 10 + anchors.margins: 10 anchors.right: parent.right - anchors.rightMargin: 10 anchors.top: parent.top - anchors.topMargin: 10 Layout.fillHeight: true Layout.fillWidth: true anchors.bottom: parent.bottom - anchors.bottomMargin: 10 - Tab { - title: qsTr("About") + color: "transparent" + + ColumnLayout { + anchors.fill: parent + Text { + id: headerLabel + text: qsTr("OpenPilot Ground Control Station") + Layout.fillWidth: true + font.pixelSize: 14 + font.bold: true + + } Text { id: versionLabel - anchors.fill: parent - anchors.margins: 10 + Layout.fillWidth: true font.pixelSize: 12 wrapMode: Text.WordWrap text: version } - } + Text { + id: licenseLabel + Layout.fillWidth: true + font.pixelSize: 9 + wrapMode: Text.WordWrap + text: qsTr("This program is free software; you can redistribute it and/or " + + "modify it under the terms of the GNU General Public License " + + "as published by the Free Software Foundation; either version 3 " + + "of the License, or (at your option) any later version.\n" + + "The program is provided AS IS with NO WARRANTY OF ANY KIND, " + + "INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.") + } - Tab { - title: qsTr("Contributors") - ListView { - id: authorsView - anchors.fill: parent - anchors.margins: 10 + Text { + id: contributorLabel + text: qsTr("Contributors") + Layout.fillWidth: true + font.pixelSize: 14 + font.bold: true - spacing: 3 - model: authors - delegate: Text { - text: name + } + ScrollView { + Layout.fillWidth: true + Layout.fillHeight: true + frameVisible: true + ListView { + id: authorsView + anchors.fill: parent + + spacing: 3 + model: authors + delegate: Text { + font.pixelSize: 12 + text: name + } + clip: true } - clip: true } } } } Button { id: button - x: 512 - y: 369 text: qsTr("Ok") activeFocusOnPress: true anchors.right: parent.right anchors.rightMargin: 10 anchors.bottom: parent.bottom anchors.bottomMargin: 10 + onClicked: dialog.close() } } }