From 8eaacd566948f2c594b76d1e1890ed905e48c0a7 Mon Sep 17 00:00:00 2001 From: Pavel Pisa Date: Tue, 11 Jun 2019 18:09:00 +0200 Subject: Add simple printing of core view. Signed-off-by: Pavel Pisa --- qtmips_gui/MainWindow.ui | 9 +++++++++ qtmips_gui/mainwindow.cpp | 21 +++++++++++++++++++++ qtmips_gui/mainwindow.h | 1 + qtmips_gui/qtmips_gui.pro | 2 ++ 4 files changed, 33 insertions(+) (limited to 'qtmips_gui') 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 @@ + @@ -320,6 +321,14 @@ Ctrl+Shift+R + + + Print + + + Ctrl+P + + Program Cache 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 +#ifdef QTMIPS_WITH_PRINTING +#include +#include +#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 -- cgit v1.2.3