Improve coding style

This commit is contained in:
Vladimir Golovnev (Glassez) 2020-11-16 10:02:11 +03:00
parent acad35c5bc
commit c41df9ffbd
No known key found for this signature in database
GPG key ID: 52A2C7DEE2DFA6F7
147 changed files with 4454 additions and 2227 deletions

View file

@ -105,7 +105,8 @@ QPixmap Utils::Gui::scaledPixmapSvg(const QString &path, const QWidget *widget,
QPixmap pm;
QPixmapCache cache;
if (!cache.find(normalizedKey, &pm)) {
if (!cache.find(normalizedKey, &pm))
{
pm = QIcon(path).pixmap(scaledHeight);
cache.insert(normalizedKey, pm);
}
@ -178,7 +179,8 @@ void Utils::Gui::openFolderSelect(const QString &absolutePath)
QString path {Utils::Fs::toUniformPath(absolutePath)};
const QFileInfo pathInfo {path};
// If the item to select doesn't exist, try to open its parent
if (!pathInfo.exists(path)) {
if (!pathInfo.exists(path))
{
openPath(path.left(path.lastIndexOf('/')));
return;
}
@ -186,7 +188,8 @@ void Utils::Gui::openFolderSelect(const QString &absolutePath)
#ifdef Q_OS_WIN
HRESULT hresult = ::CoInitializeEx(nullptr, COINIT_MULTITHREADED);
PIDLIST_ABSOLUTE pidl = ::ILCreateFromPathW(reinterpret_cast<PCTSTR>(Utils::Fs::toNativePath(path).utf16()));
if (pidl) {
if (pidl)
{
::SHOpenFolderAndSelectItems(pidl, 0, nullptr, 0);
::ILFree(pidl);
}
@ -197,11 +200,13 @@ void Utils::Gui::openFolderSelect(const QString &absolutePath)
proc.start("xdg-mime", {"query", "default", "inode/directory"});
proc.waitForFinished();
const QString output = proc.readLine().simplified();
if ((output == "dolphin.desktop") || (output == "org.kde.dolphin.desktop")) {
if ((output == "dolphin.desktop") || (output == "org.kde.dolphin.desktop"))
{
proc.startDetached("dolphin", {"--select", Utils::Fs::toNativePath(path)});
}
else if ((output == "nautilus.desktop") || (output == "org.gnome.Nautilus.desktop")
|| (output == "nautilus-folder-handler.desktop")) {
|| (output == "nautilus-folder-handler.desktop"))
{
if (pathInfo.isDir())
path = path.left(path.lastIndexOf('/'));
proc.start("nautilus", {"--version"});
@ -213,15 +218,18 @@ void Utils::Gui::openFolderSelect(const QString &absolutePath)
else
proc.startDetached("nautilus", {"--no-desktop", Utils::Fs::toNativePath(path)});
}
else if (output == "nemo.desktop") {
else if (output == "nemo.desktop")
{
if (pathInfo.isDir())
path = path.left(path.lastIndexOf('/'));
proc.startDetached("nemo", {"--no-desktop", Utils::Fs::toNativePath(path)});
}
else if ((output == "konqueror.desktop") || (output == "kfmclient_dir.desktop")) {
else if ((output == "konqueror.desktop") || (output == "kfmclient_dir.desktop"))
{
proc.startDetached("konqueror", {"--select", Utils::Fs::toNativePath(path)});
}
else {
else
{
// "caja" manager can't pinpoint the file, see: https://github.com/qbittorrent/qBittorrent/issues/5003
openPath(path.left(path.lastIndexOf('/')));
}