From 515349c6e2e76a58ea9cf78d17c9a63dc524cfdb Mon Sep 17 00:00:00 2001 From: Colin Duquesnoy Date: Sat, 15 Jul 2017 02:59:35 +0200 Subject: [PATCH] A few more improvements and minor bug fixes --- .../StreamingServicesControllerViewModel.cpp | 25 ++++++++----------- .../StreamingServicesControllerViewModel.hpp | 8 +++--- .../MellowPlayer/Controls/MainToolBar.qml | 4 +-- .../MellowPlayer/Controls/WebViewStack.qml | 2 ++ .../Views/MellowPlayer/Pages/MainPage.qml | 2 +- 5 files changed, 20 insertions(+), 21 deletions(-) diff --git a/lib/MellowPlayer/Presentation/ViewModels/StreamingServices/StreamingServicesControllerViewModel.cpp b/lib/MellowPlayer/Presentation/ViewModels/StreamingServices/StreamingServicesControllerViewModel.cpp index 4d4f38e7..a93a3c40 100644 --- a/lib/MellowPlayer/Presentation/ViewModels/StreamingServices/StreamingServicesControllerViewModel.cpp +++ b/lib/MellowPlayer/Presentation/ViewModels/StreamingServices/StreamingServicesControllerViewModel.cpp @@ -89,6 +89,7 @@ void StreamingServicesControllerViewModel::setCurrentIndex(int value) { } emit currentIndexChanged(currentIndex); emit currentServiceChanged(currentService); + onPlayerRunningChanged(); } void StreamingServicesControllerViewModel::reload() { @@ -153,22 +154,14 @@ int StreamingServicesControllerViewModel::getPreviousIndex(int index) const { return previousIndex; } -bool StreamingServicesControllerViewModel::getHasRunningServices() const { - return hasRunningServices; -} - void StreamingServicesControllerViewModel::onPlayerRunningChanged() { - bool hadRunningServices = hasRunningServices; - hasRunningServices = false; - for (int i = 0; i < allServices->count(); ++i) { - if (allServices->at(i)->isRunning()) { - hasRunningServices = true; - break; - } - } + bool wasCurrentServiceRunning = isCurrentServiceRunning_; + isCurrentServiceRunning_ = false; + if (currentService != nullptr) + isCurrentServiceRunning_ = currentService->isRunning(); - if (hadRunningServices != hasRunningServices) { - emit hasRunningServicesChanged(); + if (wasCurrentServiceRunning != isCurrentServiceRunning_) { + emit isCurrentServiceRunningChanged(); } } @@ -182,3 +175,7 @@ void StreamingServicesControllerViewModel::onServiceEnabledChanged() { emit currentIndexChanged(-1); } } + +bool StreamingServicesControllerViewModel::isCurrentServiceRunning() const { + return isCurrentServiceRunning_; +} diff --git a/lib/MellowPlayer/Presentation/ViewModels/StreamingServices/StreamingServicesControllerViewModel.hpp b/lib/MellowPlayer/Presentation/ViewModels/StreamingServices/StreamingServicesControllerViewModel.hpp index 6c4da0da..c9739512 100644 --- a/lib/MellowPlayer/Presentation/ViewModels/StreamingServices/StreamingServicesControllerViewModel.hpp +++ b/lib/MellowPlayer/Presentation/ViewModels/StreamingServices/StreamingServicesControllerViewModel.hpp @@ -28,7 +28,7 @@ namespace MellowPlayer::Presentation { Q_PROPERTY(QAbstractItemModel* enabledServices READ getEnabledServices CONSTANT) Q_PROPERTY(QObject* currentService READ getCurrentService WRITE setCurrentService NOTIFY currentServiceChanged) Q_PROPERTY(int currentIndex READ getCurrentIndex NOTIFY currentIndexChanged) - Q_PROPERTY(bool hasRunningServices READ getHasRunningServices NOTIFY hasRunningServicesChanged) + Q_PROPERTY(bool isCurrentServiceRunning READ isCurrentServiceRunning NOTIFY isCurrentServiceRunningChanged) public: StreamingServicesControllerViewModel(Application::StreamingServicesController& streamingServices, Application::Players& players, @@ -43,7 +43,7 @@ namespace MellowPlayer::Presentation { StreamingServiceProxyListModel* getEnabledServices() { return &enabledServices; } StreamingServiceViewModel* getCurrentService() const; int getCurrentIndex() const; - bool getHasRunningServices() const; + bool isCurrentServiceRunning() const; Q_INVOKABLE int getWebViewIndex(const QString& serviceName) const; @@ -58,7 +58,7 @@ namespace MellowPlayer::Presentation { signals: void currentServiceChanged(QObject* currentService); void currentIndexChanged(int currentIndex); - void hasRunningServicesChanged(); + void isCurrentServiceRunningChanged(); void serviceCreated(const QString& directory); private slots: @@ -81,7 +81,7 @@ namespace MellowPlayer::Presentation { StreamingServiceProxyListModel enabledServices; StreamingServiceViewModel* currentService = nullptr; int currentIndex = -1; - bool hasRunningServices = false; + bool isCurrentServiceRunning_ = false; }; } diff --git a/lib/MellowPlayer/Presentation/Views/MellowPlayer/Controls/MainToolBar.qml b/lib/MellowPlayer/Presentation/Views/MellowPlayer/Controls/MainToolBar.qml index ea4443e3..31c5c487 100644 --- a/lib/MellowPlayer/Presentation/Views/MellowPlayer/Controls/MainToolBar.qml +++ b/lib/MellowPlayer/Presentation/Views/MellowPlayer/Controls/MainToolBar.qml @@ -10,7 +10,7 @@ ToolBar { id: root property bool isWebViewMode: false - property bool hasRunningServices: false + property bool isCurrentServiceRunning_: false signal showOverviewRequested() signal showWebViewRequested() @@ -49,7 +49,7 @@ ToolBar { font.family: MaterialIcons.family font.pixelSize: d.iconSize + 2 hoverEnabled: true - visible: hasRunningServices || isWebViewMode + visible: isCurrentServiceRunning_ || isWebViewMode onClicked: switchView() diff --git a/lib/MellowPlayer/Presentation/Views/MellowPlayer/Controls/WebViewStack.qml b/lib/MellowPlayer/Presentation/Views/MellowPlayer/Controls/WebViewStack.qml index de2baac2..4e3a6b94 100644 --- a/lib/MellowPlayer/Presentation/Views/MellowPlayer/Controls/WebViewStack.qml +++ b/lib/MellowPlayer/Presentation/Views/MellowPlayer/Controls/WebViewStack.qml @@ -20,12 +20,14 @@ StackLayout { var webView = currentWebView(); webView.url = webView.urlToLoad webView.reload(); + weView.start(); } function goForward() { currentWebView().goForward(); } function reload() { currentWebView().reload(); + currentWebView().start(); } function toList() { var list = [] diff --git a/lib/MellowPlayer/Presentation/Views/MellowPlayer/Pages/MainPage.qml b/lib/MellowPlayer/Presentation/Views/MellowPlayer/Pages/MainPage.qml index 47bc2fd5..1d3cc34e 100644 --- a/lib/MellowPlayer/Presentation/Views/MellowPlayer/Pages/MainPage.qml +++ b/lib/MellowPlayer/Presentation/Views/MellowPlayer/Pages/MainPage.qml @@ -48,7 +48,7 @@ Page { id: toolBar isWebViewMode: body.state === "webview" - hasRunningServices: _streamingServices.hasRunningServices + isCurrentServiceRunning_: _streamingServices.isCurrentServiceRunning onShowOverviewRequested: webViewStack.updatePreviewImage(body.showOverview) onShowWebViewRequested: root.showWebView()