mirror of
https://github.com/libretro/RetroArch
synced 2025-02-11 06:40:48 +00:00
Qt: add delete key option to list/grid view to remove playlist items
This commit is contained in:
parent
c883a81c42
commit
8835e2d9a2
@ -3662,3 +3662,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_PLAYLIST_ENTRY_DATABASE,
|
|||||||
"データベース:")
|
"データベース:")
|
||||||
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_FOR_THUMBNAILS,
|
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_FOR_THUMBNAILS,
|
||||||
"(サムネイルを見つかることに使う)")
|
"(サムネイルを見つかることに使う)")
|
||||||
|
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_CONFIRM_DELETE_PLAYLIST_ITEM,
|
||||||
|
"「%1」というアイテムを削除しますか?")
|
||||||
|
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_CANNOT_ADD_TO_ALL_PLAYLISTS,
|
||||||
|
"まずひとつのプレイリストを選択してください。")
|
||||||
|
@ -3820,3 +3820,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_PLAYLIST_ENTRY_DATABASE,
|
|||||||
"Database:")
|
"Database:")
|
||||||
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_FOR_THUMBNAILS,
|
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_FOR_THUMBNAILS,
|
||||||
"(used to find thumbnails)")
|
"(used to find thumbnails)")
|
||||||
|
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_CONFIRM_DELETE_PLAYLIST_ITEM,
|
||||||
|
"Are you sure you want to delete the item \"%1\"?")
|
||||||
|
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_CANNOT_ADD_TO_ALL_PLAYLISTS,
|
||||||
|
"Please choose a single playlist first.")
|
||||||
|
@ -1883,6 +1883,7 @@ enum msg_hash_enums
|
|||||||
MENU_ENUM_LABEL_VALUE_QT_ENTER_NEW_PLAYLIST_NAME,
|
MENU_ENUM_LABEL_VALUE_QT_ENTER_NEW_PLAYLIST_NAME,
|
||||||
MENU_ENUM_LABEL_VALUE_QT_DELETE_PLAYLIST,
|
MENU_ENUM_LABEL_VALUE_QT_DELETE_PLAYLIST,
|
||||||
MENU_ENUM_LABEL_VALUE_QT_CONFIRM_DELETE_PLAYLIST,
|
MENU_ENUM_LABEL_VALUE_QT_CONFIRM_DELETE_PLAYLIST,
|
||||||
|
MENU_ENUM_LABEL_VALUE_QT_CONFIRM_DELETE_PLAYLIST_ITEM,
|
||||||
MENU_ENUM_LABEL_VALUE_QT_QUESTION,
|
MENU_ENUM_LABEL_VALUE_QT_QUESTION,
|
||||||
MENU_ENUM_LABEL_VALUE_QT_COULD_NOT_DELETE_FILE,
|
MENU_ENUM_LABEL_VALUE_QT_COULD_NOT_DELETE_FILE,
|
||||||
MENU_ENUM_LABEL_VALUE_QT_GATHERING_LIST_OF_FILES,
|
MENU_ENUM_LABEL_VALUE_QT_GATHERING_LIST_OF_FILES,
|
||||||
@ -1891,6 +1892,7 @@ enum msg_hash_enums
|
|||||||
MENU_ENUM_LABEL_VALUE_QT_PLAYLIST_ENTRY_CORE,
|
MENU_ENUM_LABEL_VALUE_QT_PLAYLIST_ENTRY_CORE,
|
||||||
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_LABEL(MIDI_INPUT),
|
MENU_LABEL(MIDI_INPUT),
|
||||||
MENU_LABEL(MIDI_OUTPUT),
|
MENU_LABEL(MIDI_OUTPUT),
|
||||||
|
@ -216,6 +216,17 @@ FileDropWidget::FileDropWidget(QWidget *parent) :
|
|||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FileDropWidget::keyPressEvent(QKeyEvent *event)
|
||||||
|
{
|
||||||
|
if (event->key() == Qt::Key_Delete)
|
||||||
|
{
|
||||||
|
event->accept();
|
||||||
|
emit deletePressed();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
QWidget::keyPressEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
void FileDropWidget::dragEnterEvent(QDragEnterEvent *event)
|
void FileDropWidget::dragEnterEvent(QDragEnterEvent *event)
|
||||||
{
|
{
|
||||||
const QMimeData *data = event->mimeData();
|
const QMimeData *data = event->mimeData();
|
||||||
@ -257,6 +268,11 @@ void TableWidget::keyPressEvent(QKeyEvent *event)
|
|||||||
event->accept();
|
event->accept();
|
||||||
emit enterPressed();
|
emit enterPressed();
|
||||||
}
|
}
|
||||||
|
else if (event->key() == Qt::Key_Delete)
|
||||||
|
{
|
||||||
|
event->accept();
|
||||||
|
emit deletePressed();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
QTableWidget::keyPressEvent(event);
|
QTableWidget::keyPressEvent(event);
|
||||||
}
|
}
|
||||||
@ -984,6 +1000,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
connect(m_tableWidget, SIGNAL(currentItemChanged(QTableWidgetItem*, QTableWidgetItem*)), this, SLOT(onCurrentTableItemChanged(QTableWidgetItem*, QTableWidgetItem*)));
|
connect(m_tableWidget, SIGNAL(currentItemChanged(QTableWidgetItem*, QTableWidgetItem*)), this, SLOT(onCurrentTableItemChanged(QTableWidgetItem*, QTableWidgetItem*)));
|
||||||
connect(m_tableWidget, SIGNAL(itemDoubleClicked(QTableWidgetItem*)), this, SLOT(onContentItemDoubleClicked(QTableWidgetItem*)));
|
connect(m_tableWidget, SIGNAL(itemDoubleClicked(QTableWidgetItem*)), this, SLOT(onContentItemDoubleClicked(QTableWidgetItem*)));
|
||||||
connect(m_tableWidget, SIGNAL(enterPressed()), this, SLOT(onTableWidgetEnterPressed()));
|
connect(m_tableWidget, SIGNAL(enterPressed()), this, SLOT(onTableWidgetEnterPressed()));
|
||||||
|
connect(m_tableWidget, SIGNAL(deletePressed()), this, SLOT(onTableWidgetDeletePressed()));
|
||||||
connect(m_startCorePushButton, SIGNAL(clicked()), this, SLOT(onStartCoreClicked()));
|
connect(m_startCorePushButton, SIGNAL(clicked()), this, SLOT(onStartCoreClicked()));
|
||||||
connect(m_coreInfoPushButton, SIGNAL(clicked()), m_coreInfoDialog, SLOT(showCoreInfo()));
|
connect(m_coreInfoPushButton, SIGNAL(clicked()), m_coreInfoDialog, SLOT(showCoreInfo()));
|
||||||
connect(m_runPushButton, SIGNAL(clicked()), this, SLOT(onRunClicked()));
|
connect(m_runPushButton, SIGNAL(clicked()), this, SLOT(onRunClicked()));
|
||||||
@ -995,7 +1012,6 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(onZoomValueChanged(int)));
|
connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(onZoomValueChanged(int)));
|
||||||
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_tableWidget, SIGNAL(filesDropped(QStringList)), this, SLOT(onPlaylistFilesDropped(QStringList)));
|
|
||||||
connect(m_gridLayoutWidget, SIGNAL(filesDropped(QStringList)), this, SLOT(onPlaylistFilesDropped(QStringList)));
|
connect(m_gridLayoutWidget, SIGNAL(filesDropped(QStringList)), this, SLOT(onPlaylistFilesDropped(QStringList)));
|
||||||
|
|
||||||
/* 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) */
|
||||||
@ -1065,6 +1081,12 @@ void MainWindow::addFilesToPlaylist(QStringList files)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (currentPlaylistPath == ALL_PLAYLISTS_TOKEN)
|
||||||
|
{
|
||||||
|
ui_window.qtWindow->showMessageBox(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_CANNOT_ADD_TO_ALL_PLAYLISTS), MainWindow::MSGBOX_TYPE_ERROR, Qt::ApplicationModal);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!playlistDialog->showDialog())
|
if (!playlistDialog->showDialog())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -2380,6 +2402,67 @@ void MainWindow::onTableWidgetEnterPressed()
|
|||||||
onRunClicked();
|
onRunClicked();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::onTableWidgetDeletePressed()
|
||||||
|
{
|
||||||
|
deleteCurrentPlaylistItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::deleteCurrentPlaylistItem()
|
||||||
|
{
|
||||||
|
QTableWidgetItem *contentItem = m_tableWidget->currentItem();
|
||||||
|
QListWidgetItem *playlistItem = m_listWidget->currentItem();
|
||||||
|
QHash<QString, QString> contentHash;
|
||||||
|
QString playlistPath;
|
||||||
|
QByteArray playlistArray;
|
||||||
|
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 (!contentItem)
|
||||||
|
return;
|
||||||
|
|
||||||
|
contentHash = contentItem->data(Qt::UserRole).value<QHash<QString, QString> >();
|
||||||
|
}
|
||||||
|
else if (viewType == VIEW_TYPE_ICONS)
|
||||||
|
contentHash = m_currentGridHash;
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (contentHash.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
playlistArray = playlistPath.toUtf8();
|
||||||
|
playlistData = playlistArray.constData();
|
||||||
|
|
||||||
|
index = contentHash.value("index").toUInt(&ok);
|
||||||
|
|
||||||
|
if (!ok)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!ui_window.qtWindow->showMessageBox(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_CONFIRM_DELETE_PLAYLIST_ITEM)).arg(contentHash["label"]), MainWindow::MSGBOX_TYPE_QUESTION, Qt::ApplicationModal, false))
|
||||||
|
return;
|
||||||
|
|
||||||
|
playlist = playlist_init(playlistData, COLLECTION_SIZE);
|
||||||
|
|
||||||
|
playlist_delete_index(playlist, index);
|
||||||
|
playlist_write_file(playlist);
|
||||||
|
playlist_free(playlist);
|
||||||
|
|
||||||
|
reloadPlaylists();
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::onContentItemDoubleClicked(QTableWidgetItem*)
|
void MainWindow::onContentItemDoubleClicked(QTableWidgetItem*)
|
||||||
{
|
{
|
||||||
onRunClicked();
|
onRunClicked();
|
||||||
@ -2415,6 +2498,8 @@ QHash<QString, QString> MainWindow::getSelectedCore()
|
|||||||
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 coreHash;
|
||||||
|
|
||||||
switch(coreSelection)
|
switch(coreSelection)
|
||||||
{
|
{
|
||||||
@ -2620,6 +2705,8 @@ void MainWindow::onRunClicked()
|
|||||||
contentHash = item->data(Qt::UserRole).value<QHash<QString, QString> >();
|
contentHash = item->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;
|
||||||
|
|
||||||
loadContent(contentHash);
|
loadContent(contentHash);
|
||||||
#endif
|
#endif
|
||||||
@ -3073,6 +3160,8 @@ void MainWindow::onSearchLineEditEdited(const QString &text)
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3300,6 +3389,7 @@ void MainWindow::setCurrentViewType(ViewType viewType)
|
|||||||
case VIEW_TYPE_LIST:
|
case VIEW_TYPE_LIST:
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
|
m_viewType = VIEW_TYPE_LIST;
|
||||||
m_gridWidget->hide();
|
m_gridWidget->hide();
|
||||||
m_tableWidget->show();
|
m_tableWidget->show();
|
||||||
break;
|
break;
|
||||||
@ -3932,6 +4022,8 @@ QVector<QHash<QString, QString> > MainWindow::getPlaylistItems(QString pathStrin
|
|||||||
else
|
else
|
||||||
hash["path"] = path;
|
hash["path"] = path;
|
||||||
|
|
||||||
|
hash["index"] = QString::number(i);
|
||||||
|
|
||||||
if (string_is_empty(label))
|
if (string_is_empty(label))
|
||||||
{
|
{
|
||||||
hash["label"] = path;
|
hash["label"] = path;
|
||||||
|
@ -279,6 +279,7 @@ static void* ui_companion_qt_init(void)
|
|||||||
widget->setObjectName("tableWidget");
|
widget->setObjectName("tableWidget");
|
||||||
|
|
||||||
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()));
|
||||||
|
|
||||||
layout = new QVBoxLayout();
|
layout = new QVBoxLayout();
|
||||||
layout->addWidget(mainwindow->contentTableWidget());
|
layout->addWidget(mainwindow->contentTableWidget());
|
||||||
|
@ -147,9 +147,11 @@ public:
|
|||||||
FileDropWidget(QWidget *parent = 0);
|
FileDropWidget(QWidget *parent = 0);
|
||||||
signals:
|
signals:
|
||||||
void filesDropped(QStringList files);
|
void filesDropped(QStringList files);
|
||||||
|
void deletePressed();
|
||||||
protected:
|
protected:
|
||||||
void dragEnterEvent(QDragEnterEvent *event);
|
void dragEnterEvent(QDragEnterEvent *event);
|
||||||
void dropEvent(QDropEvent *event);
|
void dropEvent(QDropEvent *event);
|
||||||
|
void keyPressEvent(QKeyEvent *event);
|
||||||
};
|
};
|
||||||
|
|
||||||
class TableWidget : public QTableWidget
|
class TableWidget : public QTableWidget
|
||||||
@ -159,6 +161,7 @@ public:
|
|||||||
TableWidget(QWidget *parent = 0);
|
TableWidget(QWidget *parent = 0);
|
||||||
signals:
|
signals:
|
||||||
void enterPressed();
|
void enterPressed();
|
||||||
|
void deletePressed();
|
||||||
protected:
|
protected:
|
||||||
void keyPressEvent(QKeyEvent *event);
|
void keyPressEvent(QKeyEvent *event);
|
||||||
};
|
};
|
||||||
@ -358,6 +361,7 @@ public slots:
|
|||||||
void loadContent(const QHash<QString, QString> &contentHash);
|
void loadContent(const QHash<QString, QString> &contentHash);
|
||||||
void onStartCoreClicked();
|
void onStartCoreClicked();
|
||||||
void onTableWidgetEnterPressed();
|
void onTableWidgetEnterPressed();
|
||||||
|
void onTableWidgetDeletePressed();
|
||||||
void selectBrowserDir(QString path);
|
void selectBrowserDir(QString path);
|
||||||
void resizeThumbnails(bool one, bool two, bool three);
|
void resizeThumbnails(bool one, bool two, bool three);
|
||||||
void onResizeThumbnailOne();
|
void onResizeThumbnailOne();
|
||||||
@ -373,6 +377,7 @@ public slots:
|
|||||||
void onIconViewClicked();
|
void onIconViewClicked();
|
||||||
void onListViewClicked();
|
void onListViewClicked();
|
||||||
void onTabWidgetIndexChanged(int index);
|
void onTabWidgetIndexChanged(int index);
|
||||||
|
void deleteCurrentPlaylistItem();
|
||||||
|
|
||||||
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