diff --git a/src/encoder/encoderopussettings.cpp b/src/encoder/encoderopussettings.cpp index d4ec046f643..fe76cd3ee0d 100644 --- a/src/encoder/encoderopussettings.cpp +++ b/src/encoder/encoderopussettings.cpp @@ -3,7 +3,6 @@ #include "encoder/encoderopussettings.h" #include "recording/defs_recording.h" #include "util/logger.h" -#include "util/compatibility.h" namespace { const int kDefaultQualityIndex = 6; diff --git a/src/library/autodj/autodjfeature.cpp b/src/library/autodj/autodjfeature.cpp index eb18b36296d..e70b831707f 100644 --- a/src/library/autodj/autodjfeature.cpp +++ b/src/library/autodj/autodjfeature.cpp @@ -17,7 +17,6 @@ #include "moc_autodjfeature.cpp" #include "sources/soundsourceproxy.h" #include "track/track.h" -#include "util/compatibility.h" #include "util/dnd.h" #include "widget/wlibrary.h" #include "widget/wlibrarysidebar.h" diff --git a/src/library/autodj/dlgautodj.cpp b/src/library/autodj/dlgautodj.cpp index 487b7f24bb3..a116213549c 100644 --- a/src/library/autodj/dlgautodj.cpp +++ b/src/library/autodj/dlgautodj.cpp @@ -7,7 +7,6 @@ #include "moc_dlgautodj.cpp" #include "track/track.h" #include "util/assert.h" -#include "util/compatibility.h" #include "util/duration.h" #include "widget/wlibrary.h" #include "widget/wtracktableview.h" diff --git a/src/library/basetrackcache.cpp b/src/library/basetrackcache.cpp index d3fcdd686f3..3e7064c146b 100644 --- a/src/library/basetrackcache.cpp +++ b/src/library/basetrackcache.cpp @@ -7,7 +7,6 @@ #include "track/globaltrackcache.h" #include "track/keyutils.h" #include "track/track.h" -#include "util/compatibility.h" #include "util/performancetimer.h" namespace { diff --git a/src/library/basetracktablemodel.cpp b/src/library/basetracktablemodel.cpp index 05506188eed..e9ac6597b1d 100644 --- a/src/library/basetracktablemodel.cpp +++ b/src/library/basetracktablemodel.cpp @@ -1,5 +1,11 @@ #include "library/basetracktablemodel.h" +#include +// for hack to get primary screen instead of view widget's screen +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) +#include +#endif + #include "library/bpmdelegate.h" #include "library/colordelegate.h" #include "library/coverartcache.h" @@ -16,7 +22,6 @@ #include "moc_basetracktablemodel.cpp" #include "track/track.h" #include "util/assert.h" -#include "util/compatibility.h" #include "util/datetime.h" #include "util/db/sqlite.h" #include "util/logger.h" @@ -510,13 +515,24 @@ bool BaseTrackTableModel::setData( QVariant BaseTrackTableModel::composeCoverArtToolTipHtml( const QModelIndex& index) const { // Determine height of the cover art image depending on the screen size - const QScreen* primaryScreen = getPrimaryScreen(); - if (!primaryScreen) { - DEBUG_ASSERT(!"Primary screen not found!"); +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) + auto* pTableView = qobject_cast(parent()); + VERIFY_OR_DEBUG_ASSERT(pTableView) { + return QVariant(); + } + QScreen* pViewScreen = pTableView->screen(); +#else + // Ugly hack assuming that the view is on whatever Qt considers the primary screen. + QGuiApplication* app = static_cast(QCoreApplication::instance()); + VERIFY_OR_DEBUG_ASSERT(app) { + qWarning() << "Unable to get application's QGuiApplication instance, " + "cannot determine primary screen"; return QVariant(); } + QScreen* pViewScreen = app->primaryScreen(); +#endif unsigned int absoluteHeightOfCoverartToolTip = static_cast( - primaryScreen->availableGeometry().height() * + pViewScreen->availableGeometry().height() * kRelativeHeightOfCoverartToolTip); // Get image from cover art cache CoverArtCache* pCache = CoverArtCache::instance(); diff --git a/src/library/coverartcache.cpp b/src/library/coverartcache.cpp index 457e61bf0bc..56d95a8490d 100644 --- a/src/library/coverartcache.cpp +++ b/src/library/coverartcache.cpp @@ -8,7 +8,6 @@ #include "library/coverartutils.h" #include "moc_coverartcache.cpp" #include "track/track.h" -#include "util/compatibility.h" #include "util/logger.h" #include "util/thread_affinity.h" diff --git a/src/library/coverartdelegate.cpp b/src/library/coverartdelegate.cpp index f63a5ccfff1..b7abebe6dc9 100644 --- a/src/library/coverartdelegate.cpp +++ b/src/library/coverartdelegate.cpp @@ -8,7 +8,6 @@ #include "library/trackmodel.h" #include "moc_coverartdelegate.cpp" #include "track/track.h" -#include "util/compatibility.h" #include "util/logger.h" namespace { @@ -126,8 +125,7 @@ void CoverArtDelegate::paintItem( VERIFY_OR_DEBUG_ASSERT(m_pCache) { return; } - const double scaleFactor = - getDevicePixelRatioF(qobject_cast(parent())); + const double scaleFactor = qobject_cast(parent())->devicePixelRatioF(); QPixmap pixmap = m_pCache->tryLoadCover(this, coverInfo, static_cast(option.rect.width() * scaleFactor), diff --git a/src/library/coverartutils.cpp b/src/library/coverartutils.cpp index e024f79320d..067528007cb 100644 --- a/src/library/coverartutils.cpp +++ b/src/library/coverartutils.cpp @@ -7,7 +7,6 @@ #include "sources/soundsourceproxy.h" #include "track/track.h" -#include "util/compatibility.h" #include "util/logger.h" #include "util/regex.h" diff --git a/src/library/dao/playlistdao.cpp b/src/library/dao/playlistdao.cpp index 75d91bfa060..c3ed470ccec 100644 --- a/src/library/dao/playlistdao.cpp +++ b/src/library/dao/playlistdao.cpp @@ -10,7 +10,6 @@ #include "library/queryutil.h" #include "library/trackcollection.h" #include "track/track.h" -#include "util/compatibility.h" #include "util/db/fwdsqlquery.h" #include "util/math.h" diff --git a/src/library/dao/trackdao.cpp b/src/library/dao/trackdao.cpp index 03e0be89cf4..f10914bfcc4 100644 --- a/src/library/dao/trackdao.cpp +++ b/src/library/dao/trackdao.cpp @@ -30,7 +30,6 @@ #include "track/track.h" #include "track/tracknumbers.h" #include "util/assert.h" -#include "util/compatibility.h" #include "util/datetime.h" #include "util/db/fwdsqlquery.h" #include "util/db/sqlite.h" diff --git a/src/library/dlgcoverartfullsize.cpp b/src/library/dlgcoverartfullsize.cpp index 3a09667d128..9723f3abb75 100644 --- a/src/library/dlgcoverartfullsize.cpp +++ b/src/library/dlgcoverartfullsize.cpp @@ -9,7 +9,6 @@ #include "library/coverartutils.h" #include "moc_dlgcoverartfullsize.cpp" #include "track/track.h" -#include "util/compatibility.h" #include "util/widgethelper.h" DlgCoverArtFullSize::DlgCoverArtFullSize(QWidget* parent, BaseTrackPlayer* pPlayer) @@ -187,10 +186,10 @@ void DlgCoverArtFullSize::slotCoverFound( } else if (dialogSize.width() > screenGeometry.width()) { dialogSize.scale(screenGeometry.width(), dialogSize.height(), Qt::KeepAspectRatio); } - QPixmap resizedPixmap = m_pixmap.scaled(size() * getDevicePixelRatioF(this), + QPixmap resizedPixmap = m_pixmap.scaled(size() * devicePixelRatioF(), Qt::KeepAspectRatio, Qt::SmoothTransformation); - resizedPixmap.setDevicePixelRatio(getDevicePixelRatioF(this)); + resizedPixmap.setDevicePixelRatio(devicePixelRatioF()); coverArt->setPixmap(resizedPixmap); // center the window @@ -265,9 +264,10 @@ void DlgCoverArtFullSize::resizeEvent(QResizeEvent* event) { return; } // qDebug() << "DlgCoverArtFullSize::resizeEvent" << size(); - QPixmap resizedPixmap = m_pixmap.scaled(size() * getDevicePixelRatioF(this), - Qt::KeepAspectRatio, Qt::SmoothTransformation); - resizedPixmap.setDevicePixelRatio(getDevicePixelRatioF(this)); + QPixmap resizedPixmap = m_pixmap.scaled(size() * devicePixelRatioF(), + Qt::KeepAspectRatio, + Qt::SmoothTransformation); + resizedPixmap.setDevicePixelRatio(devicePixelRatioF()); coverArt->setPixmap(resizedPixmap); } diff --git a/src/library/dlgtrackinfo.cpp b/src/library/dlgtrackinfo.cpp index fb8333190b9..e28c0e1b4be 100644 --- a/src/library/dlgtrackinfo.cpp +++ b/src/library/dlgtrackinfo.cpp @@ -19,7 +19,6 @@ #include "track/keyutils.h" #include "track/track.h" #include "util/color/colorpalette.h" -#include "util/compatibility.h" #include "util/datetime.h" #include "util/desktophelper.h" #include "util/duration.h" diff --git a/src/library/searchqueryparser.cpp b/src/library/searchqueryparser.cpp index a5c7740c3a2..591d7fd184c 100644 --- a/src/library/searchqueryparser.cpp +++ b/src/library/searchqueryparser.cpp @@ -1,7 +1,5 @@ #include "library/searchqueryparser.h" -#include "util/compatibility.h" - #include "track/keyutils.h" constexpr char kNegatePrefix[] = "-"; diff --git a/src/library/trackset/setlogfeature.cpp b/src/library/trackset/setlogfeature.cpp index b7418c02aaa..7a94d1bdb88 100644 --- a/src/library/trackset/setlogfeature.cpp +++ b/src/library/trackset/setlogfeature.cpp @@ -15,7 +15,6 @@ #include "mixer/playermanager.h" #include "moc_setlogfeature.cpp" #include "track/track.h" -#include "util/compatibility.h" #include "widget/wlibrary.h" #include "widget/wlibrarysidebar.h" #include "widget/wtracktableview.h" diff --git a/src/preferences/dialog/dlgprefcolors.cpp b/src/preferences/dialog/dlgprefcolors.cpp index c6d4699f3f9..788d63b03b2 100644 --- a/src/preferences/dialog/dlgprefcolors.cpp +++ b/src/preferences/dialog/dlgprefcolors.cpp @@ -11,7 +11,6 @@ #include "library/trackcollection.h" #include "moc_dlgprefcolors.cpp" #include "util/color/predefinedcolorpalettes.h" -#include "util/compatibility.h" #include "util/math.h" #include "util/memory.h" diff --git a/src/preferences/dialog/dlgprefdeck.cpp b/src/preferences/dialog/dlgprefdeck.cpp index 9e81d0a6499..4424e6d4a89 100644 --- a/src/preferences/dialog/dlgprefdeck.cpp +++ b/src/preferences/dialog/dlgprefdeck.cpp @@ -18,7 +18,6 @@ #include "mixxxmainwindow.h" #include "moc_dlgprefdeck.cpp" #include "preferences/usersettings.h" -#include "util/compatibility.h" #include "util/duration.h" #include "widget/wnumberpos.h" diff --git a/src/preferences/dialog/dlgprefinterface.cpp b/src/preferences/dialog/dlgprefinterface.cpp index eeaa5bd2c45..9562073339b 100644 --- a/src/preferences/dialog/dlgprefinterface.cpp +++ b/src/preferences/dialog/dlgprefinterface.cpp @@ -17,7 +17,6 @@ #include "skin/legacy/legacyskinparser.h" #include "skin/skin.h" #include "skin/skinloader.h" -#include "util/compatibility.h" #include "util/screensaver.h" #include "util/screensavermanager.h" #include "util/widgethelper.h" @@ -56,7 +55,7 @@ DlgPrefInterface::DlgPrefInterface( setupUi(this); // get the pixel ratio to display a crisp skin preview when Mixxx is scaled - m_dDevicePixelRatio = getDevicePixelRatioF(this); + m_dDevicePixelRatio = devicePixelRatioF(); // Calculate the minimum scale factor that leads to a device pixel ratio of 1.0 // m_dDevicePixelRatio must not drop below 1.0 because this creates an diff --git a/src/preferences/dialog/dlgprefkey.cpp b/src/preferences/dialog/dlgprefkey.cpp index 14d27baf7f6..a0c2a469dfc 100644 --- a/src/preferences/dialog/dlgprefkey.cpp +++ b/src/preferences/dialog/dlgprefkey.cpp @@ -7,7 +7,6 @@ #include "control/controlproxy.h" #include "library/library_prefs.h" #include "moc_dlgprefkey.cpp" -#include "util/compatibility.h" #include "util/xml.h" DlgPrefKey::DlgPrefKey(QWidget* parent, UserSettingsPointer pConfig) diff --git a/src/preferences/dialog/dlgprefsounditem.cpp b/src/preferences/dialog/dlgprefsounditem.cpp index 043f14e5da9..a1b76eae382 100644 --- a/src/preferences/dialog/dlgprefsounditem.cpp +++ b/src/preferences/dialog/dlgprefsounditem.cpp @@ -5,7 +5,6 @@ #include "moc_dlgprefsounditem.cpp" #include "soundio/sounddevice.h" #include "soundio/soundmanagerconfig.h" -#include "util/compatibility.h" /** * Constructs a new preferences sound item, representing an AudioPath and SoundDevice diff --git a/src/util/compatibility.h b/src/util/compatibility.h deleted file mode 100644 index faa9287cff4..00000000000 --- a/src/util/compatibility.h +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once - -// TODO: Split this file into separate header files in subdirectory util/compatibility - -#include -#include -#include -#include -#include - -#include "util/assert.h" - -inline qreal getDevicePixelRatioF(const QWidget* widget) { - return widget->devicePixelRatioF(); -} - -inline QScreen* getPrimaryScreen() { - QGuiApplication* app = static_cast(QCoreApplication::instance()); - VERIFY_OR_DEBUG_ASSERT(app) { - qWarning() << "Unable to get applications QCoreApplication instance, cannot determine primary screen!"; - // All attempts to find primary screen failed, return nullptr - return nullptr; - } - return app->primaryScreen(); -} diff --git a/src/vinylcontrol/vinylcontrolmanager.cpp b/src/vinylcontrol/vinylcontrolmanager.cpp index 97d85579647..44d73be71a8 100644 --- a/src/vinylcontrol/vinylcontrolmanager.cpp +++ b/src/vinylcontrol/vinylcontrolmanager.cpp @@ -7,7 +7,6 @@ #include "mixer/playermanager.h" #include "moc_vinylcontrolmanager.cpp" #include "soundio/soundmanager.h" -#include "util/compatibility.h" #include "util/timer.h" #include "vinylcontrol/defs_vinylcontrol.h" #include "vinylcontrol/vinylcontrol.h" diff --git a/src/waveform/widgets/waveformwidgetabstract.cpp b/src/waveform/widgets/waveformwidgetabstract.cpp index 77f5af3cdd2..00c5fdad0dd 100644 --- a/src/waveform/widgets/waveformwidgetabstract.cpp +++ b/src/waveform/widgets/waveformwidgetabstract.cpp @@ -3,7 +3,6 @@ #include #include -#include "util/compatibility.h" #include "waveform/renderers/waveformwidgetrenderer.h" WaveformWidgetAbstract::WaveformWidgetAbstract(const QString& group) @@ -43,7 +42,7 @@ void WaveformWidgetAbstract::resize(int width, int height) { qreal devicePixelRatio = 1.0; if (m_widget) { m_widget->resize(width, height); - devicePixelRatio = getDevicePixelRatioF(m_widget); + devicePixelRatio = m_widget->devicePixelRatioF(); } WaveformWidgetRenderer::resize(width, height, static_cast(devicePixelRatio)); } diff --git a/src/widget/wcoverart.cpp b/src/widget/wcoverart.cpp index 7ab0e6b6a1b..a60adaf0c13 100644 --- a/src/widget/wcoverart.cpp +++ b/src/widget/wcoverart.cpp @@ -14,7 +14,6 @@ #include "library/dlgcoverartfullsize.h" #include "moc_wcoverart.cpp" #include "track/track.h" -#include "util/compatibility.h" #include "util/dnd.h" #include "util/math.h" #include "widget/wskincolor.h" @@ -199,9 +198,10 @@ QPixmap WCoverArt::scaledCoverArt(const QPixmap& normal) { return QPixmap(); } QPixmap scaled; - scaled = normal.scaled(size() * getDevicePixelRatioF(this), - Qt::KeepAspectRatio, Qt::SmoothTransformation); - scaled.setDevicePixelRatio(getDevicePixelRatioF(this)); + scaled = normal.scaled(size() * devicePixelRatioF(), + Qt::KeepAspectRatio, + Qt::SmoothTransformation); + scaled.setDevicePixelRatio(devicePixelRatioF()); return scaled; } diff --git a/src/widget/wcoverartlabel.cpp b/src/widget/wcoverartlabel.cpp index 88c10e9bc7f..39dcba0ee81 100644 --- a/src/widget/wcoverartlabel.cpp +++ b/src/widget/wcoverartlabel.cpp @@ -6,7 +6,6 @@ #include "library/dlgcoverartfullsize.h" #include "moc_wcoverartlabel.cpp" #include "track/track.h" -#include "util/compatibility.h" #include "widget/wcoverartmenu.h" namespace { @@ -16,7 +15,7 @@ constexpr QSize kDeviceIndependentCoverLabelSize = QSize(100, 100); inline QPixmap scaleCoverLabel( QWidget* parent, QPixmap pixmap) { - const auto devicePixelRatioF = getDevicePixelRatioF(parent); + const auto devicePixelRatioF = parent->devicePixelRatioF(); pixmap.setDevicePixelRatio(devicePixelRatioF); return pixmap.scaled( kDeviceIndependentCoverLabelSize * devicePixelRatioF, @@ -62,9 +61,9 @@ void WCoverArtLabel::setCoverArt(const CoverInfo& coverInfo, } #if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) - QSize frameSize = pixmap(Qt::ReturnByValue).size() / getDevicePixelRatioF(this); + QSize frameSize = pixmap(Qt::ReturnByValue).size() / devicePixelRatioF(); #else - QSize frameSize = pixmap()->size() / getDevicePixelRatioF(this); + QSize frameSize = pixmap()->size() / devicePixelRatioF(); #endif frameSize += QSize(2,2); // margin setMinimumSize(frameSize); diff --git a/src/widget/woverview.cpp b/src/widget/woverview.cpp index 8754c8961fa..89d8f815f0f 100644 --- a/src/widget/woverview.cpp +++ b/src/widget/woverview.cpp @@ -29,7 +29,6 @@ #include "preferences/colorpalettesettings.h" #include "track/track.h" #include "util/color/color.h" -#include "util/compatibility.h" #include "util/dnd.h" #include "util/duration.h" #include "util/math.h" @@ -939,7 +938,7 @@ void WOverview::drawMarks(QPainter* pPainter, const float offset, const float ga m_labelTextColor, m_labelBackgroundColor, width(), - getDevicePixelRatioF(this)); + devicePixelRatioF()); } // Show cue position when hovered @@ -987,7 +986,7 @@ void WOverview::drawMarks(QPainter* pPainter, const float offset, const float ga m_labelTextColor, m_labelBackgroundColor, width(), - getDevicePixelRatioF(this)); + devicePixelRatioF()); QPointF timeDistancePoint(positionTextPoint.x(), (fontMetrics.height() + height()) / 2); @@ -999,7 +998,7 @@ void WOverview::drawMarks(QPainter* pPainter, const float offset, const float ga m_labelTextColor, m_labelBackgroundColor, width(), - getDevicePixelRatioF(this)); + devicePixelRatioF()); markHovered = true; } } @@ -1094,7 +1093,7 @@ void WOverview::drawTimeRuler(QPainter* pPainter) { m_labelTextColor, m_labelBackgroundColor, width(), - getDevicePixelRatioF(this)); + devicePixelRatioF()); m_timeRulerPositionLabel.draw(pPainter); QString timeDistanceText = mixxx::Duration::formatTime(fabs(timeDistance)); @@ -1110,7 +1109,7 @@ void WOverview::drawTimeRuler(QPainter* pPainter) { m_labelTextColor, m_labelBackgroundColor, width(), - getDevicePixelRatioF(this)); + devicePixelRatioF()); m_timeRulerDistanceLabel.draw(pPainter); } else { m_timeRulerPositionLabel.clear(); @@ -1182,7 +1181,7 @@ void WOverview::drawMarkLabels(QPainter* pPainter, const float offset, const flo m_labelTextColor, m_labelBackgroundColor, width(), - getDevicePixelRatioF(this)); + devicePixelRatioF()); if (!(markRange.m_durationLabel.intersects(m_cuePositionLabel) || markRange.m_durationLabel.intersects(m_cueTimeDistanceLabel) || markRange.m_durationLabel.intersects(m_timeRulerPositionLabel) || markRange.m_durationLabel.intersects(m_timeRulerDistanceLabel))) { markRange.m_durationLabel.draw(pPainter); @@ -1247,7 +1246,7 @@ void WOverview::resizeEvent(QResizeEvent* pEvent) { m_a = (length() - 1) / (one - zero); m_b = zero * m_a; - m_devicePixelRatio = getDevicePixelRatioF(this); + m_devicePixelRatio = devicePixelRatioF(); m_waveformImageScaled = QImage(); m_diffGain = 0; diff --git a/src/widget/wspinny.cpp b/src/widget/wspinny.cpp index 44be4559638..7c1653bd91e 100644 --- a/src/widget/wspinny.cpp +++ b/src/widget/wspinny.cpp @@ -13,7 +13,6 @@ #include "library/coverartutils.h" #include "moc_wspinny.cpp" #include "track/track.h" -#include "util/compatibility.h" #include "util/dnd.h" #include "util/fpclassify.h" #include "vinylcontrol/vinylcontrol.h" @@ -329,7 +328,7 @@ void WSpinny::render(VSyncThread* vSyncThread) { &m_dGhostAngleCurrentPlaypos); } - double scaleFactor = getDevicePixelRatioF(this); + double scaleFactor = devicePixelRatioF(); QPainter p(this); p.setRenderHint(QPainter::Antialiasing); @@ -418,9 +417,10 @@ QPixmap WSpinny::scaledCoverArt(const QPixmap& normal) { if (normal.isNull()) { return QPixmap(); } - QPixmap scaled = normal.scaled(size() * getDevicePixelRatioF(this), - Qt::KeepAspectRatio, Qt::SmoothTransformation); - scaled.setDevicePixelRatio(getDevicePixelRatioF(this)); + QPixmap scaled = normal.scaled(size() * devicePixelRatioF(), + Qt::KeepAspectRatio, + Qt::SmoothTransformation); + scaled.setDevicePixelRatio(devicePixelRatioF()); return scaled; } diff --git a/src/widget/wtrackmenu.cpp b/src/widget/wtrackmenu.cpp index fcb2782500d..cf7e0993a76 100644 --- a/src/widget/wtrackmenu.cpp +++ b/src/widget/wtrackmenu.cpp @@ -26,7 +26,6 @@ #include "preferences/colorpalettesettings.h" #include "sources/soundsourceproxy.h" #include "track/track.h" -#include "util/compatibility.h" #include "util/desktophelper.h" #include "util/parented_ptr.h" #include "util/qt.h"