refacor media widget, apply clang format rule
This commit is contained in:
@@ -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);
|
||||
};
|
||||
@@ -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();
|
||||
};
|
||||
24
include/widgets/controlCenter/mediaWidget.hpp
Normal file
24
include/widgets/controlCenter/mediaWidget.hpp
Normal 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;
|
||||
};
|
||||
Reference in New Issue
Block a user