diff --git a/ui/drivers/qt/filedropwidget.cpp b/ui/drivers/qt/filedropwidget.cpp index 7d42a9742c..a53b588e7e 100644 --- a/ui/drivers/qt/filedropwidget.cpp +++ b/ui/drivers/qt/filedropwidget.cpp @@ -81,7 +81,6 @@ void FileDropWidget::dropEvent(QDropEvent *event) void MainWindow::onFileDropWidgetContextMenuRequested(const QPoint &pos) { - settings_t *settings = config_get_ptr(); QScopedPointer menu; QScopedPointer downloadThumbnailAction; QScopedPointer addEntryAction; @@ -92,47 +91,23 @@ void MainWindow::onFileDropWidgetContextMenuRequested(const QPoint &pos) QPointer selectedAction; QPoint cursorPos = QCursor::pos(); QHash contentHash = getCurrentContentHash(); - QDir playlistDir(settings->paths.directory_playlist); - QString playlistDirAbsPath = playlistDir.absolutePath(); - QFileInfo currentPlaylistFileInfo; - QString currentPlaylistPath; - QString currentPlaylistFileName; - QString currentPlaylistDirPath; - QListWidgetItem *currentPlaylistItem = NULL; - bool specialPlaylist = false; + bool specialPlaylist = currentPlaylistIsSpecial(); + bool allPlaylist = currentPlaylistIsAll(); bool actionsAdded = false; if (m_browserAndPlaylistTabWidget->tabText(m_browserAndPlaylistTabWidget->currentIndex()) != msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_TAB_PLAYLISTS)) return; - currentPlaylistItem = m_listWidget->currentItem(); - - if (!currentPlaylistItem) - return; - - if (currentPlaylistItem) - { - currentPlaylistPath = currentPlaylistItem->data(Qt::UserRole).toString(); - - currentPlaylistFileInfo = QFileInfo(currentPlaylistPath); - currentPlaylistFileName = currentPlaylistFileInfo.fileName(); - currentPlaylistDirPath = currentPlaylistFileInfo.absoluteDir().absolutePath(); - } - menu.reset(new QMenu(this)); - /* Don't just compare strings in case there are case differences on Windows that should be ignored. */ - if (QDir(currentPlaylistDirPath) != QDir(playlistDirAbsPath)) - { - /* special playlists like history etc. can't have an association */ - specialPlaylist = true; - } - if (!specialPlaylist) { downloadThumbnailAction.reset(new QAction(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_DOWNLOAD_THUMBNAIL)), this)); menu->addAction(downloadThumbnailAction.data()); + } + if (!allPlaylist) + { addEntryAction.reset(new QAction(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_ADD_ENTRY)), this)); menu->addAction(addEntryAction.data()); @@ -183,7 +158,11 @@ void MainWindow::onFileDropWidgetContextMenuRequested(const QPoint &pos) } } } - else if (selectedAction == addFilesAction.data()) + } + + if (!allPlaylist) + { + if (selectedAction == addFilesAction.data()) { QStringList filePaths = QFileDialog::getOpenFileNames(this, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_SELECT_FILES)); diff --git a/ui/drivers/qt/playlist.cpp b/ui/drivers/qt/playlist.cpp index 38d97a9038..7217f19f5a 100644 --- a/ui/drivers/qt/playlist.cpp +++ b/ui/drivers/qt/playlist.cpp @@ -985,6 +985,45 @@ QString MainWindow::getCurrentPlaylistPath() return playlistPath; } +bool MainWindow::currentPlaylistIsSpecial() +{ + settings_t *settings = config_get_ptr(); + QDir playlistDir(settings->paths.directory_playlist); + QString playlistDirAbsPath = playlistDir.absolutePath(); + QFileInfo currentPlaylistFileInfo; + QString currentPlaylistPath; + QString currentPlaylistDirPath; + QListWidgetItem *currentPlaylistItem = m_listWidget->currentItem(); + bool specialPlaylist = false; + + if (!currentPlaylistItem) + return false; + + currentPlaylistPath = currentPlaylistItem->data(Qt::UserRole).toString(); + currentPlaylistFileInfo = QFileInfo(currentPlaylistPath); + currentPlaylistDirPath = currentPlaylistFileInfo.absoluteDir().absolutePath(); + + /* Don't just compare strings in case there are case differences on Windows that should be ignored. */ + if (QDir(currentPlaylistDirPath) != QDir(playlistDirAbsPath)) + specialPlaylist = true; + + return specialPlaylist; +} + +bool MainWindow::currentPlaylistIsAll() +{ + QListWidgetItem *currentPlaylistItem = m_listWidget->currentItem(); + bool all = false; + + if (!currentPlaylistItem) + return false; + + if (currentPlaylistItem->data(Qt::UserRole).toString() == ALL_PLAYLISTS_TOKEN) + all = true; + + return all; +} + void MainWindow::deleteCurrentPlaylistItem() { QString playlistPath = getCurrentPlaylistPath(); @@ -994,6 +1033,10 @@ void MainWindow::deleteCurrentPlaylistItem() const char *playlistData = NULL; unsigned index = 0; bool ok = false; + bool isAllPlaylist = currentPlaylistIsAll(); + + if (isAllPlaylist) + return; if (playlistPath.isEmpty()) return; diff --git a/ui/drivers/ui_qt.h b/ui/drivers/ui_qt.h index ee0f75752f..7c050d075b 100644 --- a/ui/drivers/ui_qt.h +++ b/ui/drivers/ui_qt.h @@ -452,6 +452,8 @@ private: void removeUpdateTempFiles(); bool addDirectoryFilesToList(QProgressDialog *dialog, QStringList &list, QDir &dir, QStringList &extensions); void renamePlaylistItem(QListWidgetItem *item, QString newName); + bool currentPlaylistIsSpecial(); + bool currentPlaylistIsAll(); QVector > getPlaylistItems(QString pathString); LoadCoreWindow *m_loadCoreWindow;