From ea9ab4b2cbd5f34be72d5dad1882c265cd810c93 Mon Sep 17 00:00:00 2001 From: Arif Hasanic Date: Mon, 9 Feb 2026 13:50:26 +0100 Subject: [PATCH] clang format --- include/components/timer.hpp | 8 ++--- include/helpers/hypr.hpp | 6 ++-- include/helpers/string.hpp | 2 +- include/services/hyprland.hpp | 5 ++- include/services/notificationController.hpp | 2 +- include/services/timerService.hpp | 1 - .../controlCenter/bluetoothSettings.hpp | 8 ++--- include/widgets/controlCenter/mediaWidget.hpp | 2 +- include/widgets/controlCenter/settings.hpp | 6 ++-- include/widgets/controlCenter/timer.hpp | 4 ++- main.cpp | 3 +- src/components/mediaControl.cpp | 3 +- src/components/popover.cpp | 1 - src/connection/dbus/bluetooth.cpp | 34 +++++++++++-------- src/services/hyprland.cpp | 28 +++++++-------- src/services/notificationController.cpp | 2 +- src/widgets/controlCenter/controlCenter.cpp | 13 ++++--- src/widgets/controlCenter/mediaWidget.cpp | 4 +-- src/widgets/controlCenter/timer.cpp | 1 - 19 files changed, 66 insertions(+), 67 deletions(-) diff --git a/include/components/timer.hpp b/include/components/timer.hpp index 2f95cb7..d4cd7f9 100644 --- a/include/components/timer.hpp +++ b/include/components/timer.hpp @@ -71,11 +71,11 @@ class Timer : public Gtk::Box { } void updateTimeLeft(uint64_t timeValue) { - uint64_t s = timeValue % 100; - uint64_t m = (timeValue / 100) % 100; - uint64_t h = timeValue / 10000; + uint64_t s = timeValue % 100; + uint64_t m = (timeValue / 100) % 100; + uint64_t h = timeValue / 10000; uint64_t totalSeconds = h * 3600 + m * 60 + s; - this->timeLeft = totalSeconds; + this->timeLeft = totalSeconds; std::ostringstream out; if (h > 0) { diff --git a/include/helpers/hypr.hpp b/include/helpers/hypr.hpp index 3a9ab3b..353ab51 100644 --- a/include/helpers/hypr.hpp +++ b/include/helpers/hypr.hpp @@ -4,8 +4,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -57,7 +57,7 @@ class HyprctlHelper { int socketFd = socket(AF_UNIX, SOCK_STREAM, 0); assert(socketFd != -1 && "Failed to create Hyprland command socket"); - struct sockaddr_un addr {}; + struct sockaddr_un addr{}; std::memset(&addr, 0, sizeof(addr)); addr.sun_family = AF_UNIX; @@ -78,7 +78,7 @@ class HyprctlHelper { std::string response; constexpr size_t kBufferSize = 4096; - std::array buffer {}; + std::array buffer{}; while (true) { ssize_t bytesRead = recv(socketFd, buffer.data(), buffer.size(), 0); if (bytesRead <= 0) { diff --git a/include/helpers/string.hpp b/include/helpers/string.hpp index 1f160d9..c9efac2 100644 --- a/include/helpers/string.hpp +++ b/include/helpers/string.hpp @@ -46,7 +46,7 @@ class StringHelper { while (len > 0 && (static_cast(input[len]) & 0xC0) == 0x80) { len--; } - + return input.substr(0, len) + "..."; } }; \ No newline at end of file diff --git a/include/services/hyprland.hpp b/include/services/hyprland.hpp index a1de68a..bd0a1e3 100644 --- a/include/services/hyprland.hpp +++ b/include/services/hyprland.hpp @@ -19,7 +19,6 @@ class HyprlandService { static inline std::shared_ptr instance; - public: struct Client { std::string address; @@ -66,7 +65,7 @@ class HyprlandService { private: HyprlandService(); - + enum SocketEventType { WORKSPACE_CHANGED, @@ -92,7 +91,7 @@ class HyprlandService { {"monitorremoved", MONITOR_REMOVED}, {"monitoradded", MONITOR_ADDED}, }; - + void onWorkspaceChanged(int workspaceId); void onFocusedMonitorChanged(std::string monitorData); void onOpenWindow(std::string windowData); diff --git a/include/services/notificationController.hpp b/include/services/notificationController.hpp index 295f28c..9bda325 100644 --- a/include/services/notificationController.hpp +++ b/include/services/notificationController.hpp @@ -12,7 +12,7 @@ #include "gdkmm/monitor.h" class NotificationController { - inline static std::shared_ptr instance = nullptr; + inline static std::shared_ptr instance = nullptr; public: static std::shared_ptr getInstance() { diff --git a/include/services/timerService.hpp b/include/services/timerService.hpp index 5c86102..f1c78e6 100644 --- a/include/services/timerService.hpp +++ b/include/services/timerService.hpp @@ -49,7 +49,6 @@ class TimerService { } ringingTimerCounter++; - } void removeTimer(uint64_t timerId) { diff --git a/include/widgets/controlCenter/bluetoothSettings.hpp b/include/widgets/controlCenter/bluetoothSettings.hpp index 8d15341..952a71c 100644 --- a/include/widgets/controlCenter/bluetoothSettings.hpp +++ b/include/widgets/controlCenter/bluetoothSettings.hpp @@ -15,7 +15,6 @@ class BluetoothSettingsRow : public Gtk::Box { set_spacing(10); set_margin_bottom(6); - if (!device.icon.empty()) { this->icon.set_from_icon_name(device.icon); this->icon.set_pixel_size(24); @@ -94,16 +93,13 @@ class BluetoothSettings : public Gtk::Box { std::map activeBluetoothDevices; std::map> deviceRows; - std::shared_ptr powerButton = std::make_shared(Icon::POWER_SETTINGS_NEW); - std::shared_ptr scanButton = std::make_shared(Icon::BLUETOOTH_SEARCHING); - - + std::shared_ptr scanButton = std::make_shared(Icon::BLUETOOTH_SEARCHING); Gtk::Box connectedDevicesBox; Gtk::Box availableDevicesBox; - bool bluetoothIsPowered = false; + bool bluetoothIsPowered = false; bool bluetoothIsScanning = false; void addBluetoothDevice(const BluetoothDevice &device); diff --git a/include/widgets/controlCenter/mediaWidget.hpp b/include/widgets/controlCenter/mediaWidget.hpp index 0065643..dc288a1 100644 --- a/include/widgets/controlCenter/mediaWidget.hpp +++ b/include/widgets/controlCenter/mediaWidget.hpp @@ -1,10 +1,10 @@ #pragma once -#include "components/mediaPlayer.hpp" #include #include #include +#include "components/mediaPlayer.hpp" #include "connection/dbus/mpris.hpp" #include "gtkmm/box.h" diff --git a/include/widgets/controlCenter/settings.hpp b/include/widgets/controlCenter/settings.hpp index 9bce8c9..c5c2f5a 100644 --- a/include/widgets/controlCenter/settings.hpp +++ b/include/widgets/controlCenter/settings.hpp @@ -1,14 +1,16 @@ #pragma once #include + #include "connection/dbus/bluetooth.hpp" #include "widgets/controlCenter/bluetoothSettings.hpp" + #include "gtkmm/box.h" class SettingsWidget : public Gtk::Box { public: SettingsWidget(); - private: + + private: BluetoothSettings bluetoothSettings; - }; \ No newline at end of file diff --git a/include/widgets/controlCenter/timer.hpp b/include/widgets/controlCenter/timer.hpp index 99bb5ec..216b725 100644 --- a/include/widgets/controlCenter/timer.hpp +++ b/include/widgets/controlCenter/timer.hpp @@ -3,8 +3,10 @@ #include #include #include + #include "components/timer.hpp" #include "services/timerService.hpp" + #include "gtkmm/box.h" class TimerWidget : public Gtk::Box { @@ -17,7 +19,7 @@ class TimerWidget : public Gtk::Box { private: std::shared_ptr timerService = TimerService::getInstance(); - bool updatingText = false; + bool updatingText = false; std::string rawDigits; std::map> activeTimers; diff --git a/main.cpp b/main.cpp index 94e5720..7b279a6 100644 --- a/main.cpp +++ b/main.cpp @@ -1,7 +1,6 @@ #include "app.hpp" -int main() -{ +int main() { App app; return app.run(); diff --git a/src/components/mediaControl.cpp b/src/components/mediaControl.cpp index 194d760..fe867fc 100644 --- a/src/components/mediaControl.cpp +++ b/src/components/mediaControl.cpp @@ -1,6 +1,5 @@ -#include "components/mediaPlayer.hpp" - #include "components/button/iconButton.hpp" +#include "components/mediaPlayer.hpp" #include "helpers/string.hpp" #include "services/textureCache.hpp" diff --git a/src/components/popover.cpp b/src/components/popover.cpp index b3b6154..9bf087b 100644 --- a/src/components/popover.cpp +++ b/src/components/popover.cpp @@ -16,7 +16,6 @@ Popover::~Popover() { if (popover) { popover->popdown(); popover->unparent(); - } }; diff --git a/src/connection/dbus/bluetooth.cpp b/src/connection/dbus/bluetooth.cpp index 221e656..9694736 100644 --- a/src/connection/dbus/bluetooth.cpp +++ b/src/connection/dbus/bluetooth.cpp @@ -84,7 +84,8 @@ void BluetoothController::pairDevice(const std::string &object_path) { void BluetoothController::unpairDevice(const std::string &object_path) { spdlog::info("Bluetooth: unpairing device {}", object_path); - if (!m_adapter_proxy) return; + if (!m_adapter_proxy) + return; auto params = Glib::VariantContainerBase::create_tuple( Glib::Variant::create(object_path)); @@ -148,7 +149,8 @@ void BluetoothController::onBusConnected(const Glib::RefPtr &r // --------------------------------------------------------------------------- void BluetoothController::enumerateObjects() { - if (!m_object_manager_proxy) return; + if (!m_object_manager_proxy) + return; try { auto result = m_object_manager_proxy->call_sync("GetManagedObjects"); @@ -230,7 +232,8 @@ void BluetoothController::onObjectManagerSignal( .get()); auto ifaces = Glib::VariantBase::cast_dynamic< - Glib::Variant>>(parameters.get_child(1)).get(); + Glib::Variant>>(parameters.get_child(1)) + .get(); for (const auto &iface : ifaces) { if (iface == "org.bluez.Device1") { @@ -307,7 +310,7 @@ void BluetoothController::onAdapterPropertiesChanged( void BluetoothController::addDevice(const std::string &path, const PropertiesMap &properties) { - auto device = parseDeviceProperties(path, properties); + auto device = parseDeviceProperties(path, properties); m_devices[path] = device; spdlog::info("Bluetooth device added: {} ({}) {}", device.name, device.address, device.icon); @@ -344,7 +347,8 @@ void BluetoothController::onDevicePropertiesChanged( const std::vector &) { auto it = m_devices.find(object_path); - if (it == m_devices.end()) return; + if (it == m_devices.end()) + return; auto &device = it->second; @@ -404,10 +408,12 @@ BluetoothDevice BluetoothController::parseDeviceProperties( return false; }; - device.address = getString("Address"); - device.name = getString("Name"); - if (device.name.empty()) device.name = getString("Alias"); - if (device.name.empty()) device.name = device.address; + device.address = getString("Address"); + device.name = getString("Name"); + if (device.name.empty()) + device.name = getString("Alias"); + if (device.name.empty()) + device.name = device.address; device.icon = getString("Icon"); device.paired = getBool("Paired"); device.connected = getBool("Connected"); @@ -429,17 +435,17 @@ void BluetoothController::setDbusProperty(const std::string &object_path, const std::string &interface, const std::string &property, const Glib::VariantBase &value) { - if (!connection || object_path.empty()) return; + if (!connection || object_path.empty()) + return; try { auto props_proxy = Gio::DBus::Proxy::create_sync( connection, "org.bluez", object_path, "org.freedesktop.DBus.Properties"); auto wrapped = Glib::Variant::create(value); - auto params = Glib::VariantContainerBase::create_tuple({ - Glib::Variant::create(interface), - Glib::Variant::create(property), - wrapped}); + auto params = Glib::VariantContainerBase::create_tuple({Glib::Variant::create(interface), + Glib::Variant::create(property), + wrapped}); props_proxy->call_sync("Set", params); } catch (const Glib::Error &ex) { diff --git a/src/services/hyprland.cpp b/src/services/hyprland.cpp index 0565cdc..29f98ff 100644 --- a/src/services/hyprland.cpp +++ b/src/services/hyprland.cpp @@ -284,26 +284,26 @@ void HyprlandService::handleSocketMessage(SocketHelper::SocketMessage message) { void HyprlandService::onMonitorAdded(std::string monitorName) { spdlog::info("[Hyprland] Monitor added: {}", monitorName); auto monitorDataJson = HyprctlHelper::getMonitorData(); - auto monitorIt = std::ranges::find_if(monitorDataJson, - [&monitorName](const auto &item) { - return item.contains("name") && item["name"] == monitorName; - }); + auto monitorIt = std::ranges::find_if(monitorDataJson, + [&monitorName](const auto &item) { + return item.contains("name") && item["name"] == monitorName; + }); if (monitorIt == monitorDataJson.end()) { spdlog::warn("[Hyprland] Monitor data not found for {}", monitorName); return; } - auto monitorPtr = std::make_shared(); - monitorPtr->id = (*monitorIt)["id"]; - monitorPtr->name = monitorName; - monitorPtr->activeWorkspaceId = (*monitorIt)["activeWorkspace"]["id"]; - monitorPtr->focused = (*monitorIt)["focused"]; - this->monitors[monitorName] = monitorPtr; + auto monitorPtr = std::make_shared(); + monitorPtr->id = (*monitorIt)["id"]; + monitorPtr->name = monitorName; + monitorPtr->activeWorkspaceId = (*monitorIt)["activeWorkspace"]["id"]; + monitorPtr->focused = (*monitorIt)["focused"]; + this->monitors[monitorName] = monitorPtr; auto onClick = sigc::mem_fun(*this, &HyprlandService::switchToWorkspace); for (int i = 1; i <= NUM_WORKSPACES; i++) { - auto state = std::make_shared(); + auto state = std::make_shared(); int workspaceId = i + (NUM_WORKSPACES * monitorPtr->id); state->id = workspaceId; @@ -337,7 +337,7 @@ void HyprlandService::onMonitorAdded(std::string monitorName) { if (this->clients.find(address) != this->clients.end()) { continue; } - int workspaceId = client["workspace"]["id"].get(); + int workspaceId = client["workspace"]["id"].get(); auto workspaceIt = workspaces.find(workspaceId); if (workspaceIt == workspaces.end()) { continue; @@ -413,7 +413,7 @@ void HyprlandService::onActiveWindowChanged(std::string windowAddress) { } std::shared_ptr HyprlandService::getWorkspaceIndicatorsForMonitor(std::string monitorName) { - auto box = std::make_shared(Gtk::Orientation::HORIZONTAL); + auto box = std::make_shared(Gtk::Orientation::HORIZONTAL); auto monitorIt = monitors.find(monitorName); if (monitorIt == monitors.end()) { return box; @@ -434,7 +434,7 @@ void HyprlandService::switchToWorkspace(int workspaceId) { void HyprlandService::refreshIndicator(std::shared_ptr workspace) { auto view = workspace->view; - auto state = workspace->state; + auto state = workspace->state; auto monitorIt = monitors.find(state->monitorName); if (monitorIt == monitors.end()) { return; diff --git a/src/services/notificationController.cpp b/src/services/notificationController.cpp index 70f592d..71442f5 100644 --- a/src/services/notificationController.cpp +++ b/src/services/notificationController.cpp @@ -154,7 +154,7 @@ void NotificationController::closeNotification(uint64_t notificationId) { } void NotificationController::addMonitor(std::shared_ptr monitor) { - auto name = monitor->get_connector(); + auto name = monitor->get_connector(); this->activeMonitors[name] = monitor; } diff --git a/src/widgets/controlCenter/controlCenter.cpp b/src/widgets/controlCenter/controlCenter.cpp index 7c0ff55..bed5684 100644 --- a/src/widgets/controlCenter/controlCenter.cpp +++ b/src/widgets/controlCenter/controlCenter.cpp @@ -24,9 +24,9 @@ ControlCenter::ControlCenter(Icon::Type icon, std::string name) this->tabRow.set_margin_bottom(4); this->tabRow.add_css_class("control-center-tab-row"); - this->mediaTabButton = std::make_unique(Icon::PLAY_CIRCLE); - this->infoTabButton = std::make_unique(Icon::EMPTY_DASHBOARD); - this->timerButton = std::make_unique(Icon::TOKEN); + this->mediaTabButton = std::make_unique(Icon::PLAY_CIRCLE); + this->infoTabButton = std::make_unique(Icon::EMPTY_DASHBOARD); + this->timerButton = std::make_unique(Icon::TOKEN); this->settingsTabButton = std::make_unique(Icon::SETTINGS); this->tabRow.append(*this->mediaTabButton); @@ -41,9 +41,9 @@ ControlCenter::ControlCenter(Icon::Type icon, std::string name) this->contentStack.set_transition_type(Gtk::StackTransitionType::CROSSFADE); this->mediaControlWidget = std::make_unique(); - this->weatherWidget = std::make_unique(); - this->timerWidget = std::make_unique(); - this->settingsWidget = std::make_unique(); + this->weatherWidget = std::make_unique(); + this->timerWidget = std::make_unique(); + this->settingsWidget = std::make_unique(); this->contentStack.add(*this->mediaControlWidget, "controls", "Controls"); this->contentStack.add(*this->weatherWidget, "info", "Info"); @@ -87,4 +87,3 @@ void ControlCenter::setActiveTab(const std::string &tab_name) { this->timerButton->setActive(true); } } - diff --git a/src/widgets/controlCenter/mediaWidget.cpp b/src/widgets/controlCenter/mediaWidget.cpp index 1af1fb4..7e0a9d5 100644 --- a/src/widgets/controlCenter/mediaWidget.cpp +++ b/src/widgets/controlCenter/mediaWidget.cpp @@ -33,7 +33,7 @@ void MediaWidget::addPlayerWidget(const std::string &bus_name) { auto controller = MprisController::createForPlayer(bus_name); auto widget = std::make_unique(controller); - + this->mediaWidgets.emplace(bus_name, std::move(widget)); this->container.append(*this->mediaWidgets[bus_name]); } @@ -44,7 +44,7 @@ void MediaWidget::removePlayerWidget(const std::string &bus_name) { if (it == this->mediaWidgets.end()) { return; } - + this->container.remove(*it->second); this->mediaWidgets.erase(it); } \ No newline at end of file diff --git a/src/widgets/controlCenter/timer.cpp b/src/widgets/controlCenter/timer.cpp index 2123447..226e670 100644 --- a/src/widgets/controlCenter/timer.cpp +++ b/src/widgets/controlCenter/timer.cpp @@ -6,7 +6,6 @@ #include #include - #include "gtkmm/entry.h" #include "gtkmm/eventcontrollerkey.h" #include "gtkmm/label.h"