summaryrefslogtreecommitdiff
path: root/src/mainwindow.cpp
blob: 9eba5724b57c60f7c85d299df4d2f6a5c6a20085 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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);
}