From 2e92107ccee9b8c06d42089038bc7f406a132c25 Mon Sep 17 00:00:00 2001 From: sawinglogz <3787776-sawinglogz@users.noreply.gitlab.com> Date: Thu, 16 Jan 2020 13:05:55 -0500 Subject: [PATCH] Update version display throughout to use the new information and be consistent. The full version now includes the build/git information embedded within it as build metadata according to the Semantic Versioning 2.0.0 spec, for example: "1.1.0-beta-1+branch-name-a1b2c3d". Now the full version string, with all detail is always displayed EXCEPT for release versions, in which case just the simple version number ("1.1.0") is displayed in the primary UI. - Main window title: simple version for release versions, full version string otherwise - Notifications: same as main window title - System tray: same as main window title - About window title: same as main window title - About window release notes: always include full version string - Reports: always include full version string - Under the logo (about dialog, profile selector, new profile window): removed, as it is largely redundant and can interfere with the window geometry. - Database upgrade alert: same as main window title - Database newer alert: same as main window title The full version string is also included within the preference and profile .xml files, but because build metadata is ignored in version comparisons, differences in builds will not cause any spurious alerts. However, changes in prerelease versions will continue to be significant, as they should be. --- oscar/SleepLib/common.cpp | 4 ++-- oscar/SleepLib/profiles.cpp | 4 ++-- oscar/aboutdialog.cpp | 6 +++--- oscar/main.cpp | 8 +++++--- oscar/mainwindow.cpp | 18 +++++++++++++----- oscar/mainwindow.h | 3 ++- oscar/newprofile.cpp | 2 +- oscar/profileselect.cpp | 2 +- oscar/profileselector.cpp | 2 +- oscar/reports.cpp | 5 +++-- oscar/statistics.cpp | 4 ++-- oscar/version.cpp | 24 +++--------------------- oscar/version.h | 1 - 13 files changed, 38 insertions(+), 45 deletions(-) diff --git a/oscar/SleepLib/common.cpp b/oscar/SleepLib/common.cpp index d197eccc..64660915 100644 --- a/oscar/SleepLib/common.cpp +++ b/oscar/SleepLib/common.cpp @@ -556,7 +556,7 @@ QString STR_TR_PrRelief; // Pressure Relief QString STR_TR_Bookmarks; QString STR_TR_OSCAR; -QString STR_TR_AppVersion; +//QString STR_TR_AppVersion; QString STR_TR_Default; @@ -761,7 +761,7 @@ void initializeStrings() STR_TR_Bookmarks = QObject::tr("Bookmarks"); STR_TR_OSCAR = QObject::tr("OSCAR"); - STR_TR_AppVersion = QObject::tr("v%1").arg(getVersion()); + //STR_TR_AppVersion = QObject::tr("v%1").arg(getVersion()); STR_TR_Mode = QObject::tr("Mode"); STR_TR_Model = QObject::tr("Model"); diff --git a/oscar/SleepLib/profiles.cpp b/oscar/SleepLib/profiles.cpp index 740839a2..ee2fa3c9 100644 --- a/oscar/SleepLib/profiles.cpp +++ b/oscar/SleepLib/profiles.cpp @@ -505,8 +505,8 @@ void Profile::DataFormatError(Machine *m) { QString msg; - msg = ""+QObject::tr("OSCAR (%1) needs to upgrade its database for %2 %3 %4"). - arg(getVersion()). + msg = ""+QObject::tr("OSCAR %1 needs to upgrade its database for %2 %3 %4"). + arg(getVersion().displayString()). arg(m->brand()).arg(m->model()).arg(m->serial()) + "

"; diff --git a/oscar/aboutdialog.cpp b/oscar/aboutdialog.cpp index 55da52c3..2458562c 100644 --- a/oscar/aboutdialog.cpp +++ b/oscar/aboutdialog.cpp @@ -28,7 +28,7 @@ AboutDialog::AboutDialog(QWidget *parent) : ui->creditsText->setHtml(getCredits()); ui->licenseText->setHtml(getLicense()); ui->relnotesText->setHtml(getRelnotes()); - ui->versionLabel->setText(getVersion()); + ui->versionLabel->setText(""); // QString gitrev = gitRevision(); // @@ -44,7 +44,7 @@ AboutDialog::AboutDialog(QWidget *parent) : ui->infoLabel->setText(text); - setWindowTitle(tr("About OSCAR")); + setWindowTitle(tr("About OSCAR %1").arg(getVersion().displayString())); setMinimumSize(QSize(400,400)); this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint); connect(ui->closeButton, SIGNAL(clicked(bool)), this, SLOT(accept())); @@ -123,7 +123,7 @@ QString AboutDialog::getRelnotes() QString text = "" "" ""+tr("Release Notes")+"
" - ""+tr("OSCAR v%1").arg(getVersion())+"" + ""+tr("OSCAR %1").arg(getVersion())+"" "
"; if (getVersion().IsReleaseVersion() == false) { text += "

"+tr("Important:")+" " diff --git a/oscar/main.cpp b/oscar/main.cpp index 0f71a773..d3f98090 100644 --- a/oscar/main.cpp +++ b/oscar/main.cpp @@ -246,7 +246,7 @@ bool migrateFromSH(QString destDir) { int main(int argc, char* argv[]) { initializeStrings(); - qDebug() << STR_TR_OSCAR + " " + getBranchVersion(); + qDebug() << STR_TR_OSCAR + " " + getVersion(); AutoTest::run(argc, argv); } @@ -554,8 +554,10 @@ int main(int argc, char *argv[]) { // check_updates = false; } else if (currentVersion < settingsVersion) { if (QMessageBox::warning(nullptr, STR_MessageBox_Error, - QObject::tr("The version of OSCAR you just ran is OLDER than the one used to create this data (%1)."). - arg(AppSetting->versionString()) +"\n\n"+ + QObject::tr("The version of OSCAR you are running (%1) is OLDER than the one used to create this data (%2).") + .arg(currentVersion.displayString()) + .arg(settingsVersion.displayString()) + +"\n\n"+ QObject::tr("It is likely that doing this will cause data corruption, are you sure you want to do this?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::No) { diff --git a/oscar/mainwindow.cpp b/oscar/mainwindow.cpp index c9d46c27..db1c7f94 100644 --- a/oscar/mainwindow.cpp +++ b/oscar/mainwindow.cpp @@ -94,7 +94,7 @@ MainWindow::MainWindow(QWidget *parent) : // seems to need the systray menu for notifications to work systraymenu = new QMenu(this); systray->setContextMenu(systraymenu); - QAction *a = systraymenu->addAction(STR_TR_OSCAR + " v" + getVersion()); + QAction *a = systraymenu->addAction(STR_TR_OSCAR + " " + getVersion().displayString()); a->setEnabled(false); systraymenu->addSeparator(); systraymenu->addAction(tr("&About"), this, SLOT(on_action_About_triggered())); @@ -113,11 +113,19 @@ MainWindow::MainWindow(QWidget *parent) : bool setupRunning = false; +QString MainWindow::getMainWindowTitle() +{ + QString title = STR_TR_OSCAR + " " + getVersion().displayString(); +#ifdef BROKEN_OPENGL_BUILD + title += " ["+CSTR_GFX_BrokenGL+"]"; +#endif + return title; +} + void MainWindow::SetupGUI() { setupRunning = true; - QString version = getBranchVersion(); - setWindowTitle(STR_TR_OSCAR + QString(" %1").arg(version)); + setWindowTitle(getMainWindowTitle()); #ifdef Q_OS_MAC ui->action_About->setMenuRole(QAction::ApplicationSpecificRole); @@ -317,7 +325,7 @@ void MainWindow::EnableTabs(bool b) void MainWindow::Notify(QString s, QString title, int ms) { if (title.isEmpty()) { - title = tr("%1 %2").arg(STR_TR_OSCAR).arg(STR_TR_AppVersion); + title = STR_TR_OSCAR + " " + getVersion().displayString(); } if (systray) { QString msg = s; @@ -527,7 +535,7 @@ bool MainWindow::OpenProfile(QString profileName, bool skippassword) PopulatePurgeMenu(); AppSetting->setProfileName(p_profile->user->userName()); - setWindowTitle(STR_TR_OSCAR + QString(" %1 (" + tr("Profile") + ": %2)").arg(getBranchVersion()).arg(AppSetting->profileName())); + setWindowTitle(tr("%1 (Profile: %2)").arg(getMainWindowTitle()).arg(AppSetting->profileName())); QList oximachines = p_profile->GetMachines(MT_OXIMETER); // Machines of any type except Journal QList posmachines = p_profile->GetMachines(MT_POSITION); diff --git a/oscar/mainwindow.h b/oscar/mainwindow.h index c3171827..b9e6a4a1 100644 --- a/oscar/mainwindow.h +++ b/oscar/mainwindow.h @@ -113,7 +113,7 @@ class MainWindow : public QMainWindow void CloseProfile(); bool OpenProfile(QString name, bool skippassword = false); - /*! \fn Notify(QString s,int ms=5000, QString title="OSCAR v"+getVersion()); + /*! \fn Notify(QString s, QString title="OSCAR (version)", int ms=5000); \brief Pops up a message box near the system tray \param QString string \param title @@ -348,6 +348,7 @@ class MainWindow : public QMainWindow private: + QString getMainWindowTitle(); void importCPAPBackups(); void finishCPAPImport(); QList detectCPAPCards(); diff --git a/oscar/newprofile.cpp b/oscar/newprofile.cpp index 9c21bff9..df2ddbff 100644 --- a/oscar/newprofile.cpp +++ b/oscar/newprofile.cpp @@ -93,7 +93,7 @@ NewProfile::NewProfile(QWidget *parent, const QString *user) : f.close(); } - ui->versionLabel->setText(getVersion()); + ui->versionLabel->setText(""); ui->textBrowser->setHtml(getIntroHTML()); } diff --git a/oscar/profileselect.cpp b/oscar/profileselect.cpp index ae7cd0c4..fa62f99c 100644 --- a/oscar/profileselect.cpp +++ b/oscar/profileselect.cpp @@ -95,7 +95,7 @@ ProfileSelect::ProfileSelect(QWidget *parent) : popupMenu->addAction(tr("Delete Profile"), this, SLOT(deleteProfile())); ui->labelAppName->setText(STR_TR_OSCAR); - ui->labelVersion->setText(STR_TR_AppVersion); + ui->labelVersion->setText(""); // if (GIT_BRANCH!="master") // ui->labelBuild->setText(GIT_BRANCH); // else ui->labelBuild->setText(QString()); diff --git a/oscar/profileselector.cpp b/oscar/profileselector.cpp index 34c7397c..8db6f013 100644 --- a/oscar/profileselector.cpp +++ b/oscar/profileselector.cpp @@ -56,7 +56,7 @@ ProfileSelector::ProfileSelector(QWidget *parent) : showDiskUsage = false; // in case I want to preference it later on_diskSpaceInfo_linkActivated(showDiskUsage ? "show" : "hide"); - ui->versionLabel->setText(getVersion()); + ui->versionLabel->setText(""); ui->diskSpaceInfo->setVisible(false); QItemSelectionModel * sm = ui->profileView->selectionModel(); diff --git a/oscar/reports.cpp b/oscar/reports.cpp index c4b3011c..484ea1b1 100644 --- a/oscar/reports.cpp +++ b/oscar/reports.cpp @@ -558,8 +558,9 @@ void Report::PrintReport(gGraphView *gv, QString name, QDate date) if (first) { QDateTime timestamp = QDateTime::currentDateTime(); - QString footer = QObject::tr("%1 OSCAR v%2").arg(timestamp.toString(MedDateFormat+" hh:mm")) - .arg(getVersion()+" (" + gitRevision() + ")"); + QString footer = QObject::tr("%1 %2 %3").arg(timestamp.toString(MedDateFormat+" hh:mm")) + .arg(STR_TR_OSCAR) + .arg(getVersion()); QRectF bounds = painter.boundingRect(QRectF(0, virt_height, virt_width, normal_height), footer, diff --git a/oscar/statistics.cpp b/oscar/statistics.cpp index d4cb8d98..19b47534 100644 --- a/oscar/statistics.cpp +++ b/oscar/statistics.cpp @@ -719,8 +719,8 @@ QString Statistics::generateFooter(bool showinfo) if (showinfo) { html += "


"; QDateTime timestamp = QDateTime::currentDateTime(); - html += tr("This report was prepared on %1 by OSCAR v%2").arg(timestamp.toString(MedDateFormat + " hh:mm")) - .arg(getVersion() + " (" + gitRevision() + ")") + html += tr("This report was prepared on %1 by OSCAR %2").arg(timestamp.toString(MedDateFormat + " hh:mm")) + .arg(getVersion()) + "
" + tr("OSCAR is free open-source CPAP report software"); html += "
"; diff --git a/oscar/version.cpp b/oscar/version.cpp index 9636c29c..faf97a04 100644 --- a/oscar/version.cpp +++ b/oscar/version.cpp @@ -35,24 +35,6 @@ const QString & gitBranch() return GIT_BRANCH; } -QString getBranchVersion() -{ - QString version = STR_TR_AppVersion; - - if (getVersion().IsReleaseVersion() == false) - version += " ("+GIT_REVISION + ")"; - - if (GIT_BRANCH != "master") { - version += " [Branch: " + GIT_BRANCH + "]"; - } - -#ifdef BROKEN_OPENGL_BUILD - version += " ["+CSTR_GFX_BrokenGL+"]"; -#endif - return version; -} - - QString getPrereleaseSuffix() { QString suffix; @@ -100,7 +82,7 @@ const QString & Version::toString() const // Alternate formatting of the version string for display or logging const QString Version::minimalString() const { - return toString().section("+", 0); + return toString().section("+", 0, 0); } const QString & Version::getBuildMetadata() const @@ -120,10 +102,10 @@ const QString Version::displayString() const const QString Version::PrereleaseType() const { // Extract the first identifier - QString type = mPrerelease.section(".", 0); + QString type = mPrerelease.section(".", 0, 0); // Remove any "-2", etc. that's included in the first identifier rather than as a dot-separated identifier - type = type.section("-", 0); + type = type.section("-", 0, 0); return type.toLower(); } diff --git a/oscar/version.h b/oscar/version.h index b518ef17..b037193b 100644 --- a/oscar/version.h +++ b/oscar/version.h @@ -51,7 +51,6 @@ protected: //!brief Get the current version of the application. const Version & getVersion(); -QString getBranchVersion(); QString getPrereleaseSuffix(); const QString & gitRevision(); const QString & gitBranch();