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:
parent
63ad5e69da
commit
300888e8b1
@ -31,40 +31,26 @@
|
|||||||
#include <QtCore/QDate>
|
#include <QtCore/QDate>
|
||||||
#include <QtCore/QFile>
|
#include <QtCore/QFile>
|
||||||
#include <QtCore/QSysInfo>
|
#include <QtCore/QSysInfo>
|
||||||
|
#include <QDesktopServices>
|
||||||
|
|
||||||
#include <QtQuick/QQuickView>
|
#include <QtQuick>
|
||||||
|
#include <QQuickView>
|
||||||
|
#include <QQmlEngine>
|
||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
|
|
||||||
using namespace Core::Constants;
|
using namespace Core::Constants;
|
||||||
|
|
||||||
AboutDialog::AboutDialog(QWidget *parent) :
|
AboutDialog::AboutDialog(QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent)
|
||||||
ui(new Ui::AboutDialog)
|
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
|
||||||
|
|
||||||
setWindowIcon(QIcon(":/core/images/openpilot_logo_32.png"));
|
setWindowIcon(QIcon(":/core/images/openpilot_logo_32.png"));
|
||||||
setWindowTitle(tr("About OpenPilot"));
|
setWindowTitle(tr("About OpenPilot"));
|
||||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||||
|
setMinimumSize(600, 400);
|
||||||
// This loads a QML doc
|
setMaximumSize(800, 600);
|
||||||
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));
|
|
||||||
|
|
||||||
const QString description = tr(
|
const QString description = tr(
|
||||||
"<h3>OpenPilot Ground Control Station</h3>"
|
"Revision: <b>%1</b><br/>"
|
||||||
"GCS Revision: <b>%1</b><br/>"
|
|
||||||
"UAVO Hash: <b>%2</b><br/>"
|
"UAVO Hash: <b>%2</b><br/>"
|
||||||
"<br/>"
|
"<br/>"
|
||||||
"Built from %3<br/>"
|
"Built from %3<br/>"
|
||||||
@ -72,15 +58,6 @@ AboutDialog::AboutDialog(QWidget *parent) :
|
|||||||
"Based on Qt %6 (%7 bit)<br/>"
|
"Based on Qt %6 (%7 bit)<br/>"
|
||||||
"<br/>"
|
"<br/>"
|
||||||
"© %8, 2010-%9. All rights reserved.<br/>"
|
"© %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>"
|
|
||||||
).arg(
|
).arg(
|
||||||
VersionInfo::revision().left(60), // %1
|
VersionInfo::revision().left(60), // %1
|
||||||
VersionInfo::uavoHash().left(8), // %2
|
VersionInfo::uavoHash().left(8), // %2
|
||||||
@ -92,11 +69,28 @@ AboutDialog::AboutDialog(QWidget *parent) :
|
|||||||
QLatin1String(GCS_AUTHOR), // %8
|
QLatin1String(GCS_AUTHOR), // %8
|
||||||
VersionInfo::year() // %9
|
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->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()
|
AboutDialog::~AboutDialog()
|
||||||
{
|
{
|
||||||
delete ui;
|
|
||||||
}
|
}
|
||||||
|
@ -26,10 +26,6 @@
|
|||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class AboutDialog;
|
|
||||||
}
|
|
||||||
|
|
||||||
class AboutDialog : public QDialog
|
class AboutDialog : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -38,8 +34,9 @@ public:
|
|||||||
explicit AboutDialog(QWidget *parent = 0);
|
explicit AboutDialog(QWidget *parent = 0);
|
||||||
~AboutDialog();
|
~AboutDialog();
|
||||||
|
|
||||||
private:
|
public slots:
|
||||||
Ui::AboutDialog *ui;
|
void openUrl(const QString &url);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ABOUTDIALOG_H
|
#endif // ABOUTDIALOG_H
|
||||||
|
@ -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>
|
|
@ -2,7 +2,8 @@ TEMPLATE = lib
|
|||||||
TARGET = Core
|
TARGET = Core
|
||||||
DEFINES += CORE_LIBRARY
|
DEFINES += CORE_LIBRARY
|
||||||
|
|
||||||
QT += quick \
|
QT += qml \
|
||||||
|
quick \
|
||||||
xml \
|
xml \
|
||||||
network \
|
network \
|
||||||
script \
|
script \
|
||||||
@ -137,8 +138,7 @@ FORMS += dialogs/settingsdialog.ui \
|
|||||||
dialogs/shortcutsettings.ui \
|
dialogs/shortcutsettings.ui \
|
||||||
generalsettings.ui \
|
generalsettings.ui \
|
||||||
uavgadgetoptionspage.ui \
|
uavgadgetoptionspage.ui \
|
||||||
workspacesettings.ui \
|
workspacesettings.ui
|
||||||
aboutdialog.ui
|
|
||||||
|
|
||||||
RESOURCES += core.qrc \
|
RESOURCES += core.qrc \
|
||||||
fancyactionbar.qrc
|
fancyactionbar.qrc
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file aboutdialog.qml
|
* @file aboutdialog.qml
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2013.
|
||||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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.,
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
import QtQuick 2.1
|
||||||
import QtQuick 2.0
|
|
||||||
import QtQuick.Layouts 1.0
|
import QtQuick.Layouts 1.0
|
||||||
import QtQuick.Controls 1.0
|
import QtQuick.Controls 1.0
|
||||||
|
|
||||||
GridLayout {
|
Rectangle {
|
||||||
|
id: container
|
||||||
width: 600
|
width: 600
|
||||||
height: 400
|
height: 400
|
||||||
|
|
||||||
|
property AuthorsModel authors: AuthorsModel {}
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: columnLayout1
|
id: columnLayout1
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
spacing: 10
|
spacing: 10
|
||||||
RowLayout {
|
RowLayout {
|
||||||
id: rowLayout1
|
id: rowLayout1
|
||||||
|
opacity: 1
|
||||||
Image {
|
Image {
|
||||||
id: logo
|
id: logo
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
@ -43,58 +47,94 @@ GridLayout {
|
|||||||
source: "../images/openpilot_logo_128.png"
|
source: "../images/openpilot_logo_128.png"
|
||||||
z: 100
|
z: 100
|
||||||
fillMode: Image.PreserveAspectFit
|
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.left: logo.right
|
||||||
anchors.leftMargin: 10
|
anchors.margins: 10
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.rightMargin: 10
|
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.topMargin: 10
|
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.bottomMargin: 10
|
color: "transparent"
|
||||||
Tab {
|
|
||||||
title: qsTr("About")
|
ColumnLayout {
|
||||||
|
anchors.fill: parent
|
||||||
|
Text {
|
||||||
|
id: headerLabel
|
||||||
|
text: qsTr("OpenPilot Ground Control Station")
|
||||||
|
Layout.fillWidth: true
|
||||||
|
font.pixelSize: 14
|
||||||
|
font.bold: true
|
||||||
|
|
||||||
|
}
|
||||||
Text {
|
Text {
|
||||||
id: versionLabel
|
id: versionLabel
|
||||||
anchors.fill: parent
|
Layout.fillWidth: true
|
||||||
anchors.margins: 10
|
|
||||||
font.pixelSize: 12
|
font.pixelSize: 12
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
text: version
|
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 {
|
Text {
|
||||||
title: qsTr("Contributors")
|
id: contributorLabel
|
||||||
ListView {
|
text: qsTr("Contributors")
|
||||||
id: authorsView
|
Layout.fillWidth: true
|
||||||
anchors.fill: parent
|
font.pixelSize: 14
|
||||||
anchors.margins: 10
|
font.bold: true
|
||||||
|
|
||||||
spacing: 3
|
}
|
||||||
model: authors
|
ScrollView {
|
||||||
delegate: Text {
|
Layout.fillWidth: true
|
||||||
text: name
|
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 {
|
Button {
|
||||||
id: button
|
id: button
|
||||||
x: 512
|
|
||||||
y: 369
|
|
||||||
text: qsTr("Ok")
|
text: qsTr("Ok")
|
||||||
activeFocusOnPress: true
|
activeFocusOnPress: true
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.rightMargin: 10
|
anchors.rightMargin: 10
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.bottomMargin: 10
|
anchors.bottomMargin: 10
|
||||||
|
onClicked: dialog.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user