mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-30 15:52:12 +01:00
Merge remote-tracking branch 'origin/dwillis/OP-1453_VersionCheck' into next
This commit is contained in:
commit
d4d1c9c482
@ -30,10 +30,10 @@ Rectangle {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
// distribute a vertical space between the icons blocks an community widget as:
|
||||
// top - 48% - Icons - 27% - CommunityWidget - 25% - bottom
|
||||
y: (parent.height - buttons.height - communityPanel.height) * 0.48
|
||||
y: (parent.height - buttons.height - communityPanel.height - versionInfo.height) * 0.48
|
||||
width: parent.width
|
||||
height: 600
|
||||
spacing: (parent.height - buttons.height - communityPanel.height) * 0.1
|
||||
spacing: (parent.height - buttons.height - communityPanel.height - versionInfo.height) * 0.1
|
||||
|
||||
Row {
|
||||
//if the buttons grid overlaps vertically with the wizard buttons,
|
||||
@ -109,5 +109,43 @@ Rectangle {
|
||||
width: Math.min(sourceSize.width, container.width)
|
||||
height: Math.min(450, container.height*0.5)
|
||||
}
|
||||
|
||||
Row {
|
||||
id: versionInfo
|
||||
|
||||
height: 18
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
width: textOpVersion.width + textOpVersionAvailable.width
|
||||
spacing: 16
|
||||
|
||||
Text {
|
||||
id: textOpVersion
|
||||
color: "#c4c0c0"
|
||||
text: welcomePlugin.versionString
|
||||
verticalAlignment: Text.AlignTop
|
||||
anchors.left: parent.anchors.left
|
||||
font.bold: true
|
||||
styleColor: "#00000000"
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
font.pixelSize: 14
|
||||
}
|
||||
Text {
|
||||
id: textOpVersionAvailable
|
||||
color: "#5fcf07"
|
||||
text: welcomePlugin.newVersionText
|
||||
anchors.rightMargin: 0
|
||||
font.bold: true
|
||||
styleColor: "#00000000"
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
font.pixelSize: 14
|
||||
anchors.left: textOpVersion.right
|
||||
|
||||
MouseArea{
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
onClicked: welcomePlugin.openUrl("http://wiki.openpilot.org/display/BUILDS/OpenPilot+Software+Downloads")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,2 +1,3 @@
|
||||
include(../../plugins/coreplugin/coreplugin.pri)
|
||||
include(../../libs/utils/utils.pri)
|
||||
include(../../libs/version_info/version_info.pri)
|
||||
|
@ -45,6 +45,9 @@
|
||||
#include <QtCore/QUrl>
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
|
||||
#include <QtQuick>
|
||||
#include <QQuickView>
|
||||
#include <QQmlEngine>
|
||||
@ -68,13 +71,32 @@ WelcomeModePrivate::WelcomeModePrivate()
|
||||
// --- WelcomeMode
|
||||
WelcomeMode::WelcomeMode() :
|
||||
m_d(new WelcomeModePrivate),
|
||||
m_priority(Core::Constants::P_MODE_WELCOME)
|
||||
m_priority(Core::Constants::P_MODE_WELCOME),
|
||||
m_newVersionText("")
|
||||
{
|
||||
m_d->quickView = new QQuickView;
|
||||
m_d->quickView->setResizeMode(QQuickView::SizeRootObjectToView);
|
||||
m_d->quickView->engine()->rootContext()->setContextProperty("welcomePlugin", this);
|
||||
m_d->quickView->setSource(QUrl("qrc:/welcome/qml/main.qml"));
|
||||
m_container = NULL;
|
||||
|
||||
QNetworkAccessManager* networkAccessManager = new QNetworkAccessManager;
|
||||
|
||||
// Only attempt to request our version info if the network is accessible
|
||||
if(networkAccessManager->networkAccessible() == QNetworkAccessManager::Accessible)
|
||||
{
|
||||
connect(networkAccessManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkResponseReady(QNetworkReply*)));
|
||||
|
||||
// This will delete the network access manager instance when we're done
|
||||
connect(networkAccessManager, SIGNAL(finished(QNetworkReply*)), networkAccessManager, SLOT(deleteLater()));
|
||||
|
||||
networkAccessManager->get(QNetworkRequest(QUrl("http://www.openpilot.org/opver")));
|
||||
}
|
||||
else
|
||||
{
|
||||
// No network, can delete this now as we don't need it.
|
||||
delete networkAccessManager;
|
||||
}
|
||||
}
|
||||
|
||||
WelcomeMode::~WelcomeMode()
|
||||
@ -135,4 +157,21 @@ void WelcomeMode::triggerAction(const QString &actionId)
|
||||
{
|
||||
Core::ModeManager::instance()->triggerAction(actionId);
|
||||
}
|
||||
|
||||
void WelcomeMode::networkResponseReady(QNetworkReply* reply)
|
||||
{
|
||||
if(reply != NULL)
|
||||
{
|
||||
QString version(reply->readAll());
|
||||
version = version.trimmed();
|
||||
|
||||
reply->deleteLater();
|
||||
|
||||
if(version != VersionInfo::tagOrHash8())
|
||||
{
|
||||
m_newVersionText = tr("(Update Available: %1)").arg(version);
|
||||
emit newVersionTextChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace Welcome
|
||||
|
@ -29,6 +29,7 @@
|
||||
#ifndef WELCOMEMODE_H
|
||||
#define WELCOMEMODE_H
|
||||
|
||||
#include "version_info/version_info.h"
|
||||
#include "welcome_global.h"
|
||||
|
||||
#include <coreplugin/imode.h>
|
||||
@ -37,6 +38,7 @@
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QWidget;
|
||||
class QUrl;
|
||||
class QNetworkReply;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Welcome {
|
||||
@ -44,6 +46,8 @@ struct WelcomeModePrivate;
|
||||
|
||||
class WELCOME_EXPORT WelcomeMode : public Core::IMode {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString versionString READ versionString)
|
||||
Q_PROPERTY(QString newVersionText READ newVersionText NOTIFY newVersionTextChanged)
|
||||
|
||||
public:
|
||||
WelcomeMode();
|
||||
@ -65,6 +69,17 @@ public:
|
||||
{
|
||||
m_priority = priority;
|
||||
}
|
||||
QString versionString() const
|
||||
{
|
||||
return tr("OpenPilot GCS Version: %1 ").arg(VersionInfo::tagOrHash8());
|
||||
}
|
||||
QString newVersionText() const
|
||||
{
|
||||
return m_newVersionText;
|
||||
}
|
||||
|
||||
signals:
|
||||
void newVersionTextChanged();
|
||||
|
||||
public slots:
|
||||
void openUrl(const QString &url);
|
||||
@ -75,6 +90,10 @@ private:
|
||||
QWidget *m_container;
|
||||
WelcomeModePrivate *m_d;
|
||||
int m_priority;
|
||||
QString m_newVersionText;
|
||||
|
||||
private slots:
|
||||
void networkResponseReady(QNetworkReply* reply);
|
||||
};
|
||||
} // namespace Welcome
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user