diff options
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r-- | src/mainwindow.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
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 <QApplication> +#include <QPixmap> +#include <QResizeEvent> + +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); +} |