clang format
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <span>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
@@ -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<char, kBufferSize> buffer {};
|
||||
std::array<char, kBufferSize> buffer{};
|
||||
while (true) {
|
||||
ssize_t bytesRead = recv(socketFd, buffer.data(), buffer.size(), 0);
|
||||
if (bytesRead <= 0) {
|
||||
|
||||
@@ -46,7 +46,7 @@ class StringHelper {
|
||||
while (len > 0 && (static_cast<unsigned char>(input[len]) & 0xC0) == 0x80) {
|
||||
len--;
|
||||
}
|
||||
|
||||
|
||||
return input.substr(0, len) + "...";
|
||||
}
|
||||
};
|
||||
@@ -19,7 +19,6 @@
|
||||
class HyprlandService {
|
||||
static inline std::shared_ptr<HyprlandService> 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);
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "gdkmm/monitor.h"
|
||||
|
||||
class NotificationController {
|
||||
inline static std::shared_ptr<NotificationController> instance = nullptr;
|
||||
inline static std::shared_ptr<NotificationController> instance = nullptr;
|
||||
|
||||
public:
|
||||
static std::shared_ptr<NotificationController> getInstance() {
|
||||
|
||||
@@ -49,7 +49,6 @@ class TimerService {
|
||||
}
|
||||
|
||||
ringingTimerCounter++;
|
||||
|
||||
}
|
||||
|
||||
void removeTimer(uint64_t timerId) {
|
||||
|
||||
@@ -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<std::string, BluetoothDevice> activeBluetoothDevices;
|
||||
std::map<std::string, std::shared_ptr<BluetoothSettingsRow>> deviceRows;
|
||||
|
||||
|
||||
std::shared_ptr<IconButton> powerButton = std::make_shared<IconButton>(Icon::POWER_SETTINGS_NEW);
|
||||
std::shared_ptr<IconButton> scanButton = std::make_shared<IconButton>(Icon::BLUETOOTH_SEARCHING);
|
||||
|
||||
|
||||
std::shared_ptr<IconButton> scanButton = std::make_shared<IconButton>(Icon::BLUETOOTH_SEARCHING);
|
||||
|
||||
Gtk::Box connectedDevicesBox;
|
||||
Gtk::Box availableDevicesBox;
|
||||
|
||||
bool bluetoothIsPowered = false;
|
||||
bool bluetoothIsPowered = false;
|
||||
bool bluetoothIsScanning = false;
|
||||
|
||||
void addBluetoothDevice(const BluetoothDevice &device);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "components/mediaPlayer.hpp"
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "components/mediaPlayer.hpp"
|
||||
#include "connection/dbus/mpris.hpp"
|
||||
|
||||
#include "gtkmm/box.h"
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
|
||||
#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;
|
||||
|
||||
};
|
||||
@@ -3,8 +3,10 @@
|
||||
#include <memory>
|
||||
#include <sigc++/connection.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#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 = TimerService::getInstance();
|
||||
bool updatingText = false;
|
||||
bool updatingText = false;
|
||||
std::string rawDigits;
|
||||
|
||||
std::map<uint64_t, std::unique_ptr<Timer>> activeTimers;
|
||||
|
||||
3
main.cpp
3
main.cpp
@@ -1,7 +1,6 @@
|
||||
#include "app.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
int main() {
|
||||
App app;
|
||||
|
||||
return app.run();
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ Popover::~Popover() {
|
||||
if (popover) {
|
||||
popover->popdown();
|
||||
popover->unparent();
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -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<Glib::DBusObjectPathString>::create(object_path));
|
||||
@@ -148,7 +149,8 @@ void BluetoothController::onBusConnected(const Glib::RefPtr<Gio::AsyncResult> &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<std::vector<Glib::ustring>>>(parameters.get_child(1)).get();
|
||||
Glib::Variant<std::vector<Glib::ustring>>>(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<Glib::ustring> &) {
|
||||
|
||||
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<Glib::VariantBase>::create(value);
|
||||
auto params = Glib::VariantContainerBase::create_tuple({
|
||||
Glib::Variant<Glib::ustring>::create(interface),
|
||||
Glib::Variant<Glib::ustring>::create(property),
|
||||
wrapped});
|
||||
auto params = Glib::VariantContainerBase::create_tuple({Glib::Variant<Glib::ustring>::create(interface),
|
||||
Glib::Variant<Glib::ustring>::create(property),
|
||||
wrapped});
|
||||
|
||||
props_proxy->call_sync("Set", params);
|
||||
} catch (const Glib::Error &ex) {
|
||||
|
||||
@@ -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<Monitor>();
|
||||
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<Monitor>();
|
||||
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<WorkspaceData>();
|
||||
auto state = std::make_shared<WorkspaceData>();
|
||||
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>();
|
||||
int workspaceId = client["workspace"]["id"].get<int>();
|
||||
auto workspaceIt = workspaces.find(workspaceId);
|
||||
if (workspaceIt == workspaces.end()) {
|
||||
continue;
|
||||
@@ -413,7 +413,7 @@ void HyprlandService::onActiveWindowChanged(std::string windowAddress) {
|
||||
}
|
||||
|
||||
std::shared_ptr<Gtk::Box> HyprlandService::getWorkspaceIndicatorsForMonitor(std::string monitorName) {
|
||||
auto box = std::make_shared<Gtk::Box>(Gtk::Orientation::HORIZONTAL);
|
||||
auto box = std::make_shared<Gtk::Box>(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> workspace) {
|
||||
auto view = workspace->view;
|
||||
|
||||
auto state = workspace->state;
|
||||
auto state = workspace->state;
|
||||
auto monitorIt = monitors.find(state->monitorName);
|
||||
if (monitorIt == monitors.end()) {
|
||||
return;
|
||||
|
||||
@@ -154,7 +154,7 @@ void NotificationController::closeNotification(uint64_t notificationId) {
|
||||
}
|
||||
|
||||
void NotificationController::addMonitor(std::shared_ptr<Gdk::Monitor> monitor) {
|
||||
auto name = monitor->get_connector();
|
||||
auto name = monitor->get_connector();
|
||||
this->activeMonitors[name] = monitor;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<TabButton>(Icon::PLAY_CIRCLE);
|
||||
this->infoTabButton = std::make_unique<TabButton>(Icon::EMPTY_DASHBOARD);
|
||||
this->timerButton = std::make_unique<TabButton>(Icon::TOKEN);
|
||||
this->mediaTabButton = std::make_unique<TabButton>(Icon::PLAY_CIRCLE);
|
||||
this->infoTabButton = std::make_unique<TabButton>(Icon::EMPTY_DASHBOARD);
|
||||
this->timerButton = std::make_unique<TabButton>(Icon::TOKEN);
|
||||
this->settingsTabButton = std::make_unique<TabButton>(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<MediaWidget>();
|
||||
this->weatherWidget = std::make_unique<WeatherWidget>();
|
||||
this->timerWidget = std::make_unique<TimerWidget>();
|
||||
this->settingsWidget = std::make_unique<SettingsWidget>();
|
||||
this->weatherWidget = std::make_unique<WeatherWidget>();
|
||||
this->timerWidget = std::make_unique<TimerWidget>();
|
||||
this->settingsWidget = std::make_unique<SettingsWidget>();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ void MediaWidget::addPlayerWidget(const std::string &bus_name) {
|
||||
|
||||
auto controller = MprisController::createForPlayer(bus_name);
|
||||
auto widget = std::make_unique<MediaPlayer>(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);
|
||||
}
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
|
||||
#include "gtkmm/entry.h"
|
||||
#include "gtkmm/eventcontrollerkey.h"
|
||||
#include "gtkmm/label.h"
|
||||
|
||||
Reference in New Issue
Block a user