From a97f90531826b33cd5b7a2bc6cbef079b8ebaac2 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Sun, 1 Nov 2020 20:01:00 +0200 Subject: Initial commit --- src/mainwindow.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/mainwindow.cpp (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp new file mode 100644 index 0000000..9eba572 --- /dev/null +++ b/src/mainwindow.cpp @@ -0,0 +1,29 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" +#include +#include +#include + +MainWindow::MainWindow(const QStringList &filePaths, QWidget *parent) + : QMainWindow(parent), ui(new Ui::MainWindow) { + ui->setupUi(this); + + connect(ui->actionQuit, &QAction::triggered, qApp, &QApplication::quit); + + if (!filePaths.isEmpty()) { + current.load(filePaths.first()); + setWindowTitle(title_format.arg(filePaths.first())); + ui->label->setPixmap(current); + } +} + +MainWindow::~MainWindow() { delete ui; } + +void MainWindow::resizeEvent(QResizeEvent *event) { + const auto width = ui->label->width(); + const auto height = ui->label->height(); + + ui->label->setPixmap(current.scaled(width, height, Qt::KeepAspectRatio)); + + QMainWindow::resizeEvent(event); +} -- cgit v1.2.1