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

View File

@@ -1,88 +1,14 @@
#pragma once
#include <spdlog/spdlog.h>
#include "components/button/iconButton.hpp"
#include "connection/dbus/bluetooth.hpp"
#include "gtkmm/box.h"
#include "gtkmm/button.h"
#include "gtkmm/image.h"
#include "gtkmm/label.h"
#include "gtkmm/scrolledwindow.h"
class BluetoothSettingsRow : public Gtk::Box {
public:
BluetoothSettingsRow(const BluetoothDevice &device) : device(device) {
set_orientation(Gtk::Orientation::HORIZONTAL);
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);
append(this->icon);
}
nameLabel.set_text(device.name.empty() ? "Unknown Device" : device.name);
nameLabel.set_halign(Gtk::Align::START);
nameLabel.set_valign(Gtk::Align::CENTER);
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");
append(addressLabel);
pairButton.set_label(device.paired ? "Unpair" : "Pair");
pairButton.signal_clicked().connect([device]() {
if (device.paired) {
BluetoothController::getInstance()->unpairDevice(device.object_path);
} else {
BluetoothController::getInstance()->pairDevice(device.object_path);
}
});
append(pairButton);
connectButton.set_label(device.connected ? "Disconnect" : "Connect");
connectButton.signal_clicked().connect([device]() {
if (device.connected) {
BluetoothController::getInstance()->disconnectDevice(device.object_path);
} else {
BluetoothController::getInstance()->connectDevice(device.object_path);
}
});
append(connectButton);
trustButton.set_label(device.trusted ? "Distrust" : "Trust");
trustButton.signal_clicked().connect([device]() {
BluetoothController::getInstance()->trustDevice(device.object_path, !device.trusted);
});
append(trustButton);
}
void updateDevice(const BluetoothDevice &device) {
this->device = device;
if (!device.icon.empty()) {
this->icon.set_from_icon_name(device.icon);
}
nameLabel.set_text(device.name.empty() ? "Unknown Device" : device.name);
addressLabel.set_text(device.address);
pairButton.set_label(device.paired ? "Unpair" : "Pair");
connectButton.set_label(device.connected ? "Disconnect" : "Connect");
trustButton.set_label(device.trusted ? "Distrust" : "Trust");
}
private:
BluetoothDevice device;
Gtk::Image icon;
Gtk::Label nameLabel;
Gtk::Label addressLabel;
Gtk::Button pairButton;
Gtk::Button connectButton;
Gtk::Button trustButton;
};
#include "widgets/controlCenter/bluetoothSettingsRow.hpp"
class BluetoothSettings : public Gtk::Box {
public:
@@ -96,8 +22,11 @@ class BluetoothSettings : public Gtk::Box {
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);
Gtk::Box buttonRow;
Gtk::Box connectedDevicesBox;
Gtk::ScrolledWindow connectedDevicesScroll;
Gtk::Box availableDevicesBox;
Gtk::ScrolledWindow availableDevicesScroll;
bool bluetoothIsPowered = false;
bool bluetoothIsScanning = false;

View File

@@ -0,0 +1,24 @@
#pragma once
#include <spdlog/spdlog.h>
#include "components/button/iconButton.hpp"
#include "connection/dbus/bluetooth.hpp"
#include "gtkmm/box.h"
#include "gtkmm/button.h"
#include "gtkmm/image.h"
#include "gtkmm/label.h"
class BluetoothSettingsRow : public Gtk::Box {
public:
BluetoothSettingsRow(const BluetoothDevice &device);
void updateDevice(const BluetoothDevice &device);
private:
BluetoothDevice device;
Gtk::Image icon;
Gtk::Label nameLabel;
Gtk::Label addressLabel;
IconButton pairButton;
IconButton connectButton;
IconButton trustButton;
};