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 | |
| parent | 1c0024b2feda8b5c152d2e211205601ee807e517 (diff) | |
add image dimension to toolbar and tooltip
don't scroll when selecting an image with the mouse
Diffstat (limited to 'src')
| -rw-r--r-- | src/modinfodialog.ui | 9 | ||||
| -rw-r--r-- | src/modinfodialogimages.cpp | 35 | ||||
| -rw-r--r-- | src/modinfodialogimages.h | 2 |
3 files changed, 36 insertions, 10 deletions
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 @@ <widget class="QWidget" name="widget_8" native="true">
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="1,0,0">
<property name="spacing">
- <number>3</number>
+ <number>6</number>
</property>
<property name="leftMargin">
<number>0</number>
@@ -281,6 +281,13 @@ </property>
</widget>
</item>
+ <item>
+ <widget class="QLabel" name="imagesSize">
+ <property name="text">
+ <string>0x0</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
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); |
