Qt: Add export button for tile view (closes #1507)
Vicki Pfau vi@endrift.com
Sun, 25 Aug 2019 19:08:46 -0700
5 files changed,
103 insertions(+),
81 deletions(-)
M
CHANGES
→
CHANGES
@@ -18,6 +18,7 @@ - Ports: Ability to crop SGB borders off screen (closes mgba.io/i/1204)
- Cheats: Add support for loading Libretro-style cht files - GBA Cheats: Add support for loading EZ Flash-style cht files - Support for unlicensed Wisdom Tree Game Boy mapper + - Qt: Add export button for tile view (closes mgba.io/i/1507) Emulation fixes: - GBA: All IRQs have 7 cycle delay (fixes mgba.io/i/539, mgba.io/i/1208) - GBA: Reset now reloads multiboot ROMs
M
src/platform/qt/TilePainter.h
→
src/platform/qt/TilePainter.h
@@ -19,6 +19,8 @@
public: TilePainter(QWidget* parent = nullptr); + QPixmap backing() const { return m_backing; } + public slots: void setTile(int index, const color_t*); void setTileCount(int tiles);
M
src/platform/qt/TileView.cpp
→
src/platform/qt/TileView.cpp
@@ -86,6 +86,8 @@ m_ui.tiles->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
} updateTiles(true); }); + + connect(m_ui.exportButton, &QAbstractButton::clicked, this, &TileView::exportTiles); } #ifdef M_CORE_GBA@@ -156,3 +158,12 @@ m_paletteId = palette;
m_ui.tile->setPalette(palette); updateTiles(true); } + +void TileView::exportTiles() { + QString filename = GBAApp::app()->getSaveFileName(this, tr("Export tiles"), + tr("Portable Network Graphics (*.png)")); + CoreController::Interrupter interrupter(m_controller); + updateTiles(false); + QPixmap pixmap(m_ui.tiles->backing()); + pixmap.save(filename, "PNG"); +}
M
src/platform/qt/TileView.h
→
src/platform/qt/TileView.h
@@ -23,6 +23,7 @@ TileView(std::shared_ptr<CoreController> controller, QWidget* parent = nullptr);
public slots: void updatePalette(int); + void exportTiles(); private: #ifdef M_CORE_GBA
M
src/platform/qt/TileView.ui
→
src/platform/qt/TileView.ui
@@ -14,87 +14,6 @@ <property name="windowTitle">
<string>Tiles</string> </property> <layout class="QGridLayout" name="gridLayout" columnstretch="0,1"> - <item row="0" column="1" rowspan="4"> - <widget class="QScrollArea" name="scrollArea"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="widgetResizable"> - <bool>true</bool> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> - </property> - <widget class="QWidget" name="scrollAreaWidgetContents"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>405</width> - <height>768</height> - </rect> - </property> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Maximum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <property name="spacing"> - <number>0</number> - </property> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QGBA::TilePainter" name="tiles" native="true"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>256</width> - <height>768</height> - </size> - </property> - </widget> - </item> - </layout> - </widget> - </widget> - </item> - <item row="3" column="0"> - <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 row="1" column="0"> - <widget class="QGBA::AssetTile" name="tile"/> - </item> <item row="0" column="0"> <layout class="QFormLayout" name="formLayout"> <item row="0" column="0">@@ -171,6 +90,94 @@ </property>
</widget> </item> </layout> + </item> + <item row="3" column="0"> + <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 row="1" column="0"> + <widget class="QGBA::AssetTile" name="tile"/> + </item> + <item row="4" column="0"> + <widget class="QPushButton" name="exportButton"> + <property name="text"> + <string>Export</string> + </property> + </widget> + </item> + <item row="0" column="1" rowspan="5"> + <widget class="QScrollArea" name="scrollArea"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="widgetResizable"> + <bool>true</bool> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + <widget class="QWidget" name="scrollAreaWidgetContents"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>405</width> + <height>768</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Maximum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <property name="spacing"> + <number>0</number> + </property> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="QGBA::TilePainter" name="tiles" native="true"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>256</width> + <height>768</height> + </size> + </property> + </widget> + </item> + </layout> + </widget> + </widget> </item> </layout> </widget>