From ff89f7ca4562010c5977a99864aa9feadef29f4a Mon Sep 17 00:00:00 2001 From: Megamouse Date: Fri, 30 Mar 2018 17:14:09 +0200 Subject: [PATCH] Qt: add show_windowed_image to qt_utils --- rpcs3/rpcs3qt/qt_utils.cpp | 14 ++++++++++++++ rpcs3/rpcs3qt/qt_utils.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/rpcs3/rpcs3qt/qt_utils.cpp b/rpcs3/rpcs3qt/qt_utils.cpp index 2e1ba7317d..5c6bdd8206 100644 --- a/rpcs3/rpcs3qt/qt_utils.cpp +++ b/rpcs3/rpcs3qt/qt_utils.cpp @@ -191,5 +191,19 @@ namespace gui if (table->horizontalScrollBar()) table->removeRow(--item_count); } + + void show_windowed_image(const QImage& img, const QString& title) + { + if (img.isNull()) + return; + + QLabel* canvas = new QLabel(); + canvas->setWindowTitle(title); + canvas->setObjectName("windowed_image"); + canvas->setPixmap(QPixmap::fromImage(img)); + canvas->setFixedSize(img.size()); + canvas->ensurePolished(); + canvas->show(); + } } // utils } // gui diff --git a/rpcs3/rpcs3qt/qt_utils.h b/rpcs3/rpcs3qt/qt_utils.h index 4bdc8e3849..95b5736714 100644 --- a/rpcs3/rpcs3qt/qt_utils.h +++ b/rpcs3/rpcs3qt/qt_utils.h @@ -40,5 +40,8 @@ namespace gui // Recalculates a table's item count based on the available visible space and fills it with empty items void update_table_item_count(QTableWidget* table); + + // Opens an image in a new window with original size + void show_windowed_image(const QImage& img, const QString& title = ""); } // utils } // gui