mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-05-29 13:20:18 +02:00
clang-tidy formatting
Signed-off-by: QazCetelic <qaz.cetelic@protonmail.com>
This commit is contained in:
parent
6b0007291b
commit
40c3866f63
@ -47,19 +47,19 @@
|
|||||||
|
|
||||||
#define MAX_SIZE 1024
|
#define MAX_SIZE 1024
|
||||||
|
|
||||||
IconList::IconList(const QStringList& builtinPaths, QString path, QObject* parent) : QAbstractListModel(parent)
|
IconList::IconList(const QStringList& builtinPaths, const QString& path, QObject* parent) : QAbstractListModel(parent)
|
||||||
{
|
{
|
||||||
QSet<QString> builtinNames;
|
QSet<QString> builtinNames;
|
||||||
|
|
||||||
// add builtin icons
|
// add builtin icons
|
||||||
for (auto& builtinPath : builtinPaths) {
|
for (const auto& builtinPath : builtinPaths) {
|
||||||
QDir instance_icons(builtinPath);
|
QDir instance_icons(builtinPath);
|
||||||
auto file_info_list = instance_icons.entryInfoList(QDir::Files, QDir::Name);
|
auto file_info_list = instance_icons.entryInfoList(QDir::Files, QDir::Name);
|
||||||
for (auto file_info : file_info_list) {
|
for (const auto& file_info : file_info_list) {
|
||||||
builtinNames.insert(file_info.baseName());
|
builtinNames.insert(file_info.baseName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (auto& builtinName : builtinNames) {
|
for (const auto& builtinName : builtinNames) {
|
||||||
addThemeIcon(builtinName);
|
addThemeIcon(builtinName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ void IconList::sortIconList()
|
|||||||
bool aIsSubdir = a.m_key.contains(std::filesystem::path::preferred_separator);
|
bool aIsSubdir = a.m_key.contains(std::filesystem::path::preferred_separator);
|
||||||
bool bIsSubdir = b.m_key.contains(std::filesystem::path::preferred_separator);
|
bool bIsSubdir = b.m_key.contains(std::filesystem::path::preferred_separator);
|
||||||
if (aIsSubdir != bIsSubdir) {
|
if (aIsSubdir != bIsSubdir) {
|
||||||
return !aIsSubdir; // root-level icons come first
|
return !aIsSubdir; // root-level icons come first
|
||||||
}
|
}
|
||||||
return a.m_key.localeAwareCompare(b.m_key) < 0;
|
return a.m_key.localeAwareCompare(b.m_key) < 0;
|
||||||
});
|
});
|
||||||
@ -102,10 +102,8 @@ bool IconList::addPathRecursively(const QString& path)
|
|||||||
|
|
||||||
// Add all subdirectories
|
// Add all subdirectories
|
||||||
QFileInfoList entries = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
|
QFileInfoList entries = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||||
for (const QFileInfo& entry : entries)
|
for (const QFileInfo& entry : entries) {
|
||||||
{
|
if (addPathRecursively(entry.absoluteFilePath())) {
|
||||||
if (addPathRecursively(entry.absoluteFilePath()))
|
|
||||||
{
|
|
||||||
watching = true;
|
watching = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -122,15 +120,13 @@ void IconList::removePathRecursively(const QString& path)
|
|||||||
if (idx == -1)
|
if (idx == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
} else if (file_info.isDir()) {
|
||||||
else if (file_info.isDir()) {
|
|
||||||
// Remove the directory itself
|
// Remove the directory itself
|
||||||
m_watcher->removePath(path);
|
m_watcher->removePath(path);
|
||||||
|
|
||||||
const QDir dir(path);
|
const QDir dir(path);
|
||||||
// Remove all files within the directory
|
// Remove all files within the directory
|
||||||
for (const QFileInfo& file : dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot))
|
for (const QFileInfo& file : dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)) {
|
||||||
{
|
|
||||||
removePathRecursively(file.absoluteFilePath());
|
removePathRecursively(file.absoluteFilePath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -138,13 +134,13 @@ void IconList::removePathRecursively(const QString& path)
|
|||||||
|
|
||||||
QStringList IconList::getIconFilePaths() const
|
QStringList IconList::getIconFilePaths() const
|
||||||
{
|
{
|
||||||
QStringList icon_files {};
|
QStringList icon_files{};
|
||||||
QStringList directories {m_dir.absolutePath()};
|
QStringList directories{ m_dir.absolutePath() };
|
||||||
while (!directories.isEmpty()) {
|
while (!directories.isEmpty()) {
|
||||||
QString first = directories.takeFirst();
|
QString first = directories.takeFirst();
|
||||||
QDir dir(first);
|
QDir dir(first);
|
||||||
for (QString& file_name : dir.entryList(QDir::AllDirs | QDir::Files |QDir::NoDotAndDotDot, QDir::Name)) {
|
for (QString& file_name : dir.entryList(QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot, QDir::Name)) {
|
||||||
QString full_path = dir.filePath(file_name); // Convert to full path
|
QString full_path = dir.filePath(file_name); // Convert to full path
|
||||||
QFileInfo file_info(full_path);
|
QFileInfo file_info(full_path);
|
||||||
if (file_info.isDir())
|
if (file_info.isDir())
|
||||||
directories.push_back(full_path);
|
directories.push_back(full_path);
|
||||||
@ -159,10 +155,10 @@ QString formatName(const QDir& icons_dir, const QFileInfo& file)
|
|||||||
{
|
{
|
||||||
if (file.dir() == icons_dir) {
|
if (file.dir() == icons_dir) {
|
||||||
return file.baseName();
|
return file.baseName();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
const QString delimiter = " » ";
|
const QString delimiter = " » ";
|
||||||
return (icons_dir.relativeFilePath(file.dir().path()) + std::filesystem::path::preferred_separator + file.baseName()).replace(std::filesystem::path::preferred_separator, delimiter);
|
return (icons_dir.relativeFilePath(file.dir().path()) + std::filesystem::path::preferred_separator + file.baseName())
|
||||||
|
.replace(std::filesystem::path::preferred_separator, delimiter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,7 +248,7 @@ void IconList::fileChanged(const QString& path)
|
|||||||
if (idx == -1)
|
if (idx == -1)
|
||||||
return;
|
return;
|
||||||
QIcon icon(path);
|
QIcon icon(path);
|
||||||
if (!icon.availableSizes().size())
|
if (icon.availableSizes().empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
icons[idx].m_images[IconType::FileBased].icon = icon;
|
icons[idx].m_images[IconType::FileBased].icon = icon;
|
||||||
@ -260,7 +256,7 @@ void IconList::fileChanged(const QString& path)
|
|||||||
emit iconUpdated(key);
|
emit iconUpdated(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IconList::SettingChanged(const Setting& setting, QVariant value)
|
void IconList::SettingChanged(const Setting& setting, const QVariant& value)
|
||||||
{
|
{
|
||||||
if (setting.id() != "IconsDir")
|
if (setting.id() != "IconsDir")
|
||||||
return;
|
return;
|
||||||
@ -335,12 +331,12 @@ Qt::ItemFlags IconList::flags(const QModelIndex& index) const
|
|||||||
QVariant IconList::data(const QModelIndex& index, int role) const
|
QVariant IconList::data(const QModelIndex& index, int role) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QVariant();
|
return {};
|
||||||
|
|
||||||
int row = index.row();
|
int row = index.row();
|
||||||
|
|
||||||
if (row < 0 || row >= icons.size())
|
if (row < 0 || row >= icons.size())
|
||||||
return QVariant();
|
return {};
|
||||||
|
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case Qt::DecorationRole:
|
case Qt::DecorationRole:
|
||||||
@ -350,7 +346,7 @@ QVariant IconList::data(const QModelIndex& index, int role) const
|
|||||||
case Qt::UserRole:
|
case Qt::UserRole:
|
||||||
return icons[row].m_key;
|
return icons[row].m_key;
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -361,7 +357,7 @@ int IconList::rowCount(const QModelIndex& parent) const
|
|||||||
|
|
||||||
void IconList::installIcons(const QStringList& iconFiles)
|
void IconList::installIcons(const QStringList& iconFiles)
|
||||||
{
|
{
|
||||||
for (QString file : iconFiles)
|
for (const QString& file : iconFiles)
|
||||||
installIcon(file, {});
|
installIcon(file, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -467,7 +463,7 @@ void IconList::reindex()
|
|||||||
for (auto& iter : icons) {
|
for (auto& iter : icons) {
|
||||||
name_index[iter.m_key] = i;
|
name_index[iter.m_key] = i;
|
||||||
i++;
|
i++;
|
||||||
emit iconUpdated(iter.m_key); // prevents incorrect indices with proxy model
|
emit iconUpdated(iter.m_key); // prevents incorrect indices with proxy model
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -483,7 +479,7 @@ QIcon IconList::getIcon(const QString& key) const
|
|||||||
|
|
||||||
if (icon_index != -1)
|
if (icon_index != -1)
|
||||||
return icons[icon_index].icon();
|
return icons[icon_index].icon();
|
||||||
return QIcon();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
int IconList::getIconIndex(const QString& key) const
|
int IconList::getIconIndex(const QString& key) const
|
||||||
@ -503,7 +499,7 @@ QString IconList::getDirectory() const
|
|||||||
/// Returns the directory of the icon with the given key or the default directory if it's a builtin icon.
|
/// Returns the directory of the icon with the given key or the default directory if it's a builtin icon.
|
||||||
QString IconList::iconDirectory(const QString& key) const
|
QString IconList::iconDirectory(const QString& key) const
|
||||||
{
|
{
|
||||||
for (auto mmc_icon : icons) {
|
for (const auto& mmc_icon : icons) {
|
||||||
if (mmc_icon.m_key == key && mmc_icon.has(IconType::FileBased)) {
|
if (mmc_icon.m_key == key && mmc_icon.has(IconType::FileBased)) {
|
||||||
QFileInfo icon_file(mmc_icon.getFilePath());
|
QFileInfo icon_file(mmc_icon.getFilePath());
|
||||||
return icon_file.dir().path();
|
return icon_file.dir().path();
|
||||||
|
@ -51,7 +51,7 @@ class QFileSystemWatcher;
|
|||||||
class IconList : public QAbstractListModel {
|
class IconList : public QAbstractListModel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit IconList(const QStringList& builtinPaths, QString path, QObject* parent = 0);
|
explicit IconList(const QStringList& builtinPaths, const QString& path, QObject* parent = 0);
|
||||||
virtual ~IconList() {};
|
virtual ~IconList() {};
|
||||||
|
|
||||||
QIcon getIcon(const QString& key) const;
|
QIcon getIcon(const QString& key) const;
|
||||||
@ -101,7 +101,7 @@ class IconList : public QAbstractListModel {
|
|||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void fileChanged(const QString& path);
|
void fileChanged(const QString& path);
|
||||||
void SettingChanged(const Setting& setting, QVariant value);
|
void SettingChanged(const Setting& setting, const QVariant& value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
shared_qobject_ptr<QFileSystemWatcher> m_watcher;
|
shared_qobject_ptr<QFileSystemWatcher> m_watcher;
|
||||||
|
@ -15,9 +15,9 @@
|
|||||||
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
|
#include <QLineEdit>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
#include <QLineEdit>
|
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user