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 <QPaintEvent>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QPicture>
|
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
|
||||||
#include "InputController.h"
|
#include "InputController.h"
|
||||||
|
@ -21,9 +20,7 @@ const qreal GBAKeyEditor::DPAD_HEIGHT = 0.1;
|
||||||
|
|
||||||
GBAKeyEditor::GBAKeyEditor(InputController* controller, int type, QWidget* parent)
|
GBAKeyEditor::GBAKeyEditor(InputController* controller, int type, QWidget* parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, m_background(QString(":/res/keymap.png"))
|
|
||||||
{
|
{
|
||||||
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
|
||||||
setWindowFlags(windowFlags() & ~Qt::WindowFullscreenButtonHint);
|
setWindowFlags(windowFlags() & ~Qt::WindowFullscreenButtonHint);
|
||||||
setMinimumSize(300, 300);
|
setMinimumSize(300, 300);
|
||||||
|
|
||||||
|
@ -118,9 +115,7 @@ GBAKeyEditor::GBAKeyEditor(InputController* controller, int type, QWidget* paren
|
||||||
|
|
||||||
m_currentKey = m_keyOrder.end();
|
m_currentKey = m_keyOrder.end();
|
||||||
|
|
||||||
QPixmap background(":/res/keymap.png");
|
m_background.load(":/res/keymap.qpic");
|
||||||
m_background = background.scaled(QSize(300, 300) * devicePixelRatio(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
|
||||||
m_background.setDevicePixelRatio(devicePixelRatio());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GBAKeyEditor::setAll() {
|
void GBAKeyEditor::setAll() {
|
||||||
|
@ -144,7 +139,8 @@ void GBAKeyEditor::resizeEvent(QResizeEvent* event) {
|
||||||
|
|
||||||
void GBAKeyEditor::paintEvent(QPaintEvent* event) {
|
void GBAKeyEditor::paintEvent(QPaintEvent* event) {
|
||||||
QPainter painter(this);
|
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() {
|
void GBAKeyEditor::setNext() {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#define QGBA_GBA_KEY_EDITOR
|
#define QGBA_GBA_KEY_EDITOR
|
||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QPixmap>
|
#include <QPicture>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
|
@ -51,7 +51,7 @@ private:
|
||||||
|
|
||||||
InputController* m_controller;
|
InputController* m_controller;
|
||||||
|
|
||||||
QPixmap m_background;
|
QPicture m_background;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<!DOCTYPE RCC><RCC version="1.0">
|
<!DOCTYPE RCC><RCC version="1.0">
|
||||||
<qresource>
|
<qresource>
|
||||||
<file>../../../res/mgba-1024.png</file>
|
<file>../../../res/mgba-1024.png</file>
|
||||||
<file>../../../res/keymap.png</file>
|
<file>../../../res/keymap.qpic</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
Loading…
Reference in New Issue