all: fix failing lints

This commit is contained in:
outfoxxed 2024-06-18 20:46:58 -07:00
parent 8ec245ac66
commit 3033cba52d
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
4 changed files with 83 additions and 89 deletions

View file

@ -4,10 +4,8 @@
#include <qdebug.h> #include <qdebug.h>
#include <qdir.h> #include <qdir.h>
#include <qfileinfo.h> #include <qfileinfo.h>
#include <qfilesystemwatcher.h>
#include <qhash.h> #include <qhash.h>
#include <qlist.h> #include <qlist.h>
#include <qlocale.h>
#include <qlogging.h> #include <qlogging.h>
#include <qloggingcategory.h> #include <qloggingcategory.h>
#include <qnamespace.h> #include <qnamespace.h>
@ -94,7 +92,7 @@ void DesktopEntry::parseEntry(const QString& text) {
auto groupName = QString(); auto groupName = QString();
auto entries = QHash<QString, QPair<Locale, QString>>(); auto entries = QHash<QString, QPair<Locale, QString>>();
auto finishCategory = [&]() { auto finishCategory = [this, &groupName, &entries]() {
if (groupName == "Desktop Entry") { if (groupName == "Desktop Entry") {
if (entries["Type"].second != "Application") return; if (entries["Type"].second != "Application") return;
if (entries.contains("Hidden") && entries["Hidden"].second == "true") return; if (entries.contains("Hidden") && entries["Hidden"].second == "true") return;
@ -334,13 +332,13 @@ void DesktopEntryManager::scanPath(const QDir& dir, const QString& prefix) {
qCDebug(logDesktopEntry) << "Found desktop entry" << id << "at" << path; qCDebug(logDesktopEntry) << "Found desktop entry" << id << "at" << path;
if (desktopEntries.contains(id)) { if (this->desktopEntries.contains(id)) {
qCDebug(logDesktopEntry) << "Replacing old entry for" << id; qCDebug(logDesktopEntry) << "Replacing old entry for" << id;
delete desktopEntries.value(id); delete this->desktopEntries.value(id);
desktopEntries.remove(id); this->desktopEntries.remove(id);
} }
desktopEntries.insert(id, dentry); this->desktopEntries.insert(id, dentry);
} }
} }
} }

View file

@ -10,7 +10,9 @@
#include <qguiapplication.h> #include <qguiapplication.h>
#include <qhash.h> #include <qhash.h>
#include <qicon.h> #include <qicon.h>
#include <qlist.h>
#include <qlogging.h> #include <qlogging.h>
#include <qnamespace.h>
#include <qqmldebug.h> #include <qqmldebug.h>
#include <qquickwindow.h> #include <qquickwindow.h>
#include <qstandardpaths.h> #include <qstandardpaths.h>

View file

@ -7,6 +7,7 @@
#include <qobject.h> #include <qobject.h>
#include <qquickitem.h> #include <qquickitem.h>
#include <qquickwindow.h> #include <qquickwindow.h>
#include <qtmetamacros.h>
void TransformWatcher::resolveChains(QQuickItem* a, QQuickItem* b, QQuickItem* commonParent) { void TransformWatcher::resolveChains(QQuickItem* a, QQuickItem* b, QQuickItem* commonParent) {
if (a == nullptr || b == nullptr) return; if (a == nullptr || b == nullptr) return;

View file

@ -377,58 +377,55 @@ void HyprlandIpc::refreshWorkspaces(bool canCreate) {
if (this->requestingWorkspaces) return; if (this->requestingWorkspaces) return;
this->requestingWorkspaces = true; this->requestingWorkspaces = true;
this->makeRequest( this->makeRequest("j/workspaces", [this, canCreate](bool success, const QByteArray& resp) {
"j/workspaces", this->requestingWorkspaces = false;
[this, canCreate](bool success, const QByteArray& resp) { if (!success) return;
this->requestingWorkspaces = false;
if (!success) return;
qCDebug(logHyprlandIpc) << "parsing workspaces response"; qCDebug(logHyprlandIpc) << "parsing workspaces response";
auto json = QJsonDocument::fromJson(resp).array(); auto json = QJsonDocument::fromJson(resp).array();
const auto& mList = this->mWorkspaces.valueList(); const auto& mList = this->mWorkspaces.valueList();
auto names = QVector<QString>(); auto names = QVector<QString>();
for (auto entry: json) { for (auto entry: json) {
auto object = entry.toObject().toVariantMap(); auto object = entry.toObject().toVariantMap();
auto name = object.value("name").toString(); auto name = object.value("name").toString();
auto workspaceIter = auto workspaceIter =
std::find_if(mList.begin(), mList.end(), [name](const HyprlandWorkspace* m) { std::find_if(mList.begin(), mList.end(), [name](const HyprlandWorkspace* m) {
return m->name() == name; return m->name() == name;
}); });
auto* workspace = workspaceIter == mList.end() ? nullptr : *workspaceIter; auto* workspace = workspaceIter == mList.end() ? nullptr : *workspaceIter;
auto existed = workspace != nullptr; auto existed = workspace != nullptr;
if (workspace == nullptr) { if (workspace == nullptr) {
if (!canCreate) continue; if (!canCreate) continue;
workspace = new HyprlandWorkspace(this); workspace = new HyprlandWorkspace(this);
} }
workspace->updateFromObject(object); workspace->updateFromObject(object);
if (!existed) { if (!existed) {
this->mWorkspaces.insertObject(workspace); this->mWorkspaces.insertObject(workspace);
} }
names.push_back(name); names.push_back(name);
} }
auto removedWorkspaces = QVector<HyprlandWorkspace*>(); auto removedWorkspaces = QVector<HyprlandWorkspace*>();
for (auto* workspace: mList) { for (auto* workspace: mList) {
if (!names.contains(workspace->name())) { if (!names.contains(workspace->name())) {
removedWorkspaces.push_back(workspace); removedWorkspaces.push_back(workspace);
} }
} }
for (auto* workspace: removedWorkspaces) { for (auto* workspace: removedWorkspaces) {
this->mWorkspaces.removeObject(workspace); this->mWorkspaces.removeObject(workspace);
delete workspace; delete workspace;
} }
} });
);
} }
HyprlandMonitor* HyprlandMonitor*
@ -489,61 +486,57 @@ void HyprlandIpc::refreshMonitors(bool canCreate) {
if (this->requestingMonitors) return; if (this->requestingMonitors) return;
this->requestingMonitors = true; this->requestingMonitors = true;
this->makeRequest( this->makeRequest("j/monitors", [this, canCreate](bool success, const QByteArray& resp) {
"j/monitors", this->requestingMonitors = false;
[this, canCreate](bool success, const QByteArray& resp) { if (!success) return;
this->requestingMonitors = false;
if (!success) return;
this->monitorsRequested = true; this->monitorsRequested = true;
qCDebug(logHyprlandIpc) << "parsing monitors response"; qCDebug(logHyprlandIpc) << "parsing monitors response";
auto json = QJsonDocument::fromJson(resp).array(); auto json = QJsonDocument::fromJson(resp).array();
const auto& mList = this->mMonitors.valueList(); const auto& mList = this->mMonitors.valueList();
auto names = QVector<QString>(); auto names = QVector<QString>();
for (auto entry: json) { for (auto entry: json) {
auto object = entry.toObject().toVariantMap(); auto object = entry.toObject().toVariantMap();
auto name = object.value("name").toString(); auto name = object.value("name").toString();
auto monitorIter = auto monitorIter = std::find_if(mList.begin(), mList.end(), [name](const HyprlandMonitor* m) {
std::find_if(mList.begin(), mList.end(), [name](const HyprlandMonitor* m) { return m->name() == name;
return m->name() == name; });
});
auto* monitor = monitorIter == mList.end() ? nullptr : *monitorIter; auto* monitor = monitorIter == mList.end() ? nullptr : *monitorIter;
auto existed = monitor != nullptr; auto existed = monitor != nullptr;
if (monitor == nullptr) { if (monitor == nullptr) {
if (!canCreate) continue; if (!canCreate) continue;
monitor = new HyprlandMonitor(this); monitor = new HyprlandMonitor(this);
} }
monitor->updateFromObject(object); monitor->updateFromObject(object);
if (!existed) { if (!existed) {
this->mMonitors.insertObject(monitor); this->mMonitors.insertObject(monitor);
} }
names.push_back(name); names.push_back(name);
} }
auto removedMonitors = QVector<HyprlandMonitor*>(); auto removedMonitors = QVector<HyprlandMonitor*>();
for (auto* monitor: mList) { for (auto* monitor: mList) {
if (!names.contains(monitor->name())) { if (!names.contains(monitor->name())) {
removedMonitors.push_back(monitor); removedMonitors.push_back(monitor);
} }
} }
for (auto* monitor: removedMonitors) { for (auto* monitor: removedMonitors) {
this->mMonitors.removeObject(monitor); this->mMonitors.removeObject(monitor);
// see comment in onEvent // see comment in onEvent
monitor->deleteLater(); monitor->deleteLater();
} }
} });
);
} }
} // namespace qs::hyprland::ipc } // namespace qs::hyprland::ipc