fix timer

This commit is contained in:
2026-02-10 13:30:25 +01:00
parent d1b81c4d3e
commit 55a76be186
10 changed files with 38 additions and 28 deletions

View File

@@ -3,6 +3,7 @@
#include <memory> #include <memory>
#include "bar/bar.hpp" #include "bar/bar.hpp"
#include "connection/dbus/bluetooth.hpp"
#include "connection/dbus/notification.hpp" #include "connection/dbus/notification.hpp"
#include "connection/dbus/tray.hpp" #include "connection/dbus/tray.hpp"
#include "services/hyprland.hpp" #include "services/hyprland.hpp"
@@ -29,6 +30,7 @@ class App {
std::shared_ptr<NotificationService> notificationService = NotificationService::getInstance(); std::shared_ptr<NotificationService> notificationService = NotificationService::getInstance();
std::shared_ptr<NotificationController> notificationController = NotificationController::getInstance(); std::shared_ptr<NotificationController> notificationController = NotificationController::getInstance();
std::shared_ptr<BluetoothController> bluetoothController = BluetoothController::getInstance();
std::shared_ptr<MprisController> mprisController = MprisController::getInstance(); std::shared_ptr<MprisController> mprisController = MprisController::getInstance();
std::shared_ptr<HyprlandService> hyprlandService = HyprlandService::getInstance(); std::shared_ptr<HyprlandService> hyprlandService = HyprlandService::getInstance();

View File

@@ -122,4 +122,7 @@ class BluetoothController : public DbusConnection {
// HID Authorization handler // HID Authorization handler
void authorizeHIDDevice(const std::string &object_path); void authorizeHIDDevice(const std::string &object_path);
Glib::RefPtr<Gio::DBus::NodeInfo> m_node_info;
std::shared_ptr<Gio::DBus::InterfaceVTable> m_interface_vtable;
}; };

View File

@@ -37,11 +37,11 @@ struct NotifyMessage {
std::string body; std::string body;
std::vector<std::string> actions; std::vector<std::string> actions;
NotificationUrgency urgency = NORMAL; NotificationUrgency urgency = NORMAL;
int32_t expire_timeout; int32_t expire_timeout = -1;
// Callback to invoke when an action is triggered // Callback to invoke when an action is triggered
std::function<void(const std::string &action_id)> on_action; std::function<void(const std::string &action_id)> on_action;
// Guard to prevent multiple action invocations across mirrors // Guard to prevent multiple action invocations across mirrors
std::shared_ptr<bool> actionInvoked; std::shared_ptr<bool> actionInvoked = std::make_shared<bool>(false);
// image data (if any) from dbus // image data (if any) from dbus
std::optional<Glib::RefPtr<Gdk::Pixbuf>> imageData; std::optional<Glib::RefPtr<Gdk::Pixbuf>> imageData;

View File

@@ -9,6 +9,7 @@
#include "gtkmm/mediafile.h" #include "gtkmm/mediafile.h"
#include "gtkmm/mediastream.h" #include "gtkmm/mediastream.h"
#include "sigc++/signal.h" #include "sigc++/signal.h"
class TimerService { class TimerService {
struct TimerData { struct TimerData {
uint64_t duration; uint64_t duration;

View File

@@ -5,7 +5,6 @@
#include <sys/types.h> #include <sys/types.h>
#include "components/timer.hpp" #include "components/timer.hpp"
#include "services/timerService.hpp"
#include "gtkmm/box.h" #include "gtkmm/box.h"

View File

@@ -171,7 +171,6 @@ tooltip {
#spacer { #spacer {
font-weight: 900; font-weight: 900;
padding: 0 5px; padding: 0 5px;
text-shadow: 0 0 5px #ffffffaa;
border-radius: 4px; border-radius: 4px;
} }
@@ -181,10 +180,10 @@ tooltip {
} }
.workspace-pill { .workspace-pill {
padding: 2px 5px; padding: 2px 4px;
border-radius: 4px; border-radius: 4px;
text-shadow: 0 0 2px #646464;
margin: 0 2px; margin: 0 2px;
color: #cccccc;
transition: transition:
background-color 0.2s, background-color 0.2s,
color 0.2s, color 0.2s,
@@ -281,7 +280,7 @@ tooltip {
.bluetooth-device-address { .bluetooth-device-address {
font-size: 10px; font-size: 10px;
color: #cccccc; color: #cccccce7;
} }
.bluetooth-settings-row { .bluetooth-settings-row {

View File

@@ -484,28 +484,28 @@ void BluetoothController::registerAgent() {
return; return;
try { try {
auto node_info = Gio::DBus::NodeInfo::create_for_xml(agent_introspection_xml); m_node_info = Gio::DBus::NodeInfo::create_for_xml(agent_introspection_xml);
auto interface_info = node_info->lookup_interface("org.bluez.Agent1"); auto interface_info = m_node_info->lookup_interface("org.bluez.Agent1");
Gio::DBus::InterfaceVTable vtable( m_interface_vtable = std::make_shared<Gio::DBus::InterfaceVTable>(
sigc::mem_fun(*this, &BluetoothController::on_agent_method_call)); sigc::mem_fun(*this, &BluetoothController::on_agent_method_call));
m_agent_id = connection->register_object("/org/bluez/agent", interface_info, vtable); m_agent_id = connection->register_object("/org/bluez/bar_agent", interface_info, *m_interface_vtable);
auto agent_manager = Gio::DBus::Proxy::create_sync( auto agent_manager = Gio::DBus::Proxy::create_sync(
connection, "org.bluez", "/org/bluez", "org.bluez.AgentManager1"); connection, "org.bluez", "/org/bluez", "org.bluez.AgentManager1");
if (agent_manager) { if (agent_manager) {
agent_manager->call( agent_manager->call_sync(
"RegisterAgent", "RegisterAgent",
Glib::VariantContainerBase::create_tuple( Glib::VariantContainerBase::create_tuple(
{Glib::Variant<Glib::ustring>::create("/org/bluez/agent"), {Glib::Variant<Glib::DBusObjectPathString>::create("/org/bluez/bar_agent"),
Glib::Variant<Glib::ustring>::create("KeyboardDisplay")})); // Using KeyboardDisplay capacity Glib::Variant<Glib::ustring>::create("DisplayYesNo")}));
agent_manager->call( agent_manager->call_sync(
"RequestDefaultAgent", "RequestDefaultAgent",
Glib::VariantContainerBase::create_tuple( Glib::VariantContainerBase::create_tuple(
{Glib::Variant<Glib::ustring>::create("/org/bluez/agent")})); {Glib::Variant<Glib::DBusObjectPathString>::create("/org/bluez/bar_agent")}));
spdlog::info("Bluetooth Agent registered successfully"); spdlog::info("Bluetooth Agent registered successfully");
} }
@@ -523,6 +523,8 @@ void BluetoothController::on_agent_method_call(
const Glib::VariantContainerBase &parameters, const Glib::VariantContainerBase &parameters,
const Glib::RefPtr<Gio::DBus::MethodInvocation> &invocation) { const Glib::RefPtr<Gio::DBus::MethodInvocation> &invocation) {
spdlog::info("Bluetooth Agent method called: {}", method_name.c_str());
if (method_name == "RequestConfirmation") { if (method_name == "RequestConfirmation") {
// Signature: (ou) // Signature: (ou)
std::string device_path = static_cast<std::string>( std::string device_path = static_cast<std::string>(
@@ -547,7 +549,7 @@ void BluetoothController::on_agent_method_call(
msg.summary = "Bluetooth Pairing Request"; msg.summary = "Bluetooth Pairing Request";
msg.body = "Device '" + device_name + "' wants to pair.\nPasskey: " + passkey_str; msg.body = "Device '" + device_name + "' wants to pair.\nPasskey: " + passkey_str;
msg.app_name = "Bar"; msg.app_name = "Bar";
msg.actions = {"Confirm", "Cancel"}; msg.actions = {"Confirm", "Confirm", "Cancel", "Cancel"};
msg.urgency = NotificationUrgency::CRITICAL; msg.urgency = NotificationUrgency::CRITICAL;
msg.expire_timeout = -1; // No timeout, requires user interaction msg.expire_timeout = -1; // No timeout, requires user interaction
@@ -580,8 +582,8 @@ void BluetoothController::on_agent_method_call(
msg.summary = "Bluetooth Authorization Request"; msg.summary = "Bluetooth Authorization Request";
msg.body = "Device '" + device_name + "' requests authorization to connect."; msg.body = "Device '" + device_name + "' requests authorization to connect.";
msg.app_name = "Bar"; msg.app_name = "Bar";
msg.actions = {"Allow", "Deny"}; msg.actions = {"Allow", "Allow", "Deny", "Deny"};
msg.urgency = NotificationUrgency::CRITICAL; msg.urgency = NotificationUrgency::LOW;
msg.expire_timeout = -1; msg.expire_timeout = -1;
msg.on_action = [invocation](const std::string &action) { msg.on_action = [invocation](const std::string &action) {
@@ -614,7 +616,7 @@ void BluetoothController::on_agent_method_call(
msg.summary = "Bluetooth Service Authorization"; msg.summary = "Bluetooth Service Authorization";
msg.body = "Device '" + device_name + "' wants to access service: " + uuid; msg.body = "Device '" + device_name + "' wants to access service: " + uuid;
msg.app_name = "Bar"; msg.app_name = "Bar";
msg.actions = {"Allow", "Deny"}; msg.actions = {"Allow", "Allow", "Deny", "Deny"};
msg.urgency = NotificationUrgency::CRITICAL; msg.urgency = NotificationUrgency::CRITICAL;
msg.expire_timeout = -1; msg.expire_timeout = -1;
@@ -762,4 +764,5 @@ void BluetoothController::on_agent_method_call(
// Not implemented // Not implemented
invocation->return_dbus_error("org.bluez.Error.Rejected", "Not implemented"); invocation->return_dbus_error("org.bluez.Error.Rejected", "Not implemented");
} }
} }

View File

@@ -29,9 +29,8 @@ BluetoothSettingsRow::BluetoothSettingsRow(const BluetoothDevice &device)
deviceInfoBox.set_spacing(2); deviceInfoBox.set_spacing(2);
append(deviceInfoBox); append(deviceInfoBox);
std::string shortName = StringHelper::trimToSize(device.name.empty() ? "Unknown Device" : device.name, 14); nameLabel.set_ellipsize(Pango::EllipsizeMode::END);
nameLabel.set_text(device.name.empty() ? "Unknown Device" : device.name );
nameLabel.set_text(shortName);
nameLabel.set_halign(Gtk::Align::START); nameLabel.set_halign(Gtk::Align::START);
nameLabel.set_valign(Gtk::Align::CENTER); nameLabel.set_valign(Gtk::Align::CENTER);
deviceInfoBox.append(nameLabel); deviceInfoBox.append(nameLabel);
@@ -41,6 +40,7 @@ BluetoothSettingsRow::BluetoothSettingsRow(const BluetoothDevice &device)
addressLabel.set_valign(Gtk::Align::CENTER); addressLabel.set_valign(Gtk::Align::CENTER);
addressLabel.add_css_class("bluetooth-device-address"); addressLabel.add_css_class("bluetooth-device-address");
deviceInfoBox.append(addressLabel); deviceInfoBox.append(addressLabel);
deviceInfoBox.set_size_request(140, -1);
auto buttonBox = Gtk::Box(Gtk::Orientation::HORIZONTAL); auto buttonBox = Gtk::Box(Gtk::Orientation::HORIZONTAL);
buttonBox.set_hexpand(true); buttonBox.set_hexpand(true);
@@ -80,9 +80,7 @@ void BluetoothSettingsRow::updateDevice(const BluetoothDevice &device) {
spdlog::info("Updating device {}: paired={}, connected={}, trusted={}", device.name, device.paired, device.connected, device.trusted); 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(device.name.empty() ? "Unknown Device" : device.name);
nameLabel.set_text(shortName);
addressLabel.set_text(device.address); addressLabel.set_text(device.address);
pairButton.setIcon(device.paired ? Icon::BLUETOOTH_CONNECTED : Icon::BLUETOOTH); pairButton.setIcon(device.paired ? Icon::BLUETOOTH_CONNECTED : Icon::BLUETOOTH);
connectButton.setIcon(device.connected ? Icon::LINK : Icon::LINK_OFF); connectButton.setIcon(device.connected ? Icon::LINK : Icon::LINK_OFF);

View File

@@ -86,8 +86,12 @@ TimerWidget::TimerWidget() {
if (rawDigits.empty()) { if (rawDigits.empty()) {
return; return;
} }
spdlog::info("Timer set for {} seconds", rawDigits);
this->timerService->addTimer(std::stoul(rawDigits)); uint64_t rawValue = std::stoull(rawDigits);
uint64_t seconds = (rawValue / 10000) * 3600 + ((rawValue / 100) % 100) * 60 + (rawValue % 100);
spdlog::info("Timer set for {} seconds", seconds);
this->timerService->addTimer(seconds);
rawDigits.clear(); rawDigits.clear();
this->updatingText = true; this->updatingText = true;
entry->set_text(""); entry->set_text("");

View File

@@ -78,6 +78,7 @@ NotificationWindow::NotificationWindow(uint64_t notificationId, std::shared_ptr<
entry->set_hexpand(true); entry->set_hexpand(true);
entry->add_css_class("notification-entry"); entry->add_css_class("notification-entry");
vbox->append(*entry); vbox->append(*entry);
entry->grab_focus_without_selecting();
entry->signal_activate().connect([this, entry, cb = notify.on_input]() { entry->signal_activate().connect([this, entry, cb = notify.on_input]() {
if (cb) { if (cb) {