Qt: Add UI for playlist disc switching
This commit is contained in:
parent
d9893bb127
commit
86799775ce
|
@ -124,6 +124,8 @@ QVariant GameListModel::data(const QModelIndex& index, int role) const
|
||||||
{
|
{
|
||||||
case GameListEntryType::Disc:
|
case GameListEntryType::Disc:
|
||||||
return m_type_disc_pixmap;
|
return m_type_disc_pixmap;
|
||||||
|
case GameListEntryType::Playlist:
|
||||||
|
return m_type_playlist_pixmap;
|
||||||
case GameListEntryType::PSExe:
|
case GameListEntryType::PSExe:
|
||||||
default:
|
default:
|
||||||
return m_type_exe_pixmap;
|
return m_type_exe_pixmap;
|
||||||
|
@ -275,6 +277,7 @@ void GameListModel::loadCommonImages()
|
||||||
// TODO: Use svg instead of png
|
// TODO: Use svg instead of png
|
||||||
m_type_disc_pixmap.load(QStringLiteral(":/icons/media-optical-24.png"));
|
m_type_disc_pixmap.load(QStringLiteral(":/icons/media-optical-24.png"));
|
||||||
m_type_exe_pixmap.load(QStringLiteral(":/icons/applications-system-24.png"));
|
m_type_exe_pixmap.load(QStringLiteral(":/icons/applications-system-24.png"));
|
||||||
|
m_type_playlist_pixmap.load(QStringLiteral(":/icons/address-book-new-22.png"));
|
||||||
m_region_eu_pixmap.load(QStringLiteral(":/icons/flag-eu.png"));
|
m_region_eu_pixmap.load(QStringLiteral(":/icons/flag-eu.png"));
|
||||||
m_region_jp_pixmap.load(QStringLiteral(":/icons/flag-jp.png"));
|
m_region_jp_pixmap.load(QStringLiteral(":/icons/flag-jp.png"));
|
||||||
m_region_us_pixmap.load(QStringLiteral(":/icons/flag-us.png"));
|
m_region_us_pixmap.load(QStringLiteral(":/icons/flag-us.png"));
|
||||||
|
|
|
@ -53,6 +53,7 @@ private:
|
||||||
|
|
||||||
QPixmap m_type_disc_pixmap;
|
QPixmap m_type_disc_pixmap;
|
||||||
QPixmap m_type_exe_pixmap;
|
QPixmap m_type_exe_pixmap;
|
||||||
|
QPixmap m_type_playlist_pixmap;
|
||||||
|
|
||||||
QPixmap m_region_jp_pixmap;
|
QPixmap m_region_jp_pixmap;
|
||||||
QPixmap m_region_eu_pixmap;
|
QPixmap m_region_eu_pixmap;
|
||||||
|
|
|
@ -29,7 +29,8 @@
|
||||||
|
|
||||||
static constexpr char DISC_IMAGE_FILTER[] =
|
static constexpr char DISC_IMAGE_FILTER[] =
|
||||||
"All File Types (*.bin *.img *.cue *.chd *.exe *.psexe *.psf);;Single-Track Raw Images (*.bin *.img);;Cue Sheets "
|
"All File Types (*.bin *.img *.cue *.chd *.exe *.psexe *.psf);;Single-Track Raw Images (*.bin *.img);;Cue Sheets "
|
||||||
"(*.cue);;MAME CHD Images (*.chd);;PlayStation Executables (*.exe *.psexe);;Portable Sound Format Files (*.psf)";
|
"(*.cue);;MAME CHD Images (*.chd);;PlayStation Executables (*.exe *.psexe);;Portable Sound Format Files "
|
||||||
|
"(*.psf);;Playlists (*.m3u)";
|
||||||
|
|
||||||
ALWAYS_INLINE static QString getWindowTitle()
|
ALWAYS_INLINE static QString getWindowTitle()
|
||||||
{
|
{
|
||||||
|
@ -294,6 +295,16 @@ void MainWindow::onChangeDiscFromGameListActionTriggered()
|
||||||
switchToGameListView();
|
switchToGameListView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::onChangeDiscFromPlaylistMenuAboutToShow()
|
||||||
|
{
|
||||||
|
m_host_interface->populatePlaylistEntryMenu(m_ui.menuChangeDiscFromPlaylist);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::onChangeDiscFromPlaylistMenuAboutToHide()
|
||||||
|
{
|
||||||
|
m_ui.menuChangeDiscFromPlaylist->clear();
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::onRemoveDiscActionTriggered()
|
void MainWindow::onRemoveDiscActionTriggered()
|
||||||
{
|
{
|
||||||
m_host_interface->changeDisc(QString());
|
m_host_interface->changeDisc(QString());
|
||||||
|
@ -567,6 +578,10 @@ void MainWindow::connectSignals()
|
||||||
connect(m_ui.actionChangeDiscFromFile, &QAction::triggered, this, &MainWindow::onChangeDiscFromFileActionTriggered);
|
connect(m_ui.actionChangeDiscFromFile, &QAction::triggered, this, &MainWindow::onChangeDiscFromFileActionTriggered);
|
||||||
connect(m_ui.actionChangeDiscFromGameList, &QAction::triggered, this,
|
connect(m_ui.actionChangeDiscFromGameList, &QAction::triggered, this,
|
||||||
&MainWindow::onChangeDiscFromGameListActionTriggered);
|
&MainWindow::onChangeDiscFromGameListActionTriggered);
|
||||||
|
connect(m_ui.menuChangeDiscFromPlaylist, &QMenu::aboutToShow, this,
|
||||||
|
&MainWindow::onChangeDiscFromPlaylistMenuAboutToShow);
|
||||||
|
connect(m_ui.menuChangeDiscFromPlaylist, &QMenu::aboutToHide, this,
|
||||||
|
&MainWindow::onChangeDiscFromPlaylistMenuAboutToHide);
|
||||||
connect(m_ui.actionRemoveDisc, &QAction::triggered, this, &MainWindow::onRemoveDiscActionTriggered);
|
connect(m_ui.actionRemoveDisc, &QAction::triggered, this, &MainWindow::onRemoveDiscActionTriggered);
|
||||||
connect(m_ui.actionAddGameDirectory, &QAction::triggered,
|
connect(m_ui.actionAddGameDirectory, &QAction::triggered,
|
||||||
[this]() { getSettingsDialog()->getGameListSettingsWidget()->addSearchDirectory(this); });
|
[this]() { getSettingsDialog()->getGameListSettingsWidget()->addSearchDirectory(this); });
|
||||||
|
|
|
@ -55,6 +55,8 @@ private Q_SLOTS:
|
||||||
void onStartBIOSActionTriggered();
|
void onStartBIOSActionTriggered();
|
||||||
void onChangeDiscFromFileActionTriggered();
|
void onChangeDiscFromFileActionTriggered();
|
||||||
void onChangeDiscFromGameListActionTriggered();
|
void onChangeDiscFromGameListActionTriggered();
|
||||||
|
void onChangeDiscFromPlaylistMenuAboutToShow();
|
||||||
|
void onChangeDiscFromPlaylistMenuAboutToHide();
|
||||||
void onRemoveDiscActionTriggered();
|
void onRemoveDiscActionTriggered();
|
||||||
void onGitHubRepositoryActionTriggered();
|
void onGitHubRepositoryActionTriggered();
|
||||||
void onIssueTrackerActionTriggered();
|
void onIssueTrackerActionTriggered();
|
||||||
|
|
|
@ -45,8 +45,14 @@
|
||||||
<iconset resource="resources/icons.qrc">
|
<iconset resource="resources/icons.qrc">
|
||||||
<normaloff>:/icons/media-optical.png</normaloff>:/icons/media-optical.png</iconset>
|
<normaloff>:/icons/media-optical.png</normaloff>:/icons/media-optical.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
|
<widget class="QMenu" name="menuChangeDiscFromPlaylist">
|
||||||
|
<property name="title">
|
||||||
|
<string>From Playlist...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
<addaction name="actionChangeDiscFromFile"/>
|
<addaction name="actionChangeDiscFromFile"/>
|
||||||
<addaction name="actionChangeDiscFromGameList"/>
|
<addaction name="actionChangeDiscFromGameList"/>
|
||||||
|
<addaction name="menuChangeDiscFromPlaylist"/>
|
||||||
<addaction name="actionRemoveDisc"/>
|
<addaction name="actionRemoveDisc"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menuLoadState">
|
<widget class="QMenu" name="menuLoadState">
|
||||||
|
|
|
@ -808,6 +808,21 @@ void QtHostInterface::changeDisc(const QString& new_disc_filename)
|
||||||
System::RemoveMedia();
|
System::RemoveMedia();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QtHostInterface::changeDiscFromPlaylist(quint32 index)
|
||||||
|
{
|
||||||
|
if (!isOnWorkerThread())
|
||||||
|
{
|
||||||
|
QMetaObject::invokeMethod(this, "changeDiscFromPlaylist", Qt::QueuedConnection, Q_ARG(quint32, index));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (System::IsShutdown())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!System::SwitchMediaFromPlaylist(index))
|
||||||
|
ReportFormattedError("Failed to switch to playlist index %u", index);
|
||||||
|
}
|
||||||
|
|
||||||
static QString FormatTimestampForSaveStateMenu(u64 timestamp)
|
static QString FormatTimestampForSaveStateMenu(u64 timestamp)
|
||||||
{
|
{
|
||||||
const QDateTime qtime(QDateTime::fromSecsSinceEpoch(static_cast<qint64>(timestamp)));
|
const QDateTime qtime(QDateTime::fromSecsSinceEpoch(static_cast<qint64>(timestamp)));
|
||||||
|
@ -909,6 +924,24 @@ void QtHostInterface::populateGameListContextMenu(const char* game_code, QWidget
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QtHostInterface::populatePlaylistEntryMenu(QMenu* menu)
|
||||||
|
{
|
||||||
|
if (!System::IsValid())
|
||||||
|
return;
|
||||||
|
|
||||||
|
QActionGroup* ag = new QActionGroup(menu);
|
||||||
|
const u32 count = System::GetMediaPlaylistCount();
|
||||||
|
const u32 current = System::GetMediaPlaylistIndex();
|
||||||
|
for (u32 i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
QAction* action = ag->addAction(QString::fromStdString(System::GetMediaPlaylistPath(i)));
|
||||||
|
action->setCheckable(true);
|
||||||
|
action->setChecked(i == current);
|
||||||
|
connect(action, &QAction::triggered, [this, i]() { changeDiscFromPlaylist(i); });
|
||||||
|
menu->addAction(action);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void QtHostInterface::loadState(const QString& filename)
|
void QtHostInterface::loadState(const QString& filename)
|
||||||
{
|
{
|
||||||
if (!isOnWorkerThread())
|
if (!isOnWorkerThread())
|
||||||
|
|
|
@ -84,6 +84,9 @@ public:
|
||||||
/// Fills menu with save state info and handlers.
|
/// Fills menu with save state info and handlers.
|
||||||
void populateGameListContextMenu(const char* game_code, QWidget* parent_window, QMenu* menu);
|
void populateGameListContextMenu(const char* game_code, QWidget* parent_window, QMenu* menu);
|
||||||
|
|
||||||
|
/// Fills menu with the current playlist entries. The disc index is marked as checked.
|
||||||
|
void populatePlaylistEntryMenu(QMenu* menu);
|
||||||
|
|
||||||
ALWAYS_INLINE QString getSavePathForInputProfile(const QString& name) const
|
ALWAYS_INLINE QString getSavePathForInputProfile(const QString& name) const
|
||||||
{
|
{
|
||||||
return QString::fromStdString(GetSavePathForInputProfile(name.toUtf8().constData()));
|
return QString::fromStdString(GetSavePathForInputProfile(name.toUtf8().constData()));
|
||||||
|
@ -140,6 +143,7 @@ public Q_SLOTS:
|
||||||
void resetSystem();
|
void resetSystem();
|
||||||
void pauseSystem(bool paused);
|
void pauseSystem(bool paused);
|
||||||
void changeDisc(const QString& new_disc_filename);
|
void changeDisc(const QString& new_disc_filename);
|
||||||
|
void changeDiscFromPlaylist(quint32 index);
|
||||||
void loadState(const QString& filename);
|
void loadState(const QString& filename);
|
||||||
void loadState(bool global, qint32 slot);
|
void loadState(bool global, qint32 slot);
|
||||||
void saveState(bool global, qint32 slot, bool block_until_done = false);
|
void saveState(bool global, qint32 slot, bool block_until_done = false);
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
<file>icons/star-3.png</file>
|
<file>icons/star-3.png</file>
|
||||||
<file>icons/star-4.png</file>
|
<file>icons/star-4.png</file>
|
||||||
<file>icons/star-5.png</file>
|
<file>icons/star-5.png</file>
|
||||||
|
<file>icons/address-book-new-22.png</file>
|
||||||
<file>icons/applications-internet.png</file>
|
<file>icons/applications-internet.png</file>
|
||||||
<file>icons/system-search.png</file>
|
<file>icons/system-search.png</file>
|
||||||
<file>icons/list-add.png</file>
|
<file>icons/list-add.png</file>
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 924 B |
|
@ -12,6 +12,7 @@
|
||||||
<file>icons/star-3.png</file>
|
<file>icons/star-3.png</file>
|
||||||
<file>icons/star-4.png</file>
|
<file>icons/star-4.png</file>
|
||||||
<file>icons/star-5.png</file>
|
<file>icons/star-5.png</file>
|
||||||
|
<file>icons/address-book-new-22.png</file>
|
||||||
<file>icons/applications-internet.png</file>
|
<file>icons/applications-internet.png</file>
|
||||||
<file>icons/system-search.png</file>
|
<file>icons/system-search.png</file>
|
||||||
<file>icons/list-add.png</file>
|
<file>icons/list-add.png</file>
|
||||||
|
|
Loading…
Reference in New Issue