Browse Source

Merge pull request #12168 from Chocobo1/version

Get library version strings at runtime
adaptive-webui-19844
Mike Tzou 5 years ago committed by GitHub
parent
commit
0ffa0478bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/app/cmdoptions.cpp
  2. 25
      src/base/utils/misc.cpp
  3. 4
      src/gui/executionlogwidget.cpp
  4. 4
      src/gui/mainwindow.cpp
  5. 2
      src/gui/statusbar.cpp
  6. 2
      src/gui/tagfiltermodel.cpp
  7. 2
      src/gui/transferlistmodel.cpp
  8. 2
      src/webui/webapplication.h

2
src/app/cmdoptions.cpp

@ -83,7 +83,7 @@ namespace
QString envVarName() const QString envVarName() const
{ {
return QLatin1String("QBT_") return QLatin1String("QBT_")
+ QString(QLatin1String(m_name)).toUpper().replace(QLatin1Char('-'), QLatin1Char('_')); + QString::fromLatin1(m_name).toUpper().replace(QLatin1Char('-'), QLatin1Char('_'));
} }
public: public:

25
src/base/utils/misc.cpp

@ -43,8 +43,9 @@
#endif #endif
#include <boost/version.hpp> #include <boost/version.hpp>
#include <openssl/opensslv.h>
#include <libtorrent/version.hpp> #include <libtorrent/version.hpp>
#include <openssl/crypto.h>
#include <openssl/opensslv.h>
#include <zlib.h> #include <zlib.h>
#include <QCoreApplication> #include <QCoreApplication>
@ -445,29 +446,37 @@ QString Utils::Misc::boostVersionString()
{ {
// static initialization for usage in signal handler // static initialization for usage in signal handler
static const QString ver = QString("%1.%2.%3") static const QString ver = QString("%1.%2.%3")
.arg(BOOST_VERSION / 100000) .arg(QString::number(BOOST_VERSION / 100000)
.arg((BOOST_VERSION / 100) % 1000) , QString::number((BOOST_VERSION / 100) % 1000)
.arg(BOOST_VERSION % 100); , QString::number(BOOST_VERSION % 100));
return ver; return ver;
} }
QString Utils::Misc::libtorrentVersionString() QString Utils::Misc::libtorrentVersionString()
{ {
// static initialization for usage in signal handler // static initialization for usage in signal handler
static const QString ver = LIBTORRENT_VERSION; #if (LIBTORRENT_VERSION_NUM < 10200)
return ver; static const auto version {QString::fromLatin1(libtorrent::version())};
#else
static const auto version {QString::fromLatin1(lt::version())};
#endif
return version;
} }
QString Utils::Misc::opensslVersionString() QString Utils::Misc::opensslVersionString()
{ {
const QString version {OPENSSL_VERSION_TEXT}; #if (OPENSSL_VERSION_NUMBER >= 0x1010000f)
static const auto version {QString::fromLatin1(OpenSSL_version(OPENSSL_VERSION))};
#else
static const auto version {QString::fromLatin1(SSLeay_version(SSLEAY_VERSION))};
#endif
return version.splitRef(' ', QString::SkipEmptyParts)[1].toString(); return version.splitRef(' ', QString::SkipEmptyParts)[1].toString();
} }
QString Utils::Misc::zlibVersionString() QString Utils::Misc::zlibVersionString()
{ {
// static initialization for usage in signal handler // static initialization for usage in signal handler
static const QString version {ZLIB_VERSION}; static const auto version {QString::fromLatin1(zlibVersion())};
return version; return version;
} }

4
src/gui/executionlogwidget.cpp

@ -88,7 +88,7 @@ void ExecutionLogWidget::addLogMessage(const Log::Msg &msg)
} }
const QDateTime time = QDateTime::fromMSecsSinceEpoch(msg.timestamp); const QDateTime time = QDateTime::fromMSecsSinceEpoch(msg.timestamp);
const QString text = QString(QLatin1String("<font color='grey'>%1</font> - <font color='%2'>%3</font>")) const QString text = QString::fromLatin1("<font color='grey'>%1</font> - <font color='%2'>%3</font>")
.arg(time.toString(Qt::SystemLocaleShortDate), colorName, msg.message); .arg(time.toString(Qt::SystemLocaleShortDate), colorName, msg.message);
m_msgList->appendLine(text, msg.type); m_msgList->appendLine(text, msg.type);
} }
@ -96,7 +96,7 @@ void ExecutionLogWidget::addLogMessage(const Log::Msg &msg)
void ExecutionLogWidget::addPeerMessage(const Log::Peer &peer) void ExecutionLogWidget::addPeerMessage(const Log::Peer &peer)
{ {
const QDateTime time = QDateTime::fromMSecsSinceEpoch(peer.timestamp); const QDateTime time = QDateTime::fromMSecsSinceEpoch(peer.timestamp);
const QString msg = QString(QLatin1String("<font color='grey'>%1</font> - <font color='red'>%2</font>")) const QString msg = QString::fromLatin1("<font color='grey'>%1</font> - <font color='red'>%2</font>")
.arg(time.toString(Qt::SystemLocaleShortDate), peer.ip); .arg(time.toString(Qt::SystemLocaleShortDate), peer.ip);
const QString text = peer.blocked const QString text = peer.blocked

4
src/gui/mainwindow.cpp

@ -1525,7 +1525,7 @@ void MainWindow::reloadSessionStats()
#else #else
if (m_systrayIcon) { if (m_systrayIcon) {
#ifdef Q_OS_UNIX #ifdef Q_OS_UNIX
const QString toolTip = QString(QLatin1String( const QString toolTip = QString::fromLatin1(
"<div style='background-color: #678db2; color: #fff;height: 18px; font-weight: bold; margin-bottom: 5px;'>" "<div style='background-color: #678db2; color: #fff;height: 18px; font-weight: bold; margin-bottom: 5px;'>"
"qBittorrent" "qBittorrent"
"</div>" "</div>"
@ -1534,7 +1534,7 @@ void MainWindow::reloadSessionStats()
"</div>" "</div>"
"<div style='vertical-align: baseline; height: 18px;'>" "<div style='vertical-align: baseline; height: 18px;'>"
"<img src=':/icons/skin/seeding.svg' height='14'/>&nbsp;%2" "<img src=':/icons/skin/seeding.svg' height='14'/>&nbsp;%2"
"</div>")) "</div>")
.arg(tr("DL speed: %1", "e.g: Download speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadDownloadRate, true)) .arg(tr("DL speed: %1", "e.g: Download speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadDownloadRate, true))
, tr("UP speed: %1", "e.g: Upload speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadUploadRate, true))); , tr("UP speed: %1", "e.g: Upload speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadUploadRate, true)));
#else #else

2
src/gui/statusbar.cpp

@ -64,7 +64,7 @@ StatusBar::StatusBar(QWidget *parent)
m_connecStatusLblIcon->setCursor(Qt::PointingHandCursor); m_connecStatusLblIcon->setCursor(Qt::PointingHandCursor);
m_connecStatusLblIcon->setIcon(QIcon(":/icons/skin/firewalled.svg")); m_connecStatusLblIcon->setIcon(QIcon(":/icons/skin/firewalled.svg"));
m_connecStatusLblIcon->setToolTip( m_connecStatusLblIcon->setToolTip(
QString(QLatin1String("<b>%1</b><br><i>%2</i>")).arg(tr("Connection status:") QString::fromLatin1("<b>%1</b><br><i>%2</i>").arg(tr("Connection status:")
, tr("No direct connections. This may indicate network configuration problems."))); , tr("No direct connections. This may indicate network configuration problems.")));
connect(m_connecStatusLblIcon, &QAbstractButton::clicked, this, &StatusBar::connectionButtonClicked); connect(m_connecStatusLblIcon, &QAbstractButton::clicked, this, &StatusBar::connectionButtonClicked);

2
src/gui/tagfiltermodel.cpp

@ -124,7 +124,7 @@ QVariant TagFilterModel::data(const QModelIndex &index, int role) const
case Qt::DecorationRole: case Qt::DecorationRole:
return UIThemeManager::instance()->getIcon("inode-directory"); return UIThemeManager::instance()->getIcon("inode-directory");
case Qt::DisplayRole: case Qt::DisplayRole:
return QString(QLatin1String("%1 (%2)")) return QString::fromLatin1("%1 (%2)")
.arg(tagDisplayName(item.tag())).arg(item.torrentsCount()); .arg(tagDisplayName(item.tag())).arg(item.torrentsCount());
case Qt::UserRole: case Qt::UserRole:
return item.torrentsCount(); return item.torrentsCount();

2
src/gui/transferlistmodel.cpp

@ -292,7 +292,7 @@ QString TransferListModel::displayValue(const BitTorrent::TorrentHandle *torrent
{ {
progress *= 100; progress *= 100;
return (static_cast<int>(progress) == 100) return (static_cast<int>(progress) == 100)
? QString {QLatin1String {"100%"}} ? QString::fromLatin1("100%")
: Utils::String::fromDouble(progress, 1) + '%'; : Utils::String::fromDouble(progress, 1) + '%';
}; };

2
src/webui/webapplication.h

@ -126,7 +126,7 @@ private:
QHash<QString, QString> m_params; QHash<QString, QString> m_params;
const QString m_cacheID; const QString m_cacheID;
const QRegularExpression m_apiPathPattern {(QLatin1String("^/api/v2/(?<scope>[A-Za-z_][A-Za-z_0-9]*)/(?<action>[A-Za-z_][A-Za-z_0-9]*)$"))}; const QRegularExpression m_apiPathPattern {QLatin1String("^/api/v2/(?<scope>[A-Za-z_][A-Za-z_0-9]*)/(?<action>[A-Za-z_][A-Za-z_0-9]*)$")};
QHash<QString, APIController *> m_apiControllers; QHash<QString, APIController *> m_apiControllers;
QSet<QString> m_publicAPIs; QSet<QString> m_publicAPIs;

Loading…
Cancel
Save