diff options
author | Pavel Pisa <pisa@cmp.felk.cvut.cz> | 2019-06-11 18:09:00 +0200 |
---|---|---|
committer | Pavel Pisa <pisa@cmp.felk.cvut.cz> | 2019-06-11 18:09:00 +0200 |
commit | 8eaacd566948f2c594b76d1e1890ed905e48c0a7 (patch) | |
tree | 2081585409cb00ad6ace6542866a462745ea4798 | |
parent | e28b9ef4a452c176c1baf915949397d7af878c19 (diff) | |
download | qtmips-8eaacd566948f2c594b76d1e1890ed905e48c0a7.tar.gz qtmips-8eaacd566948f2c594b76d1e1890ed905e48c0a7.tar.bz2 qtmips-8eaacd566948f2c594b76d1e1890ed905e48c0a7.zip |
Add simple printing of core view.
Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
-rw-r--r-- | qtmips_gui/MainWindow.ui | 9 | ||||
-rw-r--r-- | qtmips_gui/mainwindow.cpp | 21 | ||||
-rw-r--r-- | qtmips_gui/mainwindow.h | 1 | ||||
-rw-r--r-- | qtmips_gui/qtmips_gui.pro | 2 |
4 files changed, 33 insertions, 0 deletions
diff --git a/qtmips_gui/MainWindow.ui b/qtmips_gui/MainWindow.ui index 4140a46..753460b 100644 --- a/qtmips_gui/MainWindow.ui +++ b/qtmips_gui/MainWindow.ui @@ -60,6 +60,7 @@ </property> <addaction name="actionNew"/> <addaction name="actionReload"/> + <addaction name="actionPrint"/> <addaction name="separator"/> <addaction name="actionExit"/> </widget> @@ -320,6 +321,14 @@ <string>Ctrl+Shift+R</string> </property> </action> + <action name="actionPrint"> + <property name="text"> + <string>Print</string> + </property> + <property name="shortcut"> + <string>Ctrl+P</string> + </property> + </action> <action name="actionProgram_Cache"> <property name="text"> <string>Program Cache</string> diff --git a/qtmips_gui/mainwindow.cpp b/qtmips_gui/mainwindow.cpp index cf63871..8f13a01 100644 --- a/qtmips_gui/mainwindow.cpp +++ b/qtmips_gui/mainwindow.cpp @@ -33,6 +33,12 @@ * ******************************************************************************/ +#include <QtWidgets> +#ifdef QTMIPS_WITH_PRINTING +#include <QPrinter> +#include <QPrintDialog> +#endif + #include "mainwindow.h" #include "aboutdialog.h" #include "ossyscall.h" @@ -84,6 +90,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { connect(ui->actionExit, SIGNAL(triggered(bool)), this, SLOT(close())); connect(ui->actionNew, SIGNAL(triggered(bool)), this, SLOT(new_machine())); connect(ui->actionReload, SIGNAL(triggered(bool)), this, SLOT(machine_reload())); + connect(ui->actionPrint, SIGNAL(triggered(bool)), this, SLOT(print_action())); connect(ui->actionShow_Symbol, SIGNAL(triggered(bool)), this, SLOT(show_symbol_dialog())); connect(ui->actionRegisters, SIGNAL(triggered(bool)), this, SLOT(show_registers())); connect(ui->actionProgram_memory, SIGNAL(triggered(bool)), this, SLOT(show_program())); @@ -239,6 +246,20 @@ void MainWindow::machine_reload() { } } +void MainWindow::print_action() { +#ifdef QTMIPS_WITH_PRINTING + QPrinter printer(QPrinter::HighResolution); + printer.setColorMode(QPrinter::Color); + QPrintDialog print_dialog(&printer, this); + if (print_dialog.exec() == QDialog::Accepted) { + QPainter painter(&printer); + QRectF scene_rect = corescene->sceneRect(); + QRectF target_rect = painter.viewport(); + corescene->render(&painter, target_rect, scene_rect, Qt::KeepAspectRatio); + } +#endif // QTMIPS_WITH_PRINTING +} + #define SHOW_HANDLER(NAME) void MainWindow::show_##NAME() { \ show_dockwidget(NAME); \ } \ diff --git a/qtmips_gui/mainwindow.h b/qtmips_gui/mainwindow.h index 84c9d08..cbbc9ec 100644 --- a/qtmips_gui/mainwindow.h +++ b/qtmips_gui/mainwindow.h @@ -68,6 +68,7 @@ public slots: // Actions signals void new_machine(); void machine_reload(); + void print_action(); void show_registers(); void show_program(); void show_memory(); diff --git a/qtmips_gui/qtmips_gui.pro b/qtmips_gui/qtmips_gui.pro index 9237f9b..4c52596 100644 --- a/qtmips_gui/qtmips_gui.pro +++ b/qtmips_gui/qtmips_gui.pro @@ -1,4 +1,6 @@ QT += core gui widgets +qtHaveModule(printsupport): QT += printsupport +qtHaveModule(printsupport): DEFINES += QTMIPS_WITH_PRINTING=1 TARGET = qtmips_gui CONFIG += c++11 |