Bump required Qt version to 5.12

This commit is contained in:
Jonas Kvinge 2022-01-29 01:33:40 +01:00
parent e511b2faf9
commit f8d2c7eba3
31 changed files with 24 additions and 165 deletions

View File

@ -305,7 +305,7 @@ jobs:
strategy:
fail-fast: false
matrix:
debian_version: [ 'buster', 'bullseye', 'bookworm' ]
debian_version: [ 'bullseye', 'bookworm' ]
container:
image: debian:${{matrix.debian_version}}
steps:
@ -350,12 +350,12 @@ jobs:
libmtp-dev
libgpod-dev
- name: Install Qt 5
if: matrix.debian_version == 'buster' || matrix.debian_version == 'bullseye'
if: matrix.debian_version == 'bullseye'
env:
DEBIAN_FRONTEND: noninteractive
run: apt install -y qtbase5-dev qtbase5-dev-tools qttools5-dev qttools5-dev-tools libqt5x11extras5-dev
- name: Install Qt 6
if: matrix.debian_version != 'buster' && matrix.debian_version != 'bullseye'
if: matrix.debian_version != 'bullseye'
env:
DEBIAN_FRONTEND: noninteractive
run: apt install -y qt6-base-dev qt6-base-dev-tools qt6-tools-dev qt6-tools-dev-tools qt6-l10n-tools
@ -379,7 +379,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ubuntu_version: [ 'bionic', 'focal', 'jammy', 'kinetic', 'lunar' ]
ubuntu_version: [ 'focal', 'jammy', 'kinetic', 'lunar' ]
container:
image: ubuntu:${{matrix.ubuntu_version}}
steps:
@ -427,12 +427,12 @@ jobs:
libmtp-dev
libgpod-dev
- name: Install Qt 5
if: matrix.ubuntu_version == 'bionic' || matrix.ubuntu_version == 'focal'
if: matrix.ubuntu_version == 'focal'
env:
DEBIAN_FRONTEND: noninteractive
run: apt install -y qtbase5-dev qtbase5-dev-tools qttools5-dev qttools5-dev-tools libqt5x11extras5-dev
- name: Install Qt 6
if: matrix.ubuntu_version != 'bionic' && matrix.ubuntu_version != 'focal'
if: matrix.ubuntu_version != 'focal'
env:
DEBIAN_FRONTEND: noninteractive
run: apt install -y qt6-base-dev qt6-base-dev-tools qt6-tools-dev qt6-tools-dev-tools qt6-l10n-tools

View File

@ -62,11 +62,7 @@
#include <QLocalServer>
#include <QLocalSocket>
#include <QElapsedTimer>
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
# include <QRandomGenerator>
#else
# include <QDateTime>
#endif
#include <QRandomGenerator>
#include "singleapplication_t.h"
#include "singleapplication_p.h"
@ -113,11 +109,7 @@ QString SingleApplicationPrivateClass::getUsername() {
}
#endif
if (username.isEmpty()) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
username = qEnvironmentVariable("USER");
#else
username = QString::fromLocal8Bit(qgetenv("USER"));
#endif
}
return username;
#endif
@ -129,11 +121,7 @@ QString SingleApplicationPrivateClass::getUsername() {
if (GetUserNameW(username, &usernameLength)) {
return QString::fromWCharArray(username);
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
return qEnvironmentVariable("USERNAME");
#else
return QString::fromLocal8Bit(qgetenv("USERNAME"));
#endif
#endif
}
@ -512,11 +500,6 @@ void SingleApplicationPrivateClass::slotClientConnectionClosed(QLocalSocket *clo
void SingleApplicationPrivateClass::randomSleep() {
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
QThread::msleep(QRandomGenerator::global()->bounded(8U, 18U));
#else
qsrand(QDateTime::currentMSecsSinceEpoch() % std::numeric_limits<uint>::max());
QThread::msleep(qrand() % 11 + 8);
#endif
}

View File

@ -179,7 +179,7 @@ if(DBUS_FOUND AND NOT WIN32)
list(APPEND QT_COMPONENTS DBus)
endif()
set(QT_OPTIONAL_COMPONENTS Test)
set(QT_MIN_VERSION 5.9)
set(QT_MIN_VERSION 5.12)
if(BUILD_WITH_QT6 OR QT_VERSION_MAJOR EQUAL 6)
set(QT_VERSION_MAJOR 6 CACHE STRING "" FORCE)

View File

@ -73,7 +73,7 @@ To build Strawberry from source you need the following installed on your system
* [pkg-config](https://www.freedesktop.org/wiki/Software/pkg-config/) or [pkgconf](https://github.com/pkgconf/pkgconf)
* [Boost](https://www.boost.org/)
* [GLib](https://developer.gnome.org/glib/)
* [Qt 6 or Qt 5.9 or higher with components Core, Gui, Widgets, Concurrent, Network and Sql](https://www.qt.io/)
* [Qt 6 or Qt 5.12 or higher with components Core, Gui, Widgets, Concurrent, Network and Sql](https://www.qt.io/)
* [SQLite 3.9 or newer with FTS5](https://www.sqlite.org)
* [Protobuf](https://developers.google.com/protocol-buffers/)
* [ALSA (Required on Linux)](https://www.alsa-project.org/)
@ -118,4 +118,3 @@ To compile on Windows with Visual Studio 2019 or 2022, see https://github.com/st
### :penguin: Packaging status
[![Packaging status](https://repology.org/badge/vertical-allrepos/strawberry.svg?exclude_unsupported=1)](https://repology.org/metapackage/strawberry/versions)

View File

@ -37,9 +37,7 @@
#include <QString>
#include <QStringList>
#include <QAtomicInt>
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
# include <QRandomGenerator>
#endif
#include <QRandomGenerator>
#include "core/logging.h"
@ -294,11 +292,7 @@ void WorkerPool<HandlerType>::StartOneWorker(Worker *worker) {
// Create a server, find an unused name and start listening
forever {
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
const quint32 unique_number = QRandomGenerator::global()->bounded(static_cast<quint32>(quint64(this) & 0xFFFFFFFF));
#else
const quint32 unique_number = qrand() ^ (static_cast<quint32>(quint64(this) & 0xFFFFFFFF));
#endif
const QString name = QString("%1_%2").arg(local_server_name_).arg(unique_number);
if (worker->local_server_->listen(name)) {

View File

@ -240,12 +240,9 @@ bool TagReaderTagLib::ReadFile(const QString &filename, spb::tagreader::SongMeta
song->set_basefilename(basefilename.constData(), basefilename.length());
song->set_url(url.constData(), url.size());
song->set_filesize(fileinfo.size());
song->set_mtime(fileinfo.lastModified().isValid() ? std::max(fileinfo.lastModified().toSecsSinceEpoch(), 0LL) : 0LL);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
song->set_ctime(fileinfo.birthTime().isValid() ? std::max(fileinfo.birthTime().toSecsSinceEpoch(), 0LL) : fileinfo.lastModified().isValid() ? std::max(fileinfo.lastModified().toSecsSinceEpoch(), 0LL) : 0LL);
#else
song->set_ctime(fileinfo.created().isValid() ? std::max(fileinfo.created().toSecsSinceEpoch(), 0LL) : fileinfo.lastModified().isValid() ? std::max(fileinfo.lastModified().toSecsSinceEpoch(), 0LL) : 0LL);
#endif
if (song->ctime() <= 0) {
song->set_ctime(song->mtime());

View File

@ -108,12 +108,9 @@ bool TagReaderTagParser::ReadFile(const QString &filename, spb::tagreader::SongM
song->set_basefilename(basefilename.constData(), basefilename.size());
song->set_url(url.constData(), url.size());
song->set_filesize(fileinfo.size());
song->set_mtime(fileinfo.lastModified().isValid() ? std::max(fileinfo.lastModified().toSecsSinceEpoch(), 0LL) : 0LL);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
song->set_ctime(fileinfo.birthTime().isValid() ? std::max(fileinfo.birthTime().toSecsSinceEpoch(), 0LL) : fileinfo.lastModified().isValid() ? std::max(fileinfo.lastModified().toSecsSinceEpoch(), 0LL) : 0LL);
#else
song->set_ctime(fileinfo.created().isValid() ? std::max(fileinfo.created().toSecsSinceEpoch(), 0LL) : fileinfo.lastModified().isValid() ? std::max(fileinfo.lastModified().toSecsSinceEpoch(), 0LL) : 0LL);
#endif
if (song->ctime() <= 0) {
song->set_ctime(song->mtime());

View File

@ -20,9 +20,6 @@
#include <QtGlobal>
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
# include <sys/time.h>
#endif
#include <iostream>
#include <QCoreApplication>
@ -46,13 +43,6 @@ int main(int argc, char **argv) {
return 1;
}
// Seed random number generator
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
timeval time;
gettimeofday(&time, nullptr);
qsrand((time.tv_sec * 1000) + (time.tv_usec / 1000));
#endif
logging::Init();
qLog(Info) << "TagReader worker connecting to" << args[1];
@ -67,4 +57,5 @@ int main(int argc, char **argv) {
TagReaderWorker worker(&socket);
return a.exec();
}

View File

@ -844,11 +844,7 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
QObject::connect(ui_->analyzer, &AnalyzerContainer::WheelEvent, this, &MainWindow::VolumeWheelEvent);
// Statusbar widgets
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
ui_->playlist_summary->setMinimumWidth(QFontMetrics(font()).horizontalAdvance("WW selected of WW tracks - [ WW:WW ]"));
#else
ui_->playlist_summary->setMinimumWidth(QFontMetrics(font()).width("WW selected of WW tracks - [ WW:WW ]"));
#endif
ui_->status_bar_stack->setCurrentWidget(ui_->playlist_summary_page);
QObject::connect(ui_->multi_loading_indicator, &MultiLoadingIndicator::TaskCountChange, this, &MainWindow::TaskCountChanged);

View File

@ -92,11 +92,7 @@ void SizeOverlayDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o
const QFontMetrics metrics(font);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
const int text_width = metrics.horizontalAdvance(text);
#else
const int text_width = metrics.width(text);
#endif
const QRect icon_rect(option.rect.left(), option.rect.top(), option.rect.width(), option.rect.width());

View File

@ -38,12 +38,7 @@ EqualizerSlider::EqualizerSlider(const QString &label, QWidget *parent)
ui_->band->setText(label);
QFontMetrics fm = ui_->gain->fontMetrics();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
int longestLabelWidth = fm.horizontalAdvance(tr("%1 dB").arg(-99.99));
#else
int longestLabelWidth = fm.width(tr("%1 dB").arg(-99.99));
#endif
ui_->gain->setMinimumWidth(longestLabelWidth);
ui_->gain->setMinimumWidth(fm.horizontalAdvance(tr("%1 dB").arg(-99.99)));
ui_->gain->setText(tr("%1 dB").arg(0)); // Gain [dB]
ui_->slider->setValue(0);

View File

@ -46,9 +46,7 @@
#include <QTcpSocket>
#include <QSslSocket>
#include <QDateTime>
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
# include <QRandomGenerator>
#endif
#include <QRandomGenerator>
LocalRedirectServer::LocalRedirectServer(QObject *parent)
: QTcpServer(parent),
@ -152,11 +150,7 @@ bool LocalRedirectServer::GenerateCertificate() {
return false;
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
quint64 serial = 9999999 + QRandomGenerator::global()->bounded(1000000);
#else
quint64 serial = (9999999 + qrand() % 1000000);
#endif
const quint64 serial = 9999999 + QRandomGenerator::global()->bounded(1000000);
QByteArray q_serial;
q_serial.setNum(serial);

View File

@ -175,9 +175,6 @@ int main(int argc, char *argv[]) {
// Seed the random number generators.
time_t t = time(nullptr);
srand(t);
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
qsrand(t);
#endif
#ifdef Q_OS_MACOS
Utilities::IncreaseFDLimit();

View File

@ -84,11 +84,7 @@ QDBusArgument &operator<<(QDBusArgument &arg, const QImage &image) {
qint32 bitspersample = i.depth() / channels;
arg << bitspersample;
arg << channels;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
arg << QByteArray(reinterpret_cast<const char*>(i.constBits()), static_cast<int>(i.sizeInBytes()));
#else
arg << QByteArray(reinterpret_cast<const char*>(i.constBits()), i.byteCount());
#endif
arg.endStructure();
return arg;

View File

@ -542,13 +542,7 @@ void OSDPretty::mouseReleaseEvent(QMouseEvent *) {
QScreen *OSDPretty::current_screen(const QPoint pos) const {
QScreen *screen(nullptr);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
screen = QGuiApplication::screenAt(pos);
#else
Q_UNUSED(pos)
if (window() && window()->windowHandle()) screen = window()->windowHandle()->screen();
#endif
QScreen *screen = QGuiApplication::screenAt(pos);
if (!screen) screen = QGuiApplication::primaryScreen();
return screen;

View File

@ -110,11 +110,7 @@ void QueuedItemDelegate::DrawBox(QPainter *painter, const QRect line_rect, const
smaller.setBold(true);
if (width == -1) {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
width = QFontMetrics(font).horizontalAdvance(text + " ");
#else
width = QFontMetrics(font).width(text + " ");
#endif
}
QRect rect(line_rect);

View File

@ -99,11 +99,7 @@ void PlaylistProxyStyle::drawControl(ControlElement element, const QStyleOption
const QFontMetrics &font_metrics = header_option->fontMetrics;
// Spaces added to make transition less abrupt
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
if (rect.width() < font_metrics.horizontalAdvance(text + " ")) {
#else
if (rect.width() < font_metrics.width(text + " ")) {
#endif
const Playlist::Column column = static_cast<Playlist::Column>(header_option->section);
QStyleOptionHeader new_option(*header_option);
new_option.text = Playlist::abbreviated_column_name(column);
@ -183,9 +179,7 @@ PlaylistView::PlaylistView(QWidget *parent)
setHeader(header_);
header_->setSectionsMovable(true);
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
header_->setFirstSectionMovable(true);
#endif
header_->setSortIndicator(Playlist::Column_Title, Qt::AscendingOrder);
setStyle(style_);

View File

@ -1358,7 +1358,7 @@ void QobuzRequest::AlbumCoverReceived(QNetworkReply *reply, const QUrl &cover_ur
return;
}
QByteArrayList format_list = ImageUtils::ImageFormatsForMimeType(mimetype.toUtf8());
QByteArrayList format_list = QImageReader::imageFormatsForMimeType(mimetype.toUtf8());
char *format = nullptr;
if (!format_list.isEmpty()) {
format = format_list.first().data();

View File

@ -70,13 +70,8 @@ BackendSettingsPage::BackendSettingsPage(SettingsDialog *dialog, QWidget *parent
ui_->setupUi(this);
setWindowIcon(IconLoader::Load("soundcard", true, 0, 32));
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
ui_->label_replaygainpreamp->setMinimumWidth(QFontMetrics(ui_->label_replaygainpreamp->font()).horizontalAdvance("-WW.W dB"));
ui_->label_replaygainfallbackgain->setMinimumWidth(QFontMetrics(ui_->label_replaygainfallbackgain->font()).horizontalAdvance("-WW.W dB"));
#else
ui_->label_replaygainpreamp->setMinimumWidth(QFontMetrics(ui_->label_replaygainpreamp->font()).width("-WW.W dB"));
ui_->label_replaygainfallbackgain->setMinimumWidth(QFontMetrics(ui_->label_replaygainfallbackgain->font()).width("-WW.W dB"));
#endif
QObject::connect(ui_->combobox_engine, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &BackendSettingsPage::EngineChanged);
QObject::connect(ui_->combobox_output, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &BackendSettingsPage::OutputChanged);

View File

@ -486,11 +486,7 @@ void SmartPlaylistSearchTermWidget::Overlay::paintEvent(QPaintEvent*) {
// Geometry
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
const QSize contents_size(kIconSize + kSpacing + fontMetrics().horizontalAdvance(text_), qMax(kIconSize, fontMetrics().height()));
#else
const QSize contents_size(kIconSize + kSpacing + fontMetrics().width(text_), qMax(kIconSize, fontMetrics().height()));
#endif
const QRect contents(QPoint((width() - contents_size.width()) / 2, (height() - contents_size.height()) / 2), contents_size);
const QRect icon(contents.topLeft(), QSize(kIconSize, kIconSize));

View File

@ -819,7 +819,7 @@ void SubsonicRequest::AlbumCoverReceived(QNetworkReply *reply, const AlbumCoverR
return;
}
QByteArrayList format_list = ImageUtils::ImageFormatsForMimeType(mimetype.toUtf8());
QByteArrayList format_list = QImageReader::imageFormatsForMimeType(mimetype.toUtf8());
char *format = nullptr;
if (!format_list.isEmpty()) {
format = format_list.first().data();

View File

@ -253,11 +253,7 @@ void TidalFavoriteRequest::RemoveFavoritesRequest(const FavoriteType type, const
QUrl url(QString(TidalService::kApiUrl) + QString("/") + "users/" + QString::number(service_->user_id()) + "/favorites/" + FavoriteText(type) + QString("/") + id);
url.setQuery(url_query);
QNetworkRequest req(url);
#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)
req.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
#else
req.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
#endif
req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
if (oauth() && !access_token().isEmpty()) req.setRawHeader("authorization", "Bearer " + access_token().toUtf8());
else if (!session_id().isEmpty()) req.setRawHeader("X-Tidal-SessionId", session_id().toUtf8());

View File

@ -1294,7 +1294,7 @@ void TidalRequest::AlbumCoverReceived(QNetworkReply *reply, const QString &album
return;
}
QByteArrayList format_list = ImageUtils::ImageFormatsForMimeType(mimetype.toUtf8());
QByteArrayList format_list = QImageReader::imageFormatsForMimeType(mimetype.toUtf8());
char *format = nullptr;
if (!format_list.isEmpty()) {
format = format_list.first().data();

View File

@ -61,20 +61,6 @@ QStringList ImageUtils::SupportedImageFormats() {
}
QByteArrayList ImageUtils::ImageFormatsForMimeType(const QByteArray &mimetype) {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
return QImageReader::imageFormatsForMimeType(mimetype);
#else
if (mimetype == "image/bmp") return QByteArrayList() << "BMP";
else if (mimetype == "image/gif") return QByteArrayList() << "GIF";
else if (mimetype == "image/jpeg") return QByteArrayList() << "JPG";
else if (mimetype == "image/png") return QByteArrayList() << "PNG";
else return QByteArrayList();
#endif
}
QPixmap ImageUtils::TryLoadPixmap(const QUrl &art_automatic, const QUrl &art_manual, const QUrl &url) {
QPixmap ret;

View File

@ -37,7 +37,6 @@ class ImageUtils {
public:
static QStringList SupportedImageMimeTypes();
static QStringList SupportedImageFormats();
static QByteArrayList ImageFormatsForMimeType(const QByteArray &mimetype);
static QByteArray SaveImageToJpegData(const QImage &image = QImage());
static QByteArray FileToJpegData(const QString &filename);
static QPixmap TryLoadPixmap(const QUrl &automatic, const QUrl &manual, const QUrl &url = QUrl());

View File

@ -36,11 +36,7 @@ QString MacAddress() {
!(netif.flags() & QNetworkInterface::IsUp) ||
!(netif.flags() & QNetworkInterface::IsRunning)
) { continue; }
if (ret.isEmpty()
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
|| netif.type() == QNetworkInterface::Ethernet || netif.type() == QNetworkInterface::Wifi
#endif
) {
if (ret.isEmpty() || netif.type() == QNetworkInterface::Ethernet || netif.type() == QNetworkInterface::Wifi) {
ret = netif.hardwareAddress();
}
}

View File

@ -20,9 +20,7 @@
#include <QString>
#include <QChar>
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
# include <QRandomGenerator>
#endif
#include <QRandomGenerator>
#include "randutils.h"
@ -47,11 +45,7 @@ QString GetRandomString(const int len, const QString &UseCharacters) {
QString randstr;
for (int i = 0; i < len; ++i) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
const qint64 index = QRandomGenerator::global()->bounded(0, UseCharacters.length());
#else
const int index = qrand() % UseCharacters.length();
#endif
QChar nextchar = UseCharacters.at(index);
randstr.append(nextchar);
}

View File

@ -196,11 +196,7 @@ void FreeSpaceBar::DrawText(QPainter *p, const QRect r) {
int text_width = 0;
for (const Label &label : labels) {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
text_width += kLabelBoxSize + kLabelBoxPadding + kLabelSpacing + small_metrics.horizontalAdvance(label.text);
#else
text_width += kLabelBoxSize + kLabelBoxPadding + kLabelSpacing + small_metrics.width(label.text);
#endif
}
// Draw the text
@ -215,18 +211,10 @@ void FreeSpaceBar::DrawText(QPainter *p, const QRect r) {
p->setBrush(label.color);
p->drawRect(box);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
QRect text(x + kLabelBoxSize + kLabelBoxPadding, r.top(), small_metrics.horizontalAdvance(label.text), r.height());
#else
QRect text(x + kLabelBoxSize + kLabelBoxPadding, r.top(), small_metrics.width(label.text), r.height());
#endif
p->setPen(light ? label.color.darker() : label.color);
p->drawText(text, Qt::AlignCenter, label.text);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
x += kLabelBoxSize + kLabelBoxPadding + kLabelSpacing + small_metrics.horizontalAdvance(label.text);
#else
x += kLabelBoxSize + kLabelBoxPadding + kLabelSpacing + small_metrics.width(label.text);
#endif
}
}

View File

@ -40,17 +40,15 @@ LineTextEdit::LineTextEdit(QWidget *parent) : QTextEdit(parent) {
}
QSize LineTextEdit::sizeHint() const {
QFontMetrics fm(font());
static const int kMargin = 5;
int h = 2 * kMargin + qMax(fm.height(), 14);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
int w = 2 * kMargin + fm.horizontalAdvance("W") * 15;
#else
int w = 2 * kMargin + fm.width("W") * 15;
#endif
return QSize(w, h);
}
QSize LineTextEdit::minimumSizeHint() const {

View File

@ -49,11 +49,7 @@ MultiLoadingIndicator::MultiLoadingIndicator(QWidget *parent)
QSize MultiLoadingIndicator::sizeHint() const {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
const int width = kHorizontalPadding * 2 + spinner_->sizeHint().width() + kSpacing + fontMetrics().horizontalAdvance(text_);
#else
const int width = kHorizontalPadding * 2 + spinner_->sizeHint().width() + kSpacing + fontMetrics().width(text_);
#endif
const int height = kVerticalPadding * 2 + qMax(spinner_->sizeHint().height(), fontMetrics().height());
return QSize(width, height);

View File

@ -80,11 +80,7 @@ void TrackSliderPopup::paintEvent(QPaintEvent*) {
void TrackSliderPopup::UpdatePixmap() {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
const int text_width = qMax(font_metrics_.horizontalAdvance(text_), small_font_metrics_.horizontalAdvance(small_text_));
#else
const int text_width = qMax(font_metrics_.width(text_), small_font_metrics_.width(small_text_));
#endif
const QRect text_rect1(static_cast<int>(kBlurRadius) + kTextMargin, static_cast<int>(kBlurRadius) + kTextMargin, text_width + 2, font_metrics_.height());
const QRect text_rect2(static_cast<int>(kBlurRadius) + kTextMargin, text_rect1.bottom(), text_width, small_font_metrics_.height());