mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 22:20:21 +00:00
Qt: allow special playlists (excluding all) to add/edit/delete
This commit is contained in:
parent
e64b371955
commit
329d472ee7
@ -81,7 +81,6 @@ 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;
|
||||
@ -92,47 +91,23 @@ 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 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));
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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<QHash<QString, QString> > getPlaylistItems(QString pathString);
|
||||
|
||||
LoadCoreWindow *m_loadCoreWindow;
|
||||
|
Loading…
x
Reference in New Issue
Block a user