Bump required Qt version to 5.12
This commit is contained in:
parent
e511b2faf9
commit
f8d2c7eba3
|
@ -305,7 +305,7 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
debian_version: [ 'buster', 'bullseye', 'bookworm' ]
|
debian_version: [ 'bullseye', 'bookworm' ]
|
||||||
container:
|
container:
|
||||||
image: debian:${{matrix.debian_version}}
|
image: debian:${{matrix.debian_version}}
|
||||||
steps:
|
steps:
|
||||||
|
@ -350,12 +350,12 @@ jobs:
|
||||||
libmtp-dev
|
libmtp-dev
|
||||||
libgpod-dev
|
libgpod-dev
|
||||||
- name: Install Qt 5
|
- name: Install Qt 5
|
||||||
if: matrix.debian_version == 'buster' || matrix.debian_version == 'bullseye'
|
if: matrix.debian_version == 'bullseye'
|
||||||
env:
|
env:
|
||||||
DEBIAN_FRONTEND: noninteractive
|
DEBIAN_FRONTEND: noninteractive
|
||||||
run: apt install -y qtbase5-dev qtbase5-dev-tools qttools5-dev qttools5-dev-tools libqt5x11extras5-dev
|
run: apt install -y qtbase5-dev qtbase5-dev-tools qttools5-dev qttools5-dev-tools libqt5x11extras5-dev
|
||||||
- name: Install Qt 6
|
- name: Install Qt 6
|
||||||
if: matrix.debian_version != 'buster' && matrix.debian_version != 'bullseye'
|
if: matrix.debian_version != 'bullseye'
|
||||||
env:
|
env:
|
||||||
DEBIAN_FRONTEND: noninteractive
|
DEBIAN_FRONTEND: noninteractive
|
||||||
run: apt install -y qt6-base-dev qt6-base-dev-tools qt6-tools-dev qt6-tools-dev-tools qt6-l10n-tools
|
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:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
ubuntu_version: [ 'bionic', 'focal', 'jammy', 'kinetic', 'lunar' ]
|
ubuntu_version: [ 'focal', 'jammy', 'kinetic', 'lunar' ]
|
||||||
container:
|
container:
|
||||||
image: ubuntu:${{matrix.ubuntu_version}}
|
image: ubuntu:${{matrix.ubuntu_version}}
|
||||||
steps:
|
steps:
|
||||||
|
@ -427,12 +427,12 @@ jobs:
|
||||||
libmtp-dev
|
libmtp-dev
|
||||||
libgpod-dev
|
libgpod-dev
|
||||||
- name: Install Qt 5
|
- name: Install Qt 5
|
||||||
if: matrix.ubuntu_version == 'bionic' || matrix.ubuntu_version == 'focal'
|
if: matrix.ubuntu_version == 'focal'
|
||||||
env:
|
env:
|
||||||
DEBIAN_FRONTEND: noninteractive
|
DEBIAN_FRONTEND: noninteractive
|
||||||
run: apt install -y qtbase5-dev qtbase5-dev-tools qttools5-dev qttools5-dev-tools libqt5x11extras5-dev
|
run: apt install -y qtbase5-dev qtbase5-dev-tools qttools5-dev qttools5-dev-tools libqt5x11extras5-dev
|
||||||
- name: Install Qt 6
|
- name: Install Qt 6
|
||||||
if: matrix.ubuntu_version != 'bionic' && matrix.ubuntu_version != 'focal'
|
if: matrix.ubuntu_version != 'focal'
|
||||||
env:
|
env:
|
||||||
DEBIAN_FRONTEND: noninteractive
|
DEBIAN_FRONTEND: noninteractive
|
||||||
run: apt install -y qt6-base-dev qt6-base-dev-tools qt6-tools-dev qt6-tools-dev-tools qt6-l10n-tools
|
run: apt install -y qt6-base-dev qt6-base-dev-tools qt6-tools-dev qt6-tools-dev-tools qt6-l10n-tools
|
||||||
|
|
|
@ -62,11 +62,7 @@
|
||||||
#include <QLocalServer>
|
#include <QLocalServer>
|
||||||
#include <QLocalSocket>
|
#include <QLocalSocket>
|
||||||
#include <QElapsedTimer>
|
#include <QElapsedTimer>
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
#include <QRandomGenerator>
|
||||||
# include <QRandomGenerator>
|
|
||||||
#else
|
|
||||||
# include <QDateTime>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "singleapplication_t.h"
|
#include "singleapplication_t.h"
|
||||||
#include "singleapplication_p.h"
|
#include "singleapplication_p.h"
|
||||||
|
@ -113,11 +109,7 @@ QString SingleApplicationPrivateClass::getUsername() {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (username.isEmpty()) {
|
if (username.isEmpty()) {
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
|
||||||
username = qEnvironmentVariable("USER");
|
username = qEnvironmentVariable("USER");
|
||||||
#else
|
|
||||||
username = QString::fromLocal8Bit(qgetenv("USER"));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
return username;
|
return username;
|
||||||
#endif
|
#endif
|
||||||
|
@ -129,11 +121,7 @@ QString SingleApplicationPrivateClass::getUsername() {
|
||||||
if (GetUserNameW(username, &usernameLength)) {
|
if (GetUserNameW(username, &usernameLength)) {
|
||||||
return QString::fromWCharArray(username);
|
return QString::fromWCharArray(username);
|
||||||
}
|
}
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
|
||||||
return qEnvironmentVariable("USERNAME");
|
return qEnvironmentVariable("USERNAME");
|
||||||
#else
|
|
||||||
return QString::fromLocal8Bit(qgetenv("USERNAME"));
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -512,11 +500,6 @@ void SingleApplicationPrivateClass::slotClientConnectionClosed(QLocalSocket *clo
|
||||||
|
|
||||||
void SingleApplicationPrivateClass::randomSleep() {
|
void SingleApplicationPrivateClass::randomSleep() {
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
|
||||||
QThread::msleep(QRandomGenerator::global()->bounded(8U, 18U));
|
QThread::msleep(QRandomGenerator::global()->bounded(8U, 18U));
|
||||||
#else
|
|
||||||
qsrand(QDateTime::currentMSecsSinceEpoch() % std::numeric_limits<uint>::max());
|
|
||||||
QThread::msleep(qrand() % 11 + 8);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,7 +179,7 @@ if(DBUS_FOUND AND NOT WIN32)
|
||||||
list(APPEND QT_COMPONENTS DBus)
|
list(APPEND QT_COMPONENTS DBus)
|
||||||
endif()
|
endif()
|
||||||
set(QT_OPTIONAL_COMPONENTS Test)
|
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)
|
if(BUILD_WITH_QT6 OR QT_VERSION_MAJOR EQUAL 6)
|
||||||
set(QT_VERSION_MAJOR 6 CACHE STRING "" FORCE)
|
set(QT_VERSION_MAJOR 6 CACHE STRING "" FORCE)
|
||||||
|
|
|
@ -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)
|
* [pkg-config](https://www.freedesktop.org/wiki/Software/pkg-config/) or [pkgconf](https://github.com/pkgconf/pkgconf)
|
||||||
* [Boost](https://www.boost.org/)
|
* [Boost](https://www.boost.org/)
|
||||||
* [GLib](https://developer.gnome.org/glib/)
|
* [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)
|
* [SQLite 3.9 or newer with FTS5](https://www.sqlite.org)
|
||||||
* [Protobuf](https://developers.google.com/protocol-buffers/)
|
* [Protobuf](https://developers.google.com/protocol-buffers/)
|
||||||
* [ALSA (Required on Linux)](https://www.alsa-project.org/)
|
* [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
|
### :penguin: Packaging status
|
||||||
|
|
||||||
[![Packaging status](https://repology.org/badge/vertical-allrepos/strawberry.svg?exclude_unsupported=1)](https://repology.org/metapackage/strawberry/versions)
|
[![Packaging status](https://repology.org/badge/vertical-allrepos/strawberry.svg?exclude_unsupported=1)](https://repology.org/metapackage/strawberry/versions)
|
||||||
|
|
||||||
|
|
|
@ -37,9 +37,7 @@
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QAtomicInt>
|
#include <QAtomicInt>
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
#include <QRandomGenerator>
|
||||||
# include <QRandomGenerator>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "core/logging.h"
|
#include "core/logging.h"
|
||||||
|
|
||||||
|
@ -294,11 +292,7 @@ void WorkerPool<HandlerType>::StartOneWorker(Worker *worker) {
|
||||||
|
|
||||||
// Create a server, find an unused name and start listening
|
// Create a server, find an unused name and start listening
|
||||||
forever {
|
forever {
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
|
||||||
const quint32 unique_number = QRandomGenerator::global()->bounded(static_cast<quint32>(quint64(this) & 0xFFFFFFFF));
|
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);
|
const QString name = QString("%1_%2").arg(local_server_name_).arg(unique_number);
|
||||||
|
|
||||||
if (worker->local_server_->listen(name)) {
|
if (worker->local_server_->listen(name)) {
|
||||||
|
|
|
@ -240,12 +240,9 @@ bool TagReaderTagLib::ReadFile(const QString &filename, spb::tagreader::SongMeta
|
||||||
song->set_basefilename(basefilename.constData(), basefilename.length());
|
song->set_basefilename(basefilename.constData(), basefilename.length());
|
||||||
song->set_url(url.constData(), url.size());
|
song->set_url(url.constData(), url.size());
|
||||||
song->set_filesize(fileinfo.size());
|
song->set_filesize(fileinfo.size());
|
||||||
|
|
||||||
song->set_mtime(fileinfo.lastModified().isValid() ? std::max(fileinfo.lastModified().toSecsSinceEpoch(), 0LL) : 0LL);
|
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);
|
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) {
|
if (song->ctime() <= 0) {
|
||||||
song->set_ctime(song->mtime());
|
song->set_ctime(song->mtime());
|
||||||
|
|
|
@ -108,12 +108,9 @@ bool TagReaderTagParser::ReadFile(const QString &filename, spb::tagreader::SongM
|
||||||
song->set_basefilename(basefilename.constData(), basefilename.size());
|
song->set_basefilename(basefilename.constData(), basefilename.size());
|
||||||
song->set_url(url.constData(), url.size());
|
song->set_url(url.constData(), url.size());
|
||||||
song->set_filesize(fileinfo.size());
|
song->set_filesize(fileinfo.size());
|
||||||
|
|
||||||
song->set_mtime(fileinfo.lastModified().isValid() ? std::max(fileinfo.lastModified().toSecsSinceEpoch(), 0LL) : 0LL);
|
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);
|
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) {
|
if (song->ctime() <= 0) {
|
||||||
song->set_ctime(song->mtime());
|
song->set_ctime(song->mtime());
|
||||||
|
|
|
@ -20,9 +20,6 @@
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
|
|
||||||
# include <sys/time.h>
|
|
||||||
#endif
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
@ -46,13 +43,6 @@ int main(int argc, char **argv) {
|
||||||
return 1;
|
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();
|
logging::Init();
|
||||||
qLog(Info) << "TagReader worker connecting to" << args[1];
|
qLog(Info) << "TagReader worker connecting to" << args[1];
|
||||||
|
|
||||||
|
@ -67,4 +57,5 @@ int main(int argc, char **argv) {
|
||||||
TagReaderWorker worker(&socket);
|
TagReaderWorker worker(&socket);
|
||||||
|
|
||||||
return a.exec();
|
return a.exec();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -844,11 +844,7 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
|
||||||
QObject::connect(ui_->analyzer, &AnalyzerContainer::WheelEvent, this, &MainWindow::VolumeWheelEvent);
|
QObject::connect(ui_->analyzer, &AnalyzerContainer::WheelEvent, this, &MainWindow::VolumeWheelEvent);
|
||||||
|
|
||||||
// Statusbar widgets
|
// 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 ]"));
|
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);
|
ui_->status_bar_stack->setCurrentWidget(ui_->playlist_summary_page);
|
||||||
QObject::connect(ui_->multi_loading_indicator, &MultiLoadingIndicator::TaskCountChange, this, &MainWindow::TaskCountChanged);
|
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);
|
const QFontMetrics metrics(font);
|
||||||
|
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
|
|
||||||
const int text_width = metrics.horizontalAdvance(text);
|
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());
|
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);
|
ui_->band->setText(label);
|
||||||
|
|
||||||
QFontMetrics fm = ui_->gain->fontMetrics();
|
QFontMetrics fm = ui_->gain->fontMetrics();
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
|
ui_->gain->setMinimumWidth(fm.horizontalAdvance(tr("%1 dB").arg(-99.99)));
|
||||||
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->setText(tr("%1 dB").arg(0)); // Gain [dB]
|
ui_->gain->setText(tr("%1 dB").arg(0)); // Gain [dB]
|
||||||
|
|
||||||
ui_->slider->setValue(0);
|
ui_->slider->setValue(0);
|
||||||
|
|
|
@ -46,9 +46,7 @@
|
||||||
#include <QTcpSocket>
|
#include <QTcpSocket>
|
||||||
#include <QSslSocket>
|
#include <QSslSocket>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
#include <QRandomGenerator>
|
||||||
# include <QRandomGenerator>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LocalRedirectServer::LocalRedirectServer(QObject *parent)
|
LocalRedirectServer::LocalRedirectServer(QObject *parent)
|
||||||
: QTcpServer(parent),
|
: QTcpServer(parent),
|
||||||
|
@ -152,11 +150,7 @@ bool LocalRedirectServer::GenerateCertificate() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
const quint64 serial = 9999999 + QRandomGenerator::global()->bounded(1000000);
|
||||||
quint64 serial = 9999999 + QRandomGenerator::global()->bounded(1000000);
|
|
||||||
#else
|
|
||||||
quint64 serial = (9999999 + qrand() % 1000000);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QByteArray q_serial;
|
QByteArray q_serial;
|
||||||
q_serial.setNum(serial);
|
q_serial.setNum(serial);
|
||||||
|
|
|
@ -175,9 +175,6 @@ int main(int argc, char *argv[]) {
|
||||||
// Seed the random number generators.
|
// Seed the random number generators.
|
||||||
time_t t = time(nullptr);
|
time_t t = time(nullptr);
|
||||||
srand(t);
|
srand(t);
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
|
|
||||||
qsrand(t);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
Utilities::IncreaseFDLimit();
|
Utilities::IncreaseFDLimit();
|
||||||
|
|
|
@ -84,11 +84,7 @@ QDBusArgument &operator<<(QDBusArgument &arg, const QImage &image) {
|
||||||
qint32 bitspersample = i.depth() / channels;
|
qint32 bitspersample = i.depth() / channels;
|
||||||
arg << bitspersample;
|
arg << bitspersample;
|
||||||
arg << channels;
|
arg << channels;
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
|
||||||
arg << QByteArray(reinterpret_cast<const char*>(i.constBits()), static_cast<int>(i.sizeInBytes()));
|
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();
|
arg.endStructure();
|
||||||
|
|
||||||
return arg;
|
return arg;
|
||||||
|
|
|
@ -542,13 +542,7 @@ void OSDPretty::mouseReleaseEvent(QMouseEvent *) {
|
||||||
|
|
||||||
QScreen *OSDPretty::current_screen(const QPoint pos) const {
|
QScreen *OSDPretty::current_screen(const QPoint pos) const {
|
||||||
|
|
||||||
QScreen *screen(nullptr);
|
QScreen *screen = QGuiApplication::screenAt(pos);
|
||||||
#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
|
|
||||||
if (!screen) screen = QGuiApplication::primaryScreen();
|
if (!screen) screen = QGuiApplication::primaryScreen();
|
||||||
|
|
||||||
return screen;
|
return screen;
|
||||||
|
|
|
@ -110,11 +110,7 @@ void QueuedItemDelegate::DrawBox(QPainter *painter, const QRect line_rect, const
|
||||||
smaller.setBold(true);
|
smaller.setBold(true);
|
||||||
|
|
||||||
if (width == -1) {
|
if (width == -1) {
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
|
|
||||||
width = QFontMetrics(font).horizontalAdvance(text + " ");
|
width = QFontMetrics(font).horizontalAdvance(text + " ");
|
||||||
#else
|
|
||||||
width = QFontMetrics(font).width(text + " ");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect rect(line_rect);
|
QRect rect(line_rect);
|
||||||
|
|
|
@ -99,11 +99,7 @@ void PlaylistProxyStyle::drawControl(ControlElement element, const QStyleOption
|
||||||
const QFontMetrics &font_metrics = header_option->fontMetrics;
|
const QFontMetrics &font_metrics = header_option->fontMetrics;
|
||||||
|
|
||||||
// Spaces added to make transition less abrupt
|
// Spaces added to make transition less abrupt
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
|
|
||||||
if (rect.width() < font_metrics.horizontalAdvance(text + " ")) {
|
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);
|
const Playlist::Column column = static_cast<Playlist::Column>(header_option->section);
|
||||||
QStyleOptionHeader new_option(*header_option);
|
QStyleOptionHeader new_option(*header_option);
|
||||||
new_option.text = Playlist::abbreviated_column_name(column);
|
new_option.text = Playlist::abbreviated_column_name(column);
|
||||||
|
@ -183,9 +179,7 @@ PlaylistView::PlaylistView(QWidget *parent)
|
||||||
|
|
||||||
setHeader(header_);
|
setHeader(header_);
|
||||||
header_->setSectionsMovable(true);
|
header_->setSectionsMovable(true);
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
|
|
||||||
header_->setFirstSectionMovable(true);
|
header_->setFirstSectionMovable(true);
|
||||||
#endif
|
|
||||||
header_->setSortIndicator(Playlist::Column_Title, Qt::AscendingOrder);
|
header_->setSortIndicator(Playlist::Column_Title, Qt::AscendingOrder);
|
||||||
|
|
||||||
setStyle(style_);
|
setStyle(style_);
|
||||||
|
|
|
@ -1358,7 +1358,7 @@ void QobuzRequest::AlbumCoverReceived(QNetworkReply *reply, const QUrl &cover_ur
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArrayList format_list = ImageUtils::ImageFormatsForMimeType(mimetype.toUtf8());
|
QByteArrayList format_list = QImageReader::imageFormatsForMimeType(mimetype.toUtf8());
|
||||||
char *format = nullptr;
|
char *format = nullptr;
|
||||||
if (!format_list.isEmpty()) {
|
if (!format_list.isEmpty()) {
|
||||||
format = format_list.first().data();
|
format = format_list.first().data();
|
||||||
|
|
|
@ -70,13 +70,8 @@ BackendSettingsPage::BackendSettingsPage(SettingsDialog *dialog, QWidget *parent
|
||||||
ui_->setupUi(this);
|
ui_->setupUi(this);
|
||||||
setWindowIcon(IconLoader::Load("soundcard", true, 0, 32));
|
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_replaygainpreamp->setMinimumWidth(QFontMetrics(ui_->label_replaygainpreamp->font()).horizontalAdvance("-WW.W dB"));
|
||||||
ui_->label_replaygainfallbackgain->setMinimumWidth(QFontMetrics(ui_->label_replaygainfallbackgain->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_engine, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &BackendSettingsPage::EngineChanged);
|
||||||
QObject::connect(ui_->combobox_output, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &BackendSettingsPage::OutputChanged);
|
QObject::connect(ui_->combobox_output, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &BackendSettingsPage::OutputChanged);
|
||||||
|
|
|
@ -486,11 +486,7 @@ void SmartPlaylistSearchTermWidget::Overlay::paintEvent(QPaintEvent*) {
|
||||||
|
|
||||||
// Geometry
|
// Geometry
|
||||||
|
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
|
|
||||||
const QSize contents_size(kIconSize + kSpacing + fontMetrics().horizontalAdvance(text_), qMax(kIconSize, fontMetrics().height()));
|
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 contents(QPoint((width() - contents_size.width()) / 2, (height() - contents_size.height()) / 2), contents_size);
|
||||||
const QRect icon(contents.topLeft(), QSize(kIconSize, kIconSize));
|
const QRect icon(contents.topLeft(), QSize(kIconSize, kIconSize));
|
||||||
|
|
|
@ -819,7 +819,7 @@ void SubsonicRequest::AlbumCoverReceived(QNetworkReply *reply, const AlbumCoverR
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArrayList format_list = ImageUtils::ImageFormatsForMimeType(mimetype.toUtf8());
|
QByteArrayList format_list = QImageReader::imageFormatsForMimeType(mimetype.toUtf8());
|
||||||
char *format = nullptr;
|
char *format = nullptr;
|
||||||
if (!format_list.isEmpty()) {
|
if (!format_list.isEmpty()) {
|
||||||
format = format_list.first().data();
|
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);
|
QUrl url(QString(TidalService::kApiUrl) + QString("/") + "users/" + QString::number(service_->user_id()) + "/favorites/" + FavoriteText(type) + QString("/") + id);
|
||||||
url.setQuery(url_query);
|
url.setQuery(url_query);
|
||||||
QNetworkRequest req(url);
|
QNetworkRequest req(url);
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)
|
|
||||||
req.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
|
req.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
|
||||||
#else
|
|
||||||
req.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
|
|
||||||
#endif
|
|
||||||
req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
|
req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
|
||||||
if (oauth() && !access_token().isEmpty()) req.setRawHeader("authorization", "Bearer " + access_token().toUtf8());
|
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());
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArrayList format_list = ImageUtils::ImageFormatsForMimeType(mimetype.toUtf8());
|
QByteArrayList format_list = QImageReader::imageFormatsForMimeType(mimetype.toUtf8());
|
||||||
char *format = nullptr;
|
char *format = nullptr;
|
||||||
if (!format_list.isEmpty()) {
|
if (!format_list.isEmpty()) {
|
||||||
format = format_list.first().data();
|
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 ImageUtils::TryLoadPixmap(const QUrl &art_automatic, const QUrl &art_manual, const QUrl &url) {
|
||||||
|
|
||||||
QPixmap ret;
|
QPixmap ret;
|
||||||
|
|
|
@ -37,7 +37,6 @@ class ImageUtils {
|
||||||
public:
|
public:
|
||||||
static QStringList SupportedImageMimeTypes();
|
static QStringList SupportedImageMimeTypes();
|
||||||
static QStringList SupportedImageFormats();
|
static QStringList SupportedImageFormats();
|
||||||
static QByteArrayList ImageFormatsForMimeType(const QByteArray &mimetype);
|
|
||||||
static QByteArray SaveImageToJpegData(const QImage &image = QImage());
|
static QByteArray SaveImageToJpegData(const QImage &image = QImage());
|
||||||
static QByteArray FileToJpegData(const QString &filename);
|
static QByteArray FileToJpegData(const QString &filename);
|
||||||
static QPixmap TryLoadPixmap(const QUrl &automatic, const QUrl &manual, const QUrl &url = QUrl());
|
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::IsUp) ||
|
||||||
!(netif.flags() & QNetworkInterface::IsRunning)
|
!(netif.flags() & QNetworkInterface::IsRunning)
|
||||||
) { continue; }
|
) { continue; }
|
||||||
if (ret.isEmpty()
|
if (ret.isEmpty() || netif.type() == QNetworkInterface::Ethernet || netif.type() == QNetworkInterface::Wifi) {
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
|
|
||||||
|| netif.type() == QNetworkInterface::Ethernet || netif.type() == QNetworkInterface::Wifi
|
|
||||||
#endif
|
|
||||||
) {
|
|
||||||
ret = netif.hardwareAddress();
|
ret = netif.hardwareAddress();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,9 +20,7 @@
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QChar>
|
#include <QChar>
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
#include <QRandomGenerator>
|
||||||
# include <QRandomGenerator>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "randutils.h"
|
#include "randutils.h"
|
||||||
|
|
||||||
|
@ -47,11 +45,7 @@ QString GetRandomString(const int len, const QString &UseCharacters) {
|
||||||
|
|
||||||
QString randstr;
|
QString randstr;
|
||||||
for (int i = 0; i < len; ++i) {
|
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());
|
const qint64 index = QRandomGenerator::global()->bounded(0, UseCharacters.length());
|
||||||
#else
|
|
||||||
const int index = qrand() % UseCharacters.length();
|
|
||||||
#endif
|
|
||||||
QChar nextchar = UseCharacters.at(index);
|
QChar nextchar = UseCharacters.at(index);
|
||||||
randstr.append(nextchar);
|
randstr.append(nextchar);
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,11 +196,7 @@ void FreeSpaceBar::DrawText(QPainter *p, const QRect r) {
|
||||||
|
|
||||||
int text_width = 0;
|
int text_width = 0;
|
||||||
for (const Label &label : labels) {
|
for (const Label &label : labels) {
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
|
|
||||||
text_width += kLabelBoxSize + kLabelBoxPadding + kLabelSpacing + small_metrics.horizontalAdvance(label.text);
|
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
|
// Draw the text
|
||||||
|
@ -215,18 +211,10 @@ void FreeSpaceBar::DrawText(QPainter *p, const QRect r) {
|
||||||
p->setBrush(label.color);
|
p->setBrush(label.color);
|
||||||
p->drawRect(box);
|
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());
|
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->setPen(light ? label.color.darker() : label.color);
|
||||||
p->drawText(text, Qt::AlignCenter, label.text);
|
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);
|
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 {
|
QSize LineTextEdit::sizeHint() const {
|
||||||
|
|
||||||
QFontMetrics fm(font());
|
QFontMetrics fm(font());
|
||||||
|
|
||||||
static const int kMargin = 5;
|
static const int kMargin = 5;
|
||||||
int h = 2 * kMargin + qMax(fm.height(), 14);
|
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;
|
int w = 2 * kMargin + fm.horizontalAdvance("W") * 15;
|
||||||
#else
|
|
||||||
int w = 2 * kMargin + fm.width("W") * 15;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return QSize(w, h);
|
return QSize(w, h);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize LineTextEdit::minimumSizeHint() const {
|
QSize LineTextEdit::minimumSizeHint() const {
|
||||||
|
|
|
@ -49,11 +49,7 @@ MultiLoadingIndicator::MultiLoadingIndicator(QWidget *parent)
|
||||||
|
|
||||||
QSize MultiLoadingIndicator::sizeHint() const {
|
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_);
|
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());
|
const int height = kVerticalPadding * 2 + qMax(spinner_->sizeHint().height(), fontMetrics().height());
|
||||||
|
|
||||||
return QSize(width, height);
|
return QSize(width, height);
|
||||||
|
|
|
@ -80,11 +80,7 @@ void TrackSliderPopup::paintEvent(QPaintEvent*) {
|
||||||
|
|
||||||
void TrackSliderPopup::UpdatePixmap() {
|
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_));
|
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_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());
|
const QRect text_rect2(static_cast<int>(kBlurRadius) + kTextMargin, text_rect1.bottom(), text_width, small_font_metrics_.height());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue