all repos — mgba @ 28151ee65c2e1189b6093cb5f36d4ab46f8a4ae0

mGBA Game Boy Advance Emulator

Qt: Printer quality of life improvements (fixes #1540)
Vicki Pfau vi@endrift.com
Tue, 01 Oct 2019 18:33:56 -0700
commit

28151ee65c2e1189b6093cb5f36d4ab46f8a4ae0

parent

c8cc2eba2e24129f74205d06a5038d18d03cfaa9

3 files changed, 123 insertions(+), 20 deletions(-)

jump to
M CHANGESCHANGES

@@ -77,6 +77,7 @@ - OpenGL: Only resize textures when needed

- GBA BIOS: Fix clobbered registers in CpuSet (fixes mgba.io/i/1531) - Qt: Remove What's This icon from dialogs - CMake: Don't use libzip on embedded platforms (fixes mgba.io/i/1527) + - Qt: Printer quality of life improvements (fixes mgba.io/i/1540) 0.7.3: (2019-09-15) Emulation fixes:
M src/platform/qt/PrinterView.cppsrc/platform/qt/PrinterView.cpp

@@ -8,6 +8,7 @@

#include "CoreController.h" #include "GBAApp.h" +#include <QAction> #include <QPainter> using namespace QGBA;

@@ -24,6 +25,17 @@ connect(m_ui.hurry, &QAbstractButton::clicked, this, &PrinterView::printAll);

connect(m_ui.tear, &QAbstractButton::clicked, this, &PrinterView::clear); connect(m_ui.buttonBox, &QDialogButtonBox::accepted, this, &PrinterView::save); m_timer.setInterval(80); + + connect(m_ui.magnification, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [this](int mag) { + if (m_image.isNull()) { + return; + } + int oldMag = m_ui.image->size().width() / m_image.size().width(); + m_ui.image->setPixmap(m_image.scaled(m_image.size() * mag)); + m_ui.image->setFixedWidth(m_image.size().width() * mag); + m_ui.image->setFixedHeight(m_ui.image->size().height() / oldMag * mag); + }); + clear(); }

@@ -52,22 +64,22 @@ QPainter painter(&pixmap);

painter.drawPixmap(0, 0, m_image); painter.drawImage(0, m_image.height(), image); m_image = pixmap; - m_ui.image->setPixmap(m_image); + m_ui.image->setPixmap(m_image.scaled(m_image.size() * m_ui.magnification->value())); m_timer.start(); m_ui.hurry->setEnabled(true); } void PrinterView::printLine() { - m_ui.image->setFixedHeight(m_ui.image->height() + 1); + m_ui.image->setFixedHeight(m_ui.image->height() + m_ui.magnification->value()); m_ui.scrollArea->ensureVisible(0, m_ui.image->height(), 0, 0); - if (m_ui.image->height() >= m_image.height()) { + if (m_ui.image->height() >= m_image.height() * m_ui.magnification->value()) { printAll(); } } void PrinterView::printAll() { m_timer.stop(); - m_ui.image->setFixedHeight(m_image.height()); + m_ui.image->setFixedHeight(m_image.height() * m_ui.magnification->value()); m_controller->endPrint(); m_ui.buttonBox->button(QDialogButtonBox::Save)->setEnabled(true); m_ui.hurry->setEnabled(false);
M src/platform/qt/PrinterView.uisrc/platform/qt/PrinterView.ui

@@ -6,15 +6,15 @@ <property name="geometry">

<rect> <x>0</x> <y>0</y> - <width>241</width> - <height>311</height> + <width>246</width> + <height>425</height> </rect> </property> <property name="windowTitle"> <string>Game Boy Printer</string> </property> <layout class="QVBoxLayout" name="verticalLayout"> - <item alignment="Qt::AlignHCenter"> + <item> <widget class="QScrollArea" name="scrollArea"> <property name="frameShape"> <enum>QFrame::NoFrame</enum>

@@ -23,10 +23,15 @@ <property name="widgetResizable">

<bool>true</bool> </property> <widget class="QWidget" name="scrollAreaWidgetContents"> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <property name="spacing"> - <number>0</number> - </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>234</width> + <height>249</height> + </rect> + </property> + <layout class="QGridLayout" name="gridLayout" rowstretch="1,0,1" columnminimumwidth="0,160,0"> <property name="leftMargin"> <number>0</number> </property>

@@ -39,14 +44,36 @@ </property>

<property name="bottomMargin"> <number>0</number> </property> - <item> + <property name="spacing"> + <number>0</number> + </property> + <item row="0" column="1"> <spacer name="verticalSpacer"> <property name="orientation"> <enum>Qt::Vertical</enum> </property> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> </spacer> </item> - <item> + <item row="0" column="0"> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + <item row="1" column="1"> <widget class="QLabel" name="image"> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">

@@ -60,18 +87,12 @@ <width>160</width>

<height>1</height> </size> </property> - <property name="maximumSize"> - <size> - <width>160</width> - <height>16777215</height> - </size> - </property> <property name="alignment"> <set>Qt::AlignHCenter|Qt::AlignTop</set> </property> </widget> </item> - <item> + <item row="2" column="1"> <widget class="Line" name="line"> <property name="frameShadow"> <enum>QFrame::Plain</enum>

@@ -81,6 +102,19 @@ <enum>Qt::Horizontal</enum>

</property> </widget> </item> + <item row="0" column="2"> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + </spacer> + </item> </layout> </widget> </widget>

@@ -103,6 +137,62 @@ <property name="text">

<string>Tear off</string> </property> </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_4"> + <item> + <spacer name="horizontalSpacer_3"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QSpinBox" name="magnification"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="suffix"> + <string>×</string> + </property> + <property name="minimum"> + <number>1</number> + </property> + <property name="maximum"> + <number>8</number> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Magnification</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_4"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> </item> </layout> </item>