Bump required Qt version to 5.12
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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());
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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_);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user