Better (with dependences version) --version

This commit is contained in:
Emmanuel Engelhart 2022-01-03 12:26:24 +01:00
parent 2875b52ae6
commit cc5cef3b48
No known key found for this signature in database
GPG Key ID: 120B30D020B553D3
3 changed files with 20 additions and 4 deletions

View File

@ -1,7 +1,9 @@
#include "kiwixapp.h" #include "kiwixapp.h"
#include "static_content.h" #include "static_content.h"
#include "zim/error.h" #include "zim/error.h"
#include "zim/version.h"
#include "kiwix/tools.h" #include "kiwix/tools.h"
#include "kiwix/version.h"
#include <QLocale> #include <QLocale>
#include <QLibraryInfo> #include <QLibraryInfo>
@ -36,8 +38,6 @@ KiwixApp::KiwixApp(int& argc, char *argv[])
QMessageBox::critical(nullptr, "Translation error", e.what()); QMessageBox::critical(nullptr, "Translation error", e.what());
return; return;
} }
qInfo() << "Compiled with Qt Version " << QT_VERSION_STR;
qInfo() << "Runtime Qt Version " << qVersion();
m_qtTranslator.load(QLocale(), "qt", "_", m_qtTranslator.load(QLocale(), "qt", "_",
QLibraryInfo::location(QLibraryInfo::TranslationsPath)); QLibraryInfo::location(QLibraryInfo::TranslationsPath));
installTranslator(&m_qtTranslator); installTranslator(&m_qtTranslator);
@ -444,3 +444,12 @@ void KiwixApp::updateNameMapper()
{ {
m_nameMapper.update(); m_nameMapper.update();
} }
void KiwixApp::printVersions(std::ostream& out) {
out << version.toStdString() << std::endl;
out << "+ libqt (compile time) " << QT_VERSION_STR << std::endl;
out << "+ libqt (run time) " << qVersion() << std::endl << std::endl;
kiwix::printVersions(out);
out << std::endl;
zim::printVersions(out);
}

View File

@ -101,6 +101,7 @@ public slots:
void printPage(); void printPage();
void disableItemsOnLibraryPage(bool displayed); void disableItemsOnLibraryPage(bool displayed);
void updateNameMapper(); void updateNameMapper();
void printVersions(std::ostream& out = std::cout);
protected: protected:
void createAction(); void createAction();

View File

@ -15,12 +15,18 @@ int main(int argc, char *argv[])
QWebEngineUrlScheme::registerScheme(scheme); QWebEngineUrlScheme::registerScheme(scheme);
#endif #endif
KiwixApp a(argc, argv); KiwixApp a(argc, argv);
a.setApplicationVersion(version);
QCommandLineParser parser; QCommandLineParser parser;
parser.setApplicationDescription(QStringLiteral("The Kiwix Desktop is a viewer/manager of ZIM files for GNU/Linux and Microsoft Windows OSes.")); parser.setApplicationDescription(QStringLiteral("The Kiwix Desktop is a viewer/manager of ZIM files for GNU/Linux and Microsoft Windows OSes."));
parser.addHelpOption(); parser.addHelpOption();
parser.addVersionOption();
parser.addPositionalArgument("zimfile", "The zim file"); parser.addPositionalArgument("zimfile", "The zim file");
// Set version string
std::ostringstream versions;
a.printVersions(versions);
a.setApplicationVersion(QString::fromStdString(versions.str()));
parser.addVersionOption();
parser.process(a); parser.process(a);
auto positionalArguments = parser.positionalArguments(); auto positionalArguments = parser.positionalArguments();
if (a.isRunning()) { if (a.isRunning()) {