aboutsummaryrefslogtreecommitdiff
path: root/qdeduper
diff options
context:
space:
mode:
Diffstat (limited to 'qdeduper')
-rw-r--r--qdeduper/imageitem.cpp13
-rw-r--r--qdeduper/mingui.cpp31
-rw-r--r--qdeduper/mingui.hpp2
3 files changed, 34 insertions, 12 deletions
diff --git a/qdeduper/imageitem.cpp b/qdeduper/imageitem.cpp
index 6fee930..f18d32c 100644
--- a/qdeduper/imageitem.cpp
+++ b/qdeduper/imageitem.cpp
@@ -9,6 +9,9 @@
#include <QFontMetrics>
#include <QPainter>
#include <QLocale>
+#include <qnamespace.h>
+
+#define DEBUGPAINT 0
ImageItem::ImageItem(QString fn, QString dispn, QKeySequence hotkey, double pxratio)
{
@@ -40,7 +43,6 @@ void ImageItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt
so.state |= QStyle::StateFlag::State_Active;
option.widget->style()->drawPrimitive(QStyle::PrimitiveElement::PE_PanelItemViewItem, &so, painter, option.widget);
-
QPixmap pm = index.data(Qt::ItemDataRole::DecorationRole).value<QPixmap>();
QSize imd = pm.size().scaled(imr.size(), Qt::AspectRatioMode::KeepAspectRatio);
painter->setRenderHint(QPainter::RenderHint::SmoothPixmapTransform);
@@ -88,6 +90,12 @@ void ImageItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt
r.setRight(imr.right());
QString efns = option.fontMetrics.elidedText(fns, Qt::TextElideMode::ElideMiddle, r.width());
painter->drawText(r, efns, topt);
+#if DEBUGPAINT
+ painter->setPen(QPen(Qt::GlobalColor::red));
+ painter->drawRect(so.rect);
+ painter->drawRect(option.rect);
+ qDebug() << "paint" << index.row() << option.rect;
+#endif
}
QSize ImageItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
@@ -121,6 +129,9 @@ QSize ImageItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QMod
ret.setHeight(vpsz.height() / index.model()->rowCount() - lw->spacing());
ret.setHeight(std::max(min_height + extra_height, ret.height()));
ret.setHeight(std::min(max_height + extra_height, ret.height()));
+#if DEBUGPAINT
+ qDebug() << "sizehint" << index.row() << ret;
+#endif
return ret;
}
diff --git a/qdeduper/mingui.cpp b/qdeduper/mingui.cpp
index ee4f013..2f21e5e 100644
--- a/qdeduper/mingui.cpp
+++ b/qdeduper/mingui.cpp
@@ -93,6 +93,7 @@ DeduperMainWindow::DeduperMainWindow()
lv->setHorizontalScrollMode(QAbstractItemView::ScrollMode::ScrollPerPixel);
lv->setVerticalScrollMode(QAbstractItemView::ScrollMode::ScrollPerPixel);
lv->setMinimumWidth(240);
+ lv->installEventFilter(this);
pd = new QProgressDialog(this);
pd->setModal(true);
pd->setMinimumDuration(0);
@@ -176,6 +177,9 @@ void DeduperMainWindow::setup_menu()
file->addAction("Load Database...");
file->addAction("Save Database...");
file->addSeparator();
+ file->addAction("Export Marked Images List...");
+ file->addAction("Import Marked Images List...");
+ file->addSeparator();
file->addAction("Search for Image...");
file->addSeparator();
file->addAction("Preferences...");
@@ -225,9 +229,10 @@ void DeduperMainWindow::setup_menu()
mark->addAction("Mark All");
mark->addAction("Mark None");
mark->addAction("Mark All within...");
- mark->addAction("Review Marked Imagess");
+ mark->addSeparator();
+ mark->addAction("Review Marked Images");
- help->addAction("View Documentation");
+ help->addAction("Help");
help->addAction("About");
tb = new QToolBar(this);
@@ -509,14 +514,6 @@ fs::path::string_type DeduperMainWindow::common_prefix(const std::vector<fs::pat
return ret;
}
-void DeduperMainWindow::resizeEvent(QResizeEvent *e)
-{
- QWidget::resizeEvent(e);
- if (!id || !im) return;
- for (int i = 0; i < im->rowCount(); ++i)
- id->resize(im->indexFromItem(im->item(i)));
-}
-
void DeduperMainWindow::closeEvent(QCloseEvent *e)
{
if (QMessageBox::StandardButton::Yes ==
@@ -527,3 +524,17 @@ void DeduperMainWindow::closeEvent(QCloseEvent *e)
else
e->ignore();
}
+
+bool DeduperMainWindow::eventFilter(QObject *obj, QEvent *e)
+{
+ if (e->type() == QEvent::Type::Resize)
+ {
+ if (im && id && obj == lv)
+ for (int i = 0; i < im->rowCount(); ++i)
+ {
+ id->resize(im->indexFromItem(im->item(i)));
+ }
+ return false;
+ }
+ return false;
+}
diff --git a/qdeduper/mingui.hpp b/qdeduper/mingui.hpp
index 9d8e3f4..94f5bbd 100644
--- a/qdeduper/mingui.hpp
+++ b/qdeduper/mingui.hpp
@@ -55,8 +55,8 @@ private:
std::unordered_set<fs::path> marked;
std::vector<fs::path> current_set;
protected:
- void resizeEvent(QResizeEvent *e) override;
void closeEvent(QCloseEvent *e) override;
+ bool eventFilter(QObject *obj, QEvent *ev) override;
public:
DeduperMainWindow();