Clean up version.h interface and reduce duplcate code.

Only minor cosmetic changes in how the version is displayed in
certain places.
This commit is contained in:
sawinglogz 2020-01-15 13:18:00 -05:00
parent 6f194507a8
commit fb32e16c96
8 changed files with 34 additions and 39 deletions

View File

@ -80,36 +80,14 @@ const QString getDeveloperDomain()
const QString getAppName() const QString getAppName()
{ {
QString name = STR_AppName; QString name = STR_AppName;
name += getPrereleaseSuffix();
// Append branch if there is a branch specified
if (gitBranch() != "master") {
name += "-"+gitBranch();
// qDebug() << "getAppName, not master, name is" << name << "branch is" << gitBranch();
}
// Append "-test" if not release
else if (!((ReleaseStatus.compare("r", Qt::CaseInsensitive)==0) ||
(ReleaseStatus.compare("rc", Qt::CaseInsensitive)==0) )) {
name += "-test";
// qDebug() << "getAppName, not release, name is" << name << "release type is" << ReleaseStatus;
}
return name; return name;
} }
const QString getModifiedAppData() const QString getModifiedAppData()
{ {
QString appdata = STR_AppData; QString appdata = STR_AppData;
appdata += getPrereleaseSuffix();
// Append branch if there is a branch specified
if (gitBranch() != "master")
appdata += "-"+gitBranch();
// Append "-test" if not release
else if (!((ReleaseStatus.compare("r", Qt::CaseInsensitive)==0) ||
(ReleaseStatus.compare("rc", Qt::CaseInsensitive)==0) )) {
appdata += "-test";
}
return appdata; return appdata;
} }

View File

@ -125,7 +125,7 @@ QString AboutDialog::getRelnotes()
"<body><span style=\" font-size:20pt;\">"+tr("Release Notes")+"</span><br/>" "<body><span style=\" font-size:20pt;\">"+tr("Release Notes")+"</span><br/>"
"<span style=\" font-size:14pt;\">"+tr("OSCAR v%1").arg(VersionString)+"</span>" "<span style=\" font-size:14pt;\">"+tr("OSCAR v%1").arg(VersionString)+"</span>"
"<hr/>"; "<hr/>";
if (ReleaseStatus != "r") { if (isReleaseVersion() == false) {
text += "<p><font color='red' size=+1><b>"+tr("Important:")+"</b></font> " text += "<p><font color='red' size=+1><b>"+tr("Important:")+"</b></font> "
"<font size=+1><i>"+tr("As this is a pre-release version, it is recommended that you <b>back up your data folder manually</b> before proceeding, because attempting to roll back later may break things.")+"</i></font></p><hr/>"; "<font size=+1><i>"+tr("As this is a pre-release version, it is recommended that you <b>back up your data folder manually</b> before proceeding, because attempting to roll back later may break things.")+"</i></font></p><hr/>";
} }

View File

@ -1,4 +1,4 @@
/* Create New Profile Implementation /* Create New Profile Implementation
* *
* Copyright (c) 2011-2018 Mark Watkins <mark@jedimark.net> * Copyright (c) 2011-2018 Mark Watkins <mark@jedimark.net>
* *
@ -91,7 +91,7 @@ NewProfile::NewProfile(QWidget *parent, const QString *user) :
f.close(); f.close();
} }
ui->releaseStatus->setText("v" + VersionString); ui->versionLabel->setText(VersionString);
ui->textBrowser->setHtml(getIntroHTML()); ui->textBrowser->setHtml(getIntroHTML());
} }

View File

@ -882,7 +882,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="releaseStatus"> <widget class="QLabel" name="versionLabel">
<property name="font"> <property name="font">
<font> <font>
<italic>true</italic> <italic>true</italic>

View File

@ -558,7 +558,7 @@ void Report::PrintReport(gGraphView *gv, QString name, QDate date)
if (first) { if (first) {
QDateTime timestamp = QDateTime::currentDateTime(); QDateTime timestamp = QDateTime::currentDateTime();
QString footer = QObject::tr("%1 OSCAR v%2").arg(timestamp.toString(MedDateFormat+" hh:mm")) QString footer = QObject::tr("%1 OSCAR v%2").arg(timestamp.toString(MedDateFormat+" hh:mm"))
.arg(ReleaseStatus == "r" ? ShortVersionString : VersionString+" (" + gitRevision() + ")"); .arg(VersionString+" (" + gitRevision() + ")");
QRectF bounds = painter.boundingRect(QRectF(0, virt_height, virt_width, normal_height), footer, QRectF bounds = painter.boundingRect(QRectF(0, virt_height, virt_width, normal_height), footer,

View File

@ -719,7 +719,7 @@ QString Statistics::generateFooter(bool showinfo)
html += "<hr><div align=center><font size='-1'><i>"; html += "<hr><div align=center><font size='-1'><i>";
QDateTime timestamp = QDateTime::currentDateTime(); QDateTime timestamp = QDateTime::currentDateTime();
html += tr("This report was prepared on %1 by OSCAR v%2").arg(timestamp.toString(MedDateFormat + " hh:mm")) html += tr("This report was prepared on %1 by OSCAR v%2").arg(timestamp.toString(MedDateFormat + " hh:mm"))
.arg(ReleaseStatus == "r" ? ShortVersionString : VersionString + " (" + gitRevision() + ")") .arg(VersionString + " (" + gitRevision() + ")")
+ "<br/>" + "<br/>"
+ tr("OSCAR is free open-source CPAP report software"); + tr("OSCAR is free open-source CPAP report software");
html += "</i></font></div>"; html += "</i></font></div>";

View File

@ -60,6 +60,25 @@ QString getBranchVersion()
} }
QString getPrereleaseSuffix()
{
QString suffix;
// Append branch if there is a branch specified
if (gitBranch() != "master") {
suffix += "-"+gitBranch();
}
// Append "-test" if not release
else if (!((ReleaseStatus.compare("r", Qt::CaseInsensitive)==0) ||
(ReleaseStatus.compare("rc", Qt::CaseInsensitive)==0) )) {
suffix += "-test";
}
return suffix;
}
int checkVersionStatus(QString statusstr) int checkVersionStatus(QString statusstr)
{ {
bool ok; bool ok;
@ -201,3 +220,7 @@ int compareVersion(const QString & version)
return 0; return 0;
} }
bool isReleaseVersion()
{
return (ReleaseStatus == "r");
}

View File

@ -12,21 +12,15 @@
#include <QString> #include <QString>
extern const int major_version;
extern const int minor_version;
extern const int revision_number;
extern const QString ReleaseStatus;
extern const int build_number;
extern const QString VersionString; extern const QString VersionString;
extern const QString ShortVersionString;
extern const QString PlatformString;
int compareVersion(const QString & version); int compareVersion(const QString & version);
QString getBranchVersion(); QString getBranchVersion();
QString getPrereleaseSuffix();
const QString & gitRevision(); const QString & gitRevision();
const QString & gitBranch(); const QString & gitBranch();
bool isReleaseVersion();
#endif // VERSION_H #endif // VERSION_H