mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 03:32:46 +00:00
Qt: add right-click menu to delete playlist items
This commit is contained in:
parent
978edc7acf
commit
fea09f7382
@ -3666,3 +3666,5 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_CONFIRM_DELETE_PLAYLIST_ITEM,
|
|||||||
"「%1」というアイテムを削除しますか?")
|
"「%1」というアイテムを削除しますか?")
|
||||||
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_CANNOT_ADD_TO_ALL_PLAYLISTS,
|
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_CANNOT_ADD_TO_ALL_PLAYLISTS,
|
||||||
"まずひとつのプレイリストを選択してください。")
|
"まずひとつのプレイリストを選択してください。")
|
||||||
|
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_DELETE,
|
||||||
|
"削除")
|
||||||
|
@ -4176,3 +4176,5 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_CONFIRM_DELETE_PLAYLIST_ITEM,
|
|||||||
"Are you sure you want to delete the item \"%1\"?")
|
"Are you sure you want to delete the item \"%1\"?")
|
||||||
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_CANNOT_ADD_TO_ALL_PLAYLISTS,
|
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_CANNOT_ADD_TO_ALL_PLAYLISTS,
|
||||||
"Please choose a single playlist first.")
|
"Please choose a single playlist first.")
|
||||||
|
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_DELETE,
|
||||||
|
"Delete")
|
||||||
|
@ -1949,6 +1949,7 @@ enum msg_hash_enums
|
|||||||
MENU_ENUM_LABEL_VALUE_QT_PLAYLIST_ENTRY_DATABASE,
|
MENU_ENUM_LABEL_VALUE_QT_PLAYLIST_ENTRY_DATABASE,
|
||||||
MENU_ENUM_LABEL_VALUE_QT_FOR_THUMBNAILS,
|
MENU_ENUM_LABEL_VALUE_QT_FOR_THUMBNAILS,
|
||||||
MENU_ENUM_LABEL_VALUE_QT_CANNOT_ADD_TO_ALL_PLAYLISTS,
|
MENU_ENUM_LABEL_VALUE_QT_CANNOT_ADD_TO_ALL_PLAYLISTS,
|
||||||
|
MENU_ENUM_LABEL_VALUE_QT_DELETE,
|
||||||
|
|
||||||
MENU_LABEL(MIDI_INPUT),
|
MENU_LABEL(MIDI_INPUT),
|
||||||
MENU_LABEL(MIDI_OUTPUT),
|
MENU_LABEL(MIDI_OUTPUT),
|
||||||
|
@ -991,6 +991,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
|
|
||||||
m_dirTree->setContextMenuPolicy(Qt::CustomContextMenu);
|
m_dirTree->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
m_listWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
m_listWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
m_gridLayoutWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
|
||||||
connect(m_searchLineEdit, SIGNAL(returnPressed()), this, SLOT(onSearchEnterPressed()));
|
connect(m_searchLineEdit, SIGNAL(returnPressed()), this, SLOT(onSearchEnterPressed()));
|
||||||
connect(m_searchLineEdit, SIGNAL(textEdited(const QString&)), this, SLOT(onSearchLineEditEdited(const QString&)));
|
connect(m_searchLineEdit, SIGNAL(textEdited(const QString&)), this, SLOT(onSearchLineEditEdited(const QString&)));
|
||||||
@ -1014,6 +1015,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
connect(viewTypeIconsAction, SIGNAL(triggered()), this, SLOT(onIconViewClicked()));
|
connect(viewTypeIconsAction, SIGNAL(triggered()), this, SLOT(onIconViewClicked()));
|
||||||
connect(viewTypeListAction, SIGNAL(triggered()), this, SLOT(onListViewClicked()));
|
connect(viewTypeListAction, SIGNAL(triggered()), this, SLOT(onListViewClicked()));
|
||||||
connect(m_gridLayoutWidget, SIGNAL(filesDropped(QStringList)), this, SLOT(onPlaylistFilesDropped(QStringList)));
|
connect(m_gridLayoutWidget, SIGNAL(filesDropped(QStringList)), this, SLOT(onPlaylistFilesDropped(QStringList)));
|
||||||
|
connect(m_gridLayoutWidget, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(onFileDropWidgetContextMenuRequested(const QPoint&)));
|
||||||
|
|
||||||
/* make sure these use an auto connection so it will be queued if called from a different thread (some facilities in RA log messages from other threads) */
|
/* make sure these use an auto connection so it will be queued if called from a different thread (some facilities in RA log messages from other threads) */
|
||||||
connect(this, SIGNAL(gotLogMessage(const QString&)), this, SLOT(onGotLogMessage(const QString&)), Qt::AutoConnection);
|
connect(this, SIGNAL(gotLogMessage(const QString&)), this, SLOT(onGotLogMessage(const QString&)), Qt::AutoConnection);
|
||||||
@ -1444,6 +1446,30 @@ bool MainWindow::showMessageBox(QString msg, MessageBoxType msgType, Qt::WindowM
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::onFileDropWidgetContextMenuRequested(const QPoint &pos)
|
||||||
|
{
|
||||||
|
QScopedPointer<QMenu> menu;
|
||||||
|
QScopedPointer<QAction> deleteAction;
|
||||||
|
QPointer<QAction> selectedAction;
|
||||||
|
QPoint cursorPos = QCursor::pos();
|
||||||
|
|
||||||
|
menu.reset(new QMenu(this));
|
||||||
|
|
||||||
|
deleteAction.reset(new QAction(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_DELETE)), this));
|
||||||
|
|
||||||
|
menu->addAction(deleteAction.data());
|
||||||
|
|
||||||
|
selectedAction = menu->exec(cursorPos);
|
||||||
|
|
||||||
|
if (!selectedAction)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (selectedAction == deleteAction.data())
|
||||||
|
{
|
||||||
|
deleteCurrentPlaylistItem();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::onPlaylistWidgetContextMenuRequested(const QPoint&)
|
void MainWindow::onPlaylistWidgetContextMenuRequested(const QPoint&)
|
||||||
{
|
{
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
@ -2408,37 +2434,51 @@ void MainWindow::onTableWidgetDeletePressed()
|
|||||||
deleteCurrentPlaylistItem();
|
deleteCurrentPlaylistItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::deleteCurrentPlaylistItem()
|
QString MainWindow::getCurrentPlaylistPath()
|
||||||
|
{
|
||||||
|
QListWidgetItem *playlistItem = m_listWidget->currentItem();
|
||||||
|
QHash<QString, QString> contentHash;
|
||||||
|
QString playlistPath;
|
||||||
|
|
||||||
|
if (!playlistItem)
|
||||||
|
return playlistPath;
|
||||||
|
|
||||||
|
playlistPath = playlistItem->data(Qt::UserRole).toString();
|
||||||
|
|
||||||
|
return playlistPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
QHash<QString, QString> MainWindow::getCurrentContentHash()
|
||||||
{
|
{
|
||||||
QTableWidgetItem *contentItem = m_tableWidget->currentItem();
|
QTableWidgetItem *contentItem = m_tableWidget->currentItem();
|
||||||
QListWidgetItem *playlistItem = m_listWidget->currentItem();
|
QListWidgetItem *playlistItem = m_listWidget->currentItem();
|
||||||
QHash<QString, QString> contentHash;
|
QHash<QString, QString> contentHash;
|
||||||
QString playlistPath;
|
|
||||||
QByteArray playlistArray;
|
|
||||||
ViewType viewType = getCurrentViewType();
|
ViewType viewType = getCurrentViewType();
|
||||||
playlist_t *playlist = NULL;
|
|
||||||
const char *playlistData = NULL;
|
|
||||||
unsigned index = 0;
|
|
||||||
bool ok = false;
|
|
||||||
|
|
||||||
if (!playlistItem)
|
|
||||||
return;
|
|
||||||
|
|
||||||
playlistPath = playlistItem->data(Qt::UserRole).toString();
|
|
||||||
|
|
||||||
if (playlistPath.isEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (viewType == VIEW_TYPE_LIST)
|
if (viewType == VIEW_TYPE_LIST)
|
||||||
{
|
{
|
||||||
if (!contentItem)
|
if (!contentItem)
|
||||||
return;
|
return contentHash;
|
||||||
|
|
||||||
contentHash = contentItem->data(Qt::UserRole).value<QHash<QString, QString> >();
|
contentHash = contentItem->data(Qt::UserRole).value<QHash<QString, QString> >();
|
||||||
}
|
}
|
||||||
else if (viewType == VIEW_TYPE_ICONS)
|
else if (viewType == VIEW_TYPE_ICONS)
|
||||||
contentHash = m_currentGridHash;
|
contentHash = m_currentGridHash;
|
||||||
else
|
|
||||||
|
return contentHash;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::deleteCurrentPlaylistItem()
|
||||||
|
{
|
||||||
|
QString playlistPath = getCurrentPlaylistPath();
|
||||||
|
QByteArray playlistArray;
|
||||||
|
QHash<QString, QString> contentHash = getCurrentContentHash();
|
||||||
|
playlist_t *playlist = NULL;
|
||||||
|
const char *playlistData = NULL;
|
||||||
|
unsigned index = 0;
|
||||||
|
bool ok = false;
|
||||||
|
|
||||||
|
if (playlistPath.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (contentHash.isEmpty())
|
if (contentHash.isEmpty())
|
||||||
|
@ -277,9 +277,11 @@ static void* ui_companion_qt_init(void)
|
|||||||
|
|
||||||
widget = new FileDropWidget(mainwindow);
|
widget = new FileDropWidget(mainwindow);
|
||||||
widget->setObjectName("tableWidget");
|
widget->setObjectName("tableWidget");
|
||||||
|
widget->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
|
||||||
QObject::connect(widget, SIGNAL(filesDropped(QStringList)), mainwindow, SLOT(onPlaylistFilesDropped(QStringList)));
|
QObject::connect(widget, SIGNAL(filesDropped(QStringList)), mainwindow, SLOT(onPlaylistFilesDropped(QStringList)));
|
||||||
QObject::connect(widget, SIGNAL(deletePressed()), mainwindow, SLOT(deleteCurrentPlaylistItem()));
|
QObject::connect(widget, SIGNAL(deletePressed()), mainwindow, SLOT(deleteCurrentPlaylistItem()));
|
||||||
|
QObject::connect(widget, SIGNAL(customContextMenuRequested(const QPoint&)), mainwindow, SLOT(onFileDropWidgetContextMenuRequested(const QPoint&)));
|
||||||
|
|
||||||
layout = new QVBoxLayout();
|
layout = new QVBoxLayout();
|
||||||
layout->addWidget(mainwindow->contentTableWidget());
|
layout->addWidget(mainwindow->contentTableWidget());
|
||||||
|
@ -339,6 +339,8 @@ public:
|
|||||||
void setAllPlaylistsGridMaxCount(int count);
|
void setAllPlaylistsGridMaxCount(int count);
|
||||||
PlaylistEntryDialog* playlistEntryDialog();
|
PlaylistEntryDialog* playlistEntryDialog();
|
||||||
void addFilesToPlaylist(QStringList files);
|
void addFilesToPlaylist(QStringList files);
|
||||||
|
QString getCurrentPlaylistPath();
|
||||||
|
QHash<QString, QString> getCurrentContentHash();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void thumbnailChanged(const QPixmap &pixmap);
|
void thumbnailChanged(const QPixmap &pixmap);
|
||||||
@ -378,6 +380,7 @@ public slots:
|
|||||||
void onListViewClicked();
|
void onListViewClicked();
|
||||||
void onTabWidgetIndexChanged(int index);
|
void onTabWidgetIndexChanged(int index);
|
||||||
void deleteCurrentPlaylistItem();
|
void deleteCurrentPlaylistItem();
|
||||||
|
void onFileDropWidgetContextMenuRequested(const QPoint &pos);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onLoadCoreClicked(const QStringList &extensionFilters = QStringList());
|
void onLoadCoreClicked(const QStringList &extensionFilters = QStringList());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user