Settings pointer cleanups

This commit is contained in:
twinaphex 2020-02-19 20:57:02 +01:00
parent ab94af68c1
commit 85c672a0f6
14 changed files with 590 additions and 462 deletions

View File

@ -491,13 +491,14 @@ static void *wasapi_init(const char *dev_id, unsigned rate, unsigned latency,
BYTE *dest = NULL;
settings_t *settings = config_get_ptr();
bool float_format = settings->bools.audio_wasapi_float_format;
bool exclusive_mode = settings->bools.audio_wasapi_exclusive_mode;
int sh_buffer_length = settings->ints.audio_wasapi_sh_buffer_length;
wasapi_t *w = (wasapi_t*)calloc(1, sizeof(wasapi_t));
if (!w)
return NULL;
w->exclusive = settings->bools.audio_wasapi_exclusive_mode;
w->exclusive = exclusive_mode;
w->device = wasapi_init_device(dev_id);
if (!w->device && dev_id)
w->device = wasapi_init_device(NULL);

View File

@ -75,18 +75,21 @@ void libnx_apply_overclock(void)
{
const size_t profiles_count = sizeof(SWITCH_CPU_PROFILES)
/ sizeof(SWITCH_CPU_PROFILES[1]);
settings_t *settings = config_get_ptr();
unsigned libnx_overclock = settings->uints.libnx_overclock;
if (config_get_ptr()->uints.libnx_overclock >= 0 && config_get_ptr()->uints.libnx_overclock <= profiles_count)
if (libnx_overclock >= 0 && libnx_overclock <= profiles_count)
{
if (hosversionBefore(8, 0, 0))
{
pcvSetClockRate(PcvModule_CpuBus, SWITCH_CPU_SPEEDS_VALUES[config_get_ptr()->uints.libnx_overclock]);
pcvSetClockRate(PcvModule_CpuBus, SWITCH_CPU_SPEEDS_VALUES[
libnx_overclock]);
}
else
{
ClkrstSession session = {0};
clkrstOpenSession(&session, PcvModuleId_CpuBus, 3);
clkrstSetClockRate(&session, SWITCH_CPU_SPEEDS_VALUES[config_get_ptr()->uints.libnx_overclock]);
clkrstSetClockRate(&session, SWITCH_CPU_SPEEDS_VALUES[libnx_overclock]);
clkrstCloseSession(&session);
}
}

View File

@ -2700,7 +2700,7 @@ static void menu_input_st_string_cb_enable_settings(void *userdata,
{
if (str && *str)
{
const char *label = menu_input_dialog_get_buffer();
const char *label = menu_input_dialog_get_buffer();
settings_t *settings = config_get_ptr();
if (string_is_equal(label, settings->paths.menu_content_show_settings_password))
@ -3301,7 +3301,9 @@ static int action_ok_set_switch_cpu_profile(const char *path,
snprintf(command, sizeof(command), "Current profile set to %s", profile_name);
#else
unsigned profile_clock = SWITCH_CPU_SPEEDS_VALUES[entry_idx];
config_get_ptr()->uints.libnx_overclock = entry_idx;
settings_t *settings = config_get_ptr();
settings->uints.libnx_overclock = entry_idx;
if (hosversionBefore(8, 0, 0))
pcvSetClockRate(PcvModule_CpuBus, (u32)profile_clock);
@ -4076,7 +4078,7 @@ void cb_generic_download(retro_task_t *task,
bool extract = true;
#endif
const char *dir_path = NULL;
file_transfer_t *transf = (file_transfer_t*)user_data;
file_transfer_t *transf = (file_transfer_t*)user_data;
settings_t *settings = config_get_ptr();
http_transfer_data_t *data = (http_transfer_data_t*)task_data;
@ -4256,7 +4258,7 @@ static int action_ok_download_generic(const char *path,
char s[PATH_MAX_LENGTH];
char s2[PATH_MAX_LENGTH];
char s3[PATH_MAX_LENGTH];
file_transfer_t *transf = NULL;
file_transfer_t *transf = NULL;
settings_t *settings = config_get_ptr();
bool suppress_msg = false;
retro_task_callback_t cb = cb_generic_download;

View File

@ -329,16 +329,20 @@ static bool netplay_poll(netplay_t *netplay)
if (netplay->frame_run_time_avg || netplay->stateless_mode)
{
/* FIXME: Using fixed 60fps for this calculation */
unsigned frames_per_frame = netplay->frame_run_time_avg ?
unsigned frames_per_frame = netplay->frame_run_time_avg ?
(16666 / netplay->frame_run_time_avg) :
0;
unsigned frames_ahead = (netplay->run_frame_count > netplay->unread_frame_count) ?
unsigned frames_ahead = (netplay->run_frame_count > netplay->unread_frame_count) ?
(netplay->run_frame_count - netplay->unread_frame_count) :
0;
settings_t *settings = config_get_ptr();
int input_latency_frames_min = settings->uints.netplay_input_latency_frames_min -
(settings->bools.run_ahead_enabled ? settings->uints.run_ahead_frames : 0);
int input_latency_frames_max = input_latency_frames_min + settings->uints.netplay_input_latency_frames_range;
settings_t *settings = config_get_ptr();
unsigned netplay_frames_min = settings->uints.netplay_input_latency_frames_min;
unsigned netplay_frames_range = settings->uints.netplay_input_latency_frames_range;
bool runahead_enabled = settings->bools.run_ahead_enabled;
unsigned runahead_frames = settings->uints.run_ahead_frames;
int input_latency_frames_min = netplay_frames_min -
(runahead_enabled ? runahead_frames : 0);
int input_latency_frames_max = input_latency_frames_min + netplay_frames_range;
/* Assume we need a couple frames worth of time to actually run the
* current frame */
@ -992,12 +996,14 @@ static void netplay_frontend_paused(netplay_t *netplay, bool paused)
**/
static bool netplay_pre_frame(netplay_t *netplay)
{
bool sync_stalled = false;
settings_t *settings = config_get_ptr();
bool sync_stalled = false;
settings_t *settings = config_get_ptr();
bool netplay_public_announce = settings->bools.netplay_public_announce;
bool netplay_use_mitm_server = settings->bools.netplay_use_mitm_server;
retro_assert(netplay);
if (settings->bools.netplay_public_announce)
if (netplay_public_announce)
{
reannounce++;
if ((netplay->is_server || is_mitm) && (reannounce % 600 == 0))
@ -1015,7 +1021,7 @@ static bool netplay_pre_frame(netplay_t *netplay)
if (netplay->quirks & NETPLAY_QUIRK_INITIALIZATION)
netplay_try_init_serialization(netplay);
if (netplay->is_server && !settings->bools.netplay_use_mitm_server)
if (netplay->is_server && !netplay_use_mitm_server)
{
/* Advertise our server */
netplay_lan_ad_server(netplay);
@ -1465,7 +1471,8 @@ bool init_netplay(void *direct_host, const char *server, unsigned port)
settings->bools.netplay_stateless_mode,
settings->ints.netplay_check_frames,
&cbs,
settings->bools.netplay_nat_traversal && !settings->bools.netplay_use_mitm_server,
settings->bools.netplay_nat_traversal
&& !settings->bools.netplay_use_mitm_server,
#ifdef HAVE_DISCORD
discord_get_own_username() ? discord_get_own_username() :
#endif

View File

@ -38,7 +38,7 @@ extern "C" {
PlaylistModel::PlaylistModel(QObject *parent)
: QAbstractListModel(parent)
{
m_imageFormats = QVector<QByteArray>::fromList(QImageReader::supportedImageFormats());
m_imageFormats = QVector<QByteArray>::fromList(QImageReader::supportedImageFormats());
m_fileSanitizerRegex = QRegularExpression("[&*/:`<>?\\|]");
setThumbnailCacheLimit(500);
connect(this, &PlaylistModel::imageLoaded, this, &PlaylistModel::onImageLoaded);
@ -98,7 +98,7 @@ bool PlaylistModel::setData(const QModelIndex &index, const QVariant &value, int
{
QHash<QString, QString> hash = m_contents.at(index.row());
hash["label"] = value.toString();
hash["label"] = value.toString();
hash["label_noext"] = QFileInfo(value.toString()).completeBaseName();
m_contents.replace(index.row(), hash);
@ -108,7 +108,8 @@ bool PlaylistModel::setData(const QModelIndex &index, const QVariant &value, int
return false;
}
QVariant PlaylistModel::headerData(int section, Qt::Orientation orientation, int role) const
QVariant PlaylistModel::headerData(int section,
Qt::Orientation orientation, int role) const
{
if (role != Qt::DisplayRole)
return QVariant();
@ -128,23 +129,25 @@ void PlaylistModel::setThumbnailCacheLimit(int limit)
m_cache.setMaxCost(limit * 1024);
}
QString PlaylistModel::getThumbnailPath(const QModelIndex &index, QString type) const
QString PlaylistModel::getThumbnailPath(const QModelIndex &index,
QString type) const
{
return getThumbnailPath(m_contents.at(index.row()), type);
}
QString PlaylistModel::getPlaylistThumbnailsDir(const QString playlistName) const
QString PlaylistModel::getPlaylistThumbnailsDir(
const QString playlistName) const
{
return QDir::cleanPath(QString(config_get_ptr()->paths.directory_thumbnails)) + "/" + playlistName;
settings_t *settings = config_get_ptr();
const char *path_dir_thumbnails = settings->paths.directory_thumbnails;
return QDir::cleanPath(QString(path_dir_thumbnails)) + "/" + playlistName;
}
bool PlaylistModel::isSupportedImage(const QString path) const
{
int lastIndex = -1;
QByteArray extension;
QString extensionStr;
lastIndex = path.lastIndexOf('.');
int lastIndex = path.lastIndexOf('.');
if (lastIndex >= 0)
{
@ -167,11 +170,9 @@ QString PlaylistModel::getSanitizedThumbnailName(QString label) const
QString PlaylistModel::getThumbnailPath(const QHash<QString, QString> &hash, QString type) const
{
/* use thumbnail widgets to show regular image files */
if (isSupportedImage(hash["path"]))
{
/* use thumbnail widgets to show regular image files */
return hash["path"];
}
return getPlaylistThumbnailsDir(hash.value("db_name"))
+ "/" + type + "/" + getSanitizedThumbnailName(hash["label_noext"]);
@ -207,9 +208,11 @@ void PlaylistModel::reloadSystemThumbnails(const QString system)
{
int i = 0;
QString key;
QString path = QDir::cleanPath(QString(config_get_ptr()->paths.directory_thumbnails)) + "/" + system;
QList<QString> keys = m_cache.keys();
QList<QString> pending = m_pendingImages.values();
settings_t *settings = config_get_ptr();
const char *path_dir_thumbnails = settings->paths.directory_thumbnails;
QString path = QDir::cleanPath(QString(path_dir_thumbnails)) + "/" + system;
QList<QString> keys = m_cache.keys();
QList<QString> pending = m_pendingImages.values();
for (i = 0; i < keys.size(); i++)
{
@ -253,7 +256,7 @@ void PlaylistModel::loadImage(const QModelIndex &index, const QString &path)
void PlaylistModel::onImageLoaded(const QImage image, const QModelIndex &index, const QString &path)
{
QPixmap *pixmap = new QPixmap(QPixmap::fromImage(image));
const int cost = pixmap->width() * pixmap->height() * pixmap->depth() / (8 * 1024);
const int cost = pixmap->width() * pixmap->height() * pixmap->depth() / (8 * 1024);
m_cache.insert(path, pixmap, cost);
if (index.isValid())
emit dataChanged(index, index, { THUMBNAIL });
@ -268,9 +271,9 @@ inline static bool comp_hash_name_key_lower(const QHash<QString, QString> &lhs,
bool MainWindow::addDirectoryFilesToList(QProgressDialog *dialog,
QStringList &list, QDir &dir, QStringList &extensions)
{
PlaylistEntryDialog *playlistDialog = playlistEntryDialog();
QStringList dirList = dir.entryList(QStringList(), QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System, QDir::Name);
int i;
PlaylistEntryDialog *playlistDialog = playlistEntryDialog();
QStringList dirList = dir.entryList(QStringList(), QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System, QDir::Name);
for (i = 0; i < dirList.count(); i++)
{
@ -320,17 +323,23 @@ bool MainWindow::addDirectoryFilesToList(QProgressDialog *dialog,
{
if (archive_list->size == 1)
{
/* Assume archives with one file should have that file loaded directly.
* Don't just extend this to add all files in a zip, because we might hit
* something like MAME/FBA where only the archives themselves are valid content. */
/* Assume archives with one file should have
* that file loaded directly.
* Don't just extend this to add all files
* in a ZIP, because we might hit something like
* MAME/FBA where only the archives themselves
* are valid content. */
pathArray = (QString(pathData) + "#"
+ archive_list->elems[0].data).toUtf8();
pathData = pathArray.constData();
if (!extensions.isEmpty() && playlistDialog->filterInArchive())
{
/* If the user chose to filter extensions inside archives, and this particular file inside the archive
* doesn't have one of the chosen extensions, then we skip it. */
/* If the user chose to filter extensions
* inside archives, and this particular file
* inside the archive
* doesn't have one of the chosen extensions,
* then we skip it. */
if (extensions.contains(QFileInfo(pathData).suffix()))
add = true;
}
@ -355,13 +364,14 @@ void MainWindow::onPlaylistFilesDropped(QStringList files)
addFilesToPlaylist(files);
}
/* Takes a list of files and folders and adds them to the currently selected playlist. Folders will have their contents added recursively. */
/* Takes a list of files and folders and adds them to the
* currently selected playlist. Folders will have their
* contents added recursively. */
void MainWindow::addFilesToPlaylist(QStringList files)
{
int i;
QStringList list;
QString currentPlaylistPath;
QListWidgetItem *currentItem = m_listWidget->currentItem();
QByteArray currentPlaylistArray;
QScopedPointer<QProgressDialog> dialog(NULL);
QHash<QString, QString> selectedCore;
@ -370,17 +380,20 @@ void MainWindow::addFilesToPlaylist(QStringList files)
QString selectedName;
QString selectedPath;
QStringList selectedExtensions;
QListWidgetItem *currentItem = m_listWidget->currentItem();
PlaylistEntryDialog *playlistDialog = playlistEntryDialog();
const char *currentPlaylistData = NULL;
playlist_t *playlist = NULL;
settings_t *settings = config_get_ptr();
bool playlist_use_old_format = settings->bools.playlist_use_old_format;
/* Assume a blank list means we will manually enter in all fields. */
if (files.isEmpty())
{
/* Make sure hash isn't blank, that would mean there's multiple entries to add at once. */
/* Make sure hash isn't blank, that would mean there's
* multiple entries to add at once. */
itemToAdd["label"] = "";
itemToAdd["path"] = "";
itemToAdd["path"] = "";
}
else if (files.count() == 1)
{
@ -390,7 +403,7 @@ void MainWindow::addFilesToPlaylist(QStringList files)
if (info.isFile())
{
itemToAdd["label"] = info.completeBaseName();
itemToAdd["path"] = path;
itemToAdd["path"] = path;
}
}
@ -401,7 +414,7 @@ void MainWindow::addFilesToPlaylist(QStringList files)
if (!currentPlaylistPath.isEmpty())
{
currentPlaylistArray = currentPlaylistPath.toUtf8();
currentPlaylistData = currentPlaylistArray.constData();
currentPlaylistData = currentPlaylistArray.constData();
}
}
@ -415,10 +428,10 @@ void MainWindow::addFilesToPlaylist(QStringList files)
if (!playlistDialog->showDialog(itemToAdd))
return;
selectedName = m_playlistEntryDialog->getSelectedName();
selectedPath = m_playlistEntryDialog->getSelectedPath();
selectedCore = m_playlistEntryDialog->getSelectedCore();
selectedDatabase = m_playlistEntryDialog->getSelectedDatabase();
selectedName = m_playlistEntryDialog->getSelectedName();
selectedPath = m_playlistEntryDialog->getSelectedPath();
selectedCore = m_playlistEntryDialog->getSelectedCore();
selectedDatabase = m_playlistEntryDialog->getSelectedDatabase();
selectedExtensions = m_playlistEntryDialog->getSelectedExtensions();
if (!selectedExtensions.isEmpty())
@ -435,8 +448,9 @@ void MainWindow::addFilesToPlaylist(QStringList files)
qApp->processEvents();
if (selectedName.isEmpty() || selectedPath.isEmpty() ||
selectedDatabase.isEmpty())
if ( selectedName.isEmpty()
|| selectedPath.isEmpty()
|| selectedDatabase.isEmpty())
{
showMessageBox(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_PLEASE_FILL_OUT_REQUIRED_FIELDS), MainWindow::MSGBOX_TYPE_ERROR, Qt::ApplicationModal, false);
return;
@ -461,7 +475,8 @@ void MainWindow::addFilesToPlaylist(QStringList files)
if (fileInfo.isDir())
{
QDir dir(path);
bool success = addDirectoryFilesToList(dialog.data(), list, dir, selectedExtensions);
bool success = addDirectoryFilesToList(
dialog.data(), list, dir, selectedExtensions);
if (!success)
return;
@ -482,9 +497,12 @@ void MainWindow::addFilesToPlaylist(QStringList files)
if (selectedExtensions.contains(fileInfo.suffix()))
add = true;
else if (playlistDialog->filterInArchive() && path_is_compressed_file(pathData))
else if (playlistDialog->filterInArchive()
&& path_is_compressed_file(pathData))
{
/* We'll add it here but really just delay the check until later when the archive contents are iterated. */
/* We'll add it here, but really just delay
* the check until later when the archive
* contents are iterated. */
add = true;
}
}
@ -500,25 +518,26 @@ void MainWindow::addFilesToPlaylist(QStringList files)
}
}
dialog->setLabelText(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_ADDING_FILES_TO_PLAYLIST));
dialog->setLabelText(msg_hash_to_str(
MENU_ENUM_LABEL_VALUE_QT_ADDING_FILES_TO_PLAYLIST));
dialog->setMaximum(list.count());
playlist = playlist_init(currentPlaylistData, COLLECTION_SIZE);
for (i = 0; i < list.count(); i++)
{
QString fileName = list.at(i);
QFileInfo fileInfo;
QByteArray fileBaseNameArray;
QByteArray pathArray;
QByteArray corePathArray;
QByteArray coreNameArray;
QByteArray databaseArray;
const char *pathData = NULL;
QString fileName = list.at(i);
const char *pathData = NULL;
const char *fileNameNoExten = NULL;
const char *corePathData = NULL;
const char *coreNameData = NULL;
const char *databaseData = NULL;
const char *corePathData = NULL;
const char *coreNameData = NULL;
const char *databaseData = NULL;
/* Cancel out of everything, the
* current progress will not be written
@ -532,28 +551,34 @@ void MainWindow::addFilesToPlaylist(QStringList files)
if (fileName.isEmpty())
continue;
/* a modal QProgressDialog calls processEvents() automatically in setValue() */
/* a modal QProgressDialog calls processEvents()
* automatically in setValue() */
dialog->setValue(i + 1);
fileInfo = fileName;
/* Make sure we're looking at a user-specified field and not just "<multiple>"
/* Make sure we're looking at a user-specified field
* and not just "<multiple>"
* in case it was a folder with one file in it */
if (files.count() == 1 && list.count() == 1 && i == 0 && playlistDialog->nameFieldEnabled())
if ( files.count() == 1
&& list.count() == 1
&& i == 0
&& playlistDialog->nameFieldEnabled())
{
fileBaseNameArray = selectedName.toUtf8();
pathArray = QDir::toNativeSeparators(selectedPath).toUtf8();
}
/* Otherwise just use the file name itself (minus extension) for the playlist entry title */
/* Otherwise just use the file name itself (minus extension)
* for the playlist entry title */
else
{
fileBaseNameArray = fileInfo.completeBaseName().toUtf8();
pathArray = QDir::toNativeSeparators(fileName).toUtf8();
pathArray = QDir::toNativeSeparators(fileName).toUtf8();
}
fileNameNoExten = fileBaseNameArray.constData();
fileNameNoExten = fileBaseNameArray.constData();
pathData = pathArray.constData();
pathData = pathArray.constData();
if (selectedCore.isEmpty())
{
@ -562,10 +587,11 @@ void MainWindow::addFilesToPlaylist(QStringList files)
}
else
{
corePathArray = QDir::toNativeSeparators(selectedCore.value("core_path")).toUtf8();
corePathArray = QDir::toNativeSeparators(
selectedCore.value("core_path")).toUtf8();
coreNameArray = selectedCore.value("core_name").toUtf8();
corePathData = corePathArray.constData();
coreNameData = coreNameArray.constData();
corePathData = corePathArray.constData();
coreNameData = coreNameArray.constData();
}
databaseArray = selectedDatabase.toUtf8();
@ -579,17 +605,25 @@ void MainWindow::addFilesToPlaylist(QStringList files)
{
if (list->size == 1)
{
/* Assume archives with one file should have that file loaded directly.
* Don't just extend this to add all files in a zip, because we might hit
* something like MAME/FBA where only the archives themselves are valid content. */
pathArray = QDir::toNativeSeparators(QString(pathData) + "#" + list->elems[0].data).toUtf8();
pathData = pathArray.constData();
/* Assume archives with one file should have that
* file loaded directly.
* Don't just extend this to add all files in a zip,
* because we might hit
* something like MAME/FBA where only the archives
* themselves are valid content. */
pathArray = QDir::toNativeSeparators(QString(pathData)
+ "#" + list->elems[0].data).toUtf8();
pathData = pathArray.constData();
if (!selectedExtensions.isEmpty() && playlistDialog->filterInArchive())
if ( !selectedExtensions.isEmpty()
&& playlistDialog->filterInArchive())
{
/* If the user chose to filter extensions inside archives, and this particular file inside the archive
* doesn't have one of the chosen extensions, then we skip it. */
if (!selectedExtensions.contains(QFileInfo(pathData).suffix()))
/* If the user chose to filter extensions inside archives,
* and this particular file inside the archive
* doesn't have one of the chosen extensions,
* then we skip it. */
if (!selectedExtensions.contains(
QFileInfo(pathData).suffix()))
{
string_list_free(list);
continue;
@ -603,8 +637,10 @@ void MainWindow::addFilesToPlaylist(QStringList files)
{
struct playlist_entry entry = {0};
bool fuzzy_archive_match = settings->bools.playlist_fuzzy_archive_match;
/* the push function reads our entry as const, so these casts are safe */
/* the push function reads our entry as const,
* so these casts are safe */
entry.path = const_cast<char*>(pathData);
entry.label = const_cast<char*>(fileNameNoExten);
entry.core_path = const_cast<char*>(corePathData);
@ -612,17 +648,18 @@ void MainWindow::addFilesToPlaylist(QStringList files)
entry.crc32 = const_cast<char*>("00000000|crc");
entry.db_name = const_cast<char*>(databaseData);
playlist_push(playlist, &entry, settings->bools.playlist_fuzzy_archive_match);
playlist_push(playlist, &entry, fuzzy_archive_match);
}
}
playlist_write_file(playlist, settings->bools.playlist_use_old_format);
playlist_write_file(playlist, playlist_use_old_format);
playlist_free(playlist);
reloadPlaylists();
}
bool MainWindow::updateCurrentPlaylistEntry(const QHash<QString, QString> &contentHash)
bool MainWindow::updateCurrentPlaylistEntry(
const QHash<QString, QString> &contentHash)
{
QString path;
QString label;
@ -637,7 +674,6 @@ bool MainWindow::updateCurrentPlaylistEntry(const QHash<QString, QString> &conte
QByteArray coreNameArray;
QByteArray dbNameArray;
QByteArray crc32Array;
settings_t *settings = config_get_ptr();
QString playlistPath = getCurrentPlaylistPath();
const char *playlistPathData = NULL;
const char *pathData = NULL;
@ -649,6 +685,8 @@ bool MainWindow::updateCurrentPlaylistEntry(const QHash<QString, QString> &conte
playlist_t *playlist = NULL;
unsigned index = 0;
bool ok = false;
settings_t *settings = config_get_ptr();
bool playlist_use_old_format = settings->bools.playlist_use_old_format;
if ( playlistPath.isEmpty() ||
contentHash.isEmpty() ||
@ -682,20 +720,20 @@ bool MainWindow::updateCurrentPlaylistEntry(const QHash<QString, QString> &conte
if (!dbName.isEmpty())
{
dbNameArray = (dbName + ".lpl").toUtf8();
dbNameData = dbNameArray.constData();
dbNameArray = (dbName + ".lpl").toUtf8();
dbNameData = dbNameArray.constData();
}
playlistPathData = playlistPathArray.constData();
pathData = pathArray.constData();
labelData = labelArray.constData();
coreNameData = coreNameArray.constData();
corePathData = corePathArray.constData();
playlistPathData = playlistPathArray.constData();
pathData = pathArray.constData();
labelData = labelArray.constData();
coreNameData = coreNameArray.constData();
corePathData = corePathArray.constData();
if (!crc32.isEmpty())
{
crc32Array = crc32.toUtf8();
crc32Data = crc32Array.constData();
crc32Array = crc32.toUtf8();
crc32Data = crc32Array.constData();
}
if (path_is_compressed_file(pathData))
@ -731,7 +769,7 @@ bool MainWindow::updateCurrentPlaylistEntry(const QHash<QString, QString> &conte
playlist_update(playlist, index, &entry);
}
playlist_write_file(playlist, settings->bools.playlist_use_old_format);
playlist_write_file(playlist, playlist_use_old_format);
playlist_free(playlist);
reloadPlaylists();
@ -741,7 +779,12 @@ bool MainWindow::updateCurrentPlaylistEntry(const QHash<QString, QString> &conte
void MainWindow::onPlaylistWidgetContextMenuRequested(const QPoint&)
{
settings_t *settings = config_get_ptr();
QString currentPlaylistDirPath;
QString currentPlaylistPath;
QString currentPlaylistFileName;
QFile currentPlaylistFile;
QFileInfo currentPlaylistFileInfo;
QMap<QString, const core_info_t*> coreList;
QScopedPointer<QMenu> menu;
QScopedPointer<QMenu> associateMenu;
QScopedPointer<QMenu> hiddenPlaylistsMenu;
@ -753,14 +796,11 @@ void MainWindow::onPlaylistWidgetContextMenuRequested(const QPoint&)
QScopedPointer<QAction> downloadAllThumbnailsEntireSystemAction;
QScopedPointer<QAction> downloadAllThumbnailsThisPlaylistAction;
QPointer<QAction> selectedAction;
QPoint cursorPos = QCursor::pos();
QDir playlistDir(settings->paths.directory_playlist);
QString currentPlaylistDirPath;
QString currentPlaylistPath;
QString currentPlaylistFileName;
QFile currentPlaylistFile;
QFileInfo currentPlaylistFileInfo;
QMap<QString, const core_info_t*> coreList;
QPoint cursorPos = QCursor::pos();
settings_t *settings = config_get_ptr();
const char *path_dir_playlist = settings->paths.directory_playlist;
bool playlist_use_old_format = settings->bools.playlist_use_old_format;
QDir playlistDir(path_dir_playlist);
QListWidgetItem *selectedItem = m_listWidget->itemAt(
m_listWidget->viewport()->mapFromGlobal(cursorPos));
QString playlistDirAbsPath = playlistDir.absolutePath();
@ -792,7 +832,10 @@ void MainWindow::onPlaylistWidgetContextMenuRequested(const QPoint&)
if (currentPlaylistFile.exists())
{
deletePlaylistAction.reset(new QAction(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_DELETE_PLAYLIST)) + "...", this));
deletePlaylistAction.reset(new QAction(
QString(msg_hash_to_str(
MENU_ENUM_LABEL_VALUE_QT_DELETE_PLAYLIST)) + "...",
this));
menu->addAction(deletePlaylistAction.data());
renamePlaylistAction.reset(new QAction(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_RENAME_PLAYLIST)) + "...", this));
@ -808,7 +851,7 @@ void MainWindow::onPlaylistWidgetContextMenuRequested(const QPoint&)
for (j = 0; j < m_listWidget->count(); j++)
{
QListWidgetItem *item = m_listWidget->item(j);
bool hidden = m_listWidget->isItemHidden(item);
bool hidden = m_listWidget->isItemHidden(item);
if (hidden)
{
@ -843,7 +886,7 @@ void MainWindow::onPlaylistWidgetContextMenuRequested(const QPoint&)
for (i = 0; i < core_info_list->count && core_info_list->count > 0; i++)
{
const core_info_t *core = &core_info_list->list[i];
const core_info_t *core = &core_info_list->list[i];
coreList[core->core_name] = core;
}
@ -853,9 +896,8 @@ void MainWindow::onPlaylistWidgetContextMenuRequested(const QPoint&)
while (coreListIterator.hasNext())
{
QString key;
QString key, name;
const core_info_t *core = NULL;
QString name;
QHash<QString, QString> hash;
coreListIterator.next();
@ -924,7 +966,8 @@ void MainWindow::onPlaylistWidgetContextMenuRequested(const QPoint&)
/* Load playlist, if required */
if (cachedPlaylist)
{
if (string_is_equal(currentPlaylistPathCString, playlist_get_conf_path(cachedPlaylist)))
if (string_is_equal(currentPlaylistPathCString,
playlist_get_conf_path(cachedPlaylist)))
{
playlist = cachedPlaylist;
loadPlaylist = false;
@ -953,8 +996,7 @@ void MainWindow::onPlaylistWidgetContextMenuRequested(const QPoint&)
}
/* Write changes to disk */
playlist_write_file(playlist,
settings->bools.playlist_use_old_format);
playlist_write_file(playlist, playlist_use_old_format);
/* Free playlist, if required */
if (loadPlaylist)
@ -1030,7 +1072,7 @@ void MainWindow::onPlaylistWidgetContextMenuRequested(const QPoint&)
if (row >= 0)
{
QString playlistPath = selectedAction->property("core_path").toString();
QString playlistPath = selectedAction->property("core_path").toString();
QFileInfo playlistFileInfo(playlistPath);
QString playlistFileName = playlistFileInfo.fileName();
@ -1074,20 +1116,21 @@ void MainWindow::onGotReloadPlaylists()
void MainWindow::reloadPlaylists()
{
QListWidgetItem *allPlaylistsItem = NULL;
QListWidgetItem *favoritesPlaylistsItem = NULL;
QListWidgetItem *imagePlaylistsItem = NULL;
QListWidgetItem *musicPlaylistsItem = NULL;
QListWidgetItem *videoPlaylistsItem = NULL;
QListWidgetItem *firstItem = NULL;
QListWidgetItem *currentItem = NULL;
settings_t *settings = config_get_ptr();
QDir playlistDir(settings->paths.directory_playlist);
QString currentPlaylistPath;
QStringList hiddenPlaylists = m_settings->value("hidden_playlists").toStringList();
int i = 0;
QString currentPlaylistPath;
QListWidgetItem *allPlaylistsItem = NULL;
QListWidgetItem *favoritesPlaylistsItem = NULL;
QListWidgetItem *imagePlaylistsItem = NULL;
QListWidgetItem *musicPlaylistsItem = NULL;
QListWidgetItem *videoPlaylistsItem = NULL;
QListWidgetItem *firstItem = NULL;
settings_t *settings = config_get_ptr();
const char *path_dir_playlist = settings->paths.directory_playlist;
QDir playlistDir(path_dir_playlist);
QStringList hiddenPlaylists = m_settings->value(
"hidden_playlists").toStringList();
currentItem = m_listWidget->currentItem();
QListWidgetItem *currentItem = m_listWidget->currentItem();
if (currentItem)
currentPlaylistPath = currentItem->data(Qt::UserRole).toString();
@ -1139,26 +1182,30 @@ void MainWindow::reloadPlaylists()
for (i = 0; i < m_playlistFiles.count(); i++)
{
QListWidgetItem *item = NULL;
const QString &file = m_playlistFiles.at(i);
QString fileDisplayName = file;
QString fileName = file;
bool hasIcon = false;
QIcon icon;
QString iconPath;
QListWidgetItem *item = NULL;
const QString &file = m_playlistFiles.at(i);
QString fileDisplayName = file;
QString fileName = file;
bool hasIcon = false;
fileDisplayName.remove(".lpl");
iconPath = QString(settings->paths.directory_assets) + ICON_PATH + fileDisplayName + ".png";
iconPath = QString(
settings->paths.directory_assets)
+ ICON_PATH
+ fileDisplayName
+ ".png";
hasIcon = QFile::exists(iconPath);
hasIcon = QFile::exists(iconPath);
if (hasIcon)
icon = QIcon(iconPath);
icon = QIcon(iconPath);
else
icon = m_folderIcon;
icon = m_folderIcon;
item = new QListWidgetItem(icon, fileDisplayName);
item = new QListWidgetItem(icon, fileDisplayName);
item->setFlags(item->flags() | Qt::ItemIsEditable);
item->setData(Qt::UserRole, playlistDir.absoluteFilePath(file));
@ -1179,15 +1226,15 @@ void MainWindow::reloadPlaylists()
if (firstItem)
{
bool foundCurrent = false;
bool foundInitial = false;
QString initialPlaylist = m_settings->value("initial_playlist", m_historyPlaylistsItem->data(Qt::UserRole).toString()).toString();
bool foundCurrent = false;
bool foundInitial = false;
QString initialPlaylist = m_settings->value("initial_playlist", m_historyPlaylistsItem->data(Qt::UserRole).toString()).toString();
QListWidgetItem *initialItem = NULL;
for (i = 0; i < m_listWidget->count(); i++)
{
QListWidgetItem *item = m_listWidget->item(i);
QString path;
QListWidgetItem *item = m_listWidget->item(i);
if (item)
{
@ -1195,13 +1242,17 @@ void MainWindow::reloadPlaylists()
if (!path.isEmpty())
{
/* don't break early here since we want to make sure we've found both initial and current items if they exist */
/* don't break early here since we want
* to make sure we've found both initial
* and current items if they exist */
if (!foundInitial && path == initialPlaylist)
{
foundInitial = true;
initialItem = item;
}
if (!foundCurrent && !currentPlaylistPath.isEmpty() && path == currentPlaylistPath)
if ( !foundCurrent
&& !currentPlaylistPath.isEmpty()
&& path == currentPlaylistPath)
{
foundCurrent = true;
m_listWidget->setCurrentItem(item);
@ -1216,7 +1267,8 @@ void MainWindow::reloadPlaylists()
m_listWidget->setCurrentItem(initialItem);
else
{
/* the previous playlist must be gone now, just select the first one */
/* the previous playlist must be gone now,
* just select the first one */
m_listWidget->setCurrentItem(firstItem);
}
}
@ -1322,6 +1374,7 @@ void MainWindow::deleteCurrentPlaylistItem()
QString MainWindow::getPlaylistDefaultCore(QString dbName)
{
char playlistPath[PATH_MAX_LENGTH];
settings_t *settings = config_get_ptr();
QByteArray dbNameByteArray = dbName.toUtf8();
const char *dbNameCString = dbNameByteArray.data();
@ -1329,7 +1382,6 @@ QString MainWindow::getPlaylistDefaultCore(QString dbName)
playlist_t *playlist = NULL;
bool loadPlaylist = true;
QString corePath = QString();
char playlistPath[PATH_MAX_LENGTH];
playlistPath[0] = '\0';
@ -1384,39 +1436,38 @@ void MainWindow::getPlaylistFiles()
void PlaylistModel::getPlaylistItems(QString path)
{
QByteArray pathArray;
const char *pathData = NULL;
playlist_t *playlist = NULL;
const char *pathData = NULL;
playlist_t *playlist = NULL;
unsigned playlistSize = 0;
unsigned i = 0;
unsigned i = 0;
pathArray.append(path);
pathData = pathArray.constData();
pathData = pathArray.constData();
playlist = playlist_init(pathData, COLLECTION_SIZE);
playlistSize = playlist_get_size(playlist);
playlist = playlist_init(pathData, COLLECTION_SIZE);
playlistSize = playlist_get_size(playlist);
for (i = 0; i < playlistSize; i++)
{
const struct playlist_entry *entry = NULL;
QHash<QString, QString> hash;
const struct playlist_entry *entry = NULL;
playlist_get_index(playlist, i, &entry);
if (string_is_empty(entry->path))
continue;
else
hash["path"] = entry->path;
hash["path"] = entry->path;
hash["index"] = QString::number(i);
if (string_is_empty(entry->label))
{
hash["label"] = entry->path;
hash["label"] = entry->path;
hash["label_noext"] = entry->path;
}
else
{
hash["label"] = entry->label;
hash["label"] = entry->label;
hash["label_noext"] = entry->label;
}
@ -1461,13 +1512,12 @@ void PlaylistModel::addPlaylistItems(const QStringList &paths, bool add)
void PlaylistModel::addDir(QString path, QFlags<QDir::Filter> showHidden)
{
QDir dir = path;
QStringList dirList;
int i = 0;
dirList = dir.entryList(QDir::NoDotAndDotDot |
QDir::Readable |
QDir::Files |
QDir dir = path;
int i = 0;
QStringList dirList =
dir.entryList(QDir::NoDotAndDotDot |
QDir::Readable |
QDir::Files |
showHidden,
QDir::Name);
@ -1480,9 +1530,10 @@ void PlaylistModel::addDir(QString path, QFlags<QDir::Filter> showHidden)
for (i = 0; i < dirList.count(); i++)
{
QString fileName = dirList.at(i);
QHash<QString, QString> hash;
QString filePath(QDir::toNativeSeparators(dir.absoluteFilePath(fileName)));
QString fileName = dirList.at(i);
QString filePath(
QDir::toNativeSeparators(dir.absoluteFilePath(fileName)));
QFileInfo fileInfo(filePath);
hash["path"] = filePath;

View File

@ -25,8 +25,9 @@ static const QRegularExpression decimalsRegex("%.(\\d)f");
inline void handleChange(rarch_setting_t *setting)
{
settings_t *settings = config_get_ptr();
config_get_ptr()->modified = true;
settings->modified = true;
if (setting->change_handler)
setting->change_handler(setting);

View File

@ -185,8 +185,7 @@ void ShaderParamsDialog::clearLayout()
void ShaderParamsDialog::getShaders(struct video_shader **menu_shader, struct video_shader **video_shader)
{
video_shader_ctx_t shader_info = {0};
struct video_shader *shader = menu_shader_get();
struct video_shader *shader = menu_shader_get();
if (menu_shader)
{
@ -227,11 +226,11 @@ void ShaderParamsDialog::getShaders(struct video_shader **menu_shader, struct vi
void ShaderParamsDialog::onFilterComboBoxIndexChanged(int)
{
QComboBox *comboBox = qobject_cast<QComboBox*>(sender());
QVariant passVariant;
int pass = 0;
bool ok = false;
struct video_shader *menu_shader = NULL;
QComboBox *comboBox = qobject_cast<QComboBox*>(sender());
int pass = 0;
bool ok = false;
struct video_shader *menu_shader = NULL;
struct video_shader *video_shader = NULL;
getShaders(&menu_shader, &video_shader);
@ -249,7 +248,9 @@ void ShaderParamsDialog::onFilterComboBoxIndexChanged(int)
if (!ok)
return;
if (menu_shader && pass >= 0 && pass < static_cast<int>(menu_shader->passes))
if ( menu_shader
&& (pass >= 0)
&& (pass < static_cast<int>(menu_shader->passes)))
{
QVariant data = comboBox->currentData();
@ -405,12 +406,12 @@ void ShaderParamsDialog::onShaderPassMoveDownClicked()
void ShaderParamsDialog::onShaderPassMoveUpClicked()
{
QToolButton *button = qobject_cast<QToolButton*>(sender());
QVariant passVariant;
struct video_shader *menu_shader = NULL;
int pass = 0;
bool ok = false;
struct video_shader *menu_shader = NULL;
struct video_shader *video_shader = NULL;
int pass = 0;
bool ok = false;
QToolButton *button = qobject_cast<QToolButton*>(sender());
getShaders(&menu_shader, &video_shader);
@ -487,9 +488,7 @@ void ShaderParamsDialog::onShaderLoadPresetClicked()
const char *pathData = NULL;
settings_t *settings = config_get_ptr();
enum rarch_shader_type type = RARCH_SHADER_NONE;
if (!settings)
return;
const char *path_dir_video_shader = settings->paths.directory_video_shader;
getShaders(&menu_shader, &video_shader);
@ -509,25 +508,27 @@ void ShaderParamsDialog::onShaderLoadPresetClicked()
filter += QLatin1Literal(" *") + ".slangp";
filter += ")";
path = QFileDialog::getOpenFileName(this, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET), settings->paths.directory_video_shader, filter);
path = QFileDialog::getOpenFileName(
this,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET),
path_dir_video_shader,
filter);
if (path.isEmpty())
return;
pathArray = path.toUtf8();
pathData = pathArray.constData();
type = video_shader_parse_type(pathData);
pathData = pathArray.constData();
type = video_shader_parse_type(pathData);
menu_shader_manager_set_preset(menu_shader, type, pathData, true);
}
void ShaderParamsDialog::onShaderResetPass(int pass)
{
struct video_shader *menu_shader = NULL;
struct video_shader *video_shader = NULL;
unsigned i;
struct video_shader *menu_shader = NULL;
struct video_shader *video_shader = NULL;
getShaders(&menu_shader, &video_shader);
@ -537,7 +538,8 @@ void ShaderParamsDialog::onShaderResetPass(int pass)
{
struct video_shader_parameter *param = &menu_shader->parameters[i];
/* if pass < 0, reset all params, otherwise only reset the selected pass */
/* if pass < 0, reset all params,
* otherwise only reset the selected pass */
if (pass >= 0 && param->pass != pass)
continue;
@ -551,7 +553,8 @@ void ShaderParamsDialog::onShaderResetPass(int pass)
{
struct video_shader_parameter *param = &video_shader->parameters[i];
/* if pass < 0, reset all params, otherwise only reset the selected pass */
/* if pass < 0, reset all params,
* otherwise only reset the selected pass */
if (pass >= 0 && param->pass != pass)
continue;
@ -566,15 +569,15 @@ void ShaderParamsDialog::onShaderResetPass(int pass)
void ShaderParamsDialog::onShaderResetParameter(QString parameter)
{
struct video_shader *menu_shader = NULL;
struct video_shader *menu_shader = NULL;
struct video_shader *video_shader = NULL;
getShaders(&menu_shader, &video_shader);
if (menu_shader)
{
struct video_shader_parameter *param = NULL;
int i;
struct video_shader_parameter *param = NULL;
for (i = 0; i < static_cast<int>(menu_shader->num_parameters); i++)
{
@ -590,8 +593,8 @@ void ShaderParamsDialog::onShaderResetParameter(QString parameter)
if (video_shader)
{
struct video_shader_parameter *param = NULL;
int i;
struct video_shader_parameter *param = NULL;
for (i = 0; i < static_cast<int>(video_shader->num_parameters); i++)
{
@ -624,9 +627,7 @@ void ShaderParamsDialog::onShaderAddPassClicked()
struct video_shader_pass *shader_pass = NULL;
const char *pathData = NULL;
settings_t *settings = config_get_ptr();
if (!settings)
return;
const char *path_dir_video_shader = settings->paths.directory_video_shader;
getShaders(&menu_shader, &video_shader);
@ -647,13 +648,17 @@ void ShaderParamsDialog::onShaderAddPassClicked()
filter += ")";
path = QFileDialog::getOpenFileName(this, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET), settings->paths.directory_video_shader, filter);
path = QFileDialog::getOpenFileName(
this,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET),
path_dir_video_shader,
filter);
if (path.isEmpty())
return;
pathArray = path.toUtf8();
pathData = pathArray.constData();
pathData = pathArray.constData();
if (menu_shader->passes < GFX_MAX_SHADERS)
menu_shader->passes++;
@ -667,7 +672,9 @@ void ShaderParamsDialog::onShaderAddPassClicked()
if (!shader_pass)
return;
strlcpy(shader_pass->source.path, pathData, sizeof(shader_pass->source.path));
strlcpy(shader_pass->source.path,
pathData,
sizeof(shader_pass->source.path));
video_shader_resolve_parameters(NULL, menu_shader);
@ -676,18 +683,17 @@ void ShaderParamsDialog::onShaderAddPassClicked()
void ShaderParamsDialog::onShaderSavePresetAsClicked()
{
settings_t *settings = config_get_ptr();
QString path;
QByteArray pathArray;
const char *pathData = NULL;
path = QFileDialog::getSaveFileName(this, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_AS), settings->paths.directory_video_shader);
const char *pathData = NULL;
settings_t *settings = config_get_ptr();
const char *path_dir_video_shader = settings->paths.directory_video_shader;
QString path = QFileDialog::getSaveFileName(this, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_AS), path_dir_video_shader);
if (path.isEmpty())
return;
pathArray = path.toUtf8();
pathData = pathArray.constData();
pathArray = path.toUtf8();
pathData = pathArray.constData();
operateShaderPreset(true, pathData, QT_SHADER_PRESET_NORMAL);
}
@ -697,7 +703,9 @@ void ShaderParamsDialog::operateShaderPreset(bool save, const char *path, unsign
{
bool ret;
enum auto_shader_type preset_type;
settings_t *settings = config_get_ptr();
settings_t *settings = config_get_ptr();
const char *path_dir_video_shader = settings->paths.directory_video_shader;
const char *path_dir_menu_config = settings->paths.directory_menu_config;
switch (action_type)
{
@ -722,15 +730,18 @@ void ShaderParamsDialog::operateShaderPreset(bool save, const char *path, unsign
if (save)
{
if (action_type == QT_SHADER_PRESET_NORMAL)
ret = menu_shader_manager_save_preset(menu_shader_get(), path,
settings->paths.directory_video_shader,
settings->paths.directory_menu_config,
ret = menu_shader_manager_save_preset(
menu_shader_get(),
path,
path_dir_video_shader,
path_dir_menu_config,
true);
else
ret = menu_shader_manager_save_auto_preset(menu_shader_get(),
ret = menu_shader_manager_save_auto_preset(
menu_shader_get(),
preset_type,
settings->paths.directory_video_shader,
settings->paths.directory_menu_config,
path_dir_video_shader,
path_dir_menu_config,
true);
if (ret)
@ -752,8 +763,8 @@ void ShaderParamsDialog::operateShaderPreset(bool save, const char *path, unsign
{
if (action_type != QT_SHADER_PRESET_NORMAL &&
menu_shader_manager_remove_auto_preset(preset_type,
settings->paths.directory_video_shader,
settings->paths.directory_menu_config))
path_dir_video_shader,
path_dir_menu_config))
{
#ifdef HAVE_MENU
bool refresh = false;
@ -891,26 +902,37 @@ void ShaderParamsDialog::onShaderApplyClicked()
void ShaderParamsDialog::updateRemovePresetButtonsState()
{
settings_t *settings = config_get_ptr();
settings_t *settings = config_get_ptr();
const char *path_dir_video_shader = settings->paths.directory_video_shader;
const char *path_dir_menu_config = settings->paths.directory_menu_config;
if (removeGlobalPresetAction)
removeGlobalPresetAction->setEnabled(menu_shader_manager_auto_preset_exists(SHADER_PRESET_GLOBAL,
settings->paths.directory_video_shader,
settings->paths.directory_menu_config
removeGlobalPresetAction->setEnabled(
menu_shader_manager_auto_preset_exists(
SHADER_PRESET_GLOBAL,
path_dir_video_shader,
path_dir_menu_config
));
if (removeCorePresetAction)
removeCorePresetAction->setEnabled(menu_shader_manager_auto_preset_exists(SHADER_PRESET_CORE,
settings->paths.directory_video_shader,
settings->paths.directory_menu_config
removeCorePresetAction->setEnabled(
menu_shader_manager_auto_preset_exists(
SHADER_PRESET_CORE,
path_dir_video_shader,
path_dir_menu_config
));
if (removeParentPresetAction)
removeParentPresetAction->setEnabled(menu_shader_manager_auto_preset_exists(SHADER_PRESET_PARENT,
settings->paths.directory_video_shader,
settings->paths.directory_menu_config
removeParentPresetAction->setEnabled(
menu_shader_manager_auto_preset_exists(
SHADER_PRESET_PARENT,
path_dir_video_shader,
path_dir_menu_config
));
if (removeGamePresetAction)
removeGamePresetAction->setEnabled(menu_shader_manager_auto_preset_exists(SHADER_PRESET_GAME,
settings->paths.directory_video_shader,
settings->paths.directory_menu_config
removeGamePresetAction->setEnabled(
menu_shader_manager_auto_preset_exists(
SHADER_PRESET_GAME,
path_dir_video_shader,
path_dir_menu_config
));
}
@ -921,30 +943,34 @@ void ShaderParamsDialog::reload()
void ShaderParamsDialog::buildLayout()
{
QPushButton *loadButton = NULL;
QPushButton *saveButton = NULL;
QPushButton *removeButton = NULL;
QPushButton *removePassButton = NULL;
QPushButton *applyButton = NULL;
QHBoxLayout *topButtonLayout = NULL;
QMenu *loadMenu = NULL;
QMenu *saveMenu = NULL;
QMenu *removeMenu = NULL;
QMenu *removePassMenu = NULL;
struct video_shader *menu_shader = NULL;
unsigned i;
bool hasPasses = false;
QPushButton *loadButton = NULL;
QPushButton *saveButton = NULL;
QPushButton *removeButton = NULL;
QPushButton *removePassButton = NULL;
QPushButton *applyButton = NULL;
QHBoxLayout *topButtonLayout = NULL;
QMenu *loadMenu = NULL;
QMenu *saveMenu = NULL;
QMenu *removeMenu = NULL;
QMenu *removePassMenu = NULL;
struct video_shader *menu_shader = NULL;
struct video_shader *video_shader = NULL;
struct video_shader *avail_shader = NULL;
const char *shader_path = NULL;
unsigned i;
bool hasPasses = false;
const char *shader_path = NULL;
getShaders(&menu_shader, &video_shader);
/* NOTE: For some reason, menu_shader_get() returns a COPY of what get_current_shader() gives us.
* And if you want to be able to change shader settings/parameters from both the raster menu and
* Qt at the same time... you must change BOTH or one will overwrite the other.
/* NOTE: For some reason, menu_shader_get() returns a COPY
* of what get_current_shader() gives us.
* And if you want to be able to change shader settings/parameters
* from both the raster menu and
* Qt at the same time... you must change BOTH or one will
* overwrite the other.
*
* AND, during a context reset, video_shader will be NULL but not menu_shader, so don't totally bail
* AND, during a context reset, video_shader will be NULL
* but not menu_shader, so don't totally bail
* just because video_shader is NULL.
*
* Someone please fix this mess.
@ -957,7 +983,8 @@ void ShaderParamsDialog::buildLayout()
if (video_shader->passes == 0)
setWindowTitle(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SHADER_OPTIONS));
}
/* Normally we'd only use video_shader, but the vulkan driver returns a NULL shader when there
/* Normally we'd only use video_shader,
* but the Vulkan driver returns a NULL shader when there
* are zero passes, so just fall back to menu_shader.
*/
else if (menu_shader)
@ -978,7 +1005,8 @@ void ShaderParamsDialog::buildLayout()
clearLayout();
/* Only check video_shader for the path, menu_shader seems stale... e.g. if you remove all the shader passes,
/* Only check video_shader for the path, menu_shader seems stale...
* e.g. if you remove all the shader passes,
* it still has the old path in it, but video_shader does not
*/
if (video_shader)
@ -1000,19 +1028,20 @@ void ShaderParamsDialog::buildLayout()
else
setWindowTitle(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SHADER_OPTIONS));
loadButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_LOAD), this);
saveButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_SAVE), this);
removeButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_REMOVE), this);
loadButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_LOAD), this);
saveButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_SAVE), this);
removeButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_REMOVE), this);
removePassButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_REMOVE_PASSES), this);
applyButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_APPLY), this);
applyButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_APPLY), this);
loadMenu = new QMenu(loadButton);
loadMenu = new QMenu(loadButton);
loadMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET), this, SLOT(onShaderLoadPresetClicked()));
loadMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_SHADER_ADD_PASS), this, SLOT(onShaderAddPassClicked()));
loadButton->setMenu(loadMenu);
saveMenu = new QMenu(saveButton);
saveMenu = new QMenu(saveButton);
saveMenu->addAction(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_AS)) + "...", this, SLOT(onShaderSavePresetAsClicked()));
saveMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_GLOBAL), this, SLOT(onShaderSaveGlobalPresetClicked()));
saveMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_CORE), this, SLOT(onShaderSaveCorePresetClicked()));
@ -1042,7 +1071,7 @@ void ShaderParamsDialog::buildLayout()
{
QFileInfo fileInfo(menu_shader->pass[i].source.path);
QString shaderBasename = fileInfo.completeBaseName();
QAction *action = removePassMenu->addAction(shaderBasename, this, SLOT(onShaderRemovePassClicked()));
QAction *action = removePassMenu->addAction(shaderBasename, this, SLOT(onShaderRemovePassClicked()));
action->setData(i);
}
@ -1066,16 +1095,16 @@ void ShaderParamsDialog::buildLayout()
/* NOTE: We assume that parameters are always grouped in order by the pass number, e.g., all parameters for pass 0 come first, then params for pass 1, etc. */
for (i = 0; avail_shader && i < avail_shader->passes; i++)
{
QFormLayout *form = NULL;
QGroupBox *groupBox = NULL;
QFormLayout *form = NULL;
QGroupBox *groupBox = NULL;
QFileInfo fileInfo(avail_shader->pass[i].source.path);
QString shaderBasename = fileInfo.completeBaseName();
QString shaderBasename = fileInfo.completeBaseName();
QHBoxLayout *filterScaleHBoxLayout = NULL;
QComboBox *filterComboBox = new QComboBox(this);
QComboBox *scaleComboBox = new QComboBox(this);
QToolButton *moveDownButton = NULL;
QToolButton *moveUpButton = NULL;
unsigned j = 0;
QComboBox *filterComboBox = new QComboBox(this);
QComboBox *scaleComboBox = new QComboBox(this);
QToolButton *moveDownButton = NULL;
QToolButton *moveUpButton = NULL;
unsigned j = 0;
/* Sometimes video_shader shows 1 pass with no source file, when there are really 0 passes. */
if (shaderBasename.isEmpty())
@ -1140,7 +1169,7 @@ void ShaderParamsDialog::buildLayout()
connect(filterComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onFilterComboBoxIndexChanged(int)));
connect(scaleComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onScaleComboBoxIndexChanged(int)));
form = new QFormLayout();
form = new QFormLayout();
groupBox = new QGroupBox(shaderBasename);
groupBox->setLayout(form);
groupBox->setProperty("pass", i);
@ -1195,14 +1224,12 @@ void ShaderParamsDialog::buildLayout()
void ShaderParamsDialog::onParameterLabelContextMenuRequested(const QPoint&)
{
QLabel *label = NULL;
QVariant paramVariant;
QString parameter;
QPointer<QAction> action;
QList<QAction*> actions;
QScopedPointer<QAction> resetParamAction;
QVariant paramVariant;
QString parameter;
label = qobject_cast<QLabel*>(sender());
QLabel *label = qobject_cast<QLabel*>(sender());
if (!label)
return;
@ -1224,23 +1251,19 @@ void ShaderParamsDialog::onParameterLabelContextMenuRequested(const QPoint&)
return;
if (action == resetParamAction.data())
{
onShaderResetParameter(parameter);
}
}
void ShaderParamsDialog::onGroupBoxContextMenuRequested(const QPoint&)
{
QGroupBox *groupBox = NULL;
QPointer<QAction> action;
QList<QAction*> actions;
QScopedPointer<QAction> resetPassAction;
QScopedPointer<QAction> resetAllPassesAction;
QVariant passVariant;
int pass = 0;
bool ok = false;
groupBox = qobject_cast<QGroupBox*>(sender());
int pass = 0;
bool ok = false;
QGroupBox *groupBox = qobject_cast<QGroupBox*>(sender());
if (!groupBox)
return;
@ -1267,20 +1290,16 @@ void ShaderParamsDialog::onGroupBoxContextMenuRequested(const QPoint&)
return;
if (action == resetPassAction.data())
{
onShaderResetPass(pass);
}
else if (action == resetAllPassesAction.data())
{
onShaderResetAllPasses();
}
}
void ShaderParamsDialog::addShaderParam(struct video_shader_parameter *param, QFormLayout *form)
{
QString desc = param->desc;
QString desc = param->desc;
QString parameter = param->id;
QLabel *label = new QLabel(desc);
QLabel *label = new QLabel(desc);
label->setProperty("parameter", parameter);
label->setContextMenuPolicy(Qt::CustomContextMenu);
@ -1304,19 +1323,21 @@ void ShaderParamsDialog::addShaderParam(struct video_shader_parameter *param, QF
else
{
QDoubleSpinBox *doubleSpinBox = NULL;
QSpinBox *spinBox = NULL;
QHBoxLayout *box = new QHBoxLayout();
QSlider *slider = new QSlider(Qt::Horizontal, this);
double value = MainWindow::lerp(param->minimum, param->maximum, 0, 100, param->current);
double intpart = 0;
bool stepIsFractional = modf(param->step, &intpart);
QSpinBox *spinBox = NULL;
QHBoxLayout *box = new QHBoxLayout();
QSlider *slider = new QSlider(Qt::Horizontal, this);
double value = MainWindow::lerp(
param->minimum, param->maximum, 0, 100, param->current);
double intpart = 0;
bool stepIsFractional = modf(param->step, &intpart);
slider->setRange(0, 100);
slider->setSingleStep(1);
slider->setValue(value);
slider->setProperty("param", parameter);
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(onShaderParamSliderValueChanged(int)));
connect(slider, SIGNAL(valueChanged(int)),
this, SLOT(onShaderParamSliderValueChanged(int)));
box->addWidget(slider);
@ -1353,9 +1374,9 @@ void ShaderParamsDialog::addShaderParam(struct video_shader_parameter *param, QF
void ShaderParamsDialog::onShaderParamCheckBoxClicked()
{
QCheckBox *checkBox = qobject_cast<QCheckBox*>(sender());
QVariant paramVariant;
struct video_shader *menu_shader = NULL;
QCheckBox *checkBox = qobject_cast<QCheckBox*>(sender());
struct video_shader *menu_shader = NULL;
struct video_shader *video_shader = NULL;
getShaders(&menu_shader, &video_shader);
@ -1374,8 +1395,8 @@ void ShaderParamsDialog::onShaderParamCheckBoxClicked()
if (menu_shader)
{
struct video_shader_parameter *param = NULL;
int i;
struct video_shader_parameter *param = NULL;
for (i = 0; i < static_cast<int>(menu_shader->num_parameters); i++)
{
@ -1391,8 +1412,8 @@ void ShaderParamsDialog::onShaderParamCheckBoxClicked()
if (video_shader)
{
struct video_shader_parameter *param = NULL;
int i;
struct video_shader_parameter *param = NULL;
for (i = 0; i < static_cast<int>(video_shader->num_parameters); i++)
{
@ -1415,9 +1436,9 @@ void ShaderParamsDialog::onShaderParamSliderValueChanged(int)
QVariant spinBoxVariant;
QVariant paramVariant;
QSlider *slider = qobject_cast<QSlider*>(sender());
struct video_shader *menu_shader = NULL;
struct video_shader *menu_shader = NULL;
struct video_shader *video_shader = NULL;
double newValue = 0.0;
double newValue = 0.0;
getShaders(&menu_shader, &video_shader);
@ -1425,7 +1446,7 @@ void ShaderParamsDialog::onShaderParamSliderValueChanged(int)
return;
spinBoxVariant = slider->property("spinBox");
paramVariant = slider->property("param");
paramVariant = slider->property("param");
if (paramVariant.isValid())
{
@ -1433,8 +1454,8 @@ void ShaderParamsDialog::onShaderParamSliderValueChanged(int)
if (menu_shader)
{
struct video_shader_parameter *param = NULL;
int i;
struct video_shader_parameter *param = NULL;
for (i = 0; i < static_cast<int>(menu_shader->num_parameters); i++)
{
@ -1454,8 +1475,8 @@ void ShaderParamsDialog::onShaderParamSliderValueChanged(int)
if (video_shader)
{
struct video_shader_parameter *param = NULL;
int i;
struct video_shader_parameter *param = NULL;
for (i = 0; i < static_cast<int>(video_shader->num_parameters); i++)
{
@ -1503,11 +1524,11 @@ void ShaderParamsDialog::onShaderParamSliderValueChanged(int)
void ShaderParamsDialog::onShaderParamSpinBoxValueChanged(int value)
{
QSpinBox *spinBox = qobject_cast<QSpinBox*>(sender());
QVariant sliderVariant;
QVariant paramVariant;
QSlider *slider = NULL;
struct video_shader *menu_shader = NULL;
QSpinBox *spinBox = qobject_cast<QSpinBox*>(sender());
QSlider *slider = NULL;
struct video_shader *menu_shader = NULL;
struct video_shader *video_shader = NULL;
getShaders(&menu_shader, &video_shader);
@ -1530,13 +1551,12 @@ void ShaderParamsDialog::onShaderParamSpinBoxValueChanged(int value)
if (paramVariant.isValid())
{
QString parameter = paramVariant.toString();
double newValue = 0.0;
double newValue = 0.0;
if (menu_shader)
{
struct video_shader_parameter *param = NULL;
int i;
struct video_shader_parameter *param = NULL;
for (i = 0; i < static_cast<int>(menu_shader->num_parameters); i++)
{
@ -1549,7 +1569,8 @@ void ShaderParamsDialog::onShaderParamSpinBoxValueChanged(int value)
if (param)
{
param->current = value;
newValue = MainWindow::lerp(param->minimum, param->maximum, 0, 100, param->current);
newValue = MainWindow::lerp(
param->minimum, param->maximum, 0, 100, param->current);
slider->blockSignals(true);
slider->setValue(newValue);
slider->blockSignals(false);
@ -1558,8 +1579,8 @@ void ShaderParamsDialog::onShaderParamSpinBoxValueChanged(int value)
if (video_shader)
{
struct video_shader_parameter *param = NULL;
int i;
struct video_shader_parameter *param = NULL;
for (i = 0; i < static_cast<int>(video_shader->num_parameters); i++)
{
@ -1572,7 +1593,8 @@ void ShaderParamsDialog::onShaderParamSpinBoxValueChanged(int value)
if (param)
{
param->current = value;
newValue = MainWindow::lerp(param->minimum, param->maximum, 0, 100, param->current);
newValue = MainWindow::lerp(
param->minimum, param->maximum, 0, 100, param->current);
slider->blockSignals(true);
slider->setValue(newValue);
slider->blockSignals(false);
@ -1585,11 +1607,11 @@ void ShaderParamsDialog::onShaderParamSpinBoxValueChanged(int value)
void ShaderParamsDialog::onShaderParamDoubleSpinBoxValueChanged(double value)
{
QDoubleSpinBox *doubleSpinBox = qobject_cast<QDoubleSpinBox*>(sender());
QVariant sliderVariant;
QVariant paramVariant;
QSlider *slider = NULL;
struct video_shader *menu_shader = NULL;
QSlider *slider = NULL;
QDoubleSpinBox *doubleSpinBox = qobject_cast<QDoubleSpinBox*>(sender());
struct video_shader *menu_shader = NULL;
struct video_shader *video_shader = NULL;
getShaders(&menu_shader, &video_shader);
@ -1612,13 +1634,12 @@ void ShaderParamsDialog::onShaderParamDoubleSpinBoxValueChanged(double value)
if (paramVariant.isValid())
{
QString parameter = paramVariant.toString();
double newValue = 0.0;
double newValue = 0.0;
if (menu_shader)
{
struct video_shader_parameter *param = NULL;
int i;
struct video_shader_parameter *param = NULL;
for (i = 0; i < static_cast<int>(menu_shader->num_parameters); i++)
{
@ -1631,7 +1652,8 @@ void ShaderParamsDialog::onShaderParamDoubleSpinBoxValueChanged(double value)
if (param)
{
param->current = value;
newValue = MainWindow::lerp(param->minimum, param->maximum, 0, 100, param->current);
newValue = MainWindow::lerp(
param->minimum, param->maximum, 0, 100, param->current);
slider->blockSignals(true);
slider->setValue(newValue);
slider->blockSignals(false);
@ -1640,8 +1662,8 @@ void ShaderParamsDialog::onShaderParamDoubleSpinBoxValueChanged(double value)
if (video_shader)
{
struct video_shader_parameter *param = NULL;
int i;
struct video_shader_parameter *param = NULL;
for (i = 0; i < static_cast<int>(video_shader->num_parameters); i++)
{
@ -1654,7 +1676,8 @@ void ShaderParamsDialog::onShaderParamDoubleSpinBoxValueChanged(double value)
if (param)
{
param->current = value;
newValue = MainWindow::lerp(param->minimum, param->maximum, 0, 100, param->current);
newValue = MainWindow::lerp(
param->minimum, param->maximum, 0, 100, param->current);
slider->blockSignals(true);
slider->setValue(newValue);
slider->blockSignals(false);

View File

@ -218,32 +218,35 @@ void MainWindow::onThumbnailDownloadReadyRead()
void MainWindow::downloadThumbnail(QString system, QString title, QUrl url)
{
QString systemUnderscore = system;
QString urlString;
QNetworkReply *reply = NULL;
QNetworkRequest request;
QByteArray urlArray;
QString downloadType;
settings_t *settings = config_get_ptr();
const char *urlData = NULL;
QString systemUnderscore = system;
QNetworkReply *reply = NULL;
settings_t *settings = config_get_ptr();
const char *urlData = NULL;
if (!settings || m_pendingThumbnailDownloadTypes.isEmpty())
return;
title = getScrubbedString(title);
downloadType = m_pendingThumbnailDownloadTypes.takeFirst();
systemUnderscore = systemUnderscore.replace(" ", "_");
urlString = QString(THUMBNAIL_URL_HEADER) + systemUnderscore + THUMBNAIL_URL_BRANCH + downloadType + "/" + title + THUMBNAIL_URL_FOOTER;
title = getScrubbedString(title);
downloadType = m_pendingThumbnailDownloadTypes.takeFirst();
systemUnderscore = systemUnderscore.replace(" ", "_");
urlString = QString(THUMBNAIL_URL_HEADER)
+ systemUnderscore
+ THUMBNAIL_URL_BRANCH
+ downloadType + "/"
+ title
+ THUMBNAIL_URL_FOOTER;
if (url.isEmpty())
url = urlString;
request.setUrl(url);
urlArray = url.toString().toUtf8();
urlData = urlArray.constData();
urlArray = url.toString().toUtf8();
urlData = urlArray.constData();
if (m_thumbnailDownloadFile.isOpen())
{
@ -252,11 +255,16 @@ void MainWindow::downloadThumbnail(QString system, QString title, QUrl url)
}
else
{
QString dirString = QString(settings->paths.directory_thumbnails) + "/" + system + "/" + downloadType;
QString fileName = dirString + "/" + title + THUMBNAIL_IMAGE_EXTENSION + PARTIAL_EXTENSION;
QDir dir;
QByteArray fileNameArray = fileName.toUtf8();
const char *fileNameData = fileNameArray.constData();
const char *path_dir_thumbnails = settings->paths.directory_thumbnails;
QString dirString = QString(path_dir_thumbnails) + "/" + system + "/" + downloadType;
QString fileName = dirString
+ "/"
+ title
+ THUMBNAIL_IMAGE_EXTENSION
+ PARTIAL_EXTENSION;
QByteArray fileNameArray = fileName.toUtf8();
const char *fileNameData = fileNameArray.constData();
dir.mkpath(dirString);

View File

@ -225,16 +225,19 @@ void MainWindow::onThumbnailPackDownloadReadyRead()
void MainWindow::downloadAllThumbnails(QString system, QUrl url)
{
QString urlString;
QNetworkReply *reply = NULL;
QNetworkRequest request;
QByteArray urlArray;
QNetworkReply *reply = NULL;
settings_t *settings = config_get_ptr();
const char *urlData = NULL;
const char *urlData = NULL;
if (!settings)
return;
urlString = QString(THUMBNAILPACK_URL_HEADER) + system + THUMBNAILPACK_EXTENSION;
urlString =
QString(THUMBNAILPACK_URL_HEADER)
+ system
+ THUMBNAILPACK_EXTENSION;
if (url.isEmpty())
url = urlString;
@ -242,7 +245,7 @@ void MainWindow::downloadAllThumbnails(QString system, QUrl url)
request.setUrl(url);
urlArray = url.toString().toUtf8();
urlData = urlArray.constData();
urlData = urlArray.constData();
if (m_thumbnailPackDownloadFile.isOpen())
{
@ -251,11 +254,17 @@ void MainWindow::downloadAllThumbnails(QString system, QUrl url)
}
else
{
QString dirString = QString(settings->paths.directory_thumbnails);
QString fileName = dirString + "/" + system + THUMBNAILPACK_EXTENSION + PARTIAL_EXTENSION;
QDir dir;
QByteArray fileNameArray = fileName.toUtf8();
const char *fileNameData = fileNameArray.constData();
const char *path_dir_thumbnails = settings->paths.directory_thumbnails;
QString dirString = QString(path_dir_thumbnails);
QString fileName =
dirString
+ "/"
+ system
+ THUMBNAILPACK_EXTENSION
+ PARTIAL_EXTENSION;
QByteArray fileNameArray = fileName.toUtf8();
const char *fileNameData = fileNameArray.constData();
dir.mkpath(dirString);
@ -321,6 +330,7 @@ void MainWindow::onThumbnailPackExtractFinished(bool success)
m_playlistModel->reloadSystemThumbnails(reply->property("system").toString());
reply->deleteLater();
updateVisibleItems();
/* reload thumbnail image */
/* Reload thumbnail image */
emit itemChanged();
}

View File

@ -170,10 +170,11 @@ void LoadCoreWindow::onLoadCustomCoreClicked()
{
QString path;
QByteArray pathArray;
settings_t *settings = config_get_ptr();
char core_ext[255] = {0};
char core_ext[255] = {0};
char filters[PATH_MAX_LENGTH] = {0};
const char *pathData = NULL;
const char *pathData = NULL;
settings_t *settings = config_get_ptr();
const char *path_dir_libretro = settings->paths.directory_libretro;
frontend_driver_get_core_extension(core_ext, sizeof(core_ext));
@ -181,7 +182,7 @@ void LoadCoreWindow::onLoadCustomCoreClicked()
strlcat(filters, core_ext, sizeof(filters));
strlcat(filters, ");;All Files (*.*)", sizeof(filters));
path = QFileDialog::getOpenFileName(this, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_LOAD_CORE), settings->paths.directory_libretro, filters, NULL);
path = QFileDialog::getOpenFileName(this, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_LOAD_CORE), path_dir_libretro, filters, NULL);
if (path.isEmpty())
return;
@ -194,12 +195,12 @@ void LoadCoreWindow::onLoadCustomCoreClicked()
void LoadCoreWindow::initCoreList(const QStringList &extensionFilters)
{
core_info_list_t *cores = NULL;
int j;
unsigned i;
QStringList horizontal_header_labels;
core_info_list_t *cores = NULL;
QDesktopWidget *desktop = qApp->desktop();
QRect desktopRect = desktop->availableGeometry();
unsigned i = 0;
int j = 0;
QRect desktopRect = desktop->availableGeometry();
horizontal_header_labels << msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_NAME);
horizontal_header_labels << msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_CORE_VERSION);
@ -221,18 +222,18 @@ void LoadCoreWindow::initCoreList(const QStringList &extensionFilters)
for (i = 0; i < cores->count; i++)
{
core_info_t *core = core_info_get(cores, i);
QTableWidgetItem *name_item = NULL;
QTableWidgetItem *version_item = new QTableWidgetItem(core->display_version);
QVariantHash hash;
const char *name = core->display_name;
core_info_t *core = core_info_get(cores, i);
QTableWidgetItem *name_item = NULL;
QTableWidgetItem *version_item = new QTableWidgetItem(core->display_version);
const char *name = core->display_name;
if (string_is_empty(name))
name = path_basename(core->path);
name_item = new QTableWidgetItem(name);
hash["path"] = core->path;
hash["path"] = core->path;
hash["extensions"] = QString(core->supported_extensions).split("|");
name_item->setData(Qt::UserRole, hash);
@ -250,16 +251,16 @@ void LoadCoreWindow::initCoreList(const QStringList &extensionFilters)
for (j = 0; j < m_table->rowCount(); j++)
{
bool found = false;
QTableWidgetItem *item = m_table->item(j, CORE_NAME_COLUMN);
int k;
QVariantHash hash;
QStringList extensions;
int k = 0;
bool found = false;
QTableWidgetItem *item = m_table->item(j, CORE_NAME_COLUMN);
if (!item)
continue;
hash = item->data(Qt::UserRole).toHash();
hash = item->data(Qt::UserRole).toHash();
extensions = hash["extensions"].toStringList();
if (!extensions.isEmpty())

View File

@ -359,7 +359,10 @@ MainWindow::MainWindow(QWidget *parent) :
,m_itemsCountLabel(new QLabel(this))
{
settings_t *settings = config_get_ptr();
QDir playlistDir(settings->paths.directory_playlist);
const char *path_dir_playlist = settings->paths.directory_playlist;
const char *path_dir_assets = settings->paths.directory_assets;
const char *path_dir_menu_content = settings->paths.directory_menu_content;
QDir playlistDir(path_dir_playlist);
QString configDir = QFileInfo(path_get(RARCH_PATH_CONFIG)).dir().absolutePath();
QToolButton *searchResetButton = NULL;
QHBoxLayout *zoomLayout = new QHBoxLayout();
@ -502,9 +505,9 @@ MainWindow::MainWindow(QWidget *parent) :
m_logWidget->setObjectName("logWidget");
m_folderIcon = QIcon(QString(settings->paths.directory_assets) + GENERIC_FOLDER_ICON);
m_imageFormats = QVector<QByteArray>::fromList(QImageReader::supportedImageFormats());
m_defaultStyle = QApplication::style();
m_folderIcon = QIcon(QString(path_dir_assets) + GENERIC_FOLDER_ICON);
m_imageFormats = QVector<QByteArray>::fromList(QImageReader::supportedImageFormats());
m_defaultStyle = QApplication::style();
m_defaultPalette = QApplication::palette();
/* ViewOptionsDialog needs m_settings set before it's constructed */
@ -634,7 +637,7 @@ MainWindow::MainWindow(QWidget *parent) :
connect(m_dirModel, SIGNAL(directoryLoaded(const QString&)), this, SLOT(onFileSystemDirLoaded(const QString&)));
connect(m_fileModel, SIGNAL(directoryLoaded(const QString&)), this, SLOT(onFileBrowserTableDirLoaded(const QString&)));
m_dirTree->setCurrentIndex(m_dirModel->index(settings->paths.directory_menu_content));
m_dirTree->setCurrentIndex(m_dirModel->index(path_dir_menu_content));
m_dirTree->scrollTo(m_dirTree->currentIndex(), QAbstractItemView::PositionAtTop);
m_dirTree->expand(m_dirTree->currentIndex());
@ -1036,14 +1039,17 @@ bool MainWindow::showMessageBox(QString msg, MessageBoxType msgType, Qt::WindowM
void MainWindow::onFileBrowserTreeContextMenuRequested(const QPoint&)
{
#ifdef HAVE_LIBRETRODB
QDir dir;
QByteArray dirArray;
QPointer<QAction> action;
QList<QAction*> actions;
QScopedPointer<QAction> scanAction;
QDir dir;
QString currentDirString = QDir::toNativeSeparators(m_dirModel->filePath(m_dirTree->currentIndex()));
settings_t *settings = config_get_ptr();
QByteArray dirArray;
const char *fullpath = NULL;
QString currentDirString = QDir::toNativeSeparators(
m_dirModel->filePath(m_dirTree->currentIndex()));
settings_t *settings = config_get_ptr();
const char *fullpath = NULL;
const char *path_dir_playlist = settings->paths.directory_playlist;
const char *path_content_db = settings->paths.path_content_database;
if (currentDirString.isEmpty())
return;
@ -1067,15 +1073,16 @@ void MainWindow::onFileBrowserTreeContextMenuRequested(const QPoint&)
fullpath = dirArray.constData();
task_push_dbscan(
settings->paths.directory_playlist,
settings->paths.path_content_database,
path_dir_playlist,
path_content_db,
fullpath, true,
m_settings->value("show_hidden_files", true).toBool(),
scan_finished_handler);
#endif
}
void MainWindow::showStatusMessage(QString msg, unsigned priority, unsigned duration, bool flush)
void MainWindow::showStatusMessage(QString msg,
unsigned priority, unsigned duration, bool flush)
{
emit gotStatusMessage(msg, priority, duration, flush);
}
@ -2384,9 +2391,10 @@ void MainWindow::renamePlaylistItem(QListWidgetItem *item, QString newName)
QFileInfo info;
QFileInfo playlistInfo;
QString playlistPath;
settings_t *settings = config_get_ptr();
bool specialPlaylist = false;
QDir playlistDir(settings->paths.directory_playlist);
bool specialPlaylist = false;
settings_t *settings = config_get_ptr();
const char *path_dir_playlist = settings->paths.directory_playlist;
QDir playlistDir(path_dir_playlist);
if (!item)
return;
@ -2405,12 +2413,15 @@ void MainWindow::renamePlaylistItem(QListWidgetItem *item, QString newName)
if (specialPlaylist)
{
/* special playlists shouldn't be editable already, but just in case, set the old name back and early return if they rename it */
/* special playlists shouldn't be editable already,
* but just in case, set the old name back and
* early return if they rename it */
item->setText(oldName);
return;
}
/* block this signal because setData() would trigger an infinite loop here */
/* block this signal because setData() would trigger
* an infinite loop here */
disconnect(m_listWidget, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(onCurrentListItemDataChanged(QListWidgetItem*)));
oldPath = item->data(Qt::UserRole).toString();
@ -2424,10 +2435,8 @@ void MainWindow::renamePlaylistItem(QListWidgetItem *item, QString newName)
/* absolutePath() will always use / even on Windows */
if (newPath.at(newPath.count() - 1) != '/')
{
/* add trailing slash if the path doesn't have one */
newPath += '/';
}
newPath += newName + "." + extension;

View File

@ -189,8 +189,14 @@ ViewOptionsDialog::ViewOptionsDialog(MainWindow *mainwindow, QWidget *parent) :
connect(this, SIGNAL(rejected()), this, SLOT(onRejected()));
}
QIcon getIcon(OptionsCategory *category) {
QPixmap pixmap = QPixmap(QString(config_get_ptr()->paths.directory_assets) + "/xmb/monochrome/png/" + category->categoryIconName() + ".png");
QIcon getIcon(OptionsCategory *category)
{
settings_t *settings = config_get_ptr();
const char *path_dir_assets = settings->paths.directory_assets;
QPixmap pixmap = QPixmap(QString(path_dir_assets)
+ "/xmb/monochrome/png/"
+ category->categoryIconName()
+ ".png");
return QIcon(getColorizedPixmap(pixmap, getLabelColor("iconColor")));
}
@ -203,7 +209,8 @@ void ViewOptionsDialog::addCategory(OptionsCategory *category)
for (OptionsPage* page : category->pages())
{
SmartScrollArea *scrollArea = new SmartScrollArea(this);
QWidget *widget = page->widget();
QWidget *widget = page->widget();
scrollArea->setWidget(widget);
widget->setAutoFillBackground(false);
tabWidget->addTab(scrollArea, page->displayName());
@ -216,7 +223,9 @@ void ViewOptionsDialog::addCategory(OptionsCategory *category)
if (tabWidget->count() < 2)
tabWidget->tabBar()->hide();
#endif
m_optionsList->addItem(new QListWidgetItem(getIcon(category), category->displayName()));
m_optionsList->addItem(
new QListWidgetItem(getIcon(category),
category->displayName()));
m_optionsStack->addWidget(tabWidget);
}

View File

@ -275,9 +275,8 @@ static char** waiting_argv;
#ifdef HAVE_COCOA_METAL
- (void)setViewType:(apple_view_type_t)vt {
if (vt == _vt) {
if (vt == _vt)
return;
}
RARCH_LOG("[Cocoa]: change view type: %d ? %d\n", _vt, vt);
@ -471,55 +470,57 @@ static char** waiting_argv;
static void open_core_handler(ui_browser_window_state_t *state, bool result)
{
rarch_system_info_t *info = runloop_get_system_info();
if (!state)
return;
if (string_is_empty(state->result))
return;
if (!result)
return;
rarch_system_info_t *info = runloop_get_system_info();
settings_t *settings = config_get_ptr();
bool set_supports_no_game_enable = settings->bools.set_supports_no_game_enable;
if (!state)
return;
if (string_is_empty(state->result))
return;
if (!result)
return;
settings_t *settings = config_get_ptr();
path_set(RARCH_PATH_CORE, state->result);
ui_companion_event_command(CMD_EVENT_LOAD_CORE);
path_set(RARCH_PATH_CORE, state->result);
ui_companion_event_command(CMD_EVENT_LOAD_CORE);
if (info && info->load_no_content
&& settings->bools.set_supports_no_game_enable)
{
content_ctx_info_t content_info = {0};
path_clear(RARCH_PATH_CONTENT);
task_push_load_content_with_current_core_from_companion_ui(
NULL,
&content_info,
CORE_TYPE_PLAIN,
NULL, NULL);
}
if (info
&& info->load_no_content
&& set_supports_no_game_enable)
{
content_ctx_info_t content_info = {0};
path_clear(RARCH_PATH_CONTENT);
task_push_load_content_with_current_core_from_companion_ui(
NULL,
&content_info,
CORE_TYPE_PLAIN,
NULL, NULL);
}
}
static void open_document_handler(ui_browser_window_state_t *state, bool result)
static void open_document_handler(
ui_browser_window_state_t *state, bool result)
{
if (!state)
return;
if (string_is_empty(state->result))
return;
if (!result)
return;
struct retro_system_info *system = runloop_get_libretro_system_info();
const char *core_name = system ? system->library_name : NULL;
struct retro_system_info *system = runloop_get_libretro_system_info();
const char *core_name = system ? system->library_name : NULL;
if (!state)
return;
if (string_is_empty(state->result))
return;
if (!result)
return;
path_set(RARCH_PATH_CONTENT, state->result);
path_set(RARCH_PATH_CONTENT, state->result);
if (core_name)
{
content_ctx_info_t content_info = {0};
task_push_load_content_with_current_core_from_companion_ui(
NULL,
&content_info,
CORE_TYPE_PLAIN,
NULL, NULL);
}
if (core_name)
{
content_ctx_info_t content_info = {0};
task_push_load_content_with_current_core_from_companion_ui(
NULL,
&content_info,
CORE_TYPE_PLAIN,
NULL, NULL);
}
}
- (IBAction)openCore:(id)sender {
@ -528,14 +529,16 @@ static void open_document_handler(ui_browser_window_state_t *state, bool result)
if (browser)
{
ui_browser_window_state_t browser_state;
settings_t *settings = config_get_ptr();
bool result = false;
settings_t *settings = config_get_ptr();
const char *path_dir_libretro = settings->paths.directory_libretro;
browser_state.filters = strdup("dylib");
browser_state.filters_title = strdup(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_SETTINGS));
browser_state.title = strdup(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_LIST));
browser_state.startdir = strdup(settings->paths.directory_libretro);
browser_state.filters = strdup("dylib");
browser_state.filters_title = strdup(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_SETTINGS));
browser_state.title = strdup(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_LIST));
browser_state.startdir = strdup(path_dir_libretro);
bool result = browser->open(&browser_state);
result = browser->open(&browser_state);
open_core_handler(&browser_state, result);
free(browser_state.filters);
@ -551,21 +554,25 @@ static void open_document_handler(ui_browser_window_state_t *state, bool result)
if (browser)
{
ui_browser_window_state_t browser_state = {{0}};
settings_t *settings = config_get_ptr();
NSString *startdir = BOXSTRING(settings->paths.directory_menu_content);
ui_browser_window_state_t
browser_state = {{0}};
bool result = false;
settings_t *settings = config_get_ptr();
const char *path_dir_menu_content = settings->paths.directory_menu_content;
NSString *startdir = BOXSTRING(path_dir_menu_content);
if (!startdir.length)
startdir = BOXSTRING("/");
if (!startdir.length)
startdir = BOXSTRING("/");
browser_state.title = strdup(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_LOAD_CONTENT_LIST));
browser_state.startdir = strdup([startdir UTF8String]);
browser_state.title = strdup(msg_hash_to_str(
MENU_ENUM_LABEL_VALUE_LOAD_CONTENT_LIST));
browser_state.startdir = strdup([startdir UTF8String]);
bool result = browser->open(&browser_state);
open_document_handler(&browser_state, result);
result = browser->open(&browser_state);
open_document_handler(&browser_state, result);
free(browser_state.startdir);
free(browser_state.title);
free(browser_state.startdir);
free(browser_state.title);
}
}
@ -575,8 +582,9 @@ static void open_document_handler(ui_browser_window_state_t *state, bool result)
- (IBAction)showCoresDirectory:(id)sender
{
settings_t *settings = config_get_ptr();
[[NSWorkspace sharedWorkspace] openFile:BOXSTRING(settings->paths.directory_libretro)];
settings_t *settings = config_get_ptr();
const char *path_dir_libretro = settings->paths.directory_libretro;
[[NSWorkspace sharedWorkspace] openFile:BOXSTRING(path_dir_libretro)];
}
- (IBAction)showPreferences:(id)sender
@ -674,7 +682,8 @@ static void ui_companion_cocoa_deinit(void *data)
static void *ui_companion_cocoa_init(void)
{
ui_companion_cocoa_t *handle = (ui_companion_cocoa_t*)calloc(1, sizeof(*handle));
ui_companion_cocoa_t *handle = (ui_companion_cocoa_t*)
calloc(1, sizeof(*handle));
if (!handle)
return NULL;

View File

@ -26,9 +26,7 @@ extern "C" {
#endif
#include "../ui_companion_driver.h"
#include "../../core.h"
#include "../../configuration.h"
#include "../../retroarch.h"
#include "../../verbosity.h"
#include "../../msg_hash.h"
#include "../../tasks/tasks_internal.h"
@ -614,8 +612,8 @@ static void* ui_companion_qt_init(void)
/* the initial playlist that is selected is based on the user's setting (initialPlaylist) */
for (i = 0; listWidget->count() && i < listWidget->count(); i++)
{
QListWidgetItem *item = listWidget->item(i);
QString path;
QListWidgetItem *item = listWidget->item(i);
if (!item)
continue;
@ -650,20 +648,19 @@ static void* ui_companion_qt_init(void)
return handle;
}
static void ui_companion_qt_notify_content_loaded(void *data)
{
(void)data;
}
static void ui_companion_qt_notify_content_loaded(void *data) { }
static void ui_companion_qt_toggle(void *data, bool force)
{
ui_companion_qt_t *handle = (ui_companion_qt_t*)data;
ui_window_qt_t *win_handle = (ui_window_qt_t*)handle->window;
settings_t *settings = config_get_ptr();
bool ui_companion_toggle = settings->bools.ui_companion_toggle;
bool video_fullscreen = settings->bools.video_fullscreen;
if (settings->bools.ui_companion_toggle || force)
if (ui_companion_toggle || force)
{
if (settings->bools.video_fullscreen)
if (video_fullscreen)
command_event(CMD_EVENT_FULLSCREEN_TOGGLE, NULL);
win_handle->qtWindow->activateWindow();
@ -678,7 +675,8 @@ static void ui_companion_qt_toggle(void *data, bool force)
{
already_started = true;
if (win_handle->qtWindow->settings()->value("show_welcome_screen", true).toBool())
if (win_handle->qtWindow->settings()->value(
"show_welcome_screen", true).toBool())
win_handle->qtWindow->showWelcomeScreen();
}
}
@ -707,12 +705,7 @@ static void ui_companion_qt_event_command(void *data, enum event_command cmd)
}
static void ui_companion_qt_notify_list_pushed(void *data, file_list_t *list,
file_list_t *menu_list)
{
(void)data;
(void)list;
(void)menu_list;
}
file_list_t *menu_list) { }
static void ui_companion_qt_notify_refresh(void *data)
{
@ -730,7 +723,8 @@ static void ui_companion_qt_log_msg(void *data, const char *msg)
win_handle->qtWindow->appendLogMessage(msg);
}
void ui_companion_qt_msg_queue_push(void *data, const char *msg, unsigned priority, unsigned duration, bool flush)
void ui_companion_qt_msg_queue_push(void *data,
const char *msg, unsigned priority, unsigned duration, bool flush)
{
ui_companion_qt_t *handle = (ui_companion_qt_t*)data;
ui_window_qt_t *win_handle = NULL;
@ -738,7 +732,7 @@ void ui_companion_qt_msg_queue_push(void *data, const char *msg, unsigned priori
if (!handle)
return;
win_handle = (ui_window_qt_t*)handle->window;
win_handle = (ui_window_qt_t*)handle->window;
if (win_handle)
win_handle->qtWindow->showStatusMessage(msg, priority, duration, flush);