refacor media widget, apply clang format rule

This commit is contained in:
2026-02-07 14:14:50 +01:00
parent 64b3babd3d
commit d9ac353a0d
54 changed files with 642 additions and 878 deletions

View File

@@ -6,8 +6,6 @@
#include "components/base/button.hpp"
class BluetoothEntry : Gtk::Box {
public:
BluetoothEntry(std::string name, std::string address) {
@@ -38,7 +36,6 @@ class BluetoothEntry : Gtk::Box {
sigc::signal<void(std::string)> connect_clicked;
};
class BluetoothWidget : public Gtk::Box {
public:
BluetoothWidget();

View File

@@ -1,35 +1,36 @@
#pragma once
#include <memory>
#include "components/button/iconButton.hpp"
#include "components/button/tabButton.hpp"
#include "components/popover.hpp"
#include "widgets/controlCenter/mediaWidget.hpp"
#include "widgets/weather.hpp"
#include "gtkmm/box.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(Icon::Type icon, std::string name);
private:
Gtk::ScrolledWindow scrollview;
Gtk::Box container;
Gtk::Box tabRow;
Gtk::Stack contentStack;
Gtk::Box controlCenterContainer;
WeatherWidget weatherWidget;
std::unique_ptr<TabButton> mediaControl;
std::unique_ptr<TabButton> testTabButton;
std::shared_ptr<MprisController> mprisController = MprisController::getInstance();
std::unordered_map<std::string, MediaControlWidget*> mediaWidgets;
public:
ControlCenter(Icon::Type icon, std::string name);
void addPlayerWidget(const std::string &bus_name);
void removePlayerWidget(const std::string &bus_name);
void setActiveTab(const std::string &tab_name);
private:
Gtk::ScrolledWindow scrollview;
Gtk::Box container;
Gtk::Box tabRow;
Gtk::Stack contentStack;
std::unique_ptr<TabButton> mediaTabButton;
std::unique_ptr<TabButton> infoTabButton;
std::unique_ptr<TabButton> timerButton;
std::unique_ptr<WeatherWidget> weatherWidget;
std::unique_ptr<MediaWidget> mediaControlWidget;
void addPlayerWidget(const std::string &bus_name);
void removePlayerWidget(const std::string &bus_name);
void setActiveTab(const std::string &tab_name);
};

View File

@@ -1,64 +0,0 @@
#pragma once
#include "gtkmm/box.h"
#include "gtkmm/button.h"
#include "gtkmm/label.h"
#include "gtkmm/overlay.h"
#include "gtkmm/picture.h"
#include "gtkmm/scale.h"
#include "gtkmm/scrolledwindow.h"
#include "components/button/iconButton.hpp"
#include "connection/dbus/mpris.hpp"
class MediaControlWidget : public Gtk::Box {
public:
explicit MediaControlWidget(std::shared_ptr<MprisController> controller);
private:
std::shared_ptr<MprisController> mprisController;
int64_t currentPositionUs = 0;
int64_t totalLengthUs = 0;
sigc::connection seekTimerConnection;
bool suppressSeekSignal = false;
std::string currentTrackId;
MprisController::PlaybackStatus playbackStatus = MprisController::PlaybackStatus::Stopped;
bool canSeek = true;
void setCurrentPosition(int64_t position_us);
void setTotalLength(int64_t length_us);
void resetSeekTimer(int64_t start_position_us);
bool onSeekTick();
void schedulePauseAfterSeek();
void setCanSeek(bool can_seek);
Gtk::Box spotifyContainer;
// image as background, artist, title
Gtk::Overlay topContainer;
Gtk::Picture backgroundImage;
Gtk::Box infoContainer;
Gtk::Label artistLabel;
Gtk::Label titleLabel;
//
Gtk::Box seekBarContainer;
Gtk::Label currentTimeLabel;
Gtk::Scale seekBar;
Gtk::Label totalTimeLabel;
// playback controls
Gtk::Box bottomContainer;
std::unique_ptr<IconButton> previousButton;
std::unique_ptr<IconButton> playPauseButton;
std::unique_ptr<IconButton> nextButton;
Gtk::ScrolledWindow imageWrapper;
void onSpotifyMprisUpdated(const MprisPlayer2Message &message);
void onRunningStateChanged(MprisController::PlaybackStatus status);
void onPlay();
void onPause();
void onStop();
};

View File

@@ -0,0 +1,24 @@
#pragma once
#include "components/mediaPlayer.hpp"
#include <map>
#include <memory>
#include <string>
#include "connection/dbus/mpris.hpp"
#include "gtkmm/box.h"
class MediaWidget : public Gtk::Box {
public:
MediaWidget();
private:
Gtk::Box container;
std::shared_ptr<MprisController> mprisController = MprisController::getInstance();
void addPlayerWidget(const std::string &bus_name);
void removePlayerWidget(const std::string &bus_name);
std::map<std::string, std::unique_ptr<MediaPlayer>> mediaWidgets;
};

View File

@@ -1,12 +1,10 @@
#pragma once
#include <chrono>
#include <csignal>
#include <cstdint>
#include <sigc++/connection.h>
#include "gdkmm/monitor.h"
#include "gtkmm/scrolledwindow.h"
#include "gtkmm/window.h"
#define DEFAULT_NOTIFICATION_TIMEOUT 6700
@@ -19,11 +17,9 @@ class BaseNotification : public Gtk::Window {
void resumeAutoClose();
void startAutoClose(int timeoutMs);
sigc::signal<void(int)> signal_close;
sigc::signal<void(uint64_t)> signal_close;
sigc::signal<void(bool)> signal_hover_changed;
virtual ~BaseNotification() = default;
uint64_t getNotificationId() const {
return this->notificationId;
}

View File

@@ -4,6 +4,7 @@
#include "connection/dbus/messages.hpp"
#include "widgets/notification/baseNotification.hpp"
#include "gtkmm/box.h"
class CopyNotification : public BaseNotification {

View File

@@ -2,6 +2,7 @@
#pragma once
#include <cstdint>
#include "connection/dbus/messages.hpp"
#include "widgets/notification/baseNotification.hpp"
@@ -9,5 +10,4 @@ class NotificationWindow : public BaseNotification {
public:
NotificationWindow(uint64_t notificationId, std::shared_ptr<Gdk::Monitor> monitor, NotifyMessage message);
virtual ~NotificationWindow() = default;
};

View File

@@ -39,12 +39,12 @@ class TrayIconWidget : public IconButton {
Glib::RefPtr<Gtk::PopoverMenu> menuPopover;
Glib::RefPtr<Gio::SimpleActionGroup> menuActions;
Glib::RefPtr<Gio::MenuModel> menuModel;
bool menuPopupPending = false;
bool menuPopupPending = false;
bool menuRequestInFlight = false;
bool hasRemoteMenu = false;
bool hasRemoteMenu = false;
std::shared_ptr<bool> aliveFlag;
double pendingX = 0.0;
double pendingY = 0.0;
double pendingX = 0.0;
double pendingY = 0.0;
void on_primary_released(int n_press, double x, double y);
void on_middle_released(int n_press, double x, double y);