(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 */
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
{
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_MESSAGE_POS_X);
notificationsGroup->add(MENU_ENUM_LABEL_VIDEO_MESSAGE_POS_Y);
/* TODO/FIXME - localize */
notificationsGroup->addRow("Notification Color: ", new FloatColorButton(
MENU_ENUM_LABEL_VIDEO_MESSAGE_COLOR_RED,
MENU_ENUM_LABEL_VIDEO_MESSAGE_COLOR_GREEN,
MENU_ENUM_LABEL_VIDEO_MESSAGE_COLOR_BLUE));
/* TODO/FIXME - localize */
bgGroup->addRow("Notification Background Color: ", new UIntColorButton(
MENU_ENUM_LABEL_VIDEO_MESSAGE_BGCOLOR_RED,
MENU_ENUM_LABEL_VIDEO_MESSAGE_BGCOLOR_GREEN,
@ -1123,6 +1124,7 @@ QWidget *AppearancePage::widget()
* settings since they are already covered by this one
* color button */
case MENU_ENUM_LABEL_MENU_FONT_COLOR_RED:
/* TODO/FIXME - localize */
layout->addUIntColorButton("Menu Font Color: ",
MENU_ENUM_LABEL_MENU_FONT_COLOR_RED,
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.isValid())
return QVariant();
if (index.row() >= m_contents.size() || index.row() < 0)
if (!index.isValid() || index.row() >= m_contents.size() || index.row() < 0)
return QVariant();
switch (role)
@ -85,8 +82,8 @@ QVariant PlaylistModel::data(const QModelIndex &index, int role) const
QPixmap *cachedPreview = m_cache.object(getCurrentTypeThumbnailPath(index));
if (cachedPreview)
return *cachedPreview;
return QVariant();
}
break;
}
}
return QVariant();
@ -215,7 +212,6 @@ void PlaylistModel::reloadThumbnail(const QModelIndex &index)
void PlaylistModel::reloadSystemThumbnails(const QString system)
{
int i = 0;
QString key;
settings_t *settings = config_get_ptr();
const char *path_dir_thumbnails = settings->paths.directory_thumbnails;
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++)
{
key = keys.at(i);
QString key = keys.at(i);
if (key.startsWith(path))
m_cache.remove(key);
}
for (i = 0; i < pending.size(); i++)
{
key = pending.at(i);
QString key = pending.at(i);
if (key.startsWith(path))
m_pendingImages.remove(key);
}
@ -708,9 +704,9 @@ bool MainWindow::updateCurrentPlaylistEntry(
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);
if ( playlistPath.isEmpty() ||
contentHash.isEmpty() ||
!contentHash.contains("index"))
if ( playlistPath.isEmpty()
|| contentHash.isEmpty()
|| !contentHash.contains("index"))
return false;
index = contentHash.value("index").toUInt(&ok);
@ -725,10 +721,10 @@ bool MainWindow::updateCurrentPlaylistEntry(
dbName = contentHash.value("db_name");
crc32 = contentHash.value("crc32");
if (path.isEmpty() ||
label.isEmpty() ||
coreName.isEmpty() ||
corePath.isEmpty()
if ( path.isEmpty()
|| label.isEmpty()
|| coreName.isEmpty()
|| corePath.isEmpty()
)
return false;
@ -897,12 +893,11 @@ void MainWindow::onPlaylistWidgetContextMenuRequested(const QPoint&)
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))
{
/* special playlists like history etc. can't have an association */
specialPlaylist = true;
}
if (!specialPlaylist)
{
@ -1059,7 +1054,9 @@ void MainWindow::onPlaylistWidgetContextMenuRequested(const QPoint&)
}
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";
QFile file(newPlaylistPath);
@ -1123,10 +1120,8 @@ void MainWindow::onPlaylistWidgetContextMenuRequested(const QPoint&)
downloadAllThumbnails(currentPlaylistFileInfo.completeBaseName());
}
else if (selectedAction == downloadAllThumbnailsThisPlaylistAction.data())
{
downloadPlaylistThumbnails(currentPlaylistPath);
}
}
setCoreActions();
}