bar can now toggle bluetooth power and discovery

This commit is contained in:
2025-12-22 01:41:01 +01:00
parent 0101ea1ec0
commit 5a429a3b8b
31 changed files with 507 additions and 114 deletions

70
src/widgets/bluetooth.cpp Normal file
View File

@@ -0,0 +1,70 @@
#include "widgets/bluetooth.hpp"
BluetoothWidget::BluetoothWidget(std::string icon, std::string title) : Popover(icon, title) {
this->popover->set_size_request(100, -1);
set_popover_child(this->container);
this->container.set_orientation(Gtk::Orientation::VERTICAL);
this->container.set_spacing(10);
this->container.add_css_class("bluetooth-popover-container");
this->statusArea.add_css_class("bluetooth-status-area");
this->statusArea.set_hexpand(true);
this->statusArea.set_halign(Gtk::Align::FILL);
this->container.append(this->statusArea);
this->toggleButton = Gtk::make_managed<Gtk::Button>("\ue1a8");
this->toggleButton->add_css_class("bluetooth-toggle-button");
this->toggleButton->set_tooltip_text("Turn Bluetooth Off");
this->toggleButton->signal_clicked().connect([this]() {
const bool newState = !isPowered;
setPowerState(newState);
powerStateChangedSignal.emit(newState);
});
this->toggleButton->add_css_class("toggle-button");
this->scanButton = Gtk::make_managed<Gtk::Button>("\ue1aa");
this->scanButton->set_tooltip_text("Scan for Devices");
this->scanButton->add_css_class("bluetooth-scan-button");
this->scanButton->signal_clicked().connect([this]() {
const bool newState = !isDiscovering;
setIsDiscovering(newState);
isDiscoveringChangedSignal.emit(newState);
});
this->statusArea.append(*this->toggleButton);
this->statusArea.append(*this->scanButton);
}
void BluetoothWidget::setPowerState(bool state) {
this->isPowered = state;
if (state) {
this->toggleButton->set_label("\ue1a8");
this->toggleButton->add_css_class("toggle-button-on");
this->toggleButton->remove_css_class("toggle-button-off");
} else {
this->toggleButton->set_label("\ue1a9");
this->toggleButton->add_css_class("toggle-button-off");
this->toggleButton->remove_css_class("toggle-button-on");
}
this->setIsDiscovering(false);
}
void BluetoothWidget::setIsDiscovering(bool state) {
this->isDiscovering = state;
if (state) {
this->scanButton->add_css_class("toggle-button-on");
this->scanButton->remove_css_class("toggle-button-off");
} else {
this->scanButton->add_css_class("toggle-button-off");
this->scanButton->remove_css_class("toggle-button-on");
}
}
void BluetoothWidget::update() {
setPowerState(isPowered);
setIsDiscovering(isDiscovering);
}

View File

@@ -1,4 +1,4 @@
#include "widgets/todoPopover.hpp"
#include "widgets/todo.hpp"
#include <gtkmm/box.h>
#include <gtkmm/entry.h>
@@ -12,24 +12,23 @@ TodoPopover::TodoPopover(std::string icon, std::string title) : Popover(icon, ti
container.set_spacing(10);
container.add_css_class("todo-popover-container");
auto entry = Gtk::make_managed<Gtk::Entry>();
entry->set_placeholder_text("Enter your to-do item...");
entry->add_css_class("todo-input");
entry->set_hexpand(true);
entry->set_halign(Gtk::Align::FILL);
entry->set_valign(Gtk::Align::START);
inputArea.append(*entry);
inputArea.add_css_class("todo-input-area");
inputArea.set_hexpand(true);
inputArea.set_halign(Gtk::Align::FILL);
entry->signal_activate().connect([this, entry]() {
std::string text = entry->get_text();
if (!text.empty()) {
this->todoService->addTodo(text);
entry->set_text("");
}
});
@@ -39,12 +38,12 @@ TodoPopover::TodoPopover(std::string icon, std::string title) : Popover(icon, ti
this->todoList = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL);
container.append(*todoList);
todoList->add_css_class("todo-list");
auto signal = sigc::signal<void()>();
this->todoService = new TodoService(signal);
signal.connect(sigc::mem_fun(*this, &TodoPopover::update));
this->set_popover_child(this->container);
this->update();
}
@@ -52,23 +51,23 @@ TodoPopover::TodoPopover(std::string icon, std::string title) : Popover(icon, ti
void TodoPopover::update() {
auto todos = this->todoService->getTodos();
Gtk::Widget* child = todoList->get_first_child();
Gtk::Widget *child = todoList->get_first_child();
while (child) {
Gtk::Widget* next = child->get_next_sibling();
Gtk::Widget *next = child->get_next_sibling();
bool found = false;
for (auto& [id, todo] : todos) {
for (auto &[id, todo] : todos) {
if (child == todo) {
found = true;
break;
}
}
if (!found) {
todoList->remove(*child);
}
child = next;
}

View File

@@ -1,12 +1,12 @@
#include "widgets/volumeWidget.hpp"
#include "helpers/systemHelper.hpp"
#include <cmath>
#include <iostream>
#include <regex>
#include <sigc++/functors/mem_fun.h>
#include "helpers/systemHelper.hpp"
VolumeWidget::VolumeWidget() : Gtk::Box(Gtk::Orientation::HORIZONTAL) {
set_valign(Gtk::Align::CENTER);
set_halign(Gtk::Align::CENTER);

View File

@@ -1,4 +1,5 @@
#include "widgets/webWidget.hpp"
#include <gtkmm/label.h>
#include <webkit/webkit.h>

View File

@@ -1,5 +1,4 @@
#include "widgets/workspaceIndicator.hpp"
#include "services/hyprland.hpp"
#include <cassert>
#include <gdk/gdk.h>
@@ -7,6 +6,8 @@
#include <gtkmm/widget.h>
#include <sigc++/functors/mem_fun.h>
#include "services/hyprland.hpp"
WorkspaceIndicator::WorkspaceIndicator(HyprlandService &service, int monitorId)
: Gtk::Box(Gtk::Orientation::HORIZONTAL), service(service),
monitorId(monitorId) {