1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-31 16:52:10 +01:00

Merge remote-tracking branch 'origin/dwillis/OP-1453_VersionCheck' into next

This commit is contained in:
Fredrik Larson 2014-08-29 09:51:18 +10:00
commit d4d1c9c482
4 changed files with 100 additions and 3 deletions

View File

@ -30,10 +30,10 @@ Rectangle {
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
// distribute a vertical space between the icons blocks an community widget as: // distribute a vertical space between the icons blocks an community widget as:
// top - 48% - Icons - 27% - CommunityWidget - 25% - bottom // 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 width: parent.width
height: 600 height: 600
spacing: (parent.height - buttons.height - communityPanel.height) * 0.1 spacing: (parent.height - buttons.height - communityPanel.height - versionInfo.height) * 0.1
Row { Row {
//if the buttons grid overlaps vertically with the wizard buttons, //if the buttons grid overlaps vertically with the wizard buttons,
@ -109,5 +109,43 @@ Rectangle {
width: Math.min(sourceSize.width, container.width) width: Math.min(sourceSize.width, container.width)
height: Math.min(450, container.height*0.5) 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")
}
}
}
} }
} }

View File

@ -1,2 +1,3 @@
include(../../plugins/coreplugin/coreplugin.pri) include(../../plugins/coreplugin/coreplugin.pri)
include(../../libs/utils/utils.pri) include(../../libs/utils/utils.pri)
include(../../libs/version_info/version_info.pri)

View File

@ -45,6 +45,9 @@
#include <QtCore/QUrl> #include <QtCore/QUrl>
#include <QtCore/QDebug> #include <QtCore/QDebug>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QtQuick> #include <QtQuick>
#include <QQuickView> #include <QQuickView>
#include <QQmlEngine> #include <QQmlEngine>
@ -68,13 +71,32 @@ WelcomeModePrivate::WelcomeModePrivate()
// --- WelcomeMode // --- WelcomeMode
WelcomeMode::WelcomeMode() : WelcomeMode::WelcomeMode() :
m_d(new WelcomeModePrivate), 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 = new QQuickView;
m_d->quickView->setResizeMode(QQuickView::SizeRootObjectToView); m_d->quickView->setResizeMode(QQuickView::SizeRootObjectToView);
m_d->quickView->engine()->rootContext()->setContextProperty("welcomePlugin", this); m_d->quickView->engine()->rootContext()->setContextProperty("welcomePlugin", this);
m_d->quickView->setSource(QUrl("qrc:/welcome/qml/main.qml")); m_d->quickView->setSource(QUrl("qrc:/welcome/qml/main.qml"));
m_container = NULL; 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() WelcomeMode::~WelcomeMode()
@ -135,4 +157,21 @@ void WelcomeMode::triggerAction(const QString &actionId)
{ {
Core::ModeManager::instance()->triggerAction(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 } // namespace Welcome

View File

@ -29,6 +29,7 @@
#ifndef WELCOMEMODE_H #ifndef WELCOMEMODE_H
#define WELCOMEMODE_H #define WELCOMEMODE_H
#include "version_info/version_info.h"
#include "welcome_global.h" #include "welcome_global.h"
#include <coreplugin/imode.h> #include <coreplugin/imode.h>
@ -37,6 +38,7 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QWidget; class QWidget;
class QUrl; class QUrl;
class QNetworkReply;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace Welcome { namespace Welcome {
@ -44,6 +46,8 @@ struct WelcomeModePrivate;
class WELCOME_EXPORT WelcomeMode : public Core::IMode { class WELCOME_EXPORT WelcomeMode : public Core::IMode {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QString versionString READ versionString)
Q_PROPERTY(QString newVersionText READ newVersionText NOTIFY newVersionTextChanged)
public: public:
WelcomeMode(); WelcomeMode();
@ -65,6 +69,17 @@ public:
{ {
m_priority = priority; 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: public slots:
void openUrl(const QString &url); void openUrl(const QString &url);
@ -75,6 +90,10 @@ private:
QWidget *m_container; QWidget *m_container;
WelcomeModePrivate *m_d; WelcomeModePrivate *m_d;
int m_priority; int m_priority;
QString m_newVersionText;
private slots:
void networkResponseReady(QNetworkReply* reply);
}; };
} // namespace Welcome } // namespace Welcome