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,7 +6,7 @@
#include "components/types/icon.hpp"
class IconButton : public TextButton {
public:
IconButton(Icon::Type icon, std::string fontFamilyCss = "materia-icons");
void setIcon(Icon::Type icon);
public:
IconButton(Icon::Type icon, std::string fontFamilyCss = "materia-icons");
void setIcon(Icon::Type icon);
};

View File

@@ -3,7 +3,7 @@
#include "components/button/iconButton.hpp"
class TabButton : public IconButton {
public:
TabButton(Icon::Type icon);
void setActive(bool active);
public:
TabButton(Icon::Type icon);
void setActive(bool active);
};

View File

@@ -1,7 +1,5 @@
#pragma once
#include <string>
#include "gtkmm/button.h"

View File

@@ -0,0 +1,61 @@
#pragma once
#include "components/button/iconButton.hpp"
#include "connection/dbus/mpris.hpp"
#include "gtkmm/box.h"
#include "gtkmm/label.h"
#include "gtkmm/overlay.h"
#include "gtkmm/picture.h"
#include "gtkmm/scale.h"
#include "gtkmm/scrolledwindow.h"
class MediaPlayer : public Gtk::Box {
public:
explicit MediaPlayer(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);
// 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

@@ -3,6 +3,7 @@
#include <gtkmm/button.h>
#include <gtkmm/popover.h>
#include <string>
#include "components/button/iconButton.hpp"
#include "components/button/textButton.hpp"

View File

@@ -0,0 +1 @@
#pragma once

View File

@@ -4,12 +4,10 @@
#include <string>
class Icon {
public:
public:
enum Type {
HOME_ASSISTANT,
CONTROL_CENTER,
MENU,
SKIP_PREVIOUS,
SKIP_NEXT,
@@ -22,6 +20,8 @@ class Icon {
SAVE,
CONTENT_COPY,
TOKEN,
};
static const std::string toString(Type type) {
@@ -31,7 +31,7 @@ class Icon {
private:
static inline std::map<Type, const std::string> typeToString = {
{HOME_ASSISTANT, "\uf024"},
{CONTROL_CENTER, "\ue062"},
{MENU, "\ue5d2"},
{SKIP_PREVIOUS, "\ue045"},
{SKIP_NEXT, "\ue044"},
@@ -44,5 +44,7 @@ class Icon {
{SAVE, "\ue161"},
{CONTENT_COPY, "\ue14d"},
{TOKEN, "\uea25"},
};
};

View File

@@ -8,7 +8,6 @@
class WorkspaceIndicator : public Gtk::Box {
public:
enum InidicatorState {
EMPTY,
ALIVE,