Add confirmation box for opening songs in file browser

This commit is contained in:
Jonas Kvinge 2019-06-20 17:00:10 +02:00
parent 505c0eeae2
commit 647e7e708a
3 changed files with 25 additions and 1 deletions

View File

@ -592,12 +592,15 @@ void CollectionView::FilterReturnPressed() {
}
void CollectionView::ShowInBrowser() {
SongList songs = GetSelectedSongs();
QList<QUrl> urls;
for (const Song &song : GetSelectedSongs()) {
for (const Song &song : songs) {
urls << song.url();
}
Utilities::OpenInFileBrowser(urls);
}
int CollectionView::TotalSongs() {

View File

@ -2118,6 +2118,7 @@ void MainWindow::PlaylistOpenInBrowser() {
}
Utilities::OpenInFileBrowser(urls);
}
void MainWindow::PlaylistQueue() {

View File

@ -57,6 +57,7 @@
#include <QXmlStreamReader>
#include <QSettings>
#include <QtEvents>
#include <QMessageBox>
#include <QtDebug>
#ifdef HAVE_TRANSLATIONS
# include <QTranslator>
@ -356,6 +357,25 @@ void ShowFileInExplorer(QString const &path) {
void OpenInFileBrowser(const QList<QUrl> &urls) {
if (urls.count() > 50) {
QMessageBox messagebox(QMessageBox::Critical, tr("Error"), tr("Too many songs selected."));
messagebox.exec();
return;
}
if (urls.count() > 5) {
QMessageBox messagebox(QMessageBox::Information, tr("Show in file browser"), tr("%1 songs selected, are you sure you want to open them all?").arg(urls.count()), QMessageBox::Open|QMessageBox::Cancel);
messagebox.setTextFormat(Qt::RichText);
int result = messagebox.exec();
switch (result) {
case QMessageBox::Open:
break;
case QMessageBox::Cancel:
default:
return;
}
}
QSet<QString> dirs;
for (const QUrl &url : urls) {