fix styling issues

This commit is contained in:
2026-02-09 21:01:56 +01:00
parent ea9ab4b2cb
commit d1b81c4d3e
20 changed files with 778 additions and 207 deletions
@@ -0,0 +1,90 @@
#include "widgets/controlCenter/bluetoothSettingsRow.hpp"
#include <spdlog/spdlog.h>
#include "components/button/iconButton.hpp"
#include "connection/dbus/bluetooth.hpp"
#include "helpers/string.hpp"
#include "services/notificationController.hpp"
BluetoothSettingsRow::BluetoothSettingsRow(const BluetoothDevice &device)
: device(device),
pairButton(device.paired ? Icon::BLUETOOTH_CONNECTED : Icon::BLUETOOTH),
connectButton(device.connected ? Icon::LINK : Icon::LINK_OFF),
trustButton(device.trusted ? Icon::DONE_ALL : Icon::REMOVE_DONE) {
set_orientation(Gtk::Orientation::HORIZONTAL);
set_spacing(10);
add_css_class("bluetooth-settings-row");
set_hexpand(true);
set_halign(Gtk::Align::FILL);
if (!device.icon.empty()) {
this->icon.set_from_icon_name(device.icon);
this->icon.set_pixel_size(24);
append(this->icon);
}
auto deviceInfoBox = Gtk::Box(Gtk::Orientation::VERTICAL);
deviceInfoBox.set_spacing(2);
append(deviceInfoBox);
std::string shortName = StringHelper::trimToSize(device.name.empty() ? "Unknown Device" : device.name, 14);
nameLabel.set_text(shortName);
nameLabel.set_halign(Gtk::Align::START);
nameLabel.set_valign(Gtk::Align::CENTER);
deviceInfoBox.append(nameLabel);
addressLabel.set_text(device.address);
addressLabel.set_halign(Gtk::Align::START);
addressLabel.set_valign(Gtk::Align::CENTER);
addressLabel.add_css_class("bluetooth-device-address");
deviceInfoBox.append(addressLabel);
auto buttonBox = Gtk::Box(Gtk::Orientation::HORIZONTAL);
buttonBox.set_hexpand(true);
buttonBox.set_halign(Gtk::Align::END);
append(buttonBox);
pairButton.signal_clicked().connect([this]() {
if (this->device.paired) {
BluetoothController::getInstance()->unpairDevice(this->device.object_path);
} else {
BluetoothController::getInstance()->pairDevice(this->device.object_path);
}
});
buttonBox.append(pairButton);
connectButton.signal_clicked().connect([this]() {
if (this->device.connected) {
BluetoothController::getInstance()->disconnectDevice(this->device.object_path);
} else {
BluetoothController::getInstance()->connectDevice(this->device.object_path);
}
});
buttonBox.append(connectButton);
trustButton.signal_clicked().connect([this]() {
BluetoothController::getInstance()->trustDevice(this->device.object_path, !this->device.trusted);
});
buttonBox.append(trustButton);
}
void BluetoothSettingsRow::updateDevice(const BluetoothDevice &device) {
this->device = device;
if (!device.icon.empty()) {
this->icon.set_from_icon_name(device.icon);
}
spdlog::info("Updating device {}: paired={}, connected={}, trusted={}", device.name, device.paired, device.connected, device.trusted);
std::string shortName = StringHelper::trimToSize(device.name.empty() ? "Unknown Device" : device.name, 14);
nameLabel.set_text(shortName);
addressLabel.set_text(device.address);
pairButton.setIcon(device.paired ? Icon::BLUETOOTH_CONNECTED : Icon::BLUETOOTH);
connectButton.setIcon(device.connected ? Icon::LINK : Icon::LINK_OFF);
trustButton.setIcon(device.trusted ? Icon::DONE_ALL : Icon::REMOVE_DONE);
}