mirror of https://github.com/mgba-emu/mgba.git
Qt: Draw with QPicture instead of a pixmap
This commit is contained in:
parent
81e65c08d8
commit
0f2c4e5baf
BIN
res/keymap.png
BIN
res/keymap.png
Binary file not shown.
Before Width: | Height: | Size: 32 KiB |
Binary file not shown.
|
@ -2,7 +2,6 @@
|
|||
|
||||
#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 @@ GBAKeyEditor::GBAKeyEditor(InputController* controller, int type, QWidget* paren
|
|||
|
||||
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::resizeEvent(QResizeEvent* event) {
|
|||
|
||||
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() {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define QGBA_GBA_KEY_EDITOR
|
||||
|
||||
#include <QList>
|
||||
#include <QPixmap>
|
||||
#include <QPicture>
|
||||
#include <QWidget>
|
||||
|
||||
class QPushButton;
|
||||
|
@ -51,7 +51,7 @@ private:
|
|||
|
||||
InputController* m_controller;
|
||||
|
||||
QPixmap m_background;
|
||||
QPicture m_background;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue