This repository has been archived by the owner on May 3, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
29 changed files
with
658 additions
and
331 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
lib/MellowPlayer/Presentation/ViewModels/UpdaterViewModel.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#include "UpdaterViewModel.hpp" | ||
|
||
using namespace MellowPlayer::Application; | ||
using namespace MellowPlayer::Presentation; | ||
|
||
|
||
UpdaterViewModel::UpdaterViewModel(Updater& updater): updater_(updater) { | ||
connect(&updater, &Updater::updateAvailable, this, &UpdaterViewModel::onUpdateAvailable); | ||
} | ||
|
||
bool UpdaterViewModel::isVisible() const { | ||
return visible_; | ||
} | ||
|
||
bool UpdaterViewModel::canInstall() const { | ||
return canInstall_; | ||
} | ||
|
||
int UpdaterViewModel::getProgress() const { | ||
return progress_; | ||
} | ||
|
||
void UpdaterViewModel::close() { | ||
setVisible(false); | ||
} | ||
|
||
void UpdaterViewModel::check() { | ||
updater_.check(); | ||
} | ||
|
||
void UpdaterViewModel::install() { | ||
updater_.install(); | ||
} | ||
|
||
void UpdaterViewModel::setVisible(bool visible) { | ||
if (visible_ == visible) | ||
return; | ||
|
||
visible_ = visible; | ||
emit visibleChanged(); | ||
} | ||
|
||
void UpdaterViewModel::setCanInstall(bool canInstall) { | ||
if (canInstall_ == canInstall) | ||
return; | ||
|
||
canInstall_ = canInstall; | ||
emit canInstallChanged(); | ||
} | ||
|
||
void UpdaterViewModel::setProgress(int progress) { | ||
if (progress_ == progress) | ||
return; | ||
|
||
progress_ = progress; | ||
emit progressChanged(); | ||
} | ||
|
||
void UpdaterViewModel::onUpdateAvailable() { | ||
setCanInstall(updater_.canInstall()); | ||
setProgress(-1); | ||
setVisible(true); | ||
} |
41 changes: 41 additions & 0 deletions
41
lib/MellowPlayer/Presentation/ViewModels/UpdaterViewModel.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#pragma once | ||
|
||
#include <QtCore/QObject> | ||
#include <MellowPlayer/Application/Updater/Updater.hpp> | ||
|
||
namespace MellowPlayer::Presentation { | ||
|
||
class UpdaterViewModel: public QObject { | ||
Q_OBJECT | ||
Q_PROPERTY(bool visible READ isVisible NOTIFY visibleChanged) | ||
Q_PROPERTY(bool canInstall READ canInstall NOTIFY canInstallChanged) | ||
Q_PROPERTY(int progress READ getProgress NOTIFY progressChanged) | ||
public: | ||
UpdaterViewModel(Application::Updater& updater); | ||
|
||
bool isVisible() const; | ||
bool canInstall() const; | ||
int getProgress() const; | ||
|
||
Q_INVOKABLE void close(); | ||
Q_INVOKABLE void check(); | ||
void install(); | ||
|
||
signals: | ||
void visibleChanged(); | ||
void canInstallChanged(); | ||
void progressChanged(); | ||
|
||
private slots: | ||
void setVisible(bool visible); | ||
void setCanInstall(bool canInstall); | ||
void setProgress(int progress); | ||
void onUpdateAvailable(); | ||
|
||
private: | ||
Application::Updater& updater_; | ||
bool visible_ = false; | ||
bool canInstall_ = false; | ||
int progress_ = -1; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.