aboutsummaryrefslogtreecommitdiff
path: root/app/mainwindow.cpp
diff options
context:
space:
mode:
authorJulian T <julian@jtle.dk>2020-08-13 21:17:30 +0200
committerJulian T <julian@jtle.dk>2020-08-13 21:17:30 +0200
commit65d26692ae8736f67f3951f088b26086eeb6b829 (patch)
tree7043254e116f2fab7690b5565d114a6afac3cd9b /app/mainwindow.cpp
parent5b0b916c561f602723b9ae80f5462a7939b652a1 (diff)
Added nicer ui which can save
Diffstat (limited to 'app/mainwindow.cpp')
-rw-r--r--app/mainwindow.cpp32
1 files changed, 31 insertions, 1 deletions
diff --git a/app/mainwindow.cpp b/app/mainwindow.cpp
index 3077168..a365f38 100644
--- a/app/mainwindow.cpp
+++ b/app/mainwindow.cpp
@@ -1,12 +1,42 @@
#include "mainwindow.hpp"
+#include <qaction.h>
+#include <qapplication.h>
+#include <qlabel.h>
+#include <qnamespace.h>
+#include <QFileDialog>
+#include <QMessageBox>
MainWindow::MainWindow(Renderer r)
: m_drawer(500, 500),
- m_render(this, m_drawer, r)
+ runstatus("Not running", this),
+ m_render(this, m_drawer, r, &runstatus)
{
setCentralWidget(&m_drawer);
+ auto saveAct = new QAction(tr("&Save as"), this);
+ saveAct->setStatusTip(tr("Save the rendered image"));
+ connect(saveAct, &QAction::triggered, this, &MainWindow::saveimage);
+ fileMenu = menuBar()->addMenu(tr("&File"));
+ fileMenu->addAction(saveAct);
+ helpMenu = menuBar()->addMenu(tr("&Help"));
+ helpMenu->addAction(tr("About Qt"), qApp, &QApplication::aboutQt);
+
+ statusBar()->addWidget(&runstatus);
+}
+
+void MainWindow::saveimage() {
+
+ QGuiApplication::setOverrideCursor(Qt::WaitCursor);
+ QString fileName = QFileDialog::getSaveFileName(this,
+ tr("Save image"), "", tr("PNG image (*.png);;All Files (*)"));
+ if (fileName.isEmpty()) {
+ return;
+ }
+
+ if (!m_drawer.m_img.save(fileName)) {
+ QMessageBox::information(this, tr("Unable to save file"), "");
+ }
}