diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2019-06-27 10:43:46 -0400 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2019-07-02 10:10:19 -0400 |
| commit | 162fa30c3eb10db25f6ecc7bea84d38a2ab106a1 (patch) | |
| tree | b2bc4d1b2586e947f305eb0fb10d2a80203f9f7f /src/modinfodialogimages.cpp | |
| parent | 1c0024b2feda8b5c152d2e211205601ee807e517 (diff) | |
add image dimension to toolbar and tooltip
don't scroll when selecting an image with the mouse
Diffstat (limited to 'src/modinfodialogimages.cpp')
| -rw-r--r-- | src/modinfodialogimages.cpp | 35 |
1 files changed, 27 insertions, 8 deletions
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() |
