Skip to content
This repository has been archived by the owner on May 3, 2019. It is now read-only.

Commit

Permalink
A few more improvements and minor bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinDuquesnoy committed Jul 15, 2017
1 parent ca611f6 commit 515349c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ void StreamingServicesControllerViewModel::setCurrentIndex(int value) {
}
emit currentIndexChanged(currentIndex);
emit currentServiceChanged(currentService);
onPlayerRunningChanged();
}

void StreamingServicesControllerViewModel::reload() {
Expand Down Expand Up @@ -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();
}
}

Expand All @@ -182,3 +175,7 @@ void StreamingServicesControllerViewModel::onServiceEnabledChanged() {
emit currentIndexChanged(-1);
}
}

bool StreamingServicesControllerViewModel::isCurrentServiceRunning() const {
return isCurrentServiceRunning_;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;

Expand All @@ -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:
Expand All @@ -81,7 +81,7 @@ namespace MellowPlayer::Presentation {
StreamingServiceProxyListModel enabledServices;
StreamingServiceViewModel* currentService = nullptr;
int currentIndex = -1;
bool hasRunningServices = false;
bool isCurrentServiceRunning_ = false;
};

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ToolBar {
id: root

property bool isWebViewMode: false
property bool hasRunningServices: false
property bool isCurrentServiceRunning_: false

signal showOverviewRequested()
signal showWebViewRequested()
Expand Down Expand Up @@ -49,7 +49,7 @@ ToolBar {
font.family: MaterialIcons.family
font.pixelSize: d.iconSize + 2
hoverEnabled: true
visible: hasRunningServices || isWebViewMode
visible: isCurrentServiceRunning_ || isWebViewMode

onClicked: switchView()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 515349c

Please sign in to comment.