Fix rendering of source icons in playlist view on retina OS X 10.9
This commit is contained in:
parent
55b0d00e02
commit
1a972e0f36
|
@ -451,4 +451,12 @@ void EnableFullScreen(const QWidget& main_window) {
|
|||
[window setCollectionBehavior: kFullScreenPrimary];
|
||||
}
|
||||
|
||||
float GetDevicePixelRatio(QWidget* widget) {
|
||||
NSView* view = reinterpret_cast<NSView*>(widget->winId());
|
||||
if ([[view window] respondsToSelector: @selector(backingScaleFactor)]) {
|
||||
return [[view window] backingScaleFactor];
|
||||
}
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
} // namespace mac
|
||||
|
|
|
@ -29,5 +29,6 @@ namespace mac {
|
|||
|
||||
QKeySequence KeySequenceFromNSEvent(NSEvent* event);
|
||||
void DumpDictionary(CFDictionaryRef dict);
|
||||
float GetDevicePixelRatio(QWidget* widget);
|
||||
|
||||
}
|
||||
|
|
|
@ -16,13 +16,6 @@
|
|||
*/
|
||||
|
||||
#include "playlistdelegates.h"
|
||||
#include "queue.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/player.h"
|
||||
#include "core/utilities.h"
|
||||
#include "library/librarybackend.h"
|
||||
#include "widgets/trackslider.h"
|
||||
#include "ui/iconloader.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QDir>
|
||||
|
@ -39,6 +32,18 @@
|
|||
#include <QWhatsThis>
|
||||
#include <QtConcurrentRun>
|
||||
|
||||
#include "queue.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/player.h"
|
||||
#include "core/utilities.h"
|
||||
#include "library/librarybackend.h"
|
||||
#include "widgets/trackslider.h"
|
||||
#include "ui/iconloader.h"
|
||||
|
||||
#ifdef Q_OS_DARWIN
|
||||
#include "core/mac_utilities.h"
|
||||
#endif // Q_OS_DARWIN
|
||||
|
||||
const int QueuedItemDelegate::kQueueBoxBorder = 1;
|
||||
const int QueuedItemDelegate::kQueueBoxCornerRadius = 3;
|
||||
const int QueuedItemDelegate::kQueueBoxLength = 30;
|
||||
|
@ -492,8 +497,14 @@ void SongSourceDelegate::paint(
|
|||
const QUrl& url = index.data().toUrl();
|
||||
QPixmap pixmap = LookupPixmap(url, option_copy.decorationSize);
|
||||
|
||||
float device_pixel_ratio = 1.0f;
|
||||
#ifdef Q_OS_DARWIN
|
||||
QWidget* parent_widget = reinterpret_cast<QWidget*>(parent());
|
||||
device_pixel_ratio = mac::GetDevicePixelRatio(parent_widget);
|
||||
#endif
|
||||
|
||||
// Draw the pixmap in the middle of the rectangle
|
||||
QRect draw_rect(QPoint(0, 0), option_copy.decorationSize);
|
||||
QRect draw_rect(QPoint(0, 0), option_copy.decorationSize / device_pixel_ratio);
|
||||
draw_rect.moveCenter(option_copy.rect.center());
|
||||
|
||||
painter->drawPixmap(draw_rect, pixmap);
|
||||
|
|
Loading…
Reference in New Issue