Add move to trash action
This commit is contained in:
@@ -131,6 +131,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
|
|||||||
fileMenu->addSeparator();
|
fileMenu->addSeparator();
|
||||||
fileMenu->addAction(tr("Copy marked files"), this, SLOT(copyMarked()), Qt::Key_F5);
|
fileMenu->addAction(tr("Copy marked files"), this, SLOT(copyMarked()), Qt::Key_F5);
|
||||||
fileMenu->addAction(tr("Move marked files"), this, SLOT(moveMarked()), Qt::Key_F6);
|
fileMenu->addAction(tr("Move marked files"), this, SLOT(moveMarked()), Qt::Key_F6);
|
||||||
|
fileMenu->addAction(tr("Move marked files to trash"), this, &MainWindow::deleteMarked, QKeySequence::Delete);
|
||||||
fileMenu->addSeparator();
|
fileMenu->addSeparator();
|
||||||
fileMenu->addAction(tr("Index directory"), this, SLOT(indexDir()));
|
fileMenu->addAction(tr("Index directory"), this, SLOT(indexDir()));
|
||||||
fileMenu->addAction(tr("Reindex files"), this, SLOT(reindex()));
|
fileMenu->addAction(tr("Reindex files"), this, SLOT(reindex()));
|
||||||
@@ -552,6 +553,34 @@ void MainWindow::moveMarked()
|
|||||||
copyOrMove(false);
|
copyOrMove(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::deleteMarked()
|
||||||
|
{
|
||||||
|
QStringList files = m_database->getMarkedFiles();
|
||||||
|
if(QMessageBox::question(this, tr("Move files to trash?"), tr("Do you want to move %1 files to trash?").arg(files.size())) != QMessageBox::Yes)
|
||||||
|
return;
|
||||||
|
|
||||||
|
QProgressDialog progress(tr("Moving marked files to trash"), tr("Cancel"), 0, files.size(), this);
|
||||||
|
progress.setWindowModality(Qt::WindowModal);
|
||||||
|
progress.show();
|
||||||
|
int i = 0;
|
||||||
|
for(const QString &file : files)
|
||||||
|
{
|
||||||
|
if(!QFile::exists(file))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(progress.wasCanceled())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(!QFile::moveToTrash(file))
|
||||||
|
{
|
||||||
|
QMessageBox::warning(this, tr("Failed to move file to trash"), tr("Failed to move file to trash %1").arg(file));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
progress.setValue(i++);
|
||||||
|
}
|
||||||
|
m_database->clearMarkedFiles();
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::toggleFullScreen()
|
void MainWindow::toggleFullScreen()
|
||||||
{
|
{
|
||||||
if(isFullScreen())
|
if(isFullScreen())
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ protected slots:
|
|||||||
void unmarkAndNext();
|
void unmarkAndNext();
|
||||||
void copyMarked();
|
void copyMarked();
|
||||||
void moveMarked();
|
void moveMarked();
|
||||||
|
void deleteMarked();
|
||||||
void toggleFullScreen();
|
void toggleFullScreen();
|
||||||
void liveMode(bool active);
|
void liveMode(bool active);
|
||||||
void imageStats(bool imageStats);
|
void imageStats(bool imageStats);
|
||||||
|
|||||||
Reference in New Issue
Block a user