LeechCraft 0.6.70-17335-ge406ffdcaf
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
xdg.cpp
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
9#include "xdg.h"
10#include <QIcon>
11#include <QFile>
12
13namespace LC::Util::XDG
14{
15 QIcon GetAppIcon (const QString& name)
16 {
17 return GetAppPixmap (name);
18 }
19
20 QPixmap GetAppPixmap (const QString& name)
21 {
22 static const auto prefixes =
23 {
24 "/usr/share/pixmaps/",
25 "/usr/local/share/pixmaps/"
26 };
27
28 static const auto sizes = { "192", "128", "96", "72", "64", "48", "36", "32" };
29 static const QStringList themes
30 {
31 QStringLiteral ("/usr/local/share/icons/hicolor/"),
32 QStringLiteral ("/usr/share/icons/hicolor/")
33 };
34
35 for (auto ext : { ".png", ".svg", ".xpm", ".jpg", "" })
36 {
37 for (auto prefix : prefixes)
38 if (const auto& str = prefix + name + ext;
39 QFile::exists (str))
40 return { str };
41
42 for (const auto& themeDir : themes)
43 for (const auto& size : sizes)
44 if (const auto& str = themeDir + size + 'x' + size + "/apps/" + name + ext;
45 QFile::exists (str))
46 return { str };
47 }
48
49 return {};
50 }
51}
QIcon GetAppIcon(const QString &name)
Definition xdg.cpp:15
QPixmap GetAppPixmap(const QString &name)
Definition xdg.cpp:20