MCPcopy Create free account
hub / github.com/TheAssassin/AppImageLauncher / addDirectoryToWatchToListView

Method addDirectoryToWatchToListView

src/ui/settings_dialog.cpp:61–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59}
60
61void SettingsDialog::addDirectoryToWatchToListView(const QString& dirPath) {
62 // empty paths are not permitted
63 if (dirPath.isEmpty())
64 return;
65
66 const QDir dir(dirPath);
67
68 // we don't want to redundantly add the main integration directory
69 if (dir == integratedAppImagesDestination())
70 return;
71
72 QIcon icon;
73
74 auto findIcon = [](const std::initializer_list<QString>& names) {
75 for (const auto& i : names) {
76 auto icon = QIcon::fromTheme(i, loadIconWithFallback(i));
77
78 if (!icon.isNull())
79 return icon;
80 }
81
82 return QIcon{};
83 };
84
85 if (dir.exists()) {
86 icon = findIcon({"folder"});
87 } else {
88 // TODO: search for more meaningful icon, "remove" doesn't really show the directory is missing
89 icon = findIcon({"remove"});
90 }
91
92 if (icon.isNull()) {
93 qDebug() << "item icon unavailable, using fallback";
94 }
95
96 auto* item = new QListWidgetItem(icon, dirPath);
97 ui->additionalDirsListWidget->addItem(item);
98}
99
100void SettingsDialog::loadSettings() {
101 settingsFile = getConfig();

Callers

nothing calls this directly

Calls 2

loadIconWithFallbackFunction · 0.85

Tested by

no test coverage detected