all repos — mgba @ e1b57de0356ab19713d3b6c8d77bf2e6e267c66d

mGBA Game Boy Advance Emulator

Qt: Add copy button to GB printer dialog
Vicki Pfau vi@endrift.com
Thu, 10 Sep 2020 23:40:37 -0700
commit

e1b57de0356ab19713d3b6c8d77bf2e6e267c66d

parent

5a50f47bf70069865ced0c306c789d77270af453

M CHANGESCHANGES

@@ -85,6 +85,7 @@ - Qt: Renderer can be changed while a game is running

- Qt: Add hex index to palette view - Qt: Add transformation matrix info to sprite view - Qt: Memory viewer now supports editing decimal values directly (closes mgba.io/i/1705) + - Qt: Add copy button to GB printer dialog - Util: Reset vector size on deinit - VFS: Change semantics of VFile.sync on mapped files (fixes mgba.io/i/1730)
M src/platform/qt/PrinterView.cppsrc/platform/qt/PrinterView.cpp

@@ -9,6 +9,7 @@ #include "CoreController.h"

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

@@ -23,6 +24,7 @@ connect(controller.get(), &CoreController::imagePrinted, this, &PrinterView::printImage);

connect(&m_timer, &QTimer::timeout, this, &PrinterView::printLine); connect(m_ui.hurry, &QAbstractButton::clicked, this, &PrinterView::printAll); connect(m_ui.tear, &QAbstractButton::clicked, this, &PrinterView::clear); + connect(m_ui.copyButton, &QAbstractButton::clicked, this, &PrinterView::copy); connect(m_ui.buttonBox, &QDialogButtonBox::accepted, this, &PrinterView::save); m_timer.setInterval(80);

@@ -40,6 +42,11 @@ QAction* save = new QAction(this);

save->setShortcut(QKeySequence::Save); connect(save, &QAction::triggered, this, &PrinterView::save); addAction(save); + + QAction* copyAction = new QAction(this); + copyAction->setShortcut(QKeySequence::Copy); + connect(copyAction, &QAction::triggered, this, &PrinterView::copy); + addAction(copyAction); clear(); }

@@ -56,11 +63,16 @@ }

m_image.save(filename); } +void PrinterView::copy() { + GBAApp::app()->clipboard()->setImage(m_image.toImage()); +} + void PrinterView::clear() { m_ui.image->setFixedHeight(0); m_image = QPixmap(); m_ui.image->clear(); m_ui.buttonBox->button(QDialogButtonBox::Save)->setEnabled(false); + m_ui.copyButton->setEnabled(false); } void PrinterView::printImage(const QImage& image) {

@@ -87,5 +99,6 @@ m_timer.stop();

m_ui.image->setFixedHeight(m_image.height() * m_ui.magnification->value()); m_controller->endPrint(); m_ui.buttonBox->button(QDialogButtonBox::Save)->setEnabled(true); + m_ui.copyButton->setEnabled(true); m_ui.hurry->setEnabled(false); }
M src/platform/qt/PrinterView.hsrc/platform/qt/PrinterView.h

@@ -29,6 +29,7 @@ void donePrinting();

public slots: void save(); + void copy(); void clear(); private slots:
M src/platform/qt/PrinterView.uisrc/platform/qt/PrinterView.ui

@@ -197,11 +197,51 @@ </item>

</layout> </item> <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="standardButtons"> - <set>QDialogButtonBox::Close|QDialogButtonBox::Save</set> - </property> - </widget> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <spacer name="horizontalSpacer_5"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="copyButton"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Copy</string> + </property> + <property name="icon"> + <iconset theme="edit-copy"> + <normaloff>.</normaloff>.</iconset> + </property> + </widget> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Close|QDialogButtonBox::Save</set> + </property> + </widget> + </item> + </layout> </item> </layout> </widget>