(Qt) Small cleanups
This commit is contained in:
parent
abcd42777f
commit
3862069cb7
|
@ -7,9 +7,8 @@
|
||||||
/* http://www.informit.com/articles/article.aspx?p=1613548 */
|
/* http://www.informit.com/articles/article.aspx?p=1613548 */
|
||||||
|
|
||||||
ThumbnailDelegate::ThumbnailDelegate(const GridItem &gridItem, QObject* parent) :
|
ThumbnailDelegate::ThumbnailDelegate(const GridItem &gridItem, QObject* parent) :
|
||||||
QStyledItemDelegate(parent), m_style(gridItem)
|
QStyledItemDelegate(parent), m_style(gridItem) { }
|
||||||
{
|
|
||||||
}
|
|
||||||
void ThumbnailDelegate::paint(QPainter* painter, const QStyleOptionViewItem &option, const QModelIndex& index) const
|
void ThumbnailDelegate::paint(QPainter* painter, const QStyleOptionViewItem &option, const QModelIndex& index) const
|
||||||
{
|
{
|
||||||
QStyleOptionViewItem opt = option;
|
QStyleOptionViewItem opt = option;
|
||||||
|
@ -112,7 +111,7 @@ void GridView::calculateRectsIfNecessary() const
|
||||||
int columns = (maxWidth - m_spacing) / (m_size + m_spacing);
|
int columns = (maxWidth - m_spacing) / (m_size + m_spacing);
|
||||||
if (columns > 0)
|
if (columns > 0)
|
||||||
{
|
{
|
||||||
const int actualSpacing = (maxWidth - m_spacing -
|
const int actualSpacing = (maxWidth - m_spacing -
|
||||||
m_size - (columns - 1) * m_size) / columns;
|
m_size - (columns - 1) * m_size) / columns;
|
||||||
for (row = 0; row < model()->rowCount(); ++row)
|
for (row = 0; row < model()->rowCount(); ++row)
|
||||||
{
|
{
|
||||||
|
@ -134,7 +133,7 @@ void GridView::calculateRectsIfNecessary() const
|
||||||
int columns = (maxWidth - m_spacing) / (m_size + m_spacing);
|
int columns = (maxWidth - m_spacing) / (m_size + m_spacing);
|
||||||
if (columns > 0)
|
if (columns > 0)
|
||||||
{
|
{
|
||||||
const int actualSpacing = (maxWidth - columns * m_size)
|
const int actualSpacing = (maxWidth - columns * m_size)
|
||||||
/ (columns + 1);
|
/ (columns + 1);
|
||||||
x = actualSpacing;
|
x = actualSpacing;
|
||||||
|
|
||||||
|
|
|
@ -327,9 +327,9 @@ QWidget *UserBindsPage::widget()
|
||||||
for (retro_id = 0; retro_id < RARCH_FIRST_CUSTOM_BIND + 20; retro_id++)
|
for (retro_id = 0; retro_id < RARCH_FIRST_CUSTOM_BIND + 20; retro_id++)
|
||||||
{
|
{
|
||||||
char descriptor[300];
|
char descriptor[300];
|
||||||
const struct retro_keybind *keybind =
|
const struct retro_keybind *keybind =
|
||||||
&input_config_binds[p][retro_id];
|
&input_config_binds[p][retro_id];
|
||||||
const struct retro_keybind *auto_bind =
|
const struct retro_keybind *auto_bind =
|
||||||
(const struct retro_keybind*)
|
(const struct retro_keybind*)
|
||||||
input_config_get_bind_auto(p, retro_id);
|
input_config_get_bind_auto(p, retro_id);
|
||||||
|
|
||||||
|
@ -555,7 +555,7 @@ QGroupBox *NetplayPage::createMitmServerGroup()
|
||||||
|
|
||||||
void NetplayPage::onRadioButtonClicked(int id)
|
void NetplayPage::onRadioButtonClicked(int id)
|
||||||
{
|
{
|
||||||
rarch_setting_t *setting =
|
rarch_setting_t *setting =
|
||||||
menu_setting_find_enum(MENU_ENUM_LABEL_NETPLAY_MITM_SERVER);
|
menu_setting_find_enum(MENU_ENUM_LABEL_NETPLAY_MITM_SERVER);
|
||||||
|
|
||||||
if (!setting)
|
if (!setting)
|
||||||
|
@ -617,11 +617,12 @@ QWidget *NotificationsPage::widget()
|
||||||
notificationsGroup->add(MENU_ENUM_LABEL_VIDEO_FONT_SIZE);
|
notificationsGroup->add(MENU_ENUM_LABEL_VIDEO_FONT_SIZE);
|
||||||
notificationsGroup->add(MENU_ENUM_LABEL_VIDEO_MESSAGE_POS_X);
|
notificationsGroup->add(MENU_ENUM_LABEL_VIDEO_MESSAGE_POS_X);
|
||||||
notificationsGroup->add(MENU_ENUM_LABEL_VIDEO_MESSAGE_POS_Y);
|
notificationsGroup->add(MENU_ENUM_LABEL_VIDEO_MESSAGE_POS_Y);
|
||||||
|
/* TODO/FIXME - localize */
|
||||||
notificationsGroup->addRow("Notification Color: ", new FloatColorButton(
|
notificationsGroup->addRow("Notification Color: ", new FloatColorButton(
|
||||||
MENU_ENUM_LABEL_VIDEO_MESSAGE_COLOR_RED,
|
MENU_ENUM_LABEL_VIDEO_MESSAGE_COLOR_RED,
|
||||||
MENU_ENUM_LABEL_VIDEO_MESSAGE_COLOR_GREEN,
|
MENU_ENUM_LABEL_VIDEO_MESSAGE_COLOR_GREEN,
|
||||||
MENU_ENUM_LABEL_VIDEO_MESSAGE_COLOR_BLUE));
|
MENU_ENUM_LABEL_VIDEO_MESSAGE_COLOR_BLUE));
|
||||||
|
/* TODO/FIXME - localize */
|
||||||
bgGroup->addRow("Notification Background Color: ", new UIntColorButton(
|
bgGroup->addRow("Notification Background Color: ", new UIntColorButton(
|
||||||
MENU_ENUM_LABEL_VIDEO_MESSAGE_BGCOLOR_RED,
|
MENU_ENUM_LABEL_VIDEO_MESSAGE_BGCOLOR_RED,
|
||||||
MENU_ENUM_LABEL_VIDEO_MESSAGE_BGCOLOR_GREEN,
|
MENU_ENUM_LABEL_VIDEO_MESSAGE_BGCOLOR_GREEN,
|
||||||
|
@ -999,8 +1000,8 @@ QWidget *ViewsPage::widget()
|
||||||
menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*)
|
menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*)
|
||||||
file_list_get_actiondata_at_offset(list, i);
|
file_list_get_actiondata_at_offset(list, i);
|
||||||
|
|
||||||
if (cbs->enum_idx == (kiosk_mode
|
if (cbs->enum_idx == (kiosk_mode
|
||||||
? MENU_ENUM_LABEL_CONTENT_SHOW_SETTINGS
|
? MENU_ENUM_LABEL_CONTENT_SHOW_SETTINGS
|
||||||
: MENU_ENUM_LABEL_CONTENT_SHOW_EXPLORE))
|
: MENU_ENUM_LABEL_CONTENT_SHOW_EXPLORE))
|
||||||
{
|
{
|
||||||
tabs_begin = i;
|
tabs_begin = i;
|
||||||
|
@ -1106,8 +1107,8 @@ QWidget *AppearancePage::widget()
|
||||||
menu_displaylist_build_list(
|
menu_displaylist_build_list(
|
||||||
list, settings, DISPLAYLIST_MENU_SETTINGS_LIST, true);
|
list, settings, DISPLAYLIST_MENU_SETTINGS_LIST, true);
|
||||||
|
|
||||||
/* TODO/FIXME - we haven't yet figured out how to
|
/* TODO/FIXME - we haven't yet figured out how to
|
||||||
* put a radio button setting next to another radio
|
* put a radio button setting next to another radio
|
||||||
* button on the same row */
|
* button on the same row */
|
||||||
|
|
||||||
for (i = 0; i < list->size; i++)
|
for (i = 0; i < list->size; i++)
|
||||||
|
@ -1117,12 +1118,13 @@ QWidget *AppearancePage::widget()
|
||||||
|
|
||||||
switch (cbs->enum_idx)
|
switch (cbs->enum_idx)
|
||||||
{
|
{
|
||||||
/* TODO/FIXME - this is a dirty hack - if we
|
/* TODO/FIXME - this is a dirty hack - if we
|
||||||
* detect this setting, we instead replace it with a
|
* detect this setting, we instead replace it with a
|
||||||
* color button and ignore the other two font color
|
* color button and ignore the other two font color
|
||||||
* settings since they are already covered by this one
|
* settings since they are already covered by this one
|
||||||
* color button */
|
* color button */
|
||||||
case MENU_ENUM_LABEL_MENU_FONT_COLOR_RED:
|
case MENU_ENUM_LABEL_MENU_FONT_COLOR_RED:
|
||||||
|
/* TODO/FIXME - localize */
|
||||||
layout->addUIntColorButton("Menu Font Color: ",
|
layout->addUIntColorButton("Menu Font Color: ",
|
||||||
MENU_ENUM_LABEL_MENU_FONT_COLOR_RED,
|
MENU_ENUM_LABEL_MENU_FONT_COLOR_RED,
|
||||||
MENU_ENUM_LABEL_MENU_FONT_COLOR_GREEN,
|
MENU_ENUM_LABEL_MENU_FONT_COLOR_GREEN,
|
||||||
|
@ -1209,13 +1211,13 @@ AccountsPage::AccountsPage(QObject *parent) :
|
||||||
|
|
||||||
QWidget *AccountsPage::widget()
|
QWidget *AccountsPage::widget()
|
||||||
{
|
{
|
||||||
QWidget *widget = new QWidget;
|
QWidget *widget = new QWidget;
|
||||||
QVBoxLayout *layout = new QVBoxLayout;
|
QVBoxLayout *layout = new QVBoxLayout;
|
||||||
SettingsGroup *youtubeGroup = new SettingsGroup(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_ACCOUNTS_YOUTUBE));
|
SettingsGroup *youtubeGroup = new SettingsGroup(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_ACCOUNTS_YOUTUBE));
|
||||||
SettingsGroup *twitchGroup = new SettingsGroup(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_ACCOUNTS_TWITCH));
|
SettingsGroup *twitchGroup = new SettingsGroup(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_ACCOUNTS_TWITCH));
|
||||||
SettingsGroup *facebookGroup = new SettingsGroup(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_ACCOUNTS_FACEBOOK));
|
SettingsGroup *facebookGroup = new SettingsGroup(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_ACCOUNTS_FACEBOOK));
|
||||||
#ifdef HAVE_CHEEVOS
|
#ifdef HAVE_CHEEVOS
|
||||||
SettingsGroup *cheevosGroup = new SettingsGroup(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_ACCOUNTS_RETRO_ACHIEVEMENTS));
|
SettingsGroup *cheevosGroup = new SettingsGroup(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_ACCOUNTS_RETRO_ACHIEVEMENTS));
|
||||||
|
|
||||||
cheevosGroup->add(MENU_ENUM_LABEL_CHEEVOS_USERNAME);
|
cheevosGroup->add(MENU_ENUM_LABEL_CHEEVOS_USERNAME);
|
||||||
cheevosGroup->add(MENU_ENUM_LABEL_CHEEVOS_PASSWORD);
|
cheevosGroup->add(MENU_ENUM_LABEL_CHEEVOS_PASSWORD);
|
||||||
|
@ -1369,7 +1371,7 @@ QWidget *VideoPage::widget()
|
||||||
|
|
||||||
windowedGroup->add(MENU_ENUM_LABEL_VIDEO_WINDOW_SHOW_DECORATIONS);
|
windowedGroup->add(MENU_ENUM_LABEL_VIDEO_WINDOW_SHOW_DECORATIONS);
|
||||||
windowedGroup->add(MENU_ENUM_LABEL_UI_MENUBAR_ENABLE);
|
windowedGroup->add(MENU_ENUM_LABEL_UI_MENUBAR_ENABLE);
|
||||||
|
|
||||||
vSyncGroup->add(MENU_ENUM_LABEL_VIDEO_SWAP_INTERVAL);
|
vSyncGroup->add(MENU_ENUM_LABEL_VIDEO_SWAP_INTERVAL);
|
||||||
vSyncGroup->add(MENU_ENUM_LABEL_VIDEO_BLACK_FRAME_INSERTION);
|
vSyncGroup->add(MENU_ENUM_LABEL_VIDEO_BLACK_FRAME_INSERTION);
|
||||||
vSyncGroup->add(MENU_ENUM_LABEL_VIDEO_ADAPTIVE_VSYNC);
|
vSyncGroup->add(MENU_ENUM_LABEL_VIDEO_ADAPTIVE_VSYNC);
|
||||||
|
@ -1572,7 +1574,7 @@ void CrtSwitchresPage::onCrtSuperResolutionComboIndexChanged(int index)
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
Q_UNUSED(index)
|
Q_UNUSED(index)
|
||||||
|
|
||||||
settings->uints.crt_switch_resolution_super =
|
settings->uints.crt_switch_resolution_super =
|
||||||
m_crtSuperResolutionCombo->currentData().value<unsigned>();
|
m_crtSuperResolutionCombo->currentData().value<unsigned>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,10 +66,7 @@ QVariant PlaylistModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
if (index.column() == 0)
|
if (index.column() == 0)
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid() || index.row() >= m_contents.size() || index.row() < 0)
|
||||||
return QVariant();
|
|
||||||
|
|
||||||
if (index.row() >= m_contents.size() || index.row() < 0)
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
switch (role)
|
switch (role)
|
||||||
|
@ -81,12 +78,12 @@ QVariant PlaylistModel::data(const QModelIndex &index, int role) const
|
||||||
case HASH:
|
case HASH:
|
||||||
return QVariant::fromValue(m_contents.at(index.row()));
|
return QVariant::fromValue(m_contents.at(index.row()));
|
||||||
case THUMBNAIL:
|
case THUMBNAIL:
|
||||||
{
|
{
|
||||||
QPixmap *cachedPreview = m_cache.object(getCurrentTypeThumbnailPath(index));
|
QPixmap *cachedPreview = m_cache.object(getCurrentTypeThumbnailPath(index));
|
||||||
if (cachedPreview)
|
if (cachedPreview)
|
||||||
return *cachedPreview;
|
return *cachedPreview;
|
||||||
return QVariant();
|
}
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
@ -182,7 +179,7 @@ QString PlaylistModel::getThumbnailPath(const QHash<QString, QString> &hash, QSt
|
||||||
if (isSupportedImage(hash["path"]))
|
if (isSupportedImage(hash["path"]))
|
||||||
return hash["path"];
|
return hash["path"];
|
||||||
|
|
||||||
return getPlaylistThumbnailsDir(hash.value("db_name"))
|
return getPlaylistThumbnailsDir(hash.value("db_name"))
|
||||||
+ "/" + type + "/" + getSanitizedThumbnailName(hash["label_noext"]);
|
+ "/" + type + "/" + getSanitizedThumbnailName(hash["label_noext"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,7 +212,6 @@ void PlaylistModel::reloadThumbnail(const QModelIndex &index)
|
||||||
void PlaylistModel::reloadSystemThumbnails(const QString system)
|
void PlaylistModel::reloadSystemThumbnails(const QString system)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
QString key;
|
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
const char *path_dir_thumbnails = settings->paths.directory_thumbnails;
|
const char *path_dir_thumbnails = settings->paths.directory_thumbnails;
|
||||||
QString path = QDir::cleanPath(QString(path_dir_thumbnails)) + "/" + system;
|
QString path = QDir::cleanPath(QString(path_dir_thumbnails)) + "/" + system;
|
||||||
|
@ -224,14 +220,14 @@ void PlaylistModel::reloadSystemThumbnails(const QString system)
|
||||||
|
|
||||||
for (i = 0; i < keys.size(); i++)
|
for (i = 0; i < keys.size(); i++)
|
||||||
{
|
{
|
||||||
key = keys.at(i);
|
QString key = keys.at(i);
|
||||||
if (key.startsWith(path))
|
if (key.startsWith(path))
|
||||||
m_cache.remove(key);
|
m_cache.remove(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < pending.size(); i++)
|
for (i = 0; i < pending.size(); i++)
|
||||||
{
|
{
|
||||||
key = pending.at(i);
|
QString key = pending.at(i);
|
||||||
if (key.startsWith(path))
|
if (key.startsWith(path))
|
||||||
m_pendingImages.remove(key);
|
m_pendingImages.remove(key);
|
||||||
}
|
}
|
||||||
|
@ -293,7 +289,7 @@ bool MainWindow::addDirectoryFilesToList(QProgressDialog *dialog,
|
||||||
if (dialog->wasCanceled())
|
if (dialog->wasCanceled())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* Needed to update progress dialog while doing
|
/* Needed to update progress dialog while doing
|
||||||
* a lot of stuff on the main thread. */
|
* a lot of stuff on the main thread. */
|
||||||
if (i % 25 == 0)
|
if (i % 25 == 0)
|
||||||
qApp->processEvents();
|
qApp->processEvents();
|
||||||
|
@ -324,29 +320,29 @@ bool MainWindow::addDirectoryFilesToList(QProgressDialog *dialog,
|
||||||
{
|
{
|
||||||
if (path_is_compressed_file(pathData))
|
if (path_is_compressed_file(pathData))
|
||||||
{
|
{
|
||||||
struct string_list *archive_list =
|
struct string_list *archive_list =
|
||||||
file_archive_get_file_list(pathData, NULL);
|
file_archive_get_file_list(pathData, NULL);
|
||||||
|
|
||||||
if (archive_list)
|
if (archive_list)
|
||||||
{
|
{
|
||||||
if (archive_list->size == 1)
|
if (archive_list->size == 1)
|
||||||
{
|
{
|
||||||
/* Assume archives with one file should have
|
/* Assume archives with one file should have
|
||||||
* that file loaded directly.
|
* that file loaded directly.
|
||||||
* Don't just extend this to add all files
|
* Don't just extend this to add all files
|
||||||
* in a ZIP, because we might hit something like
|
* in a ZIP, because we might hit something like
|
||||||
* MAME/FBA where only the archives themselves
|
* MAME/FBA where only the archives themselves
|
||||||
* are valid content. */
|
* are valid content. */
|
||||||
pathArray = (QString(pathData) + "#"
|
pathArray = (QString(pathData) + "#"
|
||||||
+ archive_list->elems[0].data).toUtf8();
|
+ archive_list->elems[0].data).toUtf8();
|
||||||
pathData = pathArray.constData();
|
pathData = pathArray.constData();
|
||||||
|
|
||||||
if (!extensions.isEmpty() && playlistDialog->filterInArchive())
|
if (!extensions.isEmpty() && playlistDialog->filterInArchive())
|
||||||
{
|
{
|
||||||
/* If the user chose to filter extensions
|
/* If the user chose to filter extensions
|
||||||
* inside archives, and this particular file
|
* inside archives, and this particular file
|
||||||
* inside the archive
|
* inside the archive
|
||||||
* doesn't have one of the chosen extensions,
|
* doesn't have one of the chosen extensions,
|
||||||
* then we skip it. */
|
* then we skip it. */
|
||||||
if (extensions.contains(QFileInfo(pathData).suffix()))
|
if (extensions.contains(QFileInfo(pathData).suffix()))
|
||||||
add = true;
|
add = true;
|
||||||
|
@ -372,8 +368,8 @@ void MainWindow::onPlaylistFilesDropped(QStringList files)
|
||||||
addFilesToPlaylist(files);
|
addFilesToPlaylist(files);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Takes a list of files and folders and adds them to the
|
/* Takes a list of files and folders and adds them to the
|
||||||
* currently selected playlist. Folders will have their
|
* currently selected playlist. Folders will have their
|
||||||
* contents added recursively. */
|
* contents added recursively. */
|
||||||
void MainWindow::addFilesToPlaylist(QStringList files)
|
void MainWindow::addFilesToPlaylist(QStringList files)
|
||||||
{
|
{
|
||||||
|
@ -404,7 +400,7 @@ void MainWindow::addFilesToPlaylist(QStringList files)
|
||||||
/* Assume a blank list means we will manually enter in all fields. */
|
/* Assume a blank list means we will manually enter in all fields. */
|
||||||
if (files.isEmpty())
|
if (files.isEmpty())
|
||||||
{
|
{
|
||||||
/* Make sure hash isn't blank, that would mean there's
|
/* Make sure hash isn't blank, that would mean there's
|
||||||
* multiple entries to add at once. */
|
* multiple entries to add at once. */
|
||||||
itemToAdd["label"] = "";
|
itemToAdd["label"] = "";
|
||||||
itemToAdd["path"] = "";
|
itemToAdd["path"] = "";
|
||||||
|
@ -462,8 +458,8 @@ void MainWindow::addFilesToPlaylist(QStringList files)
|
||||||
|
|
||||||
qApp->processEvents();
|
qApp->processEvents();
|
||||||
|
|
||||||
if ( selectedName.isEmpty()
|
if ( selectedName.isEmpty()
|
||||||
|| selectedPath.isEmpty()
|
|| selectedPath.isEmpty()
|
||||||
|| selectedDatabase.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);
|
showMessageBox(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_PLEASE_FILL_OUT_REQUIRED_FIELDS), MainWindow::MSGBOX_TYPE_ERROR, Qt::ApplicationModal, false);
|
||||||
|
@ -481,7 +477,7 @@ void MainWindow::addFilesToPlaylist(QStringList files)
|
||||||
if (dialog->wasCanceled())
|
if (dialog->wasCanceled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Needed to update progress dialog while
|
/* Needed to update progress dialog while
|
||||||
* doing a lot of stuff on the main thread. */
|
* doing a lot of stuff on the main thread. */
|
||||||
if (i % 25 == 0)
|
if (i % 25 == 0)
|
||||||
qApp->processEvents();
|
qApp->processEvents();
|
||||||
|
@ -511,11 +507,11 @@ void MainWindow::addFilesToPlaylist(QStringList files)
|
||||||
|
|
||||||
if (selectedExtensions.contains(fileInfo.suffix()))
|
if (selectedExtensions.contains(fileInfo.suffix()))
|
||||||
add = true;
|
add = true;
|
||||||
else if (playlistDialog->filterInArchive()
|
else if (playlistDialog->filterInArchive()
|
||||||
&& path_is_compressed_file(pathData))
|
&& path_is_compressed_file(pathData))
|
||||||
{
|
{
|
||||||
/* We'll add it here, but really just delay
|
/* We'll add it here, but really just delay
|
||||||
* the check until later when the archive
|
* the check until later when the archive
|
||||||
* contents are iterated. */
|
* contents are iterated. */
|
||||||
add = true;
|
add = true;
|
||||||
}
|
}
|
||||||
|
@ -554,8 +550,8 @@ void MainWindow::addFilesToPlaylist(QStringList files)
|
||||||
const char *coreNameData = NULL;
|
const char *coreNameData = NULL;
|
||||||
const char *databaseData = NULL;
|
const char *databaseData = NULL;
|
||||||
|
|
||||||
/* Cancel out of everything, the
|
/* Cancel out of everything, the
|
||||||
* current progress will not be written
|
* current progress will not be written
|
||||||
* to the playlist at all. */
|
* to the playlist at all. */
|
||||||
if (dialog->wasCanceled())
|
if (dialog->wasCanceled())
|
||||||
{
|
{
|
||||||
|
@ -566,16 +562,16 @@ void MainWindow::addFilesToPlaylist(QStringList files)
|
||||||
if (fileName.isEmpty())
|
if (fileName.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* a modal QProgressDialog calls processEvents()
|
/* a modal QProgressDialog calls processEvents()
|
||||||
* automatically in setValue() */
|
* automatically in setValue() */
|
||||||
dialog->setValue(i + 1);
|
dialog->setValue(i + 1);
|
||||||
|
|
||||||
fileInfo = fileName;
|
fileInfo = fileName;
|
||||||
|
|
||||||
/* Make sure we're looking at a user-specified field
|
/* Make sure we're looking at a user-specified field
|
||||||
* and not just "<multiple>"
|
* and not just "<multiple>"
|
||||||
* in case it was a folder with one file in it */
|
* in case it was a folder with one file in it */
|
||||||
if ( files.count() == 1
|
if ( files.count() == 1
|
||||||
&& list.count() == 1
|
&& list.count() == 1
|
||||||
&& i == 0
|
&& i == 0
|
||||||
&& playlistDialog->nameFieldEnabled())
|
&& playlistDialog->nameFieldEnabled())
|
||||||
|
@ -583,7 +579,7 @@ void MainWindow::addFilesToPlaylist(QStringList files)
|
||||||
fileBaseNameArray = selectedName.toUtf8();
|
fileBaseNameArray = selectedName.toUtf8();
|
||||||
pathArray = QDir::toNativeSeparators(selectedPath).toUtf8();
|
pathArray = QDir::toNativeSeparators(selectedPath).toUtf8();
|
||||||
}
|
}
|
||||||
/* Otherwise just use the file name itself (minus extension)
|
/* Otherwise just use the file name itself (minus extension)
|
||||||
* for the playlist entry title */
|
* for the playlist entry title */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -620,22 +616,22 @@ void MainWindow::addFilesToPlaylist(QStringList files)
|
||||||
{
|
{
|
||||||
if (list->size == 1)
|
if (list->size == 1)
|
||||||
{
|
{
|
||||||
/* Assume archives with one file should have that
|
/* Assume archives with one file should have that
|
||||||
* file loaded directly.
|
* file loaded directly.
|
||||||
* Don't just extend this to add all files in a zip,
|
* Don't just extend this to add all files in a zip,
|
||||||
* because we might hit
|
* because we might hit
|
||||||
* something like MAME/FBA where only the archives
|
* something like MAME/FBA where only the archives
|
||||||
* themselves are valid content. */
|
* themselves are valid content. */
|
||||||
pathArray = QDir::toNativeSeparators(QString(pathData)
|
pathArray = QDir::toNativeSeparators(QString(pathData)
|
||||||
+ "#" + list->elems[0].data).toUtf8();
|
+ "#" + list->elems[0].data).toUtf8();
|
||||||
pathData = pathArray.constData();
|
pathData = pathArray.constData();
|
||||||
|
|
||||||
if ( !selectedExtensions.isEmpty()
|
if ( !selectedExtensions.isEmpty()
|
||||||
&& playlistDialog->filterInArchive())
|
&& playlistDialog->filterInArchive())
|
||||||
{
|
{
|
||||||
/* If the user chose to filter extensions inside archives,
|
/* If the user chose to filter extensions inside archives,
|
||||||
* and this particular file inside the archive
|
* and this particular file inside the archive
|
||||||
* doesn't have one of the chosen extensions,
|
* doesn't have one of the chosen extensions,
|
||||||
* then we skip it. */
|
* then we skip it. */
|
||||||
if (!selectedExtensions.contains(
|
if (!selectedExtensions.contains(
|
||||||
QFileInfo(pathData).suffix()))
|
QFileInfo(pathData).suffix()))
|
||||||
|
@ -708,9 +704,9 @@ bool MainWindow::updateCurrentPlaylistEntry(
|
||||||
playlist_config.fuzzy_archive_match = settings->bools.playlist_fuzzy_archive_match;
|
playlist_config.fuzzy_archive_match = settings->bools.playlist_fuzzy_archive_match;
|
||||||
playlist_config_set_base_content_directory(&playlist_config, settings->bools.playlist_portable_paths ? settings->paths.directory_menu_content : NULL);
|
playlist_config_set_base_content_directory(&playlist_config, settings->bools.playlist_portable_paths ? settings->paths.directory_menu_content : NULL);
|
||||||
|
|
||||||
if ( playlistPath.isEmpty() ||
|
if ( playlistPath.isEmpty()
|
||||||
contentHash.isEmpty() ||
|
|| contentHash.isEmpty()
|
||||||
!contentHash.contains("index"))
|
|| !contentHash.contains("index"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
index = contentHash.value("index").toUInt(&ok);
|
index = contentHash.value("index").toUInt(&ok);
|
||||||
|
@ -725,10 +721,10 @@ bool MainWindow::updateCurrentPlaylistEntry(
|
||||||
dbName = contentHash.value("db_name");
|
dbName = contentHash.value("db_name");
|
||||||
crc32 = contentHash.value("crc32");
|
crc32 = contentHash.value("crc32");
|
||||||
|
|
||||||
if (path.isEmpty() ||
|
if ( path.isEmpty()
|
||||||
label.isEmpty() ||
|
|| label.isEmpty()
|
||||||
coreName.isEmpty() ||
|
|| coreName.isEmpty()
|
||||||
corePath.isEmpty()
|
|| corePath.isEmpty()
|
||||||
)
|
)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -766,7 +762,7 @@ bool MainWindow::updateCurrentPlaylistEntry(
|
||||||
{
|
{
|
||||||
/* assume archives with one file should have that file loaded directly */
|
/* assume archives with one file should have that file loaded directly */
|
||||||
pathArray = QDir::toNativeSeparators(QString(pathData) + "#" + list->elems[0].data).toUtf8();
|
pathArray = QDir::toNativeSeparators(QString(pathData) + "#" + list->elems[0].data).toUtf8();
|
||||||
pathData = pathArray.constData();
|
pathData = pathArray.constData();
|
||||||
}
|
}
|
||||||
|
|
||||||
string_list_free(list);
|
string_list_free(list);
|
||||||
|
@ -818,18 +814,18 @@ void MainWindow::onPlaylistWidgetContextMenuRequested(const QPoint&)
|
||||||
QScopedPointer<QAction> downloadAllThumbnailsThisPlaylistAction;
|
QScopedPointer<QAction> downloadAllThumbnailsThisPlaylistAction;
|
||||||
QPointer<QAction> selectedAction;
|
QPointer<QAction> selectedAction;
|
||||||
playlist_config_t playlist_config;
|
playlist_config_t playlist_config;
|
||||||
QPoint cursorPos = QCursor::pos();
|
QPoint cursorPos = QCursor::pos();
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
const char *path_dir_playlist = settings->paths.directory_playlist;
|
const char *path_dir_playlist = settings->paths.directory_playlist;
|
||||||
QDir playlistDir(path_dir_playlist);
|
QDir playlistDir(path_dir_playlist);
|
||||||
QListWidgetItem *selectedItem = m_listWidget->itemAt(
|
QListWidgetItem *selectedItem = m_listWidget->itemAt(
|
||||||
m_listWidget->viewport()->mapFromGlobal(cursorPos));
|
m_listWidget->viewport()->mapFromGlobal(cursorPos));
|
||||||
QString playlistDirAbsPath = playlistDir.absolutePath();
|
QString playlistDirAbsPath = playlistDir.absolutePath();
|
||||||
core_info_list_t *core_info_list = NULL;
|
core_info_list_t *core_info_list = NULL;
|
||||||
unsigned i = 0;
|
unsigned i = 0;
|
||||||
int j = 0;
|
int j = 0;
|
||||||
bool specialPlaylist = false;
|
bool specialPlaylist = false;
|
||||||
bool foundHiddenPlaylist = false;
|
bool foundHiddenPlaylist = false;
|
||||||
|
|
||||||
playlist_config.capacity = COLLECTION_SIZE;
|
playlist_config.capacity = COLLECTION_SIZE;
|
||||||
playlist_config.old_format = settings->bools.playlist_use_old_format;
|
playlist_config.old_format = settings->bools.playlist_use_old_format;
|
||||||
|
@ -839,12 +835,12 @@ void MainWindow::onPlaylistWidgetContextMenuRequested(const QPoint&)
|
||||||
|
|
||||||
if (selectedItem)
|
if (selectedItem)
|
||||||
{
|
{
|
||||||
currentPlaylistPath = selectedItem->data(Qt::UserRole).toString();
|
currentPlaylistPath = selectedItem->data(Qt::UserRole).toString();
|
||||||
currentPlaylistFile.setFileName(currentPlaylistPath);
|
currentPlaylistFile.setFileName(currentPlaylistPath);
|
||||||
|
|
||||||
currentPlaylistFileInfo = QFileInfo(currentPlaylistPath);
|
currentPlaylistFileInfo = QFileInfo(currentPlaylistPath);
|
||||||
currentPlaylistFileName = currentPlaylistFileInfo.fileName();
|
currentPlaylistFileName = currentPlaylistFileInfo.fileName();
|
||||||
currentPlaylistDirPath = currentPlaylistFileInfo.absoluteDir().absolutePath();
|
currentPlaylistDirPath = currentPlaylistFileInfo.absoluteDir().absolutePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
menu.reset(new QMenu(this));
|
menu.reset(new QMenu(this));
|
||||||
|
@ -897,12 +893,11 @@ void MainWindow::onPlaylistWidgetContextMenuRequested(const QPoint&)
|
||||||
|
|
||||||
menu->addMenu(hiddenPlaylistsMenu.data());
|
menu->addMenu(hiddenPlaylistsMenu.data());
|
||||||
|
|
||||||
/* Don't just compare strings in case there are case differences on Windows that should be ignored. */
|
/* Don't just compare strings in case there are case differences on Windows that should be ignored.
|
||||||
|
special playlists like history etc. can't have an association
|
||||||
|
*/
|
||||||
if (QDir(currentPlaylistDirPath) != QDir(playlistDirAbsPath))
|
if (QDir(currentPlaylistDirPath) != QDir(playlistDirAbsPath))
|
||||||
{
|
|
||||||
/* special playlists like history etc. can't have an association */
|
|
||||||
specialPlaylist = true;
|
specialPlaylist = true;
|
||||||
}
|
|
||||||
|
|
||||||
if (!specialPlaylist)
|
if (!specialPlaylist)
|
||||||
{
|
{
|
||||||
|
@ -996,7 +991,7 @@ void MainWindow::onPlaylistWidgetContextMenuRequested(const QPoint&)
|
||||||
if (string_is_equal(currentPlaylistPathCString,
|
if (string_is_equal(currentPlaylistPathCString,
|
||||||
playlist_get_conf_path(cachedPlaylist)))
|
playlist_get_conf_path(cachedPlaylist)))
|
||||||
{
|
{
|
||||||
playlist = cachedPlaylist;
|
playlist = cachedPlaylist;
|
||||||
loadPlaylist = false;
|
loadPlaylist = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1059,7 +1054,9 @@ void MainWindow::onPlaylistWidgetContextMenuRequested(const QPoint&)
|
||||||
}
|
}
|
||||||
else if (selectedAction == newPlaylistAction.data())
|
else if (selectedAction == newPlaylistAction.data())
|
||||||
{
|
{
|
||||||
QString name = QInputDialog::getText(this, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_NEW_PLAYLIST), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_ENTER_NEW_PLAYLIST_NAME));
|
QString name = QInputDialog::getText(this,
|
||||||
|
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_NEW_PLAYLIST),
|
||||||
|
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_ENTER_NEW_PLAYLIST_NAME));
|
||||||
QString newPlaylistPath = playlistDirAbsPath + "/" + name + ".lpl";
|
QString newPlaylistPath = playlistDirAbsPath + "/" + name + ".lpl";
|
||||||
QFile file(newPlaylistPath);
|
QFile file(newPlaylistPath);
|
||||||
|
|
||||||
|
@ -1123,9 +1120,7 @@ void MainWindow::onPlaylistWidgetContextMenuRequested(const QPoint&)
|
||||||
downloadAllThumbnails(currentPlaylistFileInfo.completeBaseName());
|
downloadAllThumbnails(currentPlaylistFileInfo.completeBaseName());
|
||||||
}
|
}
|
||||||
else if (selectedAction == downloadAllThumbnailsThisPlaylistAction.data())
|
else if (selectedAction == downloadAllThumbnailsThisPlaylistAction.data())
|
||||||
{
|
|
||||||
downloadPlaylistThumbnails(currentPlaylistPath);
|
downloadPlaylistThumbnails(currentPlaylistPath);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setCoreActions();
|
setCoreActions();
|
||||||
|
@ -1225,9 +1220,9 @@ void MainWindow::reloadPlaylists()
|
||||||
fileDisplayName.remove(".lpl");
|
fileDisplayName.remove(".lpl");
|
||||||
|
|
||||||
iconPath = QString(
|
iconPath = QString(
|
||||||
settings->paths.directory_assets)
|
settings->paths.directory_assets)
|
||||||
+ ICON_PATH
|
+ ICON_PATH
|
||||||
+ fileDisplayName
|
+ fileDisplayName
|
||||||
+ ".png";
|
+ ".png";
|
||||||
|
|
||||||
hasIcon = QFile::exists(iconPath);
|
hasIcon = QFile::exists(iconPath);
|
||||||
|
@ -1274,15 +1269,15 @@ void MainWindow::reloadPlaylists()
|
||||||
|
|
||||||
if (!path.isEmpty())
|
if (!path.isEmpty())
|
||||||
{
|
{
|
||||||
/* don't break early here since we want
|
/* don't break early here since we want
|
||||||
* to make sure we've found both initial
|
* to make sure we've found both initial
|
||||||
* and current items if they exist */
|
* and current items if they exist */
|
||||||
if (!foundInitial && path == initialPlaylist)
|
if (!foundInitial && path == initialPlaylist)
|
||||||
{
|
{
|
||||||
foundInitial = true;
|
foundInitial = true;
|
||||||
initialItem = item;
|
initialItem = item;
|
||||||
}
|
}
|
||||||
if ( !foundCurrent
|
if ( !foundCurrent
|
||||||
&& !currentPlaylistPath.isEmpty()
|
&& !currentPlaylistPath.isEmpty()
|
||||||
&& path == currentPlaylistPath)
|
&& path == currentPlaylistPath)
|
||||||
{
|
{
|
||||||
|
@ -1339,7 +1334,7 @@ bool MainWindow::currentPlaylistIsSpecial()
|
||||||
currentPlaylistFileInfo = QFileInfo(currentPlaylistPath);
|
currentPlaylistFileInfo = QFileInfo(currentPlaylistPath);
|
||||||
currentPlaylistDirPath = currentPlaylistFileInfo.absoluteDir().absolutePath();
|
currentPlaylistDirPath = currentPlaylistFileInfo.absoluteDir().absolutePath();
|
||||||
|
|
||||||
/* Don't just compare strings in case there are
|
/* Don't just compare strings in case there are
|
||||||
* case differences on Windows that should be ignored. */
|
* case differences on Windows that should be ignored. */
|
||||||
if (QDir(currentPlaylistDirPath) != QDir(playlistDirAbsPath))
|
if (QDir(currentPlaylistDirPath) != QDir(playlistDirAbsPath))
|
||||||
return true;
|
return true;
|
||||||
|
@ -1350,8 +1345,8 @@ bool MainWindow::currentPlaylistIsAll()
|
||||||
{
|
{
|
||||||
QListWidgetItem *currentPlaylistItem = m_listWidget->currentItem();
|
QListWidgetItem *currentPlaylistItem = m_listWidget->currentItem();
|
||||||
if (
|
if (
|
||||||
currentPlaylistItem
|
currentPlaylistItem
|
||||||
&& currentPlaylistItem->data(Qt::UserRole).toString()
|
&& currentPlaylistItem->data(Qt::UserRole).toString()
|
||||||
== ALL_PLAYLISTS_TOKEN)
|
== ALL_PLAYLISTS_TOKEN)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
|
@ -1578,7 +1573,7 @@ void PlaylistModel::addDir(QString path, QFlags<QDir::Filter> showHidden)
|
||||||
{
|
{
|
||||||
QDir dir = path;
|
QDir dir = path;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
QStringList dirList =
|
QStringList dirList =
|
||||||
dir.entryList(QDir::NoDotAndDotDot |
|
dir.entryList(QDir::NoDotAndDotDot |
|
||||||
QDir::Readable |
|
QDir::Readable |
|
||||||
QDir::Files |
|
QDir::Files |
|
||||||
|
|
Loading…
Reference in New Issue