dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
versiondialog.cpp
Go to the documentation of this file.
1 
14 /*
15  * This program is free software; you can redistribute it and/or modify
16  * it under the terms of the GNU General Public License as published by
17  * the Free Software Foundation; either version 3 of the License, or
18  * (at your option) any later version.
19  *
20  * This program is distributed in the hope that it will be useful, but
21  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
22  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23  * for more details.
24  *
25  * You should have received a copy of the GNU General Public License along
26  * with this program; if not, see <http://www.gnu.org/licenses/>
27  */
28 
29 #include "versiondialog.h"
30 
31 #include "coreconstants.h"
32 #include "icore.h"
33 
34 #include <utils/qtcassert.h>
35 
36 #include <QtCore/QDate>
37 #include <QtCore/QFile>
38 #include <QtCore/QSysInfo>
39 
40 #include <QDialogButtonBox>
41 #include <QGridLayout>
42 #include <QLabel>
43 #include <QPushButton>
44 #include <QTextBrowser>
45 #include <QApplication>
46 #include <QDebug>
47 
48 using namespace Core;
49 using namespace Core::Internal;
50 using namespace Core::Constants;
51 
53  : QDialog(parent)
54 {
55  // We need to set the window icon explicitly here since for some reason the
56  // application icon isn't used when the size of the dialog is fixed (at least not on X11/GNOME)
57  setWindowIcon(QIcon(":/core/gcs_nontrans_128"));
58 
59  setWindowTitle(tr("About " GCS_PROJECT_BRANDING_PRETTY " GCS"));
60  setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
61  QGridLayout *layout = new QGridLayout(this);
62  layout->setSizeConstraint(QLayout::SetFixedSize);
63  QString versionName;
64  QString versionHash;
65 
66  QString versionData = QLatin1String(GCS_REVISION_PRETTY_STR);
67  if (versionData.split(QLatin1String("%@%")).length() >= 2) {
68  versionName = versionData.split(QLatin1String("%@%")).at(0);
69  versionHash = versionData.split(QLatin1String("%@%")).at(1);
70  } else {
71  qWarning() << "Invalid GCS version information:" << versionData;
72  }
73 
74  QString ideRev;
75 #ifdef GCS_REVISION
76  //: This gets conditionally inserted as argument %8 into the description string.
77  QString revision = QString::fromLatin1(GCS_REVISION_STR)
78  .remove(0, 1 + (QString::fromLatin1(GCS_REVISION_STR).indexOf(":")));
79  ideRev = tr("From revision %1<br/>").arg(revision);
80 #endif
81  QString uavoHashStr;
82 #ifdef UAVO_HASH
83  //: This gets conditionally inserted as argument %11 into the description string.
84  QByteArray uavoHashArray;
85  QString uavoHash = QString::fromLatin1(Core::Constants::UAVOSHA1_STR);
86  uavoHash.chop(2);
87  uavoHash.remove(0, 2);
88  uavoHash = uavoHash.trimmed();
89  bool ok;
90  foreach (QString str, uavoHash.split(",")) {
91  uavoHashArray.append(str.toInt(&ok, 16));
92  }
93  QString gcsUavoHashStr;
94  foreach (char i, uavoHashArray) {
95  gcsUavoHashStr.append(QString::number(i, 16).right(2));
96  }
97  uavoHashStr = tr("UAVO hash %1<br/>").arg(gcsUavoHashStr.left(8));
98 #endif
99  const QString version_name = tr("<h3><center>" GCS_PROJECT_BRANDING_PRETTY "GCS<center></h3>"
100  "<h4><center>%1: %2</center></h4>")
101  .arg(versionName, versionHash);
102  const QString version_description =
103  tr("Based on Qt %1 (%2 bit)<br/>"
104  "<br/>"
105  "Built on %3 at %4<br />"
106  "<br/>"
107  "%5"
108  "<br/>"
109  "%6"
110  "<br/>")
111  .arg(QLatin1String(QT_VERSION_STR), QString::number(QSysInfo::WordSize),
112  QLatin1String(__DATE__), QLatin1String(__TIME__), ideRev, uavoHashStr);
113 
114  QString copyright =
115  tr("Copyright %0 %1, 2012-2015 Tau Labs, 2010-2012 OpenPilot. All rights reserved.<br/>"
116  "<br/>"
117  "Between 2010 and 2012, a significant part of this application was designed "
118  "and implemented within the OpenPilot project.<br/>"
119  "This work was further based on work from the Nokia Corporation for Qt Creator.<br/>"
120  "<br/>"
121  "<small>This program is free software; you can redistribute it and/or modify"
122  "it under the terms of the GNU General Public License as published by"
123  "the Free Software Foundation; either version 3 of the License, or"
124  "(at your option) any later version.<br/><br/>"
125  "The program is provided AS IS with NO WARRANTY OF ANY KIND, "
126  "INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A "
127  "PARTICULAR PURPOSE.</small><br/>")
128  .arg(QLatin1String(GCS_YEAR), (QLatin1String(GCS_AUTHOR)));
129 
130  QLabel *versionNameLabel = new QLabel(version_name);
131  QLabel *versionDescription = new QLabel(version_description);
132  versionDescription->setWordWrap(true);
133  versionDescription->setOpenExternalLinks(true);
134  versionDescription->setTextInteractionFlags(Qt::TextBrowserInteraction);
135  versionNameLabel->setWordWrap(true);
136  versionNameLabel->setOpenExternalLinks(true);
137  versionNameLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
138 
139  QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close);
140  QPushButton *closeButton = buttonBox->button(QDialogButtonBox::Close);
141  QTC_ASSERT(closeButton, );
142  buttonBox->addButton(closeButton, QDialogButtonBox::ButtonRole(QDialogButtonBox::RejectRole
143  | QDialogButtonBox::AcceptRole));
144  connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
145 
146  QLabel *logoLabel = new QLabel;
147  logoLabel->setPixmap(QPixmap(QLatin1String(":/core/gcs_logo_128")));
148 
149  QLabel *copyRightLabel = new QLabel(copyright);
150  copyRightLabel->setWordWrap(true);
151  copyRightLabel->setOpenExternalLinks(true);
152  copyRightLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
153 
154  layout->addWidget(versionNameLabel, 0, 0, 1, 2);
155  layout->addWidget(logoLabel, 1, 1, 1, 1);
156  layout->addWidget(versionDescription, 1, 0, 1, 1);
157  layout->addWidget(copyRightLabel, 3, 0, 1, 2);
158  layout->addWidget(buttonBox, 5, 0, 1, 2);
159 }
const char *const UAVOSHA1_STR
Definition: coreconstants.h:46
const char *const GCS_REVISION_PRETTY_STR
Definition: coreconstants.h:53
const char *const GCS_YEAR
Definition: coreconstants.h:41
for i
Definition: OPPlots.m:140
const char *const GCS_AUTHOR
Definition: coreconstants.h:39
const char *const GCS_REVISION_STR
Definition: coreconstants.h:45