1
0
mirror of https://github.com/libretro/RetroArch synced 2024-07-03 00:38:44 +00:00

Qt: add UI option to set startup playlist, fixes #7103

This commit is contained in:
Brad Parker 2018-08-26 17:17:39 -04:00
parent 12f1d003bb
commit 9638005332
7 changed files with 56 additions and 1 deletions

View File

@ -3792,3 +3792,5 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_DOWNLOAD_THUMBNAIL,
"サムネイルをダウンロード")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_DOWNLOAD_ALREADY_IN_PROGRESS,
"他のダウンロードが実行中です。")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_STARTUP_PLAYLIST,
"起動時に表示するプレイリスト:")

View File

@ -7390,3 +7390,5 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_DOWNLOAD_THUMBNAIL,
"Download thumbnail")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_DOWNLOAD_ALREADY_IN_PROGRESS,
"A download is already in progress.")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_STARTUP_PLAYLIST,
"Start on playlist:")

View File

@ -1913,6 +1913,7 @@ enum msg_hash_enums
MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SHOW_HIDDEN_FILES,
MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_ALL_PLAYLISTS_LIST_MAX_COUNT,
MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_ALL_PLAYLISTS_GRID_MAX_COUNT,
MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_STARTUP_PLAYLIST,
MENU_ENUM_LABEL_VALUE_QT_MENU_TOOLS,
MENU_ENUM_LABEL_VALUE_QT_MENU_HELP,
MENU_ENUM_LABEL_VALUE_QT_MENU_DOCK_CONTENT_BROWSER,

View File

@ -605,6 +605,33 @@ MainWindow::~MainWindow()
removeGridItems();
}
QVector<QPair<QString, QString> > MainWindow::getPlaylists()
{
QVector<QPair<QString, QString> > playlists;
int i;
for (i = 0; i < m_listWidget->count(); i++)
{
QListWidgetItem *item = m_listWidget->item(i);
QPair<QString, QString> pair;
QString label;
QString path;
if (!item)
continue;
label = item->text();
path = item->data(Qt::UserRole).toString();
pair.first = label;
pair.second = path;
playlists.append(pair);
}
return playlists;
}
void MainWindow::onItemChanged()
{
ViewType viewType = getCurrentViewType();
@ -633,7 +660,7 @@ QString MainWindow::getSpecialPlaylistPath(SpecialPlaylist playlist)
switch (playlist)
{
case SPECIAL_PLAYLIST_HISTORY:
return m_historyPlaylistsItem->data(Qt::UserRole).toString();
return (m_historyPlaylistsItem ? m_historyPlaylistsItem->data(Qt::UserRole).toString() : QString());
default:
return QString();
}

View File

@ -27,6 +27,7 @@ ViewOptionsDialog::ViewOptionsDialog(MainWindow *mainwindow, QWidget *parent) :
,m_saveLastTabCheckBox(new QCheckBox(this))
,m_showHiddenFilesCheckBox(new QCheckBox(this))
,m_themeComboBox(new QComboBox(this))
,m_startupPlaylistComboBox(new QComboBox(this))
,m_highlightColorPushButton(new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_CHOOSE), this))
,m_highlightColor()
,m_highlightColorLabel(new QLabel(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_HIGHLIGHT_COLOR), this))
@ -65,6 +66,7 @@ ViewOptionsDialog::ViewOptionsDialog(MainWindow *mainwindow, QWidget *parent) :
form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SUGGEST_LOADED_CORE_FIRST), m_suggestLoadedCoreFirstCheckBox);
form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_ALL_PLAYLISTS_LIST_MAX_COUNT), m_allPlaylistsListMaxCountSpinBox);
form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_ALL_PLAYLISTS_GRID_MAX_COUNT), m_allPlaylistsGridMaxCountSpinBox);
form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_STARTUP_PLAYLIST), m_startupPlaylistComboBox);
form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_THEME), m_themeComboBox);
form->addRow(m_highlightColorLabel, m_highlightColorPushButton);
@ -133,7 +135,11 @@ void ViewOptionsDialog::loadViewOptions()
{
QColor highlightColor = m_settings->value("highlight_color", QApplication::palette().highlight().color()).value<QColor>();
QPixmap highlightPixmap(m_highlightColorPushButton->iconSize());
QVector<QPair<QString, QString> > playlists = m_mainwindow->getPlaylists();
QString initialPlaylist = m_settings->value("initial_playlist", m_mainwindow->getSpecialPlaylistPath(SPECIAL_PLAYLIST_HISTORY)).toString();
int themeIndex = 0;
int playlistIndex = 0;
int i;
m_saveGeometryCheckBox->setChecked(m_settings->value("save_geometry", false).toBool());
m_saveDockPositionsCheckBox->setChecked(m_settings->value("save_dock_positions", false).toBool());
@ -156,6 +162,20 @@ void ViewOptionsDialog::loadViewOptions()
}
showOrHideHighlightColor();
m_startupPlaylistComboBox->clear();
for (i = 0; i < playlists.count(); i++)
{
const QPair<QString, QString> &pair = playlists.at(i);
m_startupPlaylistComboBox->addItem(pair.first, pair.second);
}
playlistIndex = m_startupPlaylistComboBox->findData(initialPlaylist, Qt::UserRole, Qt::MatchFixedString);
if (playlistIndex >= 0)
m_startupPlaylistComboBox->setCurrentIndex(playlistIndex);
}
void ViewOptionsDialog::showOrHideHighlightColor()
@ -183,6 +203,7 @@ void ViewOptionsDialog::saveViewOptions()
m_settings->setValue("suggest_loaded_core_first", m_suggestLoadedCoreFirstCheckBox->isChecked());
m_settings->setValue("all_playlists_list_max_count", m_allPlaylistsListMaxCountSpinBox->value());
m_settings->setValue("all_playlists_grid_max_count", m_allPlaylistsGridMaxCountSpinBox->value());
m_settings->setValue("initial_playlist", m_startupPlaylistComboBox->currentData(Qt::UserRole).toString());
if (!m_mainwindow->customThemeString().isEmpty())
m_settings->setValue("custom_theme", m_customThemePath);

View File

@ -37,6 +37,7 @@ private:
QCheckBox *m_saveLastTabCheckBox;
QCheckBox *m_showHiddenFilesCheckBox;
QComboBox *m_themeComboBox;
QComboBox *m_startupPlaylistComboBox;
QPushButton *m_highlightColorPushButton;
QColor m_highlightColor;
QLabel *m_highlightColorLabel;

View File

@ -285,6 +285,7 @@ public:
QHash<QString, QString> getCurrentContentHash();
static double lerp(double x, double y, double a, double b, double d);
QString getSpecialPlaylistPath(SpecialPlaylist playlist);
QVector<QPair<QString, QString> > getPlaylists();
signals:
void thumbnailChanged(const QPixmap &pixmap);