Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove compatibility.h #4309

Merged
merged 2 commits into from
Sep 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/encoder/encoderopussettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/library/autodj/autodjfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/library/autodj/dlgautodj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/library/basetrackcache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
26 changes: 21 additions & 5 deletions src/library/basetracktablemodel.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#include "library/basetracktablemodel.h"

#include <QScreen>
// for hack to get primary screen instead of view widget's screen
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
#include <QGuiApplication>
#endif

#include "library/bpmdelegate.h"
#include "library/colordelegate.h"
#include "library/coverartcache.h"
Expand All @@ -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"
Expand Down Expand Up @@ -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<WTrackTableView*>(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<QGuiApplication*>(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<int>(
primaryScreen->availableGeometry().height() *
pViewScreen->availableGeometry().height() *
kRelativeHeightOfCoverartToolTip);
// Get image from cover art cache
CoverArtCache* pCache = CoverArtCache::instance();
Expand Down
1 change: 0 additions & 1 deletion src/library/coverartcache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
4 changes: 1 addition & 3 deletions src/library/coverartdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -126,8 +125,7 @@ void CoverArtDelegate::paintItem(
VERIFY_OR_DEBUG_ASSERT(m_pCache) {
return;
}
const double scaleFactor =
getDevicePixelRatioF(qobject_cast<QWidget*>(parent()));
const double scaleFactor = qobject_cast<QWidget*>(parent())->devicePixelRatioF();
QPixmap pixmap = m_pCache->tryLoadCover(this,
coverInfo,
static_cast<int>(option.rect.width() * scaleFactor),
Expand Down
1 change: 0 additions & 1 deletion src/library/coverartutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#include "sources/soundsourceproxy.h"
#include "track/track.h"
#include "util/compatibility.h"
#include "util/logger.h"
#include "util/regex.h"

Expand Down
1 change: 0 additions & 1 deletion src/library/dao/playlistdao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
1 change: 0 additions & 1 deletion src/library/dao/trackdao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 6 additions & 6 deletions src/library/dlgcoverartfullsize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}

Expand Down
1 change: 0 additions & 1 deletion src/library/dlgtrackinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 0 additions & 2 deletions src/library/searchqueryparser.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#include "library/searchqueryparser.h"

#include "util/compatibility.h"

#include "track/keyutils.h"

constexpr char kNegatePrefix[] = "-";
Expand Down
1 change: 0 additions & 1 deletion src/library/trackset/setlogfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/preferences/dialog/dlgprefcolors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
1 change: 0 additions & 1 deletion src/preferences/dialog/dlgprefdeck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
3 changes: 1 addition & 2 deletions src/preferences/dialog/dlgprefinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/preferences/dialog/dlgprefkey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/preferences/dialog/dlgprefsounditem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 0 additions & 25 deletions src/util/compatibility.h

This file was deleted.

1 change: 0 additions & 1 deletion src/vinylcontrol/vinylcontrolmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions src/waveform/widgets/waveformwidgetabstract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <QWidget>
#include <QtDebug>

#include "util/compatibility.h"
#include "waveform/renderers/waveformwidgetrenderer.h"

WaveformWidgetAbstract::WaveformWidgetAbstract(const QString& group)
Expand Down Expand Up @@ -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<float>(devicePixelRatio));
}
8 changes: 4 additions & 4 deletions src/widget/wcoverart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
}

Expand Down
7 changes: 3 additions & 4 deletions src/widget/wcoverartlabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
Loading