Qt: Printer quality of life improvements (fixes #1540)

This commit is contained in:
Vicki Pfau 2019-10-01 18:33:56 -07:00
parent c8cc2eba2e
commit 28151ee65c
3 changed files with 123 additions and 20 deletions

View File

@ -77,6 +77,7 @@ Misc:
- 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:

View File

@ -8,6 +8,7 @@
#include "CoreController.h"
#include "GBAApp.h"
#include <QAction>
#include <QPainter>
using namespace QGBA;
@ -24,6 +25,17 @@ PrinterView::PrinterView(std::shared_ptr<CoreController> controller, QWidget* pa
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 @@ void PrinterView::printImage(const QImage& image) {
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);

View File

@ -6,15 +6,15 @@
<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 @@
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
<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 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 @@
<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 @@
</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>
@ -106,6 +140,62 @@
</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>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">