Skip to content

Commit fd54bf1

Browse files
committed
Unify message in About dialog and version argument
And avoid removing extension when printing command name in help message. See issue #1069
1 parent 0963cac commit fd54bf1

File tree

3 files changed

+24
-16
lines changed

3 files changed

+24
-16
lines changed

src/AboutDialog.cpp

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include "AboutDialog.h"
22
#include "ui_AboutDialog.h"
3-
#include "sqlitedb.h"
43
#include "Application.h"
54

65
AboutDialog::AboutDialog(QWidget *parent) :
@@ -10,19 +9,7 @@ AboutDialog::AboutDialog(QWidget *parent) :
109
ui->setupUi(this);
1110
this->setFixedSize(this->width(), this->height());
1211
this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
13-
14-
QString sqlite_version, sqlcipher_version;
15-
DBBrowserDB::getSqliteVersion(sqlite_version, sqlcipher_version);
16-
if(sqlcipher_version.isNull())
17-
sqlite_version = tr("SQLite Version ") + sqlite_version;
18-
else
19-
sqlite_version = tr("SQLCipher Version %1 (based on SQLite %2)").arg(sqlcipher_version, sqlite_version);
20-
21-
ui->label_version->setText(tr("Version ") + Application::versionString() + "\n\n" +
22-
tr("Built for %1, running on %2").arg(QSysInfo::buildAbi(), QSysInfo::currentCpuArchitecture()) + "\n\n" +
23-
tr("Qt Version ") + QT_VERSION_STR + "\n\n" +
24-
sqlite_version
25-
);
12+
ui->label_version->setText(Application::versionInformation());
2613
}
2714

2815
AboutDialog::~AboutDialog()

src/Application.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "RemoteNetwork.h"
1414
#include "Settings.h"
1515
#include "version.h"
16+
#include "sqlitedb.h"
1617

1718
Application::Application(int& argc, char** argv) :
1819
QApplication(argc, argv)
@@ -90,7 +91,7 @@ Application::Application(int& argc, char** argv) :
9091
{
9192
// Help
9293
qWarning() << qPrintable(tr("Usage: %1 [options] [<database>|<project>]\n").
93-
arg(QFileInfo(argv[0]).baseName()));
94+
arg(QFileInfo(argv[0]).fileName()));
9495
qWarning() << qPrintable(tr("Possible command line arguments:"));
9596
qWarning() << qPrintable(tr(" -h, --help Show command line options"));
9697
qWarning() << qPrintable(tr(" -q, --quit Exit application after running scripts"));
@@ -106,7 +107,7 @@ Application::Application(int& argc, char** argv) :
106107
qWarning() << qPrintable(tr(" <project> Open this project file (*.sqbpro)"));
107108
m_dontShowMainWindow = true;
108109
} else if(arguments().at(i) == "-v" || arguments().at(i) == "--version") {
109-
qWarning() << qPrintable(tr("DB Browser for SQLite version %1.").arg(versionString()));
110+
qWarning() << qPrintable(versionInformation());
110111
m_dontShowMainWindow = true;
111112
} else if(arguments().at(i) == "-s" || arguments().at(i) == "--sql") {
112113
// Run SQL file: If file exists add it to list of scripts to execute
@@ -227,6 +228,23 @@ QString Application::versionString()
227228
#endif
228229
}
229230

231+
QString Application::versionInformation()
232+
{
233+
QString sqlite_version, sqlcipher_version;
234+
DBBrowserDB::getSqliteVersion(sqlite_version, sqlcipher_version);
235+
if(sqlcipher_version.isNull())
236+
sqlite_version = tr("SQLite Version ") + sqlite_version;
237+
else
238+
sqlite_version = tr("SQLCipher Version %1 (based on SQLite %2)").arg(sqlcipher_version, sqlite_version);
239+
240+
return
241+
tr("DB Browser for SQLite Version %1.").arg(versionString() + "\n\n" +
242+
tr("Built for %1, running on %2").arg(QSysInfo::buildAbi(), QSysInfo::currentCpuArchitecture()) + "\n" +
243+
tr("Qt Version %1").arg(QT_VERSION_STR) + "\n" +
244+
sqlite_version
245+
);
246+
}
247+
230248
void Application::reloadSettings()
231249
{
232250
// Network settings

src/Application.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ class Application : public QApplication
2121

2222
MainWindow* mainWindow() { return m_mainWindow; }
2323

24+
// DB4S version number as string
2425
static QString versionString();
26+
// Version of DB4S and dependencies as string
27+
static QString versionInformation();
2528

2629
static void reloadSettings();
2730

0 commit comments

Comments
 (0)