some refactore
This commit is contained in:
@@ -36,8 +36,13 @@ add_library(bar_lib)
|
|||||||
target_sources(bar_lib
|
target_sources(bar_lib
|
||||||
PUBLIC
|
PUBLIC
|
||||||
src/app.cpp
|
src/app.cpp
|
||||||
|
|
||||||
src/bar/bar.cpp
|
src/bar/bar.cpp
|
||||||
|
|
||||||
|
src/components/button/iconButton.cpp
|
||||||
|
src/components/button/textButton.cpp
|
||||||
|
src/components/button/tabButton.cpp
|
||||||
|
|
||||||
src/connection/httpConnection.cpp
|
src/connection/httpConnection.cpp
|
||||||
src/connection/dbus/notification.cpp
|
src/connection/dbus/notification.cpp
|
||||||
src/connection/dbus/mpris.cpp
|
src/connection/dbus/mpris.cpp
|
||||||
@@ -63,7 +68,6 @@ target_sources(bar_lib
|
|||||||
|
|
||||||
src/components/popover.cpp
|
src/components/popover.cpp
|
||||||
src/components/workspaceIndicator.cpp
|
src/components/workspaceIndicator.cpp
|
||||||
src/components/base/button.cpp
|
|
||||||
)
|
)
|
||||||
include_directories(bar_lib PRIVATE
|
include_directories(bar_lib PRIVATE
|
||||||
include
|
include
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <gtkmm.h>
|
#include <gtkmm.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include "components/button/iconButton.hpp"
|
||||||
#include "widgets/clock.hpp"
|
#include "widgets/clock.hpp"
|
||||||
#include "widgets/date.hpp"
|
#include "widgets/date.hpp"
|
||||||
#include "widgets/tray.hpp"
|
#include "widgets/tray.hpp"
|
||||||
@@ -27,8 +28,8 @@ class Bar : public Gtk::Window {
|
|||||||
|
|
||||||
Clock clock;
|
Clock clock;
|
||||||
Date date;
|
Date date;
|
||||||
WebWidget homeAssistant{"\uf024", "Home Assistant", "https://home.rivercry.com"};
|
WebWidget homeAssistant{Icon::HOME_ASSISTANT, "Home Assistant", "https://home.rivercry.com"};
|
||||||
ControlCenter controlCenter{"\ue062", "Control Center"};
|
ControlCenter controlCenter{Icon::CONTROL_CENTER, "Control Center"};
|
||||||
|
|
||||||
std::shared_ptr<TrayWidget> trayWidget = nullptr;
|
std::shared_ptr<TrayWidget> trayWidget = nullptr;
|
||||||
std::shared_ptr<VolumeWidget> volumeWidget = nullptr;
|
std::shared_ptr<VolumeWidget> volumeWidget = nullptr;
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <gtkmm/button.h>
|
|
||||||
#include "gtkmm/image.h"
|
|
||||||
#include "sigc++/signal.h"
|
|
||||||
|
|
||||||
class Button : public Gtk::Button {
|
|
||||||
public:
|
|
||||||
Button(const std::string label);
|
|
||||||
Button(Gtk::Image &image);
|
|
||||||
|
|
||||||
sigc::signal<void()> onClickedSignal;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void on_clicked() {
|
|
||||||
onClickedSignal.emit();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
12
include/components/button/iconButton.hpp
Normal file
12
include/components/button/iconButton.hpp
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "components/button/textButton.hpp"
|
||||||
|
#include "components/types/icon.hpp"
|
||||||
|
|
||||||
|
class IconButton : public TextButton {
|
||||||
|
public:
|
||||||
|
IconButton(Icon::Type icon, std::string fontFamilyCss = "materia-icons");
|
||||||
|
void setIcon(Icon::Type icon);
|
||||||
|
};
|
||||||
9
include/components/button/tabButton.hpp
Normal file
9
include/components/button/tabButton.hpp
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "components/button/iconButton.hpp"
|
||||||
|
|
||||||
|
class TabButton : public IconButton {
|
||||||
|
public:
|
||||||
|
TabButton(Icon::Type icon);
|
||||||
|
void setActive(bool active);
|
||||||
|
};
|
||||||
13
include/components/button/textButton.hpp
Normal file
13
include/components/button/textButton.hpp
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "gtkmm/button.h"
|
||||||
|
|
||||||
|
class TextButton : public Gtk::Button {
|
||||||
|
public:
|
||||||
|
TextButton(const std::string &label);
|
||||||
|
void setText(const std::string &text);
|
||||||
|
};
|
||||||
@@ -3,11 +3,12 @@
|
|||||||
#include <gtkmm/button.h>
|
#include <gtkmm/button.h>
|
||||||
#include <gtkmm/popover.h>
|
#include <gtkmm/popover.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "components/base/button.hpp"
|
#include "components/button/iconButton.hpp"
|
||||||
|
#include "components/button/textButton.hpp"
|
||||||
|
|
||||||
class Popover : public Button {
|
class Popover : public IconButton {
|
||||||
public:
|
public:
|
||||||
Popover(const std::string icon, std::string name);
|
Popover(Icon::Type icon, std::string name);
|
||||||
~Popover() override;
|
~Popover() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
48
include/components/types/icon.hpp
Normal file
48
include/components/types/icon.hpp
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
class Icon {
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum Type {
|
||||||
|
|
||||||
|
HOME_ASSISTANT,
|
||||||
|
CONTROL_CENTER,
|
||||||
|
|
||||||
|
SKIP_PREVIOUS,
|
||||||
|
SKIP_NEXT,
|
||||||
|
PLAY_ARROW,
|
||||||
|
PAUSE,
|
||||||
|
|
||||||
|
PLAY_CIRCLE,
|
||||||
|
|
||||||
|
EMPTY_DASHBOARD,
|
||||||
|
|
||||||
|
SAVE,
|
||||||
|
CONTENT_COPY,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const std::string toString(Type type) {
|
||||||
|
return typeToString[type];
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
static inline std::map<Type, const std::string> typeToString = {
|
||||||
|
{HOME_ASSISTANT, "\uf024"},
|
||||||
|
{CONTROL_CENTER, "\ue062"},
|
||||||
|
|
||||||
|
{SKIP_PREVIOUS, "\ue045"},
|
||||||
|
{SKIP_NEXT, "\ue044"},
|
||||||
|
{PLAY_ARROW, "\ue037"},
|
||||||
|
{PAUSE, "\ue034"},
|
||||||
|
|
||||||
|
{PLAY_CIRCLE, "\ue1c4"},
|
||||||
|
|
||||||
|
{EMPTY_DASHBOARD, "\uf844"},
|
||||||
|
|
||||||
|
{SAVE, "\ue161"},
|
||||||
|
{CONTENT_COPY, "\ue14d"},
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -1,27 +1,30 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "components/button/iconButton.hpp"
|
||||||
|
#include "components/button/tabButton.hpp"
|
||||||
#include "components/popover.hpp"
|
#include "components/popover.hpp"
|
||||||
#include "gtkmm/box.h"
|
#include "gtkmm/box.h"
|
||||||
#include "gtkmm/button.h"
|
#include "gtkmm/scrolledwindow.h"
|
||||||
#include "gtkmm/label.h"
|
|
||||||
#include "gtkmm/stack.h"
|
#include "gtkmm/stack.h"
|
||||||
#include "widgets/controlCenter/mediaControl.hpp"
|
#include "widgets/controlCenter/mediaControl.hpp"
|
||||||
#include "widgets/weather.hpp"
|
#include "widgets/weather.hpp"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
class ControlCenter : public Popover {
|
class ControlCenter : public Popover {
|
||||||
public:
|
public:
|
||||||
ControlCenter(std::string icon, std::string name);
|
ControlCenter(Icon::Type icon, std::string name);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Gtk::ScrolledWindow scrollview;
|
||||||
Gtk::Box container;
|
Gtk::Box container;
|
||||||
Gtk::Box tabRow;
|
Gtk::Box tabRow;
|
||||||
Gtk::Stack contentStack;
|
Gtk::Stack contentStack;
|
||||||
Gtk::Box controlCenterContainer;
|
Gtk::Box controlCenterContainer;
|
||||||
WeatherWidget weatherWidget;
|
WeatherWidget weatherWidget;
|
||||||
Gtk::Button mediaControl;
|
std::unique_ptr<TabButton> mediaControl;
|
||||||
Gtk::Button testTabButton;
|
std::unique_ptr<TabButton> testTabButton;
|
||||||
std::shared_ptr<MprisController> mprisController = MprisController::getInstance();
|
std::shared_ptr<MprisController> mprisController = MprisController::getInstance();
|
||||||
std::unordered_map<std::string, MediaControlWidget*> mediaWidgets;
|
std::unordered_map<std::string, MediaControlWidget*> mediaWidgets;
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "gtkmm/scale.h"
|
#include "gtkmm/scale.h"
|
||||||
#include "gtkmm/scrolledwindow.h"
|
#include "gtkmm/scrolledwindow.h"
|
||||||
|
|
||||||
|
#include "components/button/iconButton.hpp"
|
||||||
#include "connection/dbus/mpris.hpp"
|
#include "connection/dbus/mpris.hpp"
|
||||||
|
|
||||||
class MediaControlWidget : public Gtk::Box {
|
class MediaControlWidget : public Gtk::Box {
|
||||||
@@ -48,9 +49,9 @@ class MediaControlWidget : public Gtk::Box {
|
|||||||
|
|
||||||
// playback controls
|
// playback controls
|
||||||
Gtk::Box bottomContainer;
|
Gtk::Box bottomContainer;
|
||||||
Gtk::Button previousButton;
|
std::unique_ptr<IconButton> previousButton;
|
||||||
Gtk::Button playPauseButton;
|
std::unique_ptr<IconButton> playPauseButton;
|
||||||
Gtk::Button nextButton;
|
std::unique_ptr<IconButton> nextButton;
|
||||||
|
|
||||||
Gtk::ScrolledWindow imageWrapper;
|
Gtk::ScrolledWindow imageWrapper;
|
||||||
|
|
||||||
|
|||||||
@@ -17,12 +17,12 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "components/button/iconButton.hpp"
|
||||||
#include "connection/dbus/tray.hpp"
|
#include "connection/dbus/tray.hpp"
|
||||||
#include "components/base/button.hpp"
|
|
||||||
|
|
||||||
class TrayIconWidget : public Button {
|
class TrayIconWidget : public IconButton {
|
||||||
public:
|
public:
|
||||||
TrayIconWidget(std::string id);
|
TrayIconWidget(Icon::Type icon, std::string id);
|
||||||
~TrayIconWidget() override;
|
~TrayIconWidget() override;
|
||||||
|
|
||||||
void update(const TrayService::Item &item);
|
void update(const TrayService::Item &item);
|
||||||
|
|||||||
@@ -3,9 +3,10 @@
|
|||||||
#include <gtkmm/button.h>
|
#include <gtkmm/button.h>
|
||||||
#include <gtkmm/popover.h>
|
#include <gtkmm/popover.h>
|
||||||
|
|
||||||
|
#include "components/button/iconButton.hpp"
|
||||||
#include "components/popover.hpp"
|
#include "components/popover.hpp"
|
||||||
|
|
||||||
class WebWidget : public Popover {
|
class WebWidget : public Popover {
|
||||||
public:
|
public:
|
||||||
WebWidget(std::string icon, std::string title, std::string url);
|
WebWidget(Icon::Type icon, std::string title, std::string url);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -23,11 +23,13 @@ window {
|
|||||||
|
|
||||||
.material-icons {
|
.material-icons {
|
||||||
font-family: var(--icon-font-material);
|
font-family: var(--icon-font-material);
|
||||||
font-size: 18px;
|
}
|
||||||
|
|
||||||
|
.icon-button {
|
||||||
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tab-icon {
|
.tab-icon {
|
||||||
font-family: var(--icon-font-material);
|
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
margin-right: 6px;
|
margin-right: 6px;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
@@ -35,13 +37,7 @@ window {
|
|||||||
padding: 2px 4px;
|
padding: 2px 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tab-icon:hover {
|
|
||||||
background-color: rgba(255, 255, 255, 0.1);
|
|
||||||
border: 1px solid rgba(255, 255, 255, 0.2);
|
|
||||||
}
|
|
||||||
|
|
||||||
.control-center-tab-row {
|
.control-center-tab-row {
|
||||||
/* mordern and sleek */
|
|
||||||
background-color: rgba(50, 50, 50, 0.8);
|
background-color: rgba(50, 50, 50, 0.8);
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
padding: 2px 4px;
|
padding: 2px 4px;
|
||||||
@@ -58,7 +54,6 @@ window {
|
|||||||
popover {
|
popover {
|
||||||
margin-top: 4px;
|
margin-top: 4px;
|
||||||
font-family: var(--text-font);
|
font-family: var(--text-font);
|
||||||
/* padding: 6px; TODO: create better padding*/
|
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
|
|
||||||
background: rgba(25, 25, 25, 0.8);
|
background: rgba(25, 25, 25, 0.8);
|
||||||
@@ -105,8 +100,6 @@ popover {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.control-center-seek-bar {
|
.control-center-seek-bar {
|
||||||
min-height: 6px;
|
|
||||||
min-width: 120px;
|
|
||||||
margin: 0 6px;
|
margin: 0 6px;
|
||||||
border-bottom: 1px solid var(--color-border);
|
border-bottom: 1px solid var(--color-border);
|
||||||
}
|
}
|
||||||
@@ -139,8 +132,14 @@ tooltip {
|
|||||||
}
|
}
|
||||||
|
|
||||||
button {
|
button {
|
||||||
font-size: 20px;
|
font-size: 14px;
|
||||||
padding: 3px 6px;
|
padding: 4px 8px;
|
||||||
|
border-radius: 4px;
|
||||||
|
color: #ffffff;
|
||||||
|
transition:
|
||||||
|
background-color 0.2s,
|
||||||
|
color 0.2s,
|
||||||
|
border-color 0.2s;
|
||||||
}
|
}
|
||||||
|
|
||||||
#spacer {
|
#spacer {
|
||||||
@@ -151,14 +150,8 @@ button {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.button:hover {
|
.button:hover {
|
||||||
background-color: #111111;
|
background-color: rgba(255, 255, 255, 0.1);
|
||||||
}
|
box-shadow: none;
|
||||||
|
|
||||||
.flat-button {
|
|
||||||
background-color: #333333;
|
|
||||||
color: #ffffff;
|
|
||||||
padding: 2px 4px;
|
|
||||||
border-radius: 10px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.workspace-pill {
|
.workspace-pill {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include <gtkmm/label.h>
|
#include <gtkmm/label.h>
|
||||||
#include <gtkmm/window.h>
|
#include <gtkmm/window.h>
|
||||||
|
|
||||||
|
#include "components/button/textButton.hpp"
|
||||||
#include "helpers/system.hpp"
|
#include "helpers/system.hpp"
|
||||||
#include "widgets/date.hpp"
|
#include "widgets/date.hpp"
|
||||||
#include "widgets/spacer.hpp"
|
#include "widgets/spacer.hpp"
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
#include "components/base/button.hpp"
|
|
||||||
|
|
||||||
#include "sigc++/functors/mem_fun.h"
|
|
||||||
|
|
||||||
Button::Button(const std::string label) : Gtk::Button(label) {
|
|
||||||
signal_clicked().connect(sigc::mem_fun(*this, &Button::on_clicked));
|
|
||||||
this->add_css_class("button");
|
|
||||||
}
|
|
||||||
|
|
||||||
Button::Button(Gtk::Image &image) : Gtk::Button() {
|
|
||||||
set_child(image);
|
|
||||||
signal_clicked().connect(sigc::mem_fun(*this, &Button::on_clicked));
|
|
||||||
this->add_css_class("button");
|
|
||||||
}
|
|
||||||
10
src/components/button/iconButton.cpp
Normal file
10
src/components/button/iconButton.cpp
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#include "components/button/iconButton.hpp"
|
||||||
|
|
||||||
|
IconButton::IconButton(Icon::Type icon, std::string fontFamilyCss) : TextButton(Icon::toString(icon)) {
|
||||||
|
this->get_style_context()->add_class(fontFamilyCss);
|
||||||
|
this->add_css_class("icon-button");
|
||||||
|
}
|
||||||
|
|
||||||
|
void IconButton::setIcon(Icon::Type icon) {
|
||||||
|
this->set_label(Icon::toString(icon));
|
||||||
|
}
|
||||||
13
src/components/button/tabButton.cpp
Normal file
13
src/components/button/tabButton.cpp
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#include "components/button/tabButton.hpp"
|
||||||
|
|
||||||
|
TabButton::TabButton(Icon::Type icon) : IconButton(icon) {
|
||||||
|
add_css_class("tab-icon");
|
||||||
|
}
|
||||||
|
|
||||||
|
void TabButton::setActive(bool active) {
|
||||||
|
if (active) {
|
||||||
|
this->add_css_class("active-button");
|
||||||
|
} else {
|
||||||
|
this->remove_css_class("active-button");
|
||||||
|
}
|
||||||
|
}
|
||||||
9
src/components/button/textButton.cpp
Normal file
9
src/components/button/textButton.cpp
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#include "components/button/textButton.hpp"
|
||||||
|
|
||||||
|
TextButton::TextButton(const std::string &label) : Gtk::Button(label) {
|
||||||
|
add_css_class("button");
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextButton::setText(const std::string &text) {
|
||||||
|
this->set_label(text);
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "components/popover.hpp"
|
#include "components/popover.hpp"
|
||||||
|
#include "components/button/iconButton.hpp"
|
||||||
|
|
||||||
Popover::Popover(const std::string icon, std::string name): Button(icon) {
|
Popover::Popover(Icon::Type icon, std::string name): IconButton(icon) {
|
||||||
signal_clicked().connect(sigc::mem_fun(*this, &Popover::on_toggle_window));
|
signal_clicked().connect(sigc::mem_fun(*this, &Popover::on_toggle_window));
|
||||||
|
|
||||||
set_name(name);
|
set_name(name);
|
||||||
|
|||||||
@@ -1,32 +1,40 @@
|
|||||||
#include "widgets/controlCenter/controlCenter.hpp"
|
#include "widgets/controlCenter/controlCenter.hpp"
|
||||||
|
#include "components/button/iconButton.hpp"
|
||||||
|
#include "components/button/tabButton.hpp"
|
||||||
|
|
||||||
|
|
||||||
ControlCenter::ControlCenter(std::string icon, std::string name)
|
ControlCenter::ControlCenter(Icon::Type icon, std::string name)
|
||||||
: Popover(icon, name) {
|
: Popover(icon, name) {
|
||||||
this->popover->add_css_class("control-center-popover");
|
this->popover->add_css_class("control-center-popover");
|
||||||
this->container.set_orientation(Gtk::Orientation::VERTICAL);
|
this->container.set_orientation(Gtk::Orientation::VERTICAL);
|
||||||
this->container.set_spacing(10);
|
this->container.set_spacing(10);
|
||||||
this->popover->set_hexpand(false);
|
|
||||||
this->popover->set_size_request(240, -1);
|
|
||||||
|
|
||||||
set_popover_child(this->container);
|
this->scrollview.set_child(this->container);
|
||||||
|
this->scrollview.set_min_content_width(220);
|
||||||
|
this->scrollview.set_max_content_width(220);
|
||||||
|
this->scrollview.set_size_request(220, -1);
|
||||||
|
this->scrollview.set_policy(
|
||||||
|
Gtk::PolicyType::NEVER, Gtk::PolicyType::AUTOMATIC);
|
||||||
|
this->scrollview.set_hexpand(false);
|
||||||
|
this->scrollview.set_vexpand(true);
|
||||||
|
this->scrollview.set_propagate_natural_height(true);
|
||||||
|
|
||||||
|
set_popover_child(this->scrollview);
|
||||||
|
|
||||||
this->tabRow.set_orientation(Gtk::Orientation::HORIZONTAL);
|
this->tabRow.set_orientation(Gtk::Orientation::HORIZONTAL);
|
||||||
this->tabRow.set_spacing(4);
|
this->tabRow.set_spacing(4);
|
||||||
this->tabRow.set_margin_bottom(4);
|
this->tabRow.set_margin_bottom(4);
|
||||||
this->tabRow.add_css_class("control-center-tab-row");
|
this->tabRow.add_css_class("control-center-tab-row");
|
||||||
|
|
||||||
this->mediaControl.set_label("\uf5d3"); // control icon
|
this->mediaControl = std::make_unique<TabButton>(Icon::PLAY_CIRCLE);
|
||||||
this->mediaControl.add_css_class("tab-icon");
|
this->testTabButton = std::make_unique<TabButton>(Icon::EMPTY_DASHBOARD);
|
||||||
this->testTabButton.set_label("\uE5CA"); // test icon
|
|
||||||
this->testTabButton.add_css_class("tab-icon");
|
|
||||||
|
|
||||||
this->tabRow.append(this->mediaControl);
|
this->tabRow.append(*this->mediaControl);
|
||||||
this->tabRow.append(this->testTabButton);
|
this->tabRow.append(*this->testTabButton);
|
||||||
|
|
||||||
this->container.append(this->tabRow);
|
this->container.append(this->tabRow);
|
||||||
|
|
||||||
this->contentStack.set_hhomogeneous(false);
|
this->contentStack.set_hhomogeneous(true);
|
||||||
this->contentStack.set_vhomogeneous(false);
|
this->contentStack.set_vhomogeneous(false);
|
||||||
this->contentStack.set_transition_type(Gtk::StackTransitionType::CROSSFADE);
|
this->contentStack.set_transition_type(Gtk::StackTransitionType::CROSSFADE);
|
||||||
this->contentStack.set_transition_duration(150);
|
this->contentStack.set_transition_duration(150);
|
||||||
@@ -41,11 +49,11 @@ ControlCenter::ControlCenter(std::string icon, std::string name)
|
|||||||
|
|
||||||
this->container.append(this->contentStack);
|
this->container.append(this->contentStack);
|
||||||
|
|
||||||
this->mediaControl.signal_clicked().connect([this]() {
|
this->mediaControl->signal_clicked().connect([this]() {
|
||||||
this->setActiveTab("controls");
|
this->setActiveTab("controls");
|
||||||
});
|
});
|
||||||
|
|
||||||
this->testTabButton.signal_clicked().connect([this]() {
|
this->testTabButton->signal_clicked().connect([this]() {
|
||||||
this->setActiveTab("test");
|
this->setActiveTab("test");
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -68,13 +76,13 @@ ControlCenter::ControlCenter(std::string icon, std::string name)
|
|||||||
void ControlCenter::setActiveTab(const std::string &tab_name) {
|
void ControlCenter::setActiveTab(const std::string &tab_name) {
|
||||||
this->contentStack.set_visible_child(tab_name);
|
this->contentStack.set_visible_child(tab_name);
|
||||||
|
|
||||||
this->mediaControl.remove_css_class("active-button");
|
this->mediaControl->setActive(false);
|
||||||
this->testTabButton.remove_css_class("active-button");
|
this->testTabButton->setActive(false);
|
||||||
|
|
||||||
if (tab_name == "controls") {
|
if (tab_name == "controls") {
|
||||||
this->mediaControl.add_css_class("active-button");
|
this->mediaControl->setActive(true);
|
||||||
} else if (tab_name == "test") {
|
} else if (tab_name == "test") {
|
||||||
this->testTabButton.add_css_class("active-button");
|
this->testTabButton->setActive(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,34 @@
|
|||||||
#include "widgets/controlCenter/mediaControl.hpp"
|
#include "widgets/controlCenter/mediaControl.hpp"
|
||||||
|
|
||||||
|
#include "components/button/iconButton.hpp"
|
||||||
#include "helpers/string.hpp"
|
#include "helpers/string.hpp"
|
||||||
#include "services/textureCache.hpp"
|
#include "services/textureCache.hpp"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
std::string formatTimeUs(int64_t time_us) {
|
||||||
|
if (time_us < 0) {
|
||||||
|
time_us = 0;
|
||||||
|
}
|
||||||
|
int64_t totalSeconds = time_us / 1000000;
|
||||||
|
int64_t hours = totalSeconds / 3600;
|
||||||
|
int64_t minutes = (totalSeconds / 60) % 60;
|
||||||
|
int64_t seconds = totalSeconds % 60;
|
||||||
|
|
||||||
|
if (hours > 0) {
|
||||||
|
return std::to_string(hours) + ":" +
|
||||||
|
(minutes < 10 ? "0" : "") + std::to_string(minutes) + ":" +
|
||||||
|
(seconds < 10 ? "0" : "") + std::to_string(seconds);
|
||||||
|
}
|
||||||
|
return std::to_string(minutes) + ":" + (seconds < 10 ? "0" : "") + std::to_string(seconds);
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
MediaControlWidget::MediaControlWidget(std::shared_ptr<MprisController> controller)
|
MediaControlWidget::MediaControlWidget(std::shared_ptr<MprisController> controller)
|
||||||
: Gtk::Box(Gtk::Orientation::VERTICAL) {
|
: Gtk::Box(Gtk::Orientation::VERTICAL) {
|
||||||
|
|
||||||
this->mprisController = std::move(controller);
|
this->mprisController = std::move(controller);
|
||||||
|
|
||||||
this->set_orientation(Gtk::Orientation::VERTICAL);
|
this->set_orientation(Gtk::Orientation::VERTICAL);
|
||||||
this->set_size_request(200, -1);
|
|
||||||
this->set_hexpand(false);
|
this->set_hexpand(false);
|
||||||
this->set_vexpand(false);
|
this->set_vexpand(false);
|
||||||
this->add_css_class("control-center-player-container");
|
this->add_css_class("control-center-player-container");
|
||||||
@@ -88,6 +107,10 @@ MediaControlWidget::MediaControlWidget(std::shared_ptr<MprisController> controll
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this->previousButton = std::make_unique<IconButton>(Icon::SKIP_PREVIOUS);
|
||||||
|
this->playPauseButton = std::make_unique<IconButton>(Icon::PLAY_ARROW);
|
||||||
|
this->nextButton = std::make_unique<IconButton>(Icon::SKIP_NEXT);
|
||||||
|
|
||||||
this->bottomContainer.set_orientation(Gtk::Orientation::HORIZONTAL);
|
this->bottomContainer.set_orientation(Gtk::Orientation::HORIZONTAL);
|
||||||
this->bottomContainer.set_vexpand(false);
|
this->bottomContainer.set_vexpand(false);
|
||||||
this->bottomContainer.set_hexpand(false);
|
this->bottomContainer.set_hexpand(false);
|
||||||
@@ -95,26 +118,17 @@ MediaControlWidget::MediaControlWidget(std::shared_ptr<MprisController> controll
|
|||||||
this->bottomContainer.set_homogeneous(true);
|
this->bottomContainer.set_homogeneous(true);
|
||||||
this->topContainer.set_vexpand(false);
|
this->topContainer.set_vexpand(false);
|
||||||
this->topContainer.set_hexpand(true);
|
this->topContainer.set_hexpand(true);
|
||||||
this->bottomContainer.append(this->previousButton);
|
this->bottomContainer.append(*this->previousButton);
|
||||||
this->bottomContainer.append(this->playPauseButton);
|
this->bottomContainer.append(*this->playPauseButton);
|
||||||
this->bottomContainer.append(this->nextButton);
|
this->bottomContainer.append(*this->nextButton);
|
||||||
|
|
||||||
this->previousButton.set_label("\u23EE"); // Previous track symbol
|
this->previousButton->signal_clicked().connect([this]() {
|
||||||
this->previousButton.add_css_class("button");
|
|
||||||
this->previousButton.add_css_class("material-icons");
|
|
||||||
this->playPauseButton.set_label("\u23EF"); // Play/Pause symbol
|
|
||||||
this->playPauseButton.add_css_class("button");
|
|
||||||
this->playPauseButton.add_css_class("material-icons");
|
|
||||||
this->nextButton.set_label("\u23ED"); // Next track symbol
|
|
||||||
this->nextButton.add_css_class("button");
|
|
||||||
this->nextButton.add_css_class("material-icons");
|
|
||||||
this->previousButton.signal_clicked().connect([this]() {
|
|
||||||
this->mprisController->previous_song();
|
this->mprisController->previous_song();
|
||||||
});
|
});
|
||||||
this->playPauseButton.signal_clicked().connect([this]() {
|
this->playPauseButton->signal_clicked().connect([this]() {
|
||||||
this->mprisController->toggle_play();
|
this->mprisController->toggle_play();
|
||||||
});
|
});
|
||||||
this->nextButton.signal_clicked().connect([this]() {
|
this->nextButton->signal_clicked().connect([this]() {
|
||||||
this->mprisController->next_song();
|
this->mprisController->next_song();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -179,10 +193,7 @@ void MediaControlWidget::onSpotifyMprisUpdated(const MprisPlayer2Message &messag
|
|||||||
|
|
||||||
void MediaControlWidget::setCurrentPosition(int64_t position_us) {
|
void MediaControlWidget::setCurrentPosition(int64_t position_us) {
|
||||||
this->currentPositionUs = position_us;
|
this->currentPositionUs = position_us;
|
||||||
int64_t seconds = (position_us / 1000000) % 60;
|
this->currentTimeLabel.set_text(formatTimeUs(position_us));
|
||||||
int64_t minutes = (position_us / (1000000 * 60)) % 60;
|
|
||||||
this->currentTimeLabel.set_text(
|
|
||||||
std::to_string(minutes) + ":" + (seconds < 10 ? "0" : "") + std::to_string(seconds));
|
|
||||||
if (totalLengthUs > 0) {
|
if (totalLengthUs > 0) {
|
||||||
double fraction = static_cast<double>(currentPositionUs) / static_cast<double>(totalLengthUs);
|
double fraction = static_cast<double>(currentPositionUs) / static_cast<double>(totalLengthUs);
|
||||||
this->suppressSeekSignal = true;
|
this->suppressSeekSignal = true;
|
||||||
@@ -193,10 +204,7 @@ void MediaControlWidget::setCurrentPosition(int64_t position_us) {
|
|||||||
|
|
||||||
void MediaControlWidget::setTotalLength(int64_t length_us) {
|
void MediaControlWidget::setTotalLength(int64_t length_us) {
|
||||||
this->totalLengthUs = length_us;
|
this->totalLengthUs = length_us;
|
||||||
int64_t seconds = (length_us / 1000000) % 60;
|
this->totalTimeLabel.set_text(formatTimeUs(length_us));
|
||||||
int64_t minutes = (length_us / (1000000 * 60)) % 60;
|
|
||||||
this->totalTimeLabel.set_text(
|
|
||||||
std::to_string(minutes) + ":" + (seconds < 10 ? "0" : "") + std::to_string(seconds));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaControlWidget::resetSeekTimer(int64_t start_position_us) {
|
void MediaControlWidget::resetSeekTimer(int64_t start_position_us) {
|
||||||
@@ -248,20 +256,21 @@ void MediaControlWidget::onRunningStateChanged(MprisController::PlaybackStatus s
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MediaControlWidget::onPlay() {
|
void MediaControlWidget::onPlay() {
|
||||||
this->playPauseButton.set_label("\u23F8"); // Pause symbol
|
this->playPauseButton->setIcon(Icon::PAUSE);
|
||||||
// strart seek timer if not already running
|
|
||||||
this->resetSeekTimer(currentPositionUs);
|
this->resetSeekTimer(currentPositionUs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaControlWidget::onPause() {
|
void MediaControlWidget::onPause() {
|
||||||
this->playPauseButton.set_label("\u23F5"); // Play symbol
|
this->playPauseButton->setIcon(Icon::PLAY_ARROW);
|
||||||
|
|
||||||
if (seekTimerConnection.connected()) {
|
if (seekTimerConnection.connected()) {
|
||||||
seekTimerConnection.disconnect();
|
seekTimerConnection.disconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaControlWidget::onStop() {
|
void MediaControlWidget::onStop() {
|
||||||
this->playPauseButton.set_label("\u23F9"); // stop symbol
|
this->playPauseButton->setIcon(Icon::PLAY_ARROW);
|
||||||
|
|
||||||
if (seekTimerConnection.connected()) {
|
if (seekTimerConnection.connected()) {
|
||||||
seekTimerConnection.disconnect();
|
seekTimerConnection.disconnect();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
#include "gdkmm/monitor.h"
|
#include "gdkmm/monitor.h"
|
||||||
#include "glibmm/main.h"
|
#include "glibmm/main.h"
|
||||||
#include "glibmm/object.h"
|
|
||||||
#include "gtk4-layer-shell.h"
|
#include "gtk4-layer-shell.h"
|
||||||
#include "gtkmm/button.h"
|
#include "gtkmm/button.h"
|
||||||
#include "gtkmm/cssprovider.h"
|
#include "gtkmm/cssprovider.h"
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <spdlog/spdlog.h>
|
#include <spdlog/spdlog.h>
|
||||||
|
#include "components/button/iconButton.hpp"
|
||||||
|
|
||||||
#include "glibmm/datetime.h"
|
#include "glibmm/datetime.h"
|
||||||
#include "glibmm/fileutils.h"
|
#include "glibmm/fileutils.h"
|
||||||
@@ -85,12 +86,8 @@ void CopyNotification::createImageNotification(NotifyMessage notify) {
|
|||||||
auto buttonBox = Gtk::make_managed<Gtk::Box>();
|
auto buttonBox = Gtk::make_managed<Gtk::Box>();
|
||||||
buttonBox->set_spacing(10);
|
buttonBox->set_spacing(10);
|
||||||
|
|
||||||
// material icons unicode
|
|
||||||
auto saveToClipboardLabel = Gtk::make_managed<Gtk::Label>("\uF0EA"); // content copy icon
|
|
||||||
auto saveToFileLabel = Gtk::make_managed<Gtk::Label>("\uF1C5"); // save icon
|
|
||||||
|
|
||||||
auto saveToClipboardButton = Gtk::make_managed<Gtk::Button>();
|
auto saveToClipboardButton = Gtk::make_managed<IconButton>(Icon::CONTENT_COPY);
|
||||||
saveToClipboardButton->set_child(*saveToClipboardLabel);
|
|
||||||
saveToClipboardButton->signal_clicked().connect([this]() {
|
saveToClipboardButton->signal_clicked().connect([this]() {
|
||||||
copyToClipboard(this->copiedImage);
|
copyToClipboard(this->copiedImage);
|
||||||
spdlog::info("Copied image to clipboard");
|
spdlog::info("Copied image to clipboard");
|
||||||
@@ -101,8 +98,7 @@ void CopyNotification::createImageNotification(NotifyMessage notify) {
|
|||||||
saveToClipboardButton->add_css_class("notification-button");
|
saveToClipboardButton->add_css_class("notification-button");
|
||||||
saveToClipboardButton->add_css_class("notification-icon-button");
|
saveToClipboardButton->add_css_class("notification-icon-button");
|
||||||
|
|
||||||
auto saveToFileButton = Gtk::make_managed<Gtk::Button>();
|
auto saveToFileButton = Gtk::make_managed<IconButton>(Icon::SAVE);
|
||||||
saveToFileButton->set_child(*saveToFileLabel);
|
|
||||||
saveToFileButton->signal_clicked().connect([this]() {
|
saveToFileButton->signal_clicked().connect([this]() {
|
||||||
// xdg-pic/screenshot // use env
|
// xdg-pic/screenshot // use env
|
||||||
auto xdgPicturesDir = Glib::get_user_special_dir(Glib::UserDirectory::PICTURES);
|
auto xdgPicturesDir = Glib::get_user_special_dir(Glib::UserDirectory::PICTURES);
|
||||||
@@ -136,9 +132,7 @@ void CopyNotification::createTextNotification(NotifyMessage notify) {
|
|||||||
textLabel->set_margin_bottom(10);
|
textLabel->set_margin_bottom(10);
|
||||||
contentBox->append(*textLabel);
|
contentBox->append(*textLabel);
|
||||||
|
|
||||||
auto copyToClipboardButton = Gtk::make_managed<Gtk::Button>();
|
auto copyToClipboardButton = Gtk::make_managed<IconButton>(Icon::CONTENT_COPY);
|
||||||
auto copyToClipboardLabel = Gtk::make_managed<Gtk::Label>("\uF0EA"); // content copy icon
|
|
||||||
copyToClipboardButton->set_child(*copyToClipboardLabel);
|
|
||||||
copyToClipboardButton->signal_clicked().connect([this]() {
|
copyToClipboardButton->signal_clicked().connect([this]() {
|
||||||
copyToClipboard(this->copiedText);
|
copyToClipboard(this->copiedText);
|
||||||
this->signal_close.emit(this->notificationId);
|
this->signal_close.emit(this->notificationId);
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
#include "widgets/notification/notificationWindow.hpp"
|
#include "widgets/notification/notificationWindow.hpp"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include "components/button/iconButton.hpp"
|
||||||
|
#include "components/button/textButton.hpp"
|
||||||
#include "helpers/string.hpp"
|
#include "helpers/string.hpp"
|
||||||
|
|
||||||
#include "gtkmm/box.h"
|
#include "gtkmm/box.h"
|
||||||
#include "gtkmm/button.h"
|
#include "gtkmm/button.h"
|
||||||
#include "gtkmm/gestureclick.h"
|
|
||||||
#include "gtkmm/image.h"
|
#include "gtkmm/image.h"
|
||||||
#include "gtkmm/label.h"
|
#include "gtkmm/label.h"
|
||||||
|
|
||||||
@@ -71,8 +72,7 @@ NotificationWindow::NotificationWindow(uint64_t notificationId, std::shared_ptr<
|
|||||||
std::string action_id = notify.actions[i];
|
std::string action_id = notify.actions[i];
|
||||||
std::string action_label = notify.actions[i + 1];
|
std::string action_label = notify.actions[i + 1];
|
||||||
|
|
||||||
auto btn = Gtk::make_managed<Gtk::Button>();
|
auto btn = Gtk::make_managed<TextButton>(action_label);
|
||||||
btn->set_label(action_label);
|
|
||||||
|
|
||||||
btn->add_css_class("notification-button");
|
btn->add_css_class("notification-button");
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "widgets/notification/spotifyNotification.hpp"
|
#include "widgets/notification/spotifyNotification.hpp"
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include "components/button/iconButton.hpp"
|
||||||
#include "helpers/string.hpp"
|
#include "helpers/string.hpp"
|
||||||
#include "services/textureCache.hpp"
|
#include "services/textureCache.hpp"
|
||||||
|
|
||||||
@@ -58,7 +59,7 @@ std::unique_ptr<Gtk::CenterBox> SpotifyNotification::createButtonBox(MprisPlayer
|
|||||||
buttonBox->set_hexpand(true);
|
buttonBox->set_hexpand(true);
|
||||||
buttonBox->set_halign(Gtk::Align::CENTER);
|
buttonBox->set_halign(Gtk::Align::CENTER);
|
||||||
|
|
||||||
auto backButton = Gtk::make_managed<Gtk::Button>("\ue045");
|
auto backButton = Gtk::make_managed<IconButton>(Icon::SKIP_PREVIOUS);
|
||||||
backButton->add_css_class("notification-icon-button");
|
backButton->add_css_class("notification-icon-button");
|
||||||
backButton->add_css_class("notification-button");
|
backButton->add_css_class("notification-button");
|
||||||
backButton->signal_clicked().connect([this, mpris]() {
|
backButton->signal_clicked().connect([this, mpris]() {
|
||||||
@@ -68,7 +69,7 @@ std::unique_ptr<Gtk::CenterBox> SpotifyNotification::createButtonBox(MprisPlayer
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
auto playPauseButton = Gtk::make_managed<Gtk::Button>("\ue037");
|
auto playPauseButton = Gtk::make_managed<IconButton>(Icon::PLAY_ARROW);
|
||||||
playPauseButton->add_css_class("notification-icon-button");
|
playPauseButton->add_css_class("notification-icon-button");
|
||||||
playPauseButton->add_css_class("notification-button");
|
playPauseButton->add_css_class("notification-button");
|
||||||
playPauseButton->signal_clicked().connect([playPauseButton, mpris]() {
|
playPauseButton->signal_clicked().connect([playPauseButton, mpris]() {
|
||||||
@@ -77,15 +78,15 @@ std::unique_ptr<Gtk::CenterBox> SpotifyNotification::createButtonBox(MprisPlayer
|
|||||||
|
|
||||||
static bool isPlaying = false;
|
static bool isPlaying = false;
|
||||||
if (isPlaying) {
|
if (isPlaying) {
|
||||||
playPauseButton->set_label("\ue037");
|
playPauseButton->setIcon(Icon::PLAY_ARROW);
|
||||||
} else {
|
} else {
|
||||||
playPauseButton->set_label("\ue034");
|
playPauseButton->setIcon(Icon::PAUSE);
|
||||||
}
|
}
|
||||||
isPlaying = !isPlaying;
|
isPlaying = !isPlaying;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
auto nextButton = Gtk::make_managed<Gtk::Button>("\ue044");
|
auto nextButton = Gtk::make_managed<IconButton>(Icon::SKIP_NEXT);
|
||||||
nextButton->add_css_class("notification-icon-button");
|
nextButton->add_css_class("notification-icon-button");
|
||||||
nextButton->add_css_class("notification-button");
|
nextButton->add_css_class("notification-button");
|
||||||
nextButton->signal_clicked().connect([this, mpris]() {
|
nextButton->signal_clicked().connect([this, mpris]() {
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
#include <graphene.h>
|
#include <graphene.h>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <spdlog/spdlog.h>
|
#include <spdlog/spdlog.h>
|
||||||
#include "components/base/button.hpp"
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
bool is_wayland_display(GtkWidget *widget) {
|
bool is_wayland_display(GtkWidget *widget) {
|
||||||
@@ -182,8 +181,7 @@ void log_menu_tree(const std::vector<TrayService::MenuNode> &nodes,
|
|||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
TrayIconWidget::TrayIconWidget( std::string id)
|
TrayIconWidget::TrayIconWidget(Icon::Type icon, std::string id) : IconButton(icon), id(std::move(id)),
|
||||||
: Button(id), id(std::move(id)),
|
|
||||||
container(Gtk::Orientation::HORIZONTAL) {
|
container(Gtk::Orientation::HORIZONTAL) {
|
||||||
aliveFlag = std::make_shared<bool>(true);
|
aliveFlag = std::make_shared<bool>(true);
|
||||||
set_has_frame(false);
|
set_has_frame(false);
|
||||||
@@ -592,7 +590,7 @@ void TrayWidget::on_item_added(const TrayService::Item &item) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto icon = std::make_unique<TrayIconWidget>(item.id);
|
auto icon = std::make_unique<TrayIconWidget>(Icon::Type::CONTENT_COPY, item.id);
|
||||||
icon->update(item);
|
icon->update(item);
|
||||||
auto *raw = icon.get();
|
auto *raw = icon.get();
|
||||||
append(*raw);
|
append(*raw);
|
||||||
|
|||||||
@@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
#include <gtkmm/label.h>
|
#include <gtkmm/label.h>
|
||||||
#include <webkit/webkit.h>
|
#include <webkit/webkit.h>
|
||||||
|
#include "components/button/iconButton.hpp"
|
||||||
|
|
||||||
WebWidget::WebWidget(std::string icon, std::string name, std::string url) : Popover(icon, name) {
|
WebWidget::WebWidget(Icon::Type icon, std::string name, std::string url) : Popover(icon, name) {
|
||||||
auto webview = webkit_web_view_new();
|
auto webview = webkit_web_view_new();
|
||||||
gtk_widget_set_hexpand(webview, true);
|
gtk_widget_set_hexpand(webview, true);
|
||||||
gtk_widget_set_vexpand(webview, true);
|
gtk_widget_set_vexpand(webview, true);
|
||||||
|
|||||||
Reference in New Issue
Block a user