fix styling issues
This commit is contained in:
@@ -25,7 +25,17 @@ class Icon {
|
||||
|
||||
SETTINGS,
|
||||
POWER_SETTINGS_NEW,
|
||||
BLUETOOTH,
|
||||
BLUETOOTH_CONNECTED,
|
||||
BLUETOOTH_SEARCHING,
|
||||
LINK,
|
||||
LINK_OFF,
|
||||
|
||||
VERIFIED,
|
||||
VERIFIED_OFF,
|
||||
|
||||
DONE_ALL,
|
||||
REMOVE_DONE,
|
||||
};
|
||||
|
||||
static const std::string toString(Type type) {
|
||||
@@ -53,6 +63,16 @@ class Icon {
|
||||
|
||||
{SETTINGS, "\ue8b8"},
|
||||
{POWER_SETTINGS_NEW, "\ue8ac"},
|
||||
{BLUETOOTH, "\ue1a7"},
|
||||
{BLUETOOTH_CONNECTED, "\ue1a8"},
|
||||
{BLUETOOTH_SEARCHING, "\ue1aa"},
|
||||
{LINK, "\ue157"},
|
||||
{LINK_OFF, "\ue16f"},
|
||||
|
||||
{VERIFIED, "\uef76"},
|
||||
{VERIFIED_OFF, "\uf30e"},
|
||||
|
||||
{DONE_ALL, "\ue877"},
|
||||
{REMOVE_DONE, "\ue9d3"},
|
||||
};
|
||||
};
|
||||
@@ -90,6 +90,17 @@ class BluetoothController : public DbusConnection {
|
||||
const Glib::ustring &signal_name,
|
||||
const Glib::VariantContainerBase ¶meters);
|
||||
|
||||
// Agent
|
||||
guint m_agent_id = 0;
|
||||
void registerAgent();
|
||||
void on_agent_method_call(const Glib::RefPtr<Gio::DBus::Connection> &connection,
|
||||
const Glib::ustring &sender,
|
||||
const Glib::ustring &object_path,
|
||||
const Glib::ustring &interface_name,
|
||||
const Glib::ustring &method_name,
|
||||
const Glib::VariantContainerBase ¶meters,
|
||||
const Glib::RefPtr<Gio::DBus::MethodInvocation> &invocation);
|
||||
|
||||
// Adapter
|
||||
void setupAdapter(const std::string &path, const PropertiesMap &properties);
|
||||
void onAdapterPropertiesChanged(const Gio::DBus::Proxy::MapChangedProperties &changed,
|
||||
@@ -105,7 +116,10 @@ class BluetoothController : public DbusConnection {
|
||||
// Helpers
|
||||
static BluetoothDevice parseDeviceProperties(const std::string &path, const PropertiesMap &properties);
|
||||
void setDbusProperty(const std::string &object_path,
|
||||
const std::string &interface,
|
||||
const std::string &property,
|
||||
const Glib::VariantBase &value);
|
||||
const std::string &interface,
|
||||
const std::string &property,
|
||||
const Glib::VariantBase &value);
|
||||
|
||||
// HID Authorization handler
|
||||
void authorizeHIDDevice(const std::string &object_path);
|
||||
};
|
||||
|
||||
@@ -44,4 +44,8 @@ struct NotifyMessage {
|
||||
std::shared_ptr<bool> actionInvoked;
|
||||
// image data (if any) from dbus
|
||||
std::optional<Glib::RefPtr<Gdk::Pixbuf>> imageData;
|
||||
|
||||
bool has_input = false;
|
||||
std::string input_placeholder;
|
||||
std::function<void(const std::string &)> on_input;
|
||||
};
|
||||
@@ -12,9 +12,11 @@ class TextureCacheService {
|
||||
|
||||
Glib::RefPtr<Gdk::Texture> getTexture(const std::string &url);
|
||||
void pruneCache();
|
||||
void clear();
|
||||
|
||||
private:
|
||||
TextureCacheService() = default;
|
||||
TextureCacheService();
|
||||
~TextureCacheService();
|
||||
|
||||
std::unordered_map<std::string, Glib::RefPtr<Gdk::Texture>> cache;
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
24
include/widgets/controlCenter/bluetoothSettingsRow.hpp
Normal file
24
include/widgets/controlCenter/bluetoothSettingsRow.hpp
Normal 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;
|
||||
};
|
||||
Reference in New Issue
Block a user