Re-work TaskbarComponent. (#61)

This commit is contained in:
Ian Walton 2021-04-23 17:07:53 -04:00
parent b72c8084ab
commit ab9c091804
5 changed files with 31 additions and 17 deletions

View File

@ -95,7 +95,6 @@ class mpvAudioPlayer {
};
self.events.trigger(self, 'stopped', [stopInfo]);
window.api.taskbar.setControlsVisible(false);
self._currentTime = null;
self._currentSrc = null;
@ -157,7 +156,6 @@ class mpvAudioPlayer {
function onPlaying() {
if (!self._started) {
self._started = true;
window.api.taskbar.setControlsVisible(true);
}
self.setPlaybackRate(1);
@ -166,7 +164,6 @@ class mpvAudioPlayer {
if (self._paused) {
self._paused = false;
self.events.trigger(self, 'unpause');
window.api.taskbar.setPaused(false);
}
self.events.trigger(self, 'playing');
@ -175,7 +172,6 @@ class mpvAudioPlayer {
function onPause() {
self._paused = true;
self.events.trigger(self, 'pause');
window.api.taskbar.setPaused(true);
}
function onError(error) {

View File

@ -164,13 +164,11 @@
// Need to override default style.
this._videoDialog.style.setProperty('background', 'transparent', 'important');
window.api.taskbar.setControlsVisible(true);
}
if (this._paused) {
this._paused = false;
this.events.trigger(this, 'unpause');
window.api.taskbar.setPaused(false);
}
this.events.trigger(this, 'playing');
@ -183,7 +181,6 @@
this._paused = true;
// For Syncplay ready notification
this.events.trigger(this, 'pause');
window.api.taskbar.setPaused(true);
};
this.onWaiting = () => {
@ -362,7 +359,6 @@
};
this.events.trigger(this, 'stopped', [stopInfo]);
window.api.taskbar.setControlsVisible(false);
this._currentTime = null;
this._currentSrc = null;

View File

@ -20,10 +20,6 @@ public:
virtual void setWindow(QQuickWindow* window);
public Q_SLOTS:
virtual void setControlsVisible(bool value) {}
virtual void setPaused(bool value) {}
protected:
QQuickWindow* m_window;
};

View File

@ -3,6 +3,8 @@
#include "TaskbarComponentWin.h"
#include "PlayerComponent.h"
#include "input/InputComponent.h"
/////////////////////////////////////////////////////////////////////////////////////////
void TaskbarComponentWin::setWindow(QQuickWindow* window)
@ -32,6 +34,9 @@ void TaskbarComponentWin::setWindow(QQuickWindow* window)
m_toolbar->addButton(m_next);
connect(&PlayerComponent::Get(), &PlayerComponent::positionUpdate, this, &TaskbarComponentWin::setProgress);
connect(&PlayerComponent::Get(), &PlayerComponent::playing, this, &TaskbarComponentWin::playing);
connect(&PlayerComponent::Get(), &PlayerComponent::paused, this, &TaskbarComponentWin::paused);
connect(&PlayerComponent::Get(), &PlayerComponent::stopped, this, &TaskbarComponentWin::stopped);
setControlsVisible(false);
setPaused(false);
@ -55,6 +60,25 @@ void TaskbarComponentWin::onPrevClicked()
InputComponent::Get().sendAction("previous");
}
/////////////////////////////////////////////////////////////////////////////////////////
void TaskbarComponentWin::playing()
{
setControlsVisible(true);
setPaused(false);
}
/////////////////////////////////////////////////////////////////////////////////////////
void TaskbarComponentWin::paused()
{
setPaused(true);
}
/////////////////////////////////////////////////////////////////////////////////////////
void TaskbarComponentWin::stopped()
{
setControlsVisible(false);
}
/////////////////////////////////////////////////////////////////////////////////////////
void TaskbarComponentWin::setControlsVisible(bool value)
{
@ -72,7 +96,7 @@ void TaskbarComponentWin::setProgress(quint64 value)
qint64 duration = PlayerComponent::Get().getDuration();
int progress = 0;
if (duration != 0) {
progress = (int) (value * 100 / duration)
progress = (int) (value / duration / 10);
}
m_button->progress()->setValue(progress);
}

View File

@ -13,16 +13,18 @@ class TaskbarComponentWin : public TaskbarComponent
{
public:
TaskbarComponentWin(): TaskbarComponent(nullptr) {}
virtual void setControlsVisible(bool value) override;
virtual void setPaused(bool value) override;
virtual void setWindow(QQuickWindow* window) override;
private:
void onPauseClicked();
void onPrevClicked();
void onNextClicked();
virtual void setProgress(quint64 value) override;
void setProgress(quint64 value);
void setControlsVisible(bool value);
void setPaused(bool value);
void playing();
void stopped();
void paused();
QWinTaskbarButton* m_button;
QWinThumbnailToolBar* m_toolbar;