From 162fa30c3eb10db25f6ecc7bea84d38a2ab106a1 Mon Sep 17 00:00:00 2001
From: isanae <14251494+isanae@users.noreply.github.com>
Date: Thu, 27 Jun 2019 10:43:46 -0400
Subject: add image dimension to toolbar and tooltip don't scroll when
selecting an image with the mouse
---
src/modinfodialog.ui | 9 ++++++++-
src/modinfodialogimages.cpp | 35 +++++++++++++++++++++++++++--------
src/modinfodialogimages.h | 2 +-
3 files changed, 36 insertions(+), 10 deletions(-)
(limited to 'src')
diff --git a/src/modinfodialog.ui b/src/modinfodialog.ui
index 3da13261..01d70d73 100644
--- a/src/modinfodialog.ui
+++ b/src/modinfodialog.ui
@@ -174,7 +174,7 @@
- 3
+ 6
0
@@ -281,6 +281,13 @@
+ -
+
+
+ 0x0
+
+
+
diff --git a/src/modinfodialogimages.cpp b/src/modinfodialogimages.cpp
index 8c323ac6..3d50876b 100644
--- a/src/modinfodialogimages.cpp
+++ b/src/modinfodialogimages.cpp
@@ -28,6 +28,12 @@ QRect centeredRect(const QRect& rect, const QSize& size)
size.height());
}
+QString dimensionString(const QSize& s)
+{
+ return QString::fromUtf8("%1 \xc3\x97 %2")
+ .arg(s.width()).arg(s.height());
+}
+
ImagesTab::ImagesTab(
OrganizerCore& oc, PluginContainer& plugin,
@@ -152,9 +158,9 @@ void ImagesTab::switchToAll()
// reselect old
if (oldSelection) {
- m_files.select(m_files.indexOf(oldSelection));
+ select(m_files.indexOf(oldSelection));
} else {
- m_files.select(BadIndex);
+ select(BadIndex);
}
}
@@ -226,7 +232,7 @@ void ImagesTab::getSupportedFormats()
}
}
-void ImagesTab::select(std::size_t i)
+void ImagesTab::select(std::size_t i, bool ev)
{
m_files.select(i);
@@ -238,11 +244,17 @@ void ImagesTab::select(std::size_t i)
ui->imagesPath->setText(QDir::toNativeSeparators(f->path()));
ui->imagesExplore->setEnabled(true);
+ ui->imagesSize->setText(dimensionString(f->original().size()));
+
m_image->setImage(f->original());
- ensureVisible(i);
+
+ if (ev) {
+ ensureVisible(i);
+ }
} else {
ui->imagesPath->clear();
ui->imagesExplore->setEnabled(false);
+ ui->imagesSize->clear();
m_image->clear();
}
@@ -444,7 +456,12 @@ void ImagesTab::thumbnailAreaMouseEvent(QMouseEvent* e)
const auto i = fileIndexAtPos(e->pos());
if (i != BadIndex) {
- select(i);
+ // 'false' so the selection is not made visible
+ //
+ // the only way to click on a thumbnail is if it's already visible, so the
+ // only thing that can happen is a click on a partially visible thumbnail,
+ // which would scroll so it is fully visible, and that's just annoying
+ select(i, false);
}
}
@@ -510,9 +527,11 @@ void ImagesTab::showTooltip(QHelpEvent* e)
return;
}
- QToolTip::showText(
- e->globalPos(), QDir::toNativeSeparators(f->path()),
- ui->imagesThumbnails);
+ const auto s = QString("%1 (%2)")
+ .arg(QDir::toNativeSeparators(f->path()))
+ .arg(dimensionString(f->original().size()));
+
+ QToolTip::showText(e->globalPos(), s, ui->imagesThumbnails);
}
void ImagesTab::onExplore()
diff --git a/src/modinfodialogimages.h b/src/modinfodialogimages.h
index 0d34b46a..566113bf 100644
--- a/src/modinfodialogimages.h
+++ b/src/modinfodialogimages.h
@@ -356,7 +356,7 @@ private:
void onShowDDS();
void onFilterChanged();
- void select(std::size_t i);
+ void select(std::size_t i, bool ensureVisible=true);
void moveSelection(int by);
void ensureVisible(std::size_t i);
--
cgit v1.3.1