(Qt) Small cleanups

This commit is contained in:
libretroadmin 2023-08-15 23:58:54 +02:00
parent abcd42777f
commit 3862069cb7
3 changed files with 103 additions and 107 deletions

View File

@ -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;

View File

@ -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,
@ -1123,6 +1124,7 @@ QWidget *AppearancePage::widget()
* 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,

View File

@ -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)
@ -85,8 +82,8 @@ QVariant PlaylistModel::data(const QModelIndex &index, int role) const
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();
@ -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);
} }
@ -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;
@ -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)
{ {
@ -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,10 +1120,8 @@ 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();
} }