git repos / SagoImageBrowser

commit a686d839

Poul Sander · 2026-06-06 22:34
a686d839847368c34f7129584beafd15318939fe patch · browse files
parent 700d6f2d0b08a4b3ace155f86a5988d2cf639415

Can now use the Delete button to delete images

Changed files

M CMakeLists.txt before
M src/mainwindow.cpp before
M src/mainwindow.h before
M src/shortcutmanager.cpp before
M src/shortcutmanager.h before
diff --git a/CMakeLists.txt b/CMakeLists.txt index e827d26..b544184 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt
@@ -41,6 +41,10 @@ qt_add_resources(SagoImageBrowser "icons" PREFIX "/icons" FILES extra/icons/sago
target_include_directories(SagoImageBrowser PRIVATE ${EXIV2_INCLUDE_DIRS})
target_link_libraries(SagoImageBrowser PRIVATE Qt6::Widgets ${EXIV2_LIBRARIES})
+add_executable(test_exifreader test_exifreader.cpp src/exifreader.cpp)
+target_include_directories(test_exifreader PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ${EXIV2_INCLUDE_DIRS})
+target_link_libraries(test_exifreader PRIVATE Qt6::Widgets ${EXIV2_LIBRARIES})
+
qt_add_translations(SagoImageBrowser
TS_FILES translations/da.ts
RESOURCE_PREFIX "/translations")
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 3872413..092e327 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp
@@ -467,6 +467,11 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *event)
navigateToNextFolder();
return true;
}
+ if (obj == m_listView
+ && sc.matches(keyEvent, ShortcutManager::MoveToTrash)) {
+ moveCurrentImageToTrash();
+ return true;
+ }
}
return QMainWindow::eventFilter(obj, event);
@@ -637,6 +642,8 @@ void MainWindow::showImageContextMenu(const QPoint &pos)
menu.addSeparator();
QAction *editDescriptionAction = menu.addAction(tr("Edit description"));
QAction *moveToTrashAction = menu.addAction(tr("Move to trash"));
+ moveToTrashAction->setShortcut(
+ ShortcutManager::instance().shortcut(ShortcutManager::MoveToTrash));
QAction *chosen = menu.exec(m_listView->viewport()->mapToGlobal(pos));
if (chosen == copyFilenameAction) {
@@ -679,6 +686,15 @@ void MainWindow::moveImageToTrash(const QByteArray &path)
QTimer::singleShot(0, this, &MainWindow::loadVisibleThumbnails);
}
+void MainWindow::moveCurrentImageToTrash()
+{
+ const QModelIndex index = m_listView->currentIndex();
+ if (!index.isValid() || m_imageModel->isFolder(index))
+ return;
+
+ moveImageToTrash(m_imageModel->filePath(index));
+}
+
void MainWindow::leaveSingleImageMode()
{
if (isFullScreen()) {
@@ -799,6 +815,14 @@ void MainWindow::keyPressEvent(QKeyEvent *event)
return;
}
+ if (sc.matches(event, ShortcutManager::MoveToTrash)
+ && m_stack->currentWidget() == m_browserPage)
+ {
+ moveCurrentImageToTrash();
+ event->accept();
+ return;
+ }
+
QMainWindow::keyPressEvent(event);
}
diff --git a/src/mainwindow.h b/src/mainwindow.h index 51043c2..26a6c57 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h
@@ -49,6 +49,7 @@ private:
void onEditCaption();
void showImageContextMenu(const QPoint &pos);
void moveImageToTrash(const QByteArray &path);
+ void moveCurrentImageToTrash();
void onPathEntered();
void updatePathField(const QByteArray &path);
QList<QByteArray> computeNeighborPaths(const QModelIndex &index) const;
diff --git a/src/shortcutmanager.cpp b/src/shortcutmanager.cpp index 6675b45..7d3d697 100644 --- a/src/shortcutmanager.cpp +++ b/src/shortcutmanager.cpp
@@ -33,6 +33,7 @@ static const ActionInfo kDefaults[ShortcutManager::ActionCount] = {
{"ActivateEntry", QT_TR_NOOP("Open folder / image"), QKeySequence(Qt::Key_Return), ShortcutManager::CatBrowser},
{"PrevFolder", QT_TR_NOOP("Previous folder"), QKeySequence(Qt::ALT | Qt::Key_Left), ShortcutManager::CatBrowser},
{"NextFolder", QT_TR_NOOP("Next folder"), QKeySequence(Qt::ALT | Qt::Key_Right), ShortcutManager::CatBrowser},
+ {"MoveToTrash", QT_TR_NOOP("Move image to trash"), QKeySequence(Qt::Key_Delete), ShortcutManager::CatBrowser},
};
} // namespace
diff --git a/src/shortcutmanager.h b/src/shortcutmanager.h index 61105a9..1255d2a 100644 --- a/src/shortcutmanager.h +++ b/src/shortcutmanager.h
@@ -30,6 +30,7 @@ public:
ActivateEntry,
PrevFolder,
NextFolder,
+ MoveToTrash,
ActionCount
};