1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

OP-1107 Implements the new About dialog in QtQuick 2.0.

This commit is contained in:
m_thread 2013-11-15 11:58:59 +01:00
parent 63ad5e69da
commit 300888e8b1
5 changed files with 103 additions and 108 deletions

View File

@ -31,56 +31,33 @@
#include <QtCore/QDate>
#include <QtCore/QFile>
#include <QtCore/QSysInfo>
#include <QDesktopServices>
#include <QtQuick/QQuickView>
#include <QtQuick>
#include <QQuickView>
#include <QQmlEngine>
#include <QQmlContext>
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<br/>").arg(VersionInfo::revision().left(10));
setMinimumSize(600, 400);
setMaximumSize(800, 600);
const QString description = tr(
"<h3>OpenPilot Ground Control Station</h3>"
"GCS Revision: <b>%1</b><br/>"
"Revision: <b>%1</b><br/>"
"UAVO Hash: <b>%2</b><br/>"
"<br/>"
"Built from %3<br/>"
"Built on %4 at %5<br/>"
"Based on Qt %6 (%7 bit)<br/>"
"<br/>"
"&copy; %8, 2010-%9. All rights reserved.<br/>"
"<br/>"
"<small>This program is free software; you can redistribute it and/or modify<br/>"
"it under the terms of the GNU General Public License as published by<br/>"
"the Free Software Foundation; either version 3 of the License, or<br/>"
"(at your option) any later version.<br/>"
"<br/>"
"The program is provided AS IS with NO WARRANTY OF ANY KIND, "
"INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A "
"PARTICULAR PURPOSE.</small>"
"&copy; %8, 2010-%9. All rights reserved.<br/>"
).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;
}

View File

@ -26,10 +26,6 @@
#include <QDialog>
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

View File

@ -1,36 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AboutDialog</class>
<widget class="QDialog" name="AboutDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -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

View File

@ -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()
}
}
}