Qt: current right click options for playlist entries are not valid for special playlists
This commit is contained in:
parent
48e7f7b7fb
commit
e64b371955
|
@ -17,6 +17,7 @@
|
|||
|
||||
extern "C" {
|
||||
#include "../../../file_path_special.h"
|
||||
#include "../../../configuration.h"
|
||||
}
|
||||
|
||||
FileDropWidget::FileDropWidget(QWidget *parent) :
|
||||
|
@ -80,6 +81,7 @@ void FileDropWidget::dropEvent(QDropEvent *event)
|
|||
|
||||
void MainWindow::onFileDropWidgetContextMenuRequested(const QPoint &pos)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
QScopedPointer<QMenu> menu;
|
||||
QScopedPointer<QAction> downloadThumbnailAction;
|
||||
QScopedPointer<QAction> addEntryAction;
|
||||
|
@ -90,35 +92,76 @@ void MainWindow::onFileDropWidgetContextMenuRequested(const QPoint &pos)
|
|||
QPointer<QAction> selectedAction;
|
||||
QPoint cursorPos = QCursor::pos();
|
||||
QHash<QString, QString> 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 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());
|
||||
|
||||
addEntryAction.reset(new QAction(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_ADD_ENTRY)), this));
|
||||
menu->addAction(addEntryAction.data());
|
||||
|
||||
addFilesAction.reset(new QAction(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_ADD_FILES)), this));
|
||||
menu->addAction(addFilesAction.data());
|
||||
|
||||
addFolderAction.reset(new QAction(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_ADD_FOLDER)), this));
|
||||
menu->addAction(addFolderAction.data());
|
||||
|
||||
editAction.reset(new QAction(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_EDIT)), this));
|
||||
deleteAction.reset(new QAction(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_DELETE)), this));
|
||||
|
||||
menu->addAction(downloadThumbnailAction.data());
|
||||
menu->addAction(addEntryAction.data());
|
||||
menu->addAction(addFilesAction.data());
|
||||
menu->addAction(addFolderAction.data());
|
||||
|
||||
if (!contentHash.isEmpty())
|
||||
{
|
||||
menu->addAction(editAction.data());
|
||||
menu->addAction(deleteAction.data());
|
||||
}
|
||||
|
||||
actionsAdded = true;
|
||||
}
|
||||
|
||||
if (actionsAdded)
|
||||
selectedAction = menu->exec(cursorPos);
|
||||
|
||||
if (!selectedAction)
|
||||
return;
|
||||
|
||||
if (!specialPlaylist)
|
||||
{
|
||||
if (selectedAction == downloadThumbnailAction.data())
|
||||
{
|
||||
QHash<QString, QString> hash = getCurrentContentHash();
|
||||
|
@ -202,4 +245,5 @@ void MainWindow::onFileDropWidgetContextMenuRequested(const QPoint &pos)
|
|||
{
|
||||
deleteCurrentPlaylistItem();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue