summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2020-11-01 21:02:13 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2020-11-01 21:02:13 +0200
commit246615f946a8063bcd68ba7c008e3cd0d3e6b615 (patch)
tree473580ef74697835e04dcee25586464410c79732
parentInitial commit (diff)
downloadqimv-246615f946a8063bcd68ba7c008e3cd0d3e6b615.tar.xz
Add original size and fit buttons
-rw-r--r--meson.build2
-rw-r--r--src/mainwindow.cpp21
-rw-r--r--src/mainwindow.h2
-rw-r--r--src/mainwindow.ui87
4 files changed, 97 insertions, 15 deletions
diff --git a/meson.build b/meson.build
index 7c3aac3..3907431 100644
--- a/meson.build
+++ b/meson.build
@@ -1,6 +1,6 @@
project('qimv', 'cpp',
version : '0.1',
- default_options : ['warning_level=3', 'cpp_std=c++14'])
+ default_options : ['warning_level=3', 'cpp_std=c++17'])
summary({
'prefix': get_option('prefix'),
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 9eba572..839b2c3 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -13,17 +13,26 @@ MainWindow::MainWindow(const QStringList &filePaths, QWidget *parent)
if (!filePaths.isEmpty()) {
current.load(filePaths.first());
setWindowTitle(title_format.arg(filePaths.first()));
- ui->label->setPixmap(current);
+ resizePixmap();
}
+
+ connect(ui->original_toolButton, &QToolButton::clicked, this,
+ [this]() { ui->label->setPixmap(current); });
+
+ connect(ui->fit_toolButton, &QToolButton::clicked, this,
+ [this]() { resizePixmap(); });
}
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));
-
+ resizePixmap();
QMainWindow::resizeEvent(event);
}
+
+void MainWindow::resizePixmap() {
+ const auto size =
+ ui->scrollArea->viewport()->size().boundedTo(current.size());
+ ui->label->setPixmap(
+ current.scaled(size, Qt::KeepAspectRatio, Qt::SmoothTransformation));
+}
diff --git a/src/mainwindow.h b/src/mainwindow.h
index a270fd8..dfd704b 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -18,6 +18,8 @@ protected:
void resizeEvent(QResizeEvent *event) override;
private:
+ void resizePixmap();
+
Ui::MainWindow *ui;
QPixmap current;
const QString title_format{"qimv [%1]"};
diff --git a/src/mainwindow.ui b/src/mainwindow.ui
index 5ea19df..733b06e 100644
--- a/src/mainwindow.ui
+++ b/src/mainwindow.ui
@@ -14,7 +14,7 @@
<string>qimv</string>
</property>
<widget class="QWidget" name="centralwidget">
- <layout class="QVBoxLayout" name="verticalLayout">
+ <layout class="QVBoxLayout" name="verticalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
@@ -28,15 +28,87 @@
<number>0</number>
</property>
<item>
- <widget class="QLabel" name="label">
- <property name="text">
- <string>[ no data ]</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
+ <widget class="QScrollArea" name="scrollArea">
+ <property name="widgetResizable">
+ <bool>true</bool>
</property>
+ <widget class="QWidget" name="scrollAreaWidgetContents">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>798</width>
+ <height>548</height>
+ </rect>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>[ no data ]</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
</widget>
</item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QToolButton" name="original_toolButton">
+ <property name="text">
+ <string>orig</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="fit_toolButton">
+ <property name="text">
+ <string>fit</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSlider" name="horizontalSlider">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
@@ -56,7 +128,6 @@
</widget>
<addaction name="menuqimv"/>
</widget>
- <widget class="QStatusBar" name="statusbar"/>
<action name="actionQuit">
<property name="text">
<string>Quit</string>