1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-30 08:24:11 +01:00

OP-955 Moved generated version info to its own lib. Updated code using version info in all referenced places.

This commit is contained in:
Fredrik Arvidsson 2013-05-18 14:28:46 +02:00
parent 76be45242c
commit 62ee55fbb8
20 changed files with 151 additions and 178 deletions

View File

@ -1,16 +1,16 @@
include(../../openpilotgcs.pri)
include(../shared/qtsingleapplication/qtsingleapplication.pri)
include(version_info.pri)
TEMPLATE = app
TARGET = $$GCS_APP_TARGET
DESTDIR = $$GCS_APP_PATH
QT += xml
SOURCES += main.cpp \
gcssplashscreen.cpp \
version_info.cpp
gcssplashscreen.cpp
include(../rpath.pri)
include(../libs/utils/utils.pri)
include(../libs/versioninfo/versioninfo.pri)
LIBS *= -l$$qtLibraryName(ExtensionSystem) -l$$qtLibraryName(Aggregation)

View File

@ -26,6 +26,7 @@
*/
#include "gcssplashscreen.h"
#include "versioninfo/version_info.h"
#include <QDebug>
const QChar CopyrightSymbol(0x00a9);
@ -33,20 +34,6 @@ const QChar CopyrightSymbol(0x00a9);
GCSSplashScreen::GCSSplashScreen() :
QSplashScreen(), m_pixmap(0), m_painter(0)
{
QString revision;
QString year;
#ifdef GCS_REVISION
revision = GCS_REVISION;
#else
revision = tr("N/A");
#endif
#ifdef GCS_YEAR
year = GCS_YEAR;
#else
year = "2013";
#endif
setWindowFlags(windowFlags());
m_pixmap = new QPixmap(":/app/splash.png");
@ -55,11 +42,11 @@ GCSSplashScreen::GCSSplashScreen() :
QFont font("Tahoma", 8);
m_painter->setFont(font);
m_painter->drawText(405, 170, QString(CopyrightSymbol) +
QString(" 2010-") + year +
QString(" 2010-") + VersionInfo::year() +
QString(tr(" The OpenPilot Project - All Rights Reserved")));
m_painter->drawText(406, 173, 310, 100, Qt::TextWordWrap|Qt::AlignTop|Qt::AlignLeft,
QString(tr("GCS Revision - ")) + revision);
QString(tr("GCS Revision - ")) + VersionInfo::revision());
setPixmap(*m_pixmap);
}

View File

@ -33,8 +33,6 @@
#include <QPainter>
#include <extensionsystem/pluginspec.h>
#include "../gcs_version_info.h"
class GCSSplashScreen : public QSplashScreen
{
Q_OBJECT

View File

@ -2,6 +2,7 @@ TEMPLATE = subdirs
CONFIG += ordered
SUBDIRS = \
versioninfo \
qscispinbox\
qtconcurrent \
aggregation \

View File

@ -23,5 +23,5 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "../version_info.h"
#include "version_info.h"
#include "../../../../build/openpilotgcs-synthetics/version_info.cpp"

View File

@ -0,0 +1 @@
LIBS *= -l$$qtLibraryName(VersionInfo)

View File

@ -1,3 +1,10 @@
TEMPLATE = lib
TARGET = VersionInfo
include(../../openpilotgcslibrary.pri)
HEADERS = version_info.h
#
# This qmake file generates a version info class implementation.
#
@ -34,7 +41,7 @@ PYTHON_DIR = python-2.7.4
VERSION_INFO_DIR = $$GCS_BUILD_TREE/../openpilotgcs-synthetics
VERSION_INFO_SCRIPT = $$ROOT_DIR/make/scripts/version-info.py
VERSION_INFO_COMMAND = $$PYTHON \"$$VERSION_INFO_SCRIPT\"
VERSION_INFO_TEMPLATE = $$GCS_SOURCE_TREE/src/app/version_info.cpp.template
VERSION_INFO_TEMPLATE = $$GCS_SOURCE_TREE/src/libs/versioninfo/version_info.cpp.template
VERSION_INFO_FILE = $$VERSION_INFO_DIR/version_info.cpp
UAVO_DEF_PATH = $$ROOT_DIR/shared/uavobjectdefinition
@ -60,3 +67,7 @@ PYTHON_DIR = python-2.7.4
}
QMAKE_EXTRA_TARGETS += version_info_hook
}
SOURCES = version_info.cpp

View File

@ -11,24 +11,24 @@
* @brief The Core GCS plugin
*****************************************************************************/
/*
* 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
* 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.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "authorsdialog.h"
#include "../../gcs_version_info.h"
#include "versioninfo/version_info.h"
#include "coreconstants.h"
#include "icore.h"
@ -43,7 +43,7 @@
#include <QtGui/QLabel>
#include <QtGui/QPushButton>
#include <QtGui/QTextBrowser>
#include <QtDeclarative/qdeclarative.h>
#include <QtDeclarative/qdeclarativeview.h>
#include <QtDeclarative/qdeclarativeengine.h>
@ -62,71 +62,70 @@ AuthorsDialog::AuthorsDialog(QWidget *parent)
setWindowIcon(QIcon(":/core/images/openpilot_logo_32.png"));
setWindowTitle(tr("About OpenPilot"));
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
// This loads a QML doc containing a Tabbed view
QDeclarativeView *view = new QDeclarativeView(this);
view->setSource(QUrl("qrc:/core/qml/AboutDialog.qml"));
// This loads a QML doc containing a Tabbed view
QDeclarativeView *view = new QDeclarativeView(this);
view->setSource(QUrl("qrc:/core/qml/AboutDialog.qml"));
QString version = QLatin1String(GCS_VERSION_LONG);
version += QDate(2007, 25, 10).toString(Qt::SystemLocaleDate);
QString version = QLatin1String(GCS_VERSION_LONG);
version += QDate(2007, 25, 10).toString(Qt::SystemLocaleDate);
QString ideRev;
#ifdef GCS_REVISION
//: This gets conditionally inserted as argument %8 into the description string.
ideRev = tr("From revision %1<br/>").arg(QString::fromLatin1(GCS_REVISION_STR).left(10));
#endif
QString ideRev;
#ifdef UAVO_HASH
//: This gets conditionally inserted as argument %11 into the description string.
QByteArray uavoHashArray;
QString uavoHash = QString::fromLatin1(Core::Constants::UAVOSHA1_STR);
uavoHash.chop(2);
uavoHash.remove(0, 2);
uavoHash = uavoHash.trimmed();
bool ok;
foreach(QString str, uavoHash.split(",")) {
uavoHashArray.append(str.toInt(&ok, 16));
}
QString gcsUavoHashStr;
foreach(char i, uavoHashArray) {
gcsUavoHashStr.append(QString::number(i, 16).right(2));
}
QString uavoHashStr = gcsUavoHashStr;
#else
QString uavoHashStr = "N/A";
#endif
const QString description = tr(
"<h3>OpenPilot Ground Control Station</h3>"
"GCS Revision: <b>%1</b><br/>"
"UAVO Hash: %2<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>"
).arg(
QString::fromLatin1(GCS_REVISION_STR).left(60), // %1
uavoHashStr, // %2
QLatin1String(GCS_ORIGIN_STR), // $3
QLatin1String(__DATE__), // %4
QLatin1String(__TIME__), // %5
QLatin1String(QT_VERSION_STR), // %6
QString::number(QSysInfo::WordSize), // %7
QLatin1String(GCS_AUTHOR), // %8
QLatin1String(GCS_YEAR_STR) // %9
);
// Expose the version description to the QML doc
view->rootContext()->setContextProperty("version", description);
// : This gets conditionally inserted as argument %8 into the description string.
ideRev = tr("From revision %1<br/>").arg(VersionInfo::revision().left(10));
QString uavoHashStr;
if (VersionInfo::uavoHash().length() > 15) {
// : This gets conditionally inserted as argument %11 into the description string.
QByteArray uavoHashArray;
QString uavoHash = VersionInfo::uavoHash();
uavoHash.chop(2);
uavoHash.remove(0, 2);
uavoHash = uavoHash.trimmed();
bool ok;
foreach(QString str, uavoHash.split(",")) {
uavoHashArray.append(str.toInt(&ok, 16));
}
QString gcsUavoHashStr;
foreach(char i, uavoHashArray) {
gcsUavoHashStr.append(QString::number(i, 16).right(2));
}
uavoHashStr = gcsUavoHashStr;
} else {
uavoHashStr = "N/A";
}
const QString description = tr(
"<h3>OpenPilot Ground Control Station</h3>"
"GCS Revision: <b>%1</b><br/>"
"UAVO Hash: %2<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>"
).arg(
VersionInfo::revision().left(60), // %1
uavoHashStr, // %2
VersionInfo::origin(), // $3
QLatin1String(__DATE__), // %4
QLatin1String(__TIME__), // %5
QLatin1String(QT_VERSION_STR), // %6
QString::number(QSysInfo::WordSize), // %7
QLatin1String(GCS_AUTHOR), // %8
VersionInfo::year() // %9
);
// Expose the version description to the QML doc
view->rootContext()->setContextProperty("version", description);
}

View File

@ -44,31 +44,6 @@ namespace Constants {
"." STRINGIFY(GCS_VERSION_RELEASE)
const char * const GCS_VERSION_LONG = GCS_VERSION;
#ifdef GCS_REVISION
const char * const GCS_REVISION_STR = GCS_REVISION;
#else
const char * const GCS_REVISION_STR = "N/A";
#endif
#ifdef GCS_YEAR
const char * const GCS_YEAR_STR = GCS_YEAR;
#else
const char * const GCS_YEAR_STR = "2013";
#endif
#ifdef GCS_ORIGIN
const char * const GCS_ORIGIN_STR = GCS_ORIGIN;
#else
const char * const GCS_ORIGIN_STR = "unknown repository";
#endif
#ifdef UAVO_HASH
const char * const UAVOSHA1_STR = STRINGIFY(UAVO_HASH);
#else
const char * const UAVOSHA1_STR = "";
#endif
const char * const GCS_AUTHOR = "The OpenPilot Project";
const char * const GCS_HELP = "http://wiki.openpilot.org";

View File

@ -11,6 +11,7 @@ QT += declarative \
include(../../openpilotgcsplugin.pri)
include(../../libs/utils/utils.pri)
include(../../libs/versioninfo/versioninfo.pri)
include(../../shared/scriptwrapper/scriptwrapper.pri)
include(coreplugin_dependencies.pri)

View File

@ -11,23 +11,23 @@
* @brief The Core GCS plugin
*****************************************************************************/
/*
* 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
* 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.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "versiondialog.h"
#include "versioninfo/version_info.h"
#include "coreconstants.h"
#include "icore.h"
@ -59,29 +59,28 @@ VersionDialog::VersionDialog(QWidget *parent)
QGridLayout *layout = new QGridLayout(this);
layout->setSizeConstraint(QLayout::SetFixedSize);
#ifdef UAVO_HASH
//: This gets conditionally inserted as argument %11 into the description string.
QByteArray uavoHashArray;
QString uavoHash = QString::fromLatin1(Core::Constants::UAVOSHA1_STR);
uavoHash.chop(2);
uavoHash.remove(0,2);
uavoHash=uavoHash.trimmed();
bool ok;
foreach(QString str,uavoHash.split(","))
{
uavoHashArray.append(str.toInt(&ok,16));
}
QString gcsUavoHashStr;
foreach(char i, uavoHashArray)
{
gcsUavoHashStr.append(QString::number(i,16).right(2));
}
QString uavoHashStr = gcsUavoHashStr;
#else
QString uavoHashStr = "N/A";
#endif
QString uavoHashStr;
if (VersionInfo::uavoHash().length() > 15) {
// : This gets conditionally inserted as argument %11 into the description string.
QByteArray uavoHashArray;
QString uavoHash = VersionInfo::uavoHash();
uavoHash.chop(2);
uavoHash.remove(0, 2);
uavoHash = uavoHash.trimmed();
bool ok;
foreach(QString str, uavoHash.split(",")) {
uavoHashArray.append(str.toInt(&ok, 16));
}
QString gcsUavoHashStr;
foreach(char i, uavoHashArray) {
gcsUavoHashStr.append(QString::number(i, 16).right(2));
}
uavoHashStr = gcsUavoHashStr;
} else {
uavoHashStr = "N/A";
}
const QString description = tr(
const QString description = tr(
"<h3>OpenPilot Ground Control Station</h3>"
"GCS Revision: <b>%1</b><br/>"
"UAVO Hash: %2<br/>"
@ -100,17 +99,17 @@ VersionDialog::VersionDialog(QWidget *parent)
"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(
QString::fromLatin1(GCS_REVISION_STR).left(60), // %1
uavoHashStr, // %2
QLatin1String(GCS_ORIGIN_STR), // $3
QLatin1String(__DATE__), // %4
QLatin1String(__TIME__), // %5
QLatin1String(QT_VERSION_STR), // %6
QString::number(QSysInfo::WordSize), // %7
QLatin1String(GCS_AUTHOR), // %8
QLatin1String(GCS_YEAR_STR) // %9
);
).arg(
VersionInfo::revision().left(60), // %1
uavoHashStr, // %2
VersionInfo::origin(), // $3
QLatin1String(__DATE__), // %4
QLatin1String(__TIME__), // %5
QLatin1String(QT_VERSION_STR), // %6
QString::number(QSysInfo::WordSize), // %7
QLatin1String(GCS_AUTHOR), // %8
VersionInfo::year() // %9
);
QLabel *copyRightLabel = new QLabel(description);
copyRightLabel->setWordWrap(true);
@ -118,14 +117,14 @@ VersionDialog::VersionDialog(QWidget *parent)
copyRightLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close);
QPushButton *closeButton = buttonBox->button(QDialogButtonBox::Close);
QPushButton *closeButton = buttonBox->button(QDialogButtonBox::Close);
QTC_ASSERT(closeButton, /**/);
buttonBox->addButton(closeButton, QDialogButtonBox::ButtonRole(QDialogButtonBox::RejectRole | QDialogButtonBox::AcceptRole));
connect(buttonBox , SIGNAL(rejected()), this, SLOT(reject()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
QLabel *logoLabel = new QLabel;
logoLabel->setPixmap(QPixmap(QLatin1String(":/core/images/openpilot_logo_128.png")));
layout->addWidget(logoLabel , 0, 0, 1, 1);
layout->addWidget(logoLabel, 0, 0, 1, 1);
layout->addWidget(copyRightLabel, 0, 1, 4, 4);
layout->addWidget(buttonBox, 4, 0, 1, 5);
}

View File

@ -29,8 +29,6 @@
#ifndef VERSIONDIALOG_H
#define VERSIONDIALOG_H
#include "../../gcs_version_info.h"
#include <QtGui/QDialog>
namespace Core {

View File

@ -30,8 +30,8 @@
#include <extensionsystem/iplugin.h>
#include "uavobjectutil/uavobjectutilmanager.h"
#include "uavsettingsimportexport_global.h"
#include "../../gcs_version_info.h"
#include "uavsettingsimportexportfactory.h"
class UAVSETTINGSIMPORTEXPORT_EXPORT UAVSettingsImportExportPlugin : public ExtensionSystem::IPlugin
{
Q_OBJECT

View File

@ -6,6 +6,7 @@ TARGET = UAVSettingsImportExport
DEFINES += UAVSETTINGSIMPORTEXPORT_LIBRARY
include(../../openpilotgcsplugin.pri)
include(uavsettingsimportexport_dependencies.pri)
include(../../libs/versioninfo/versioninfo.pri)
HEADERS += uavsettingsimportexport.h \
importsummary.h \

View File

@ -31,6 +31,7 @@
#include <QDebug>
#include <QCheckBox>
#include "importsummary.h"
#include "versioninfo/version_info.h"
// for menu item
#include <coreplugin/coreconstants.h>
@ -244,7 +245,7 @@ QString UAVSettingsImportExportFactory::createXMLDocument(const enum storedData
fw.setAttribute("tag", board.gitTag);
versionInfo.appendChild(fw);
QString gcsRevision = QString::fromLatin1(Core::Constants::GCS_REVISION_STR);
QString gcsRevision = VersionInfo::revision();
QString gcsGitDate = gcsRevision.mid(gcsRevision.indexOf(" ") + 1, 14);
QString gcsGitHash = gcsRevision.mid(gcsRevision.indexOf(":") + 1, 8);
QString gcsGitTag = gcsRevision.left(gcsRevision.indexOf(":"));

View File

@ -28,7 +28,7 @@
#define UAVSETTINGSIMPORTEXPORTFACTORY_H
#include "uavsettingsimportexport_global.h"
#include "uavobjectutil/uavobjectutilmanager.h"
#include "../../gcs_version_info.h"
class UAVSETTINGSIMPORTEXPORT_EXPORT UAVSettingsImportExportFactory : public QObject
{
Q_OBJECT

View File

@ -3,6 +3,7 @@ TARGET = Uploader
DEFINES += UPLOADER_LIBRARY
QT += svg
include(uploader_dependencies.pri)
include(../../libs/versioninfo/versioninfo.pri)
INCLUDEPATH += ../../libs/qextserialport/src
macx {
QMAKE_CXXFLAGS += -fpermissive

View File

@ -25,7 +25,7 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "uploadergadgetwidget.h"
#include "../../gcs_version_info.h"
#include "versioninfo/version_info.h"
#include <coreplugin/coreconstants.h>
#include <QDebug>
#include "flightstatus.h"
@ -907,7 +907,7 @@ void UploaderGadgetWidget::versionMatchCheck()
UAVObjectUtilManager *utilMngr = pm->getObject<UAVObjectUtilManager>();
deviceDescriptorStruct boardDescription = utilMngr->getBoardDescriptionStruct();
QByteArray uavoHashArray;
QString uavoHash = QString::fromLatin1(Core::Constants::UAVOSHA1_STR);
QString uavoHash = VersionInfo::uavoHash();
uavoHash.chop(2);
uavoHash.remove(0,2);
uavoHash=uavoHash.trimmed();
@ -920,7 +920,7 @@ void UploaderGadgetWidget::versionMatchCheck()
QByteArray fwVersion=boardDescription.uavoHash;
if (fwVersion != uavoHashArray) {
QString gcsDescription = QString::fromLatin1(Core::Constants::GCS_REVISION_STR);
QString gcsDescription = VersionInfo::revision();
QString gcsGitHash = gcsDescription.mid(gcsDescription.indexOf(":")+1, 8);
gcsGitHash.remove( QRegExp("^[0]*") );
QString gcsGitDate = gcsDescription.mid(gcsDescription.indexOf(" ")+1, 14);