some refactore
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <gtkmm.h>
|
||||
#include <memory>
|
||||
|
||||
#include "components/button/iconButton.hpp"
|
||||
#include "widgets/clock.hpp"
|
||||
#include "widgets/date.hpp"
|
||||
#include "widgets/tray.hpp"
|
||||
@@ -27,8 +28,8 @@ class Bar : public Gtk::Window {
|
||||
|
||||
Clock clock;
|
||||
Date date;
|
||||
WebWidget homeAssistant{"\uf024", "Home Assistant", "https://home.rivercry.com"};
|
||||
ControlCenter controlCenter{"\ue062", "Control Center"};
|
||||
WebWidget homeAssistant{Icon::HOME_ASSISTANT, "Home Assistant", "https://home.rivercry.com"};
|
||||
ControlCenter controlCenter{Icon::CONTROL_CENTER, "Control Center"};
|
||||
|
||||
std::shared_ptr<TrayWidget> trayWidget = 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/popover.h>
|
||||
#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:
|
||||
Popover(const std::string icon, std::string name);
|
||||
Popover(Icon::Type icon, std::string name);
|
||||
~Popover() override;
|
||||
|
||||
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
|
||||
|
||||
#include "components/button/iconButton.hpp"
|
||||
#include "components/button/tabButton.hpp"
|
||||
#include "components/popover.hpp"
|
||||
#include "gtkmm/box.h"
|
||||
#include "gtkmm/button.h"
|
||||
#include "gtkmm/label.h"
|
||||
#include "gtkmm/scrolledwindow.h"
|
||||
#include "gtkmm/stack.h"
|
||||
#include "widgets/controlCenter/mediaControl.hpp"
|
||||
#include "widgets/weather.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
|
||||
class ControlCenter : public Popover {
|
||||
public:
|
||||
ControlCenter(std::string icon, std::string name);
|
||||
ControlCenter(Icon::Type icon, std::string name);
|
||||
|
||||
private:
|
||||
Gtk::ScrolledWindow scrollview;
|
||||
Gtk::Box container;
|
||||
Gtk::Box tabRow;
|
||||
Gtk::Stack contentStack;
|
||||
Gtk::Box controlCenterContainer;
|
||||
WeatherWidget weatherWidget;
|
||||
Gtk::Button mediaControl;
|
||||
Gtk::Button testTabButton;
|
||||
std::unique_ptr<TabButton> mediaControl;
|
||||
std::unique_ptr<TabButton> testTabButton;
|
||||
std::shared_ptr<MprisController> mprisController = MprisController::getInstance();
|
||||
std::unordered_map<std::string, MediaControlWidget*> mediaWidgets;
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "gtkmm/scale.h"
|
||||
#include "gtkmm/scrolledwindow.h"
|
||||
|
||||
#include "components/button/iconButton.hpp"
|
||||
#include "connection/dbus/mpris.hpp"
|
||||
|
||||
class MediaControlWidget : public Gtk::Box {
|
||||
@@ -48,9 +49,9 @@ class MediaControlWidget : public Gtk::Box {
|
||||
|
||||
// playback controls
|
||||
Gtk::Box bottomContainer;
|
||||
Gtk::Button previousButton;
|
||||
Gtk::Button playPauseButton;
|
||||
Gtk::Button nextButton;
|
||||
std::unique_ptr<IconButton> previousButton;
|
||||
std::unique_ptr<IconButton> playPauseButton;
|
||||
std::unique_ptr<IconButton> nextButton;
|
||||
|
||||
Gtk::ScrolledWindow imageWrapper;
|
||||
|
||||
|
||||
@@ -17,12 +17,12 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "components/button/iconButton.hpp"
|
||||
#include "connection/dbus/tray.hpp"
|
||||
#include "components/base/button.hpp"
|
||||
|
||||
class TrayIconWidget : public Button {
|
||||
class TrayIconWidget : public IconButton {
|
||||
public:
|
||||
TrayIconWidget(std::string id);
|
||||
TrayIconWidget(Icon::Type icon, std::string id);
|
||||
~TrayIconWidget() override;
|
||||
|
||||
void update(const TrayService::Item &item);
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
#include <gtkmm/button.h>
|
||||
#include <gtkmm/popover.h>
|
||||
|
||||
#include "components/button/iconButton.hpp"
|
||||
#include "components/popover.hpp"
|
||||
|
||||
class WebWidget : public Popover {
|
||||
public:
|
||||
WebWidget(std::string icon, std::string title, std::string url);
|
||||
WebWidget(Icon::Type icon, std::string title, std::string url);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user