all repos — mgba @ 0f2c4e5baf62ccd5c5d3eb3f8950ca1cad36f501

mGBA Game Boy Advance Emulator

Qt: Draw with QPicture instead of a pixmap
Jeffrey Pfau jeffrey@endrift.com
Fri, 07 Nov 2014 22:46:41 -0800
commit

0f2c4e5baf62ccd5c5d3eb3f8950ca1cad36f501

parent

81e65c08d80e39d6ffa199c345f891832ebbae04

M src/platform/qt/GBAKeyEditor.cppsrc/platform/qt/GBAKeyEditor.cpp

@@ -2,7 +2,6 @@ #include "GBAKeyEditor.h"

#include <QPaintEvent> #include <QPainter> -#include <QPicture> #include <QPushButton> #include "InputController.h"

@@ -21,9 +20,7 @@ const qreal GBAKeyEditor::DPAD_HEIGHT = 0.1;

GBAKeyEditor::GBAKeyEditor(InputController* controller, int type, QWidget* parent) : QWidget(parent) - , m_background(QString(":/res/keymap.png")) { - setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); setWindowFlags(windowFlags() & ~Qt::WindowFullscreenButtonHint); setMinimumSize(300, 300);

@@ -118,9 +115,7 @@ };

m_currentKey = m_keyOrder.end(); - QPixmap background(":/res/keymap.png"); - m_background = background.scaled(QSize(300, 300) * devicePixelRatio(), Qt::KeepAspectRatio, Qt::SmoothTransformation); - m_background.setDevicePixelRatio(devicePixelRatio()); + m_background.load(":/res/keymap.qpic"); } void GBAKeyEditor::setAll() {

@@ -144,7 +139,8 @@ }

void GBAKeyEditor::paintEvent(QPaintEvent* event) { QPainter painter(this); - painter.drawPixmap(0, 0, m_background); + painter.scale(width() / 480.0, height() / 480.0); + painter.drawPicture(0, 0, m_background); } void GBAKeyEditor::setNext() {
M src/platform/qt/GBAKeyEditor.hsrc/platform/qt/GBAKeyEditor.h

@@ -2,7 +2,7 @@ #ifndef QGBA_GBA_KEY_EDITOR

#define QGBA_GBA_KEY_EDITOR #include <QList> -#include <QPixmap> +#include <QPicture> #include <QWidget> class QPushButton;

@@ -51,7 +51,7 @@ QList<KeyEditor*>::iterator m_currentKey;

InputController* m_controller; - QPixmap m_background; + QPicture m_background; }; }
M src/platform/qt/resources.qrcsrc/platform/qt/resources.qrc

@@ -1,6 +1,6 @@

<!DOCTYPE RCC><RCC version="1.0"> <qresource> <file>../../../res/mgba-1024.png</file> - <file>../../../res/keymap.png</file> + <file>../../../res/keymap.qpic</file> </qresource> </RCC>