fix timer
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include <memory>
|
||||
|
||||
#include "bar/bar.hpp"
|
||||
#include "connection/dbus/bluetooth.hpp"
|
||||
#include "connection/dbus/notification.hpp"
|
||||
#include "connection/dbus/tray.hpp"
|
||||
#include "services/hyprland.hpp"
|
||||
@@ -29,6 +30,7 @@ class App {
|
||||
|
||||
std::shared_ptr<NotificationService> notificationService = NotificationService::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<HyprlandService> hyprlandService = HyprlandService::getInstance();
|
||||
|
||||
|
||||
@@ -122,4 +122,7 @@ class BluetoothController : public DbusConnection {
|
||||
|
||||
// HID Authorization handler
|
||||
void authorizeHIDDevice(const std::string &object_path);
|
||||
|
||||
Glib::RefPtr<Gio::DBus::NodeInfo> m_node_info;
|
||||
std::shared_ptr<Gio::DBus::InterfaceVTable> m_interface_vtable;
|
||||
};
|
||||
|
||||
@@ -37,11 +37,11 @@ struct NotifyMessage {
|
||||
std::string body;
|
||||
std::vector<std::string> actions;
|
||||
NotificationUrgency urgency = NORMAL;
|
||||
int32_t expire_timeout;
|
||||
int32_t expire_timeout = -1;
|
||||
// Callback to invoke when an action is triggered
|
||||
std::function<void(const std::string &action_id)> on_action;
|
||||
// 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
|
||||
std::optional<Glib::RefPtr<Gdk::Pixbuf>> imageData;
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "gtkmm/mediafile.h"
|
||||
#include "gtkmm/mediastream.h"
|
||||
#include "sigc++/signal.h"
|
||||
|
||||
class TimerService {
|
||||
struct TimerData {
|
||||
uint64_t duration;
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "components/timer.hpp"
|
||||
#include "services/timerService.hpp"
|
||||
|
||||
#include "gtkmm/box.h"
|
||||
|
||||
|
||||
@@ -171,7 +171,6 @@ tooltip {
|
||||
#spacer {
|
||||
font-weight: 900;
|
||||
padding: 0 5px;
|
||||
text-shadow: 0 0 5px #ffffffaa;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
@@ -181,10 +180,10 @@ tooltip {
|
||||
}
|
||||
|
||||
.workspace-pill {
|
||||
padding: 2px 5px;
|
||||
padding: 2px 4px;
|
||||
border-radius: 4px;
|
||||
text-shadow: 0 0 2px #646464;
|
||||
margin: 0 2px;
|
||||
color: #cccccc;
|
||||
transition:
|
||||
background-color 0.2s,
|
||||
color 0.2s,
|
||||
@@ -281,7 +280,7 @@ tooltip {
|
||||
|
||||
.bluetooth-device-address {
|
||||
font-size: 10px;
|
||||
color: #cccccc;
|
||||
color: #cccccce7;
|
||||
}
|
||||
|
||||
.bluetooth-settings-row {
|
||||
|
||||
@@ -484,28 +484,28 @@ void BluetoothController::registerAgent() {
|
||||
return;
|
||||
|
||||
try {
|
||||
auto node_info = Gio::DBus::NodeInfo::create_for_xml(agent_introspection_xml);
|
||||
auto interface_info = node_info->lookup_interface("org.bluez.Agent1");
|
||||
m_node_info = Gio::DBus::NodeInfo::create_for_xml(agent_introspection_xml);
|
||||
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));
|
||||
|
||||
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(
|
||||
connection, "org.bluez", "/org/bluez", "org.bluez.AgentManager1");
|
||||
|
||||
if (agent_manager) {
|
||||
agent_manager->call(
|
||||
agent_manager->call_sync(
|
||||
"RegisterAgent",
|
||||
Glib::VariantContainerBase::create_tuple(
|
||||
{Glib::Variant<Glib::ustring>::create("/org/bluez/agent"),
|
||||
Glib::Variant<Glib::ustring>::create("KeyboardDisplay")})); // Using KeyboardDisplay capacity
|
||||
{Glib::Variant<Glib::DBusObjectPathString>::create("/org/bluez/bar_agent"),
|
||||
Glib::Variant<Glib::ustring>::create("DisplayYesNo")}));
|
||||
|
||||
agent_manager->call(
|
||||
agent_manager->call_sync(
|
||||
"RequestDefaultAgent",
|
||||
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");
|
||||
}
|
||||
@@ -523,6 +523,8 @@ void BluetoothController::on_agent_method_call(
|
||||
const Glib::VariantContainerBase ¶meters,
|
||||
const Glib::RefPtr<Gio::DBus::MethodInvocation> &invocation) {
|
||||
|
||||
spdlog::info("Bluetooth Agent method called: {}", method_name.c_str());
|
||||
|
||||
if (method_name == "RequestConfirmation") {
|
||||
// Signature: (ou)
|
||||
std::string device_path = static_cast<std::string>(
|
||||
@@ -547,7 +549,7 @@ void BluetoothController::on_agent_method_call(
|
||||
msg.summary = "Bluetooth Pairing Request";
|
||||
msg.body = "Device '" + device_name + "' wants to pair.\nPasskey: " + passkey_str;
|
||||
msg.app_name = "Bar";
|
||||
msg.actions = {"Confirm", "Cancel"};
|
||||
msg.actions = {"Confirm", "Confirm", "Cancel", "Cancel"};
|
||||
msg.urgency = NotificationUrgency::CRITICAL;
|
||||
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.body = "Device '" + device_name + "' requests authorization to connect.";
|
||||
msg.app_name = "Bar";
|
||||
msg.actions = {"Allow", "Deny"};
|
||||
msg.urgency = NotificationUrgency::CRITICAL;
|
||||
msg.actions = {"Allow", "Allow", "Deny", "Deny"};
|
||||
msg.urgency = NotificationUrgency::LOW;
|
||||
msg.expire_timeout = -1;
|
||||
|
||||
msg.on_action = [invocation](const std::string &action) {
|
||||
@@ -614,7 +616,7 @@ void BluetoothController::on_agent_method_call(
|
||||
msg.summary = "Bluetooth Service Authorization";
|
||||
msg.body = "Device '" + device_name + "' wants to access service: " + uuid;
|
||||
msg.app_name = "Bar";
|
||||
msg.actions = {"Allow", "Deny"};
|
||||
msg.actions = {"Allow", "Allow", "Deny", "Deny"};
|
||||
msg.urgency = NotificationUrgency::CRITICAL;
|
||||
msg.expire_timeout = -1;
|
||||
|
||||
@@ -762,4 +764,5 @@ void BluetoothController::on_agent_method_call(
|
||||
// Not implemented
|
||||
invocation->return_dbus_error("org.bluez.Error.Rejected", "Not implemented");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,9 +29,8 @@ BluetoothSettingsRow::BluetoothSettingsRow(const BluetoothDevice &device)
|
||||
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_ellipsize(Pango::EllipsizeMode::END);
|
||||
nameLabel.set_text(device.name.empty() ? "Unknown Device" : device.name );
|
||||
nameLabel.set_halign(Gtk::Align::START);
|
||||
nameLabel.set_valign(Gtk::Align::CENTER);
|
||||
deviceInfoBox.append(nameLabel);
|
||||
@@ -41,6 +40,7 @@ BluetoothSettingsRow::BluetoothSettingsRow(const BluetoothDevice &device)
|
||||
addressLabel.set_valign(Gtk::Align::CENTER);
|
||||
addressLabel.add_css_class("bluetooth-device-address");
|
||||
deviceInfoBox.append(addressLabel);
|
||||
deviceInfoBox.set_size_request(140, -1);
|
||||
|
||||
auto buttonBox = Gtk::Box(Gtk::Orientation::HORIZONTAL);
|
||||
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);
|
||||
|
||||
std::string shortName = StringHelper::trimToSize(device.name.empty() ? "Unknown Device" : device.name, 14);
|
||||
|
||||
nameLabel.set_text(shortName);
|
||||
nameLabel.set_text(device.name.empty() ? "Unknown Device" : device.name);
|
||||
addressLabel.set_text(device.address);
|
||||
pairButton.setIcon(device.paired ? Icon::BLUETOOTH_CONNECTED : Icon::BLUETOOTH);
|
||||
connectButton.setIcon(device.connected ? Icon::LINK : Icon::LINK_OFF);
|
||||
|
||||
@@ -86,8 +86,12 @@ TimerWidget::TimerWidget() {
|
||||
if (rawDigits.empty()) {
|
||||
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();
|
||||
this->updatingText = true;
|
||||
entry->set_text("");
|
||||
|
||||
@@ -78,6 +78,7 @@ NotificationWindow::NotificationWindow(uint64_t notificationId, std::shared_ptr<
|
||||
entry->set_hexpand(true);
|
||||
entry->add_css_class("notification-entry");
|
||||
vbox->append(*entry);
|
||||
entry->grab_focus_without_selecting();
|
||||
|
||||
entry->signal_activate().connect([this, entry, cb = notify.on_input]() {
|
||||
if (cb) {
|
||||
|
||||
Reference in New Issue
Block a user