diff --git a/.clang-format b/.clang-format index c18ad02e..e9aa9e4f 100644 --- a/.clang-format +++ b/.clang-format @@ -12,7 +12,7 @@ BasedOnStyle: WebKit Standard: Cpp11 -ColumnLimit: 120 +ColumnLimit: 150 # Disable reflow of qdoc comments: indentation rules are different. # Translation comments are also excluded diff --git a/lib/MellowPlayer/Application/IFileDownloader.hpp b/lib/MellowPlayer/Application/IFileDownloader.hpp index a7925a26..87317ff8 100644 --- a/lib/MellowPlayer/Application/IFileDownloader.hpp +++ b/lib/MellowPlayer/Application/IFileDownloader.hpp @@ -16,7 +16,7 @@ namespace MellowPlayer::Application virtual bool isDownloading() const = 0; signals: - void progressChanged(); + void progressChanged(double progress); void finished(bool success); }; } diff --git a/lib/MellowPlayer/Application/ListeningHistory/ListeningHistory.cpp b/lib/MellowPlayer/Application/ListeningHistory/ListeningHistory.cpp index 97f399d8..0f140b63 100644 --- a/lib/MellowPlayer/Application/ListeningHistory/ListeningHistory.cpp +++ b/lib/MellowPlayer/Application/ListeningHistory/ListeningHistory.cpp @@ -12,8 +12,7 @@ using namespace MellowPlayer::Application; -ListeningHistory::ListeningHistory(IListeningHistoryDataProvider &model, IPlayer &player, - IWorkDispatcher &workDispatcher, Settings &settings) +ListeningHistory::ListeningHistory(IListeningHistoryDataProvider &model, IPlayer &player, IWorkDispatcher &workDispatcher, Settings &settings) : logger(LoggingManager::instance().getLogger("ListeningHistory")), dataProvider(model), player(player), diff --git a/lib/MellowPlayer/Application/ListeningHistory/ListeningHistory.hpp b/lib/MellowPlayer/Application/ListeningHistory/ListeningHistory.hpp index c9078110..c4945f23 100644 --- a/lib/MellowPlayer/Application/ListeningHistory/ListeningHistory.hpp +++ b/lib/MellowPlayer/Application/ListeningHistory/ListeningHistory.hpp @@ -19,8 +19,7 @@ namespace MellowPlayer::Application { Q_OBJECT public: - ListeningHistory(IListeningHistoryDataProvider &model, IPlayer &player, IWorkDispatcher &workDispatcher, - Settings &settings); + ListeningHistory(IListeningHistoryDataProvider &model, IPlayer &player, IWorkDispatcher &workDispatcher, Settings &settings); void initialize(); const QList &getEntries() const; diff --git a/lib/MellowPlayer/Application/ListeningHistory/ListeningHistoryEntry.hpp b/lib/MellowPlayer/Application/ListeningHistory/ListeningHistoryEntry.hpp index 0e25e259..38316866 100644 --- a/lib/MellowPlayer/Application/ListeningHistory/ListeningHistoryEntry.hpp +++ b/lib/MellowPlayer/Application/ListeningHistory/ListeningHistoryEntry.hpp @@ -28,8 +28,8 @@ namespace MellowPlayer::Application bool equals(const ListeningHistoryEntry &other) const { - return other.serviceName == serviceName && other.songUniqueId == songUniqueId - && other.songTitle == songTitle && other.artist == artist && other.album == album && other.artUrl == artUrl; + return other.serviceName == serviceName && other.songUniqueId == songUniqueId && other.songTitle == songTitle && other.artist == artist + && other.album == album && other.artUrl == artUrl; } bool operator==(const ListeningHistoryEntry &other) const diff --git a/lib/MellowPlayer/Application/Logging/LoggingMacros.hpp b/lib/MellowPlayer/Application/Logging/LoggingMacros.hpp index 60ee934a..18327c3c 100644 --- a/lib/MellowPlayer/Application/Logging/LoggingMacros.hpp +++ b/lib/MellowPlayer/Application/Logging/LoggingMacros.hpp @@ -10,11 +10,11 @@ inline std::ostream &operator<<(std::ostream &os, const QString &string) return os; } -#define LOG(logger, logEvent, logLevel) \ - { \ - std::stringstream ss; \ - ss << logEvent; \ - logger.log(ss.str(), logLevel, __FILE__, __LINE__); \ +#define LOG(logger, logEvent, logLevel) \ + { \ + std::stringstream ss; \ + ss << logEvent; \ + logger.log(ss.str(), logLevel, __FILE__, __LINE__); \ } #define LOG_TRACE(logger, logEvent) LOG(logger, logEvent, LogLevel::Trace) diff --git a/lib/MellowPlayer/Application/Logging/LoggingManager.hpp b/lib/MellowPlayer/Application/Logging/LoggingManager.hpp index 1708bb4e..57595b8e 100644 --- a/lib/MellowPlayer/Application/Logging/LoggingManager.hpp +++ b/lib/MellowPlayer/Application/Logging/LoggingManager.hpp @@ -15,8 +15,7 @@ namespace MellowPlayer::Application LoggingManager &operator=(const LoggingManager &) = delete; LoggingManager &operator=(LoggingManager &&) = default; - static LoggingManager &initialize(ILoggerFactory &loggerFactory, - const LoggerConfig &defaultConfig = LoggerConfig()); + static LoggingManager &initialize(ILoggerFactory &loggerFactory, const LoggerConfig &defaultConfig = LoggerConfig()); static LoggingManager &initialize(ILoggerFactory &loggerFactory, LogLevel logLevel); static LoggingManager &instance(); diff --git a/lib/MellowPlayer/Application/Player/CurrentPlayer.cpp b/lib/MellowPlayer/Application/Player/CurrentPlayer.cpp index cc5b5e20..8da7595f 100644 --- a/lib/MellowPlayer/Application/Player/CurrentPlayer.cpp +++ b/lib/MellowPlayer/Application/Player/CurrentPlayer.cpp @@ -12,8 +12,7 @@ CurrentPlayer::CurrentPlayer(Players &players, StreamingServicesController &stre : players(players), streamingServices(streamingServices), currentPlayer(nullptr) { - connect(&streamingServices, &StreamingServicesController::currentChanged, this, - &CurrentPlayer::onCurrentServiceChanged); + connect(&streamingServices, &StreamingServicesController::currentChanged, this, &CurrentPlayer::onCurrentServiceChanged); if (streamingServices.getCurrent() != nullptr) onCurrentServiceChanged(streamingServices.getCurrent()); @@ -144,13 +143,11 @@ void CurrentPlayer::onCurrentServiceChanged(StreamingService *streamingService) if (currentPlayer != nullptr) { disconnect(currentPlayer.get(), &Player::currentSongChanged, this, &CurrentPlayer::currentSongChanged); disconnect(currentPlayer.get(), &Player::positionChanged, this, &CurrentPlayer::positionChanged); - disconnect(currentPlayer.get(), &Player::playbackStatusChanged, this, - &CurrentPlayer::playbackStatusChanged); + disconnect(currentPlayer.get(), &Player::playbackStatusChanged, this, &CurrentPlayer::playbackStatusChanged); disconnect(currentPlayer.get(), &Player::canSeekChanged, this, &CurrentPlayer::canSeekChanged); disconnect(currentPlayer.get(), &Player::canGoNextChanged, this, &CurrentPlayer::canGoNextChanged); disconnect(currentPlayer.get(), &Player::canGoPreviousChanged, this, &CurrentPlayer::canGoPreviousChanged); - disconnect(currentPlayer.get(), &Player::canAddToFavoritesChanged, this, - &CurrentPlayer::canAddToFavoritesChanged); + disconnect(currentPlayer.get(), &Player::canAddToFavoritesChanged, this, &CurrentPlayer::canAddToFavoritesChanged); disconnect(currentPlayer.get(), &Player::volumeChanged, this, &CurrentPlayer::volumeChanged); disconnect(currentPlayer.get(), &Player::isPlayingChanged, this, &CurrentPlayer::isPlayingChanged); disconnect(currentPlayer.get(), &Player::isStoppedChanged, this, &CurrentPlayer::isStoppedChanged); diff --git a/lib/MellowPlayer/Application/Player/Song.cpp b/lib/MellowPlayer/Application/Player/Song.cpp index 1f237a25..9b23a249 100644 --- a/lib/MellowPlayer/Application/Player/Song.cpp +++ b/lib/MellowPlayer/Application/Player/Song.cpp @@ -6,15 +6,9 @@ Song::Song() : uniqueId(""), title(""), artist(""), album(""), artUrl(""), durat { } -Song::Song(const QString &uniqueId, const QString &title, const QString &artist, const QString &album, - const QString &artUrl, double duration, bool isFavorite) - : uniqueId(uniqueId), - title(title), - artist(artist), - album(album), - artUrl(artUrl), - duration(duration), - isFavorite(isFavorite) +Song::Song(const QString &uniqueId, const QString &title, const QString &artist, const QString &album, const QString &artUrl, double duration, + bool isFavorite) + : uniqueId(uniqueId), title(title), artist(artist), album(album), artUrl(artUrl), duration(duration), isFavorite(isFavorite) { } diff --git a/lib/MellowPlayer/Application/Player/Song.hpp b/lib/MellowPlayer/Application/Player/Song.hpp index 173f2170..4f3364a3 100644 --- a/lib/MellowPlayer/Application/Player/Song.hpp +++ b/lib/MellowPlayer/Application/Player/Song.hpp @@ -17,8 +17,8 @@ namespace MellowPlayer::Application public: Song(); - Song(const QString &uniqueId, const QString &title, const QString &artist, const QString &album, - const QString &artUrl, double duration, bool isFavorite); + Song(const QString &uniqueId, const QString &title, const QString &artist, const QString &album, const QString &artUrl, double duration, + bool isFavorite); QString getUniqueId() const; QString getTitle() const; diff --git a/lib/MellowPlayer/Application/Settings/Setting.cpp b/lib/MellowPlayer/Application/Settings/Setting.cpp index ff46dc0e..2f168248 100644 --- a/lib/MellowPlayer/Application/Settings/Setting.cpp +++ b/lib/MellowPlayer/Application/Settings/Setting.cpp @@ -9,11 +9,7 @@ using namespace std; using namespace MellowPlayer::Application; Setting::Setting(Settings &settings, SettingsCategory &category, const Setting::Data &settingData) - : QObject(&category), - settingsProvider(settings.getSettingsProvider()), - settings(settings), - category(category), - data(settingData) + : QObject(&category), settingsProvider(settings.getSettingsProvider()), settings(settings), category(category), data(settingData) { } diff --git a/lib/MellowPlayer/Application/Settings/Settings.cpp b/lib/MellowPlayer/Application/Settings/Settings.cpp index 84cca887..b74b8f97 100644 --- a/lib/MellowPlayer/Application/Settings/Settings.cpp +++ b/lib/MellowPlayer/Application/Settings/Settings.cpp @@ -8,8 +8,7 @@ using namespace std; using namespace MellowPlayer::Application; -Settings::Settings(ISettingsSchemaLoader &configurationLoader, ISettingsProvider &settingsProvider) - : settingsProvider(settingsProvider) +Settings::Settings(ISettingsSchemaLoader &configurationLoader, ISettingsProvider &settingsProvider) : settingsProvider(settingsProvider) { QJsonDocument jsonDocument = configurationLoader.load(); QJsonObject rootObject = jsonDocument.object(); diff --git a/lib/MellowPlayer/Application/Settings/SettingsCategory.cpp b/lib/MellowPlayer/Application/Settings/SettingsCategory.cpp index 0bee5081..5a6be8b8 100644 --- a/lib/MellowPlayer/Application/Settings/SettingsCategory.cpp +++ b/lib/MellowPlayer/Application/Settings/SettingsCategory.cpp @@ -6,8 +6,7 @@ using namespace std; using namespace MellowPlayer::Application; -SettingsCategory::SettingsCategory(const SettingsCategory::Data &categoryData, Settings *appSettings) - : QObject(appSettings), data(categoryData) +SettingsCategory::SettingsCategory(const SettingsCategory::Data &categoryData, Settings *appSettings) : QObject(appSettings), data(categoryData) { for (int i = 0; i < data.parameters.count(); ++i) { QJsonObject parameterObj = data.parameters.at(i).toObject(); diff --git a/lib/MellowPlayer/Application/StreamingServices/StreamingService.cpp b/lib/MellowPlayer/Application/StreamingServices/StreamingService.cpp index 3320642a..bb435af3 100644 --- a/lib/MellowPlayer/Application/StreamingServices/StreamingService.cpp +++ b/lib/MellowPlayer/Application/StreamingServices/StreamingService.cpp @@ -8,9 +8,7 @@ using namespace MellowPlayer::Application; using namespace std; StreamingService::StreamingService(const StreamingServiceMetadata &metadata, const Theme &theme) - : metadata(metadata), - theme(theme), - script(make_unique(metadata.script, metadata.scriptPath)) + : metadata(metadata), theme(theme), script(make_unique(metadata.script, metadata.scriptPath)) { } diff --git a/lib/MellowPlayer/Application/StreamingServices/StreamingServiceMetadata.hpp b/lib/MellowPlayer/Application/StreamingServices/StreamingServiceMetadata.hpp index cdc5b99c..a1aec4a2 100644 --- a/lib/MellowPlayer/Application/StreamingServices/StreamingServiceMetadata.hpp +++ b/lib/MellowPlayer/Application/StreamingServices/StreamingServiceMetadata.hpp @@ -48,15 +48,7 @@ namespace MellowPlayer::Application */ QString version; - StreamingServiceMetadata() - : author(""), - authorWebsite(""), - logoPath(""), - name(""), - url(""), - script(""), - scriptPath(""), - version("") + StreamingServiceMetadata() : author(""), authorWebsite(""), logoPath(""), name(""), url(""), script(""), scriptPath(""), version("") { } diff --git a/lib/MellowPlayer/Application/StreamingServices/StreamingServiceScript.cpp b/lib/MellowPlayer/Application/StreamingServices/StreamingServiceScript.cpp index 7f37109c..032c91c3 100644 --- a/lib/MellowPlayer/Application/StreamingServices/StreamingServiceScript.cpp +++ b/lib/MellowPlayer/Application/StreamingServices/StreamingServiceScript.cpp @@ -2,8 +2,7 @@ using namespace MellowPlayer::Application; -StreamingServiceScript::StreamingServiceScript(const QString &code, const QString &path) - : QObject(), code(code), path(path) +StreamingServiceScript::StreamingServiceScript(const QString &code, const QString &path) : QObject(), code(code), path(path) { } diff --git a/lib/MellowPlayer/Application/StreamingServices/StreamingServicesController.cpp b/lib/MellowPlayer/Application/StreamingServices/StreamingServicesController.cpp index 8145fe2b..e1e986b3 100644 --- a/lib/MellowPlayer/Application/StreamingServices/StreamingServicesController.cpp +++ b/lib/MellowPlayer/Application/StreamingServices/StreamingServicesController.cpp @@ -8,12 +8,8 @@ using namespace MellowPlayer::Application; using namespace MellowPlayer::Application; using namespace std; -StreamingServicesController::StreamingServicesController(IStreamingServiceLoader &loader, - IStreamingServiceWatcher &watcher) - : logger(LoggingManager::instance().getLogger("StreamingServicesController")), - loader(loader), - watcher(watcher), - current(nullptr) +StreamingServicesController::StreamingServicesController(IStreamingServiceLoader &loader, IStreamingServiceWatcher &watcher) + : logger(LoggingManager::instance().getLogger("StreamingServicesController")), loader(loader), watcher(watcher), current(nullptr) { } @@ -32,8 +28,7 @@ void StreamingServicesController::load() if (!found) { LOG_DEBUG(logger, "service added: " + newService->getName()); services.append(newService); - if (!newService->getPluginDirectory().startsWith("/usr/") - && !newService->getPluginDirectory().startsWith("/tmp/")) + if (!newService->getPluginDirectory().startsWith("/usr/") && !newService->getPluginDirectory().startsWith("/tmp/")) watcher.watch(*newService); emit added(newService.get()); } diff --git a/lib/MellowPlayer/Application/Theme/Theme.hpp b/lib/MellowPlayer/Application/Theme/Theme.hpp index f5027e18..6d6285fd 100644 --- a/lib/MellowPlayer/Application/Theme/Theme.hpp +++ b/lib/MellowPlayer/Application/Theme/Theme.hpp @@ -16,8 +16,8 @@ namespace MellowPlayer::Application bool isEmpty() const { - return accent.isEmpty() || background.isEmpty() || foreground.isEmpty() || primary.isEmpty() - || primaryForeground.isEmpty() || secondary.isEmpty() || secondaryForeground.isEmpty(); + return accent.isEmpty() || background.isEmpty() || foreground.isEmpty() || primary.isEmpty() || primaryForeground.isEmpty() + || secondary.isEmpty() || secondaryForeground.isEmpty(); } }; } diff --git a/lib/MellowPlayer/Application/Updater/AbstractPlatformUpdater.cpp b/lib/MellowPlayer/Application/Updater/AbstractPlatformUpdater.cpp index 68db6cdf..05f6c28d 100644 --- a/lib/MellowPlayer/Application/Updater/AbstractPlatformUpdater.cpp +++ b/lib/MellowPlayer/Application/Updater/AbstractPlatformUpdater.cpp @@ -7,6 +7,7 @@ using namespace MellowPlayer::Application; AbstractPlatformUpdater::AbstractPlatformUpdater(IFileDownloader &fileDownloader) : fileDownloader_(fileDownloader) { + connect(&fileDownloader, &IFileDownloader::progressChanged, this, &AbstractPlatformUpdater::progressUpdated); connect(&fileDownloader, &IFileDownloader::finished, this, &AbstractPlatformUpdater::downloadFinished); } @@ -19,7 +20,7 @@ void AbstractPlatformUpdater::download() { if (release_) { assetFilePath_ = makeDestinationPath(); - fileDownloader_.download(release_->getUrl(), assetFilePath_); + fileDownloader_.download(getAssetUrl(), assetFilePath_); } } @@ -32,5 +33,6 @@ QString AbstractPlatformUpdater::makeDestinationPath() void AbstractPlatformUpdater::install() { + emit progressUpdated(-1); doInstall(assetFilePath_); } diff --git a/lib/MellowPlayer/Application/Updater/AbstractPlatformUpdater.hpp b/lib/MellowPlayer/Application/Updater/AbstractPlatformUpdater.hpp index ecf901e6..225d4918 100644 --- a/lib/MellowPlayer/Application/Updater/AbstractPlatformUpdater.hpp +++ b/lib/MellowPlayer/Application/Updater/AbstractPlatformUpdater.hpp @@ -14,15 +14,17 @@ namespace MellowPlayer::Application public: AbstractPlatformUpdater(IFileDownloader &fileDownloader); - void setRelease(const Release *release); + virtual void setRelease(const Release *release); void download(); void install(); + virtual void restart(){}; virtual bool canInstall() const = 0; signals: void downloadFinished(bool success); void installFinished(bool success); + void progressUpdated(double progress); protected: virtual void doInstall(const QString &assetFilePath) = 0; diff --git a/lib/MellowPlayer/Application/Updater/Asset.cpp b/lib/MellowPlayer/Application/Updater/Asset.cpp index 6a5a8f63..324f2adf 100644 --- a/lib/MellowPlayer/Application/Updater/Asset.cpp +++ b/lib/MellowPlayer/Application/Updater/Asset.cpp @@ -3,6 +3,10 @@ using namespace MellowPlayer::Application; +Asset::Asset() : Asset("", "") +{ +} + Asset::Asset(const QString &name, const QString &url) : name_(name), url_(url) { } @@ -12,7 +16,7 @@ QString Asset::getName() const return name_; } -QString Asset::getUrl() +QString Asset::getUrl() const { return url_; } diff --git a/lib/MellowPlayer/Application/Updater/Asset.hpp b/lib/MellowPlayer/Application/Updater/Asset.hpp index 033a8d3d..be8850a0 100644 --- a/lib/MellowPlayer/Application/Updater/Asset.hpp +++ b/lib/MellowPlayer/Application/Updater/Asset.hpp @@ -7,10 +7,11 @@ namespace MellowPlayer::Application class Asset { public: + Asset(); Asset(const QString &name, const QString &url); QString getName() const; - QString getUrl(); + QString getUrl() const; bool isAppImage() const; bool isWindowsInstaller() const; diff --git a/lib/MellowPlayer/Application/Updater/Release.cpp b/lib/MellowPlayer/Application/Updater/Release.cpp index e9055669..da4a3059 100644 --- a/lib/MellowPlayer/Application/Updater/Release.cpp +++ b/lib/MellowPlayer/Application/Updater/Release.cpp @@ -10,8 +10,7 @@ Release::Release(const QString &name, const QDate &date, QObject *parent) { } -Release::Release(const QString &url, const QString &name, const QDate &date, const AssetList &assets, bool preRelease, - QObject *parent) +Release::Release(const QString &url, const QString &name, const QDate &date, const AssetList &assets, bool preRelease, QObject *parent) : QObject(parent), url_(url), name_(name), date_(date), preRelease_(preRelease), assets_(assets) { } diff --git a/lib/MellowPlayer/Application/Updater/Release.hpp b/lib/MellowPlayer/Application/Updater/Release.hpp index aa91340a..f903a917 100644 --- a/lib/MellowPlayer/Application/Updater/Release.hpp +++ b/lib/MellowPlayer/Application/Updater/Release.hpp @@ -16,8 +16,8 @@ namespace MellowPlayer::Application Q_PROPERTY(QString date READ getDate CONSTANT) public: Release(const QString &name, const QDate &date, QObject *parent = nullptr); - Release(const QString &url, const QString &name, const QDate &date, const AssetList &assets, - bool preRelease = false, QObject *parent = nullptr); + Release(const QString &url, const QString &name, const QDate &date, const AssetList &assets, bool preRelease = false, + QObject *parent = nullptr); QString getUrl() const; QString getName() const; diff --git a/lib/MellowPlayer/Application/Updater/Updater.cpp b/lib/MellowPlayer/Application/Updater/Updater.cpp index b431cbd8..c9557b14 100644 --- a/lib/MellowPlayer/Application/Updater/Updater.cpp +++ b/lib/MellowPlayer/Application/Updater/Updater.cpp @@ -19,9 +19,12 @@ Updater::Updater(IReleaseQuerier &releaseQuerier, Settings &settings, AbstractPl releaseQuerier.setChannel(getChannel()); connect(&releaseQuerier, &IReleaseQuerier::latestReceived, this, &Updater::onLatestReleaseReceived); connect(&updateChannelSetting_, &Setting::valueChanged, this, &Updater::check); + connect(&platformUpdater, &AbstractPlatformUpdater::progressUpdated, this, &Updater::progressUpdated); + connect(&platformUpdater, &AbstractPlatformUpdater::downloadFinished, this, &Updater::onDownloadFinished); + connect(&platformUpdater, &AbstractPlatformUpdater::installFinished, this, &Updater::onInstallFinished); - Release *r = new Release("1.95.0", QDate::fromString("2017-06-15"), this); - setCurrentRelease(r); +// Release *r = new Release("1.95.0", QDate::fromString("2017-06-15"), this); +// setCurrentRelease(r); } void Updater::check() @@ -62,17 +65,16 @@ const Release *Updater::getLatestRelease() const void Updater::onLatestReleaseReceived(const Release *release) { LOG_DEBUG(logger_, "Latest release received: " + release->getName()); - setStatus(Status::None); - if (release != nullptr && *release > *currentRelease_) { - LOG_DEBUG( - logger_, - QString("Latest release is an update (%1 < %2)").arg(currentRelease_->getName()).arg(release->getName())); + LOG_DEBUG(logger_, QString("Latest release is an update (%1 < %2)").arg(currentRelease_->getName()).arg(release->getName())); + setStatus(Status::UpdateAvailable); latestRelease_ = release; + platformUpdater_.setRelease(latestRelease_); isUpdateAvailable_ = true; emit updateAvailable(); } else { LOG_DEBUG(logger_, QString("No release found")); + setStatus(Status::None); latestRelease_ = nullptr; isUpdateAvailable_ = false; emit noUpdateAvailable(); @@ -100,9 +102,26 @@ void Updater::setStatus(Updater::Status status) void Updater::onDownloadFinished(bool succes) { if (succes) { + LOG_DEBUG(logger_, "download finished, installing...") setStatus(Status::Installing); platformUpdater_.install(); } else { - setStatus(Status::None); + LOG_DEBUG(logger_, "download failed") + setStatus(Status::Failure); + } +} +void Updater::onInstallFinished(bool succes) +{ + if (succes) { + LOG_DEBUG(logger_, "install finished, you can now restart the application"); + setStatus(Status::Installed); + emit installed(); + } else { + LOG_DEBUG(logger_, "install failed"); + setStatus(Status::Failure); } } +void Updater::restart() +{ + platformUpdater_.restart(); +} diff --git a/lib/MellowPlayer/Application/Updater/Updater.hpp b/lib/MellowPlayer/Application/Updater/Updater.hpp index 21073786..2bf2fde5 100644 --- a/lib/MellowPlayer/Application/Updater/Updater.hpp +++ b/lib/MellowPlayer/Application/Updater/Updater.hpp @@ -24,8 +24,11 @@ namespace MellowPlayer::Application { None, Checking, + UpdateAvailable, Downloading, Installing, + Installed, + Failure }; void setCurrentRelease(const Release *currentRelease); @@ -38,16 +41,20 @@ namespace MellowPlayer::Application public slots: void check(); void install(); + void restart(); signals: void updateAvailable(); void noUpdateAvailable(); void statusChanged(); + void progressUpdated(double progress); + void installed(); private slots: void onLatestReleaseReceived(const Release *release); void setStatus(Status status); void onDownloadFinished(bool succes); + void onInstallFinished(bool succes); private: ILogger &logger_; diff --git a/lib/MellowPlayer/Infrastructure/Applications/CoreApplication.cpp b/lib/MellowPlayer/Infrastructure/Applications/CoreApplication.cpp index e963140c..7463db19 100644 --- a/lib/MellowPlayer/Infrastructure/Applications/CoreApplication.cpp +++ b/lib/MellowPlayer/Infrastructure/Applications/CoreApplication.cpp @@ -12,9 +12,8 @@ using namespace MellowPlayer::Application; using namespace MellowPlayer::Infrastructure; using namespace std; -CoreApplication::CoreApplication(IQtApplication &qtApp, IMainWindow &mainWindow, - StreamingServicesController &streamingServices, IHotkeysController &kotkeys, - ISystemTrayIcon &systemTrayIcon, INotifier ¬ifier) +CoreApplication::CoreApplication(IQtApplication &qtApp, IMainWindow &mainWindow, StreamingServicesController &streamingServices, + IHotkeysController &kotkeys, ISystemTrayIcon &systemTrayIcon, INotifier ¬ifier) : logger(LoggingManager::instance().getLogger("Application")), qtApp(qtApp), mainWindow(mainWindow), diff --git a/lib/MellowPlayer/Infrastructure/Applications/CoreApplication.hpp b/lib/MellowPlayer/Infrastructure/Applications/CoreApplication.hpp index 1714c1ca..a0e06616 100644 --- a/lib/MellowPlayer/Infrastructure/Applications/CoreApplication.hpp +++ b/lib/MellowPlayer/Infrastructure/Applications/CoreApplication.hpp @@ -19,9 +19,8 @@ namespace MellowPlayer::Infrastructure { public: CoreApplication(Application::IQtApplication &qtApp, Application::IMainWindow &mainWindow, - Application::StreamingServicesController &streamingServices, - Application::IHotkeysController &kotkeys, Application::ISystemTrayIcon &systemTrayIcon, - Application::INotifier ¬ifier); + Application::StreamingServicesController &streamingServices, Application::IHotkeysController &kotkeys, + Application::ISystemTrayIcon &systemTrayIcon, Application::INotifier ¬ifier); void initialize() override; void restoreWindow() override; diff --git a/lib/MellowPlayer/Infrastructure/Applications/SingleInstanceApplication.cpp b/lib/MellowPlayer/Infrastructure/Applications/SingleInstanceApplication.cpp index c635465f..d94c231f 100644 --- a/lib/MellowPlayer/Infrastructure/Applications/SingleInstanceApplication.cpp +++ b/lib/MellowPlayer/Infrastructure/Applications/SingleInstanceApplication.cpp @@ -18,8 +18,7 @@ const QString SingleInstanceApplication::nextAction = "next"; const QString SingleInstanceApplication::previousAction = "previous"; const QString SingleInstanceApplication::restoreWindowAction = "restore-window"; -SingleInstanceApplication::SingleInstanceApplication(IApplication &application, ICommandLineParser &commandLineParser, - IPlayer ¤tPlayer) +SingleInstanceApplication::SingleInstanceApplication(IApplication &application, ICommandLineParser &commandLineParser, IPlayer ¤tPlayer) : logger(LoggingManager::instance().getLogger("SingleInstanceApplication")), application(application), commandLineParser(commandLineParser), diff --git a/lib/MellowPlayer/Infrastructure/Applications/SingleInstanceApplication.hpp b/lib/MellowPlayer/Infrastructure/Applications/SingleInstanceApplication.hpp index a13708d6..365a391c 100644 --- a/lib/MellowPlayer/Infrastructure/Applications/SingleInstanceApplication.hpp +++ b/lib/MellowPlayer/Infrastructure/Applications/SingleInstanceApplication.hpp @@ -18,8 +18,7 @@ namespace MellowPlayer::Infrastructure { Q_OBJECT public: - SingleInstanceApplication(IApplication &application, Application::ICommandLineParser &commandLineParser, - Application::IPlayer ¤tPlayer); + SingleInstanceApplication(IApplication &application, Application::ICommandLineParser &commandLineParser, Application::IPlayer ¤tPlayer); int run(); diff --git a/lib/MellowPlayer/Infrastructure/Controllers/HotkeysController.cpp b/lib/MellowPlayer/Infrastructure/Controllers/HotkeysController.cpp index c8d4a3d5..edf3bd86 100644 --- a/lib/MellowPlayer/Infrastructure/Controllers/HotkeysController.cpp +++ b/lib/MellowPlayer/Infrastructure/Controllers/HotkeysController.cpp @@ -24,8 +24,7 @@ HotkeysController::HotkeysController(IPlayer &player, Settings &settings, IMainW connect(&nextShortcutSetting, &Setting::valueChanged, this, &HotkeysController::updateNextShortcut); connect(&previousShortcutSetting, &Setting::valueChanged, this, &HotkeysController::updatePreviousShorcut); connect(&favoriteShortcutSetting, &Setting::valueChanged, this, &HotkeysController::updateFavoriteShortcut); - connect(&restoreWindowShortcutSetting, &Setting::valueChanged, this, - &HotkeysController::updateRestoreWindowShortcut); + connect(&restoreWindowShortcutSetting, &Setting::valueChanged, this, &HotkeysController::updateRestoreWindowShortcut); } void HotkeysController::togglePlayPause() diff --git a/lib/MellowPlayer/Infrastructure/Controllers/HotkeysController.hpp b/lib/MellowPlayer/Infrastructure/Controllers/HotkeysController.hpp index 7639150d..ce293b86 100644 --- a/lib/MellowPlayer/Infrastructure/Controllers/HotkeysController.hpp +++ b/lib/MellowPlayer/Infrastructure/Controllers/HotkeysController.hpp @@ -22,8 +22,7 @@ namespace MellowPlayer::Infrastructure { Q_OBJECT public: - HotkeysController(Application::IPlayer &player, Application::Settings &settings, - Application::IMainWindow &mainWindow); + HotkeysController(Application::IPlayer &player, Application::Settings &settings, Application::IMainWindow &mainWindow); ~HotkeysController(); void start() override; diff --git a/lib/MellowPlayer/Infrastructure/FileDownloader.cpp b/lib/MellowPlayer/Infrastructure/FileDownloader.cpp index 9d20700b..652d43cc 100644 --- a/lib/MellowPlayer/Infrastructure/FileDownloader.cpp +++ b/lib/MellowPlayer/Infrastructure/FileDownloader.cpp @@ -1,9 +1,10 @@ #include "FileDownloader.hpp" +#include using namespace MellowPlayer::Application; using namespace MellowPlayer::Infrastructure; -FileDownloader::FileDownloader() +FileDownloader::FileDownloader() : logger_(LoggingManager::instance().getLogger("FileDownloader")) { connect(&networkAccessManager_, &QNetworkAccessManager::finished, this, &FileDownloader::onDownloadFinished); } @@ -11,6 +12,7 @@ FileDownloader::FileDownloader() void FileDownloader::download(const QString &urlToDownload, const QString &filePath) { if (!isDownloading()) { + LOG_DEBUG(logger_, "downloading " << urlToDownload << " to " << filePath); progress_ = 0; destinationPath_ = QFileInfo(filePath); currentReply = networkAccessManager_.get(QNetworkRequest(QUrl(urlToDownload))); @@ -38,6 +40,7 @@ void FileDownloader::onDownloadFinished(QNetworkReply *reply) QString redirectUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toString(); if (!redirectUrl.isEmpty()) { + LOG_DEBUG(logger_, "redirected to: " << redirectUrl); download(redirectUrl, destinationPath_.absoluteFilePath()); return; } @@ -46,9 +49,13 @@ void FileDownloader::onDownloadFinished(QNetworkReply *reply) QFile file(destinationPath_.absoluteFilePath()); if (file.open(QIODevice::WriteOnly)) { file.write(replyData); + + LOG_DEBUG(logger_, "file downloaded with success: " << destinationPath_.absoluteFilePath()); success = true; - } - } + } else + LOG_DEBUG(logger_, "failed to write file: " << destinationPath_.absoluteFilePath() << " - Error: " << file.errorString()); + } else + LOG_DEBUG(logger_, "download failed: " << reply->errorString()); emit finished(success); } @@ -62,7 +69,8 @@ void FileDownloader::onDownloadProgress(qint64 bytesReceived, qint64 bytesTotal) double progress = (ratio * 100); if (progress_ != progress) { + LOG_DEBUG(logger_, "download progress: " << progress); progress_ = progress; - emit progressChanged(); + emit progressChanged(progress_); } } diff --git a/lib/MellowPlayer/Infrastructure/FileDownloader.hpp b/lib/MellowPlayer/Infrastructure/FileDownloader.hpp index a50c1578..4b75409c 100644 --- a/lib/MellowPlayer/Infrastructure/FileDownloader.hpp +++ b/lib/MellowPlayer/Infrastructure/FileDownloader.hpp @@ -5,6 +5,11 @@ #include #include +namespace MellowPlayer::Application +{ + class ILogger; +} + namespace MellowPlayer::Infrastructure { class FileDownloader : public Application::IFileDownloader @@ -22,6 +27,7 @@ namespace MellowPlayer::Infrastructure void onDownloadProgress(qint64 bytesReceived, qint64 bytesTotal); private: + Application::ILogger &logger_; QNetworkAccessManager networkAccessManager_; QFileInfo destinationPath_; QNetworkReply *currentReply = nullptr; diff --git a/lib/MellowPlayer/Infrastructure/Logging/SpdLoggerFactory.hpp b/lib/MellowPlayer/Infrastructure/Logging/SpdLoggerFactory.hpp index b0c736c4..b3e5b42b 100644 --- a/lib/MellowPlayer/Infrastructure/Logging/SpdLoggerFactory.hpp +++ b/lib/MellowPlayer/Infrastructure/Logging/SpdLoggerFactory.hpp @@ -7,7 +7,6 @@ namespace MellowPlayer::Infrastructure class SpdLoggerFactory : public Application::ILoggerFactory { public: - std::unique_ptr create(const std::string &name, - const Application::LoggerConfig &loggerConfig) const override; + std::unique_ptr create(const std::string &name, const Application::LoggerConfig &loggerConfig) const override; }; } diff --git a/lib/MellowPlayer/Infrastructure/Platform/Linux/LinuxApplication.cpp b/lib/MellowPlayer/Infrastructure/Platform/Linux/LinuxApplication.cpp index bd02dfc9..502d5f8f 100644 --- a/lib/MellowPlayer/Infrastructure/Platform/Linux/LinuxApplication.cpp +++ b/lib/MellowPlayer/Infrastructure/Platform/Linux/LinuxApplication.cpp @@ -12,9 +12,8 @@ using namespace MellowPlayer::Application; using namespace MellowPlayer::Infrastructure; -LinuxApplication::LinuxApplication(IQtApplication &qtApp, IMainWindow &mainWindow, - StreamingServicesController &streamingServices, IHotkeysController &kotkeys, - ISystemTrayIcon &systemTrayIcon, INotifier ¬ifier, IMprisController &mprisService) +LinuxApplication::LinuxApplication(IQtApplication &qtApp, IMainWindow &mainWindow, StreamingServicesController &streamingServices, + IHotkeysController &kotkeys, ISystemTrayIcon &systemTrayIcon, INotifier ¬ifier, IMprisController &mprisService) : CoreApplication(qtApp, mainWindow, streamingServices, kotkeys, systemTrayIcon, notifier), logger(LoggingManager::instance().getLogger("LinuxApplication")), mprisService(mprisService) diff --git a/lib/MellowPlayer/Infrastructure/Platform/Linux/LinuxApplication.hpp b/lib/MellowPlayer/Infrastructure/Platform/Linux/LinuxApplication.hpp index 8cc89be7..84e88322 100644 --- a/lib/MellowPlayer/Infrastructure/Platform/Linux/LinuxApplication.hpp +++ b/lib/MellowPlayer/Infrastructure/Platform/Linux/LinuxApplication.hpp @@ -23,9 +23,8 @@ namespace MellowPlayer::Infrastructure { public: LinuxApplication(Application::IQtApplication &qtApp, Application::IMainWindow &mainWindow, - Application::StreamingServicesController &streamingServices, - Application::IHotkeysController &kotkeys, Application::ISystemTrayIcon &systemTrayIcon, - Application::INotifier ¬ifier, Application::IMprisController &mprisService); + Application::StreamingServicesController &streamingServices, Application::IHotkeysController &kotkeys, + Application::ISystemTrayIcon &systemTrayIcon, Application::INotifier ¬ifier, Application::IMprisController &mprisService); void initialize() override; private: diff --git a/lib/MellowPlayer/Infrastructure/Platform/Linux/Mpris/Mpris2Player.cpp b/lib/MellowPlayer/Infrastructure/Platform/Linux/Mpris/Mpris2Player.cpp index 9ae89f8f..26756f59 100644 --- a/lib/MellowPlayer/Infrastructure/Platform/Linux/Mpris/Mpris2Player.cpp +++ b/lib/MellowPlayer/Infrastructure/Platform/Linux/Mpris/Mpris2Player.cpp @@ -336,8 +336,7 @@ void Mpris2Player::signalUpdate(const QVariantMap &map, const QString &interface { LOG_TRACE(logger, "signalUpdate"); if (!map.isEmpty()) { - QDBusMessage signal = - QDBusMessage::createSignal("/org/mpris/MediaPlayer2", "org.freedesktop.DBus.Properties", "PropertiesChanged"); + QDBusMessage signal = QDBusMessage::createSignal("/org/mpris/MediaPlayer2", "org.freedesktop.DBus.Properties", "PropertiesChanged"); QVariantList args = QVariantList() << interfaceName << map << QStringList(); signal.setArguments(args); diff --git a/lib/MellowPlayer/Infrastructure/Platform/Linux/Mpris/Mpris2Player.hpp b/lib/MellowPlayer/Infrastructure/Platform/Linux/Mpris/Mpris2Player.hpp index 74c8e483..02cb334f 100644 --- a/lib/MellowPlayer/Infrastructure/Platform/Linux/Mpris/Mpris2Player.hpp +++ b/lib/MellowPlayer/Infrastructure/Platform/Linux/Mpris/Mpris2Player.hpp @@ -20,8 +20,7 @@ namespace MellowPlayer::Infrastructure Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.mpris.MediaPlayer2.Player") public: - explicit Mpris2Player(Application::IPlayer &player, Application::ILocalAlbumArt &localAlbumArt, - QObject *parent = nullptr); + explicit Mpris2Player(Application::IPlayer &player, Application::ILocalAlbumArt &localAlbumArt, QObject *parent = nullptr); Q_PROPERTY(QVariantMap Metadata READ metadata) Q_PROPERTY(bool CanControl READ canControl) diff --git a/lib/MellowPlayer/Infrastructure/Platform/Linux/Mpris/Mpris2Root.cpp b/lib/MellowPlayer/Infrastructure/Platform/Linux/Mpris/Mpris2Root.cpp index 4fdfd5dd..9a3363bb 100644 --- a/lib/MellowPlayer/Infrastructure/Platform/Linux/Mpris/Mpris2Root.cpp +++ b/lib/MellowPlayer/Infrastructure/Platform/Linux/Mpris/Mpris2Root.cpp @@ -7,10 +7,7 @@ using namespace MellowPlayer::Application; using namespace MellowPlayer::Infrastructure; Mpris2Root::Mpris2Root(IMainWindow &window, IQtApplication &qtApp, QObject *parent) - : QDBusAbstractAdaptor(parent), - logger(LoggingManager::instance().getLogger("Mpris2Root")), - window(window), - qtApp(qtApp) + : QDBusAbstractAdaptor(parent), logger(LoggingManager::instance().getLogger("Mpris2Root")), window(window), qtApp(qtApp) { } diff --git a/lib/MellowPlayer/Infrastructure/Platform/Linux/MprisController.cpp b/lib/MellowPlayer/Infrastructure/Platform/Linux/MprisController.cpp index 0de6ed75..6ae11929 100644 --- a/lib/MellowPlayer/Infrastructure/Platform/Linux/MprisController.cpp +++ b/lib/MellowPlayer/Infrastructure/Platform/Linux/MprisController.cpp @@ -16,8 +16,7 @@ QString MprisController::SERVICE_NAME = "org.mpris.MediaPlayer2."; QString MprisController::OBJECT_NAME = "/org/mpris/MediaPlayer2"; -MprisController::MprisController(IPlayer &player, ILocalAlbumArt &localAlbumArt, IMainWindow &window, - IQtApplication &application) +MprisController::MprisController(IPlayer &player, ILocalAlbumArt &localAlbumArt, IMainWindow &window, IQtApplication &application) : logger(LoggingManager::instance().getLogger("Mpris")), parent(make_unique()), mpris2Root(new Mpris2Root(window, application, parent.get())), @@ -34,8 +33,7 @@ MprisController::~MprisController() bool MprisController::start() { - if (!QDBusConnection::sessionBus().registerService(serviceName) - || !QDBusConnection::sessionBus().registerObject(OBJECT_NAME, parent.get())) { + if (!QDBusConnection::sessionBus().registerService(serviceName) || !QDBusConnection::sessionBus().registerObject(OBJECT_NAME, parent.get())) { LOG_WARN(logger, "failed to register service on the session bus: " + serviceName); LOG_WARN(logger, "failed to register object on the session bus: " + OBJECT_NAME); return false; diff --git a/lib/MellowPlayer/Infrastructure/Platform/Linux/MprisController.hpp b/lib/MellowPlayer/Infrastructure/Platform/Linux/MprisController.hpp index 4d7d65f7..5b9b4aa7 100644 --- a/lib/MellowPlayer/Infrastructure/Platform/Linux/MprisController.hpp +++ b/lib/MellowPlayer/Infrastructure/Platform/Linux/MprisController.hpp @@ -22,8 +22,8 @@ namespace MellowPlayer::Infrastructure class MprisController : public Application::IMprisController { public: - MprisController(Application::IPlayer &player, Application::ILocalAlbumArt &localAlbumArt, - Application::IMainWindow &window, Application::IQtApplication &application); + MprisController(Application::IPlayer &player, Application::ILocalAlbumArt &localAlbumArt, Application::IMainWindow &window, + Application::IQtApplication &application); ~MprisController(); bool start() override; diff --git a/lib/MellowPlayer/Infrastructure/Platform/Linux/Updater/LinuxUpdater.cpp b/lib/MellowPlayer/Infrastructure/Platform/Linux/Updater/LinuxUpdater.cpp new file mode 100644 index 00000000..90714b03 --- /dev/null +++ b/lib/MellowPlayer/Infrastructure/Platform/Linux/Updater/LinuxUpdater.cpp @@ -0,0 +1,79 @@ +#include "LinuxUpdater.hpp" +#include +#include +#include +#include +#include +#include + +using namespace MellowPlayer::Application; +using namespace MellowPlayer::Infrastructure; + +LinuxUpdater::LinuxUpdater(IFileDownloader &fileDownloader) : AbstractPlatformUpdater(fileDownloader) +{ +} + +bool LinuxUpdater::canInstall() const +{ + QString appImagePath = getDestinationDir(); + return asset_.isValid() && asset_.isAppImage() && !appImagePath.isEmpty(); +} + +QString LinuxUpdater::getDestinationDir() const +{ + QString appImagePath = qgetenv("APPIMAGE"); + if (!appImagePath.isEmpty()) + return QFileInfo(appImagePath).dir().absolutePath(); + return ""; +} + +void LinuxUpdater::doInstall(const QString &assetLocalPath) +{ + QString destinationPath = getDestinationPath(); + QString backupPath = destinationPath + ".backup"; + + QFile::remove(backupPath); + QFile::rename(destinationPath, backupPath); + QFile::copy(assetLocalPath, destinationPath); + + QProcess::startDetached("chmod +x " + destinationPath); + + emit installFinished(QFile::exists(destinationPath)); +} +QString LinuxUpdater::getDestinationPath() const +{ + QString destinationDir = getDestinationDir(); + QString destinationPath = destinationDir + "/" + getAssetFileName(); + return destinationPath; +} + +QString LinuxUpdater::getAssetUrl() const +{ + return asset_.getUrl(); +} + +QString LinuxUpdater::getAssetFileName() const +{ + return asset_.getName(); +} + +void LinuxUpdater::setRelease(const Release *release) +{ + AbstractPlatformUpdater::setRelease(release); + + if (release_ != nullptr) { + for (auto &asset : release_->getAssets()) { + if (asset.isAppImage()) { + asset_ = asset; + break; + } + } + } +} +void LinuxUpdater::restart() +{ + // QFile file(getDestinationPath()); + // QFile::setPermissions(getDestinationPath(), QFile::ExeUser | QFile::ExeOwner); + QProcess::startDetached(getDestinationPath()); + qApp->quit(); +} diff --git a/lib/MellowPlayer/Infrastructure/Platform/Linux/Updater/LinuxUpdater.hpp b/lib/MellowPlayer/Infrastructure/Platform/Linux/Updater/LinuxUpdater.hpp new file mode 100644 index 00000000..cc4b6f4c --- /dev/null +++ b/lib/MellowPlayer/Infrastructure/Platform/Linux/Updater/LinuxUpdater.hpp @@ -0,0 +1,25 @@ +#pragma once + +#include +#include + +namespace MellowPlayer::Infrastructure +{ + class LinuxUpdater : public Application::AbstractPlatformUpdater + { + public: + LinuxUpdater(Application::IFileDownloader &fileDownloader); + + void setRelease(const Application::Release *release) override; + bool canInstall() const override; + void restart() override; + + protected: + void doInstall(const QString &assetLocalPath) override; + QString getAssetUrl() const override; + QString getAssetFileName() const override; + Application::Asset asset_; + QString getDestinationDir() const; + QString getDestinationPath() const; + }; +} diff --git a/lib/MellowPlayer/Infrastructure/StreamingServices/StreamingServiceCreator.cpp b/lib/MellowPlayer/Infrastructure/StreamingServices/StreamingServiceCreator.cpp index babb1cce..a74c73f7 100644 --- a/lib/MellowPlayer/Infrastructure/StreamingServices/StreamingServiceCreator.cpp +++ b/lib/MellowPlayer/Infrastructure/StreamingServices/StreamingServiceCreator.cpp @@ -15,8 +15,8 @@ const QString StreamingServiceCreator::LOGO_FILE_NAME = "logo.svg"; const QString StreamingServiceCreator::METADATA_FILE_NAME = "metadata.ini"; const QString StreamingServiceCreator::THEME_FILE_NAME = "theme.json"; -QString StreamingServiceCreator::create(const QString &serviceName, const QString &serviceUrl, - const QString &authorName, const QString &authorWebsite) const +QString StreamingServiceCreator::create(const QString &serviceName, const QString &serviceUrl, const QString &authorName, + const QString &authorWebsite) const { auto pluginDir = getPluginDir(serviceName); QDir().mkpath(pluginDir); @@ -44,12 +44,10 @@ void StreamingServiceCreator::createTheme(const QString &pluginDir) const createPluginFile(pluginDir, THEME_FILE_NAME); } -void StreamingServiceCreator::createMetadata(const QString &serviceName, const QString &serviceUrl, - const QString &authorName, const QString &authorWebsite, - const QString &pluginDir) const +void StreamingServiceCreator::createMetadata(const QString &serviceName, const QString &serviceUrl, const QString &authorName, + const QString &authorWebsite, const QString &pluginDir) const { - createPluginFile(pluginDir, METADATA_FILE_NAME, - [&](QString string) { return string.arg(authorName, authorWebsite, serviceName, serviceUrl); }); + createPluginFile(pluginDir, METADATA_FILE_NAME, [&](QString string) { return string.arg(authorName, authorWebsite, serviceName, serviceUrl); }); } QString StreamingServiceCreator::getPluginDir(const QString &serviceName) const @@ -83,8 +81,7 @@ QString StreamingServiceCreator::getFilePath(const QString &pluginDir, const QSt return QDir::cleanPath(pluginDir + QDir::separator() + fileName); } -void StreamingServiceCreator::createPluginFile(const QString &pluginDir, const QString &fileName, - const function transformer) const +void StreamingServiceCreator::createPluginFile(const QString &pluginDir, const QString &fileName, const function transformer) const { const QString filePath = getFilePath(pluginDir, fileName); const QString content = transformer(readTemplateFile(fileName)); diff --git a/lib/MellowPlayer/Infrastructure/StreamingServices/StreamingServiceCreator.hpp b/lib/MellowPlayer/Infrastructure/StreamingServices/StreamingServiceCreator.hpp index ea9888a4..e577431d 100644 --- a/lib/MellowPlayer/Infrastructure/StreamingServices/StreamingServiceCreator.hpp +++ b/lib/MellowPlayer/Infrastructure/StreamingServices/StreamingServiceCreator.hpp @@ -9,23 +9,20 @@ namespace MellowPlayer::Infrastructure class StreamingServiceCreator : public Application::IStreamingServiceCreator { public: - QString create(const QString &serviceName, const QString &serviceUrl, const QString &authorName, - const QString &authorWebsite) const override; + QString create(const QString &serviceName, const QString &serviceUrl, const QString &authorName, const QString &authorWebsite) const override; private: void createScript(const QString &pluginDir) const; void createLogo(const QString &pluginDir) const; void createTheme(const QString &pluginDir) const; - void createMetadata(const QString &serviceName, const QString &serviceUrl, const QString &authorName, - const QString &authorWebsite, const QString &pluginDir) const; + void createMetadata(const QString &serviceName, const QString &serviceUrl, const QString &authorName, const QString &authorWebsite, + const QString &pluginDir) const; QString getPluginDir(const QString &serviceName) const; QString readTemplateFile(const QString &fileName) const; void write(const QString &path, const QString &content) const; QString getFilePath(const QString &pluginDir, const QString &fileName) const; void createPluginFile(const QString &pluginDir, const QString &fileName, - const std::function transformer = [](QString string) { - return string; - }) const; + const std::function transformer = [](QString string) { return string; }) const; static const QString RESOURCE_PATH; static const QString SCRIPT_FILE_NAME; diff --git a/lib/MellowPlayer/Infrastructure/StreamingServices/StreamingServiceLoader.cpp b/lib/MellowPlayer/Infrastructure/StreamingServices/StreamingServiceLoader.cpp index 6b89de49..ef20406a 100644 --- a/lib/MellowPlayer/Infrastructure/StreamingServices/StreamingServiceLoader.cpp +++ b/lib/MellowPlayer/Infrastructure/StreamingServices/StreamingServiceLoader.cpp @@ -20,8 +20,7 @@ using namespace MellowPlayer::Application; using namespace MellowPlayer::Infrastructure; using namespace std; -StreamingServiceLoader::StreamingServiceLoader() - : logger(LoggingManager::instance().getLogger("StreamingServiceLoader")) +StreamingServiceLoader::StreamingServiceLoader() : logger(LoggingManager::instance().getLogger("StreamingServiceLoader")) { } @@ -38,14 +37,10 @@ QList> StreamingServiceLoader::load() const if (checkServiceDirectory(directory.absoluteFilePath())) { shared_ptr service = loadService(directory.absoluteFilePath()); if (service->isValid() && !containsService(services, service)) { - LOG_DEBUG(logger, - service->getName() + " streamingService successfully loaded (from \"" - + directory.absoluteFilePath() + "\")"); + LOG_DEBUG(logger, service->getName() + " streamingService successfully loaded (from \"" + directory.absoluteFilePath() + "\")"); services.append(service); } else { - LOG_DEBUG(logger, - "skipping streamingService " + service->getName() - + ", already loaded from another source or invalid"); + LOG_DEBUG(logger, "skipping streamingService " + service->getName() + ", already loaded from another source or invalid"); } } } @@ -123,8 +118,7 @@ bool StreamingServiceLoader::checkServiceDirectory(const QString &directory) con QString StreamingServiceLoader::getUserDirectory() { - return QFileInfo(QStandardPaths::standardLocations(QStandardPaths::AppLocalDataLocation)[0], "plugins") - .absoluteFilePath(); + return QFileInfo(QStandardPaths::standardLocations(QStandardPaths::AppLocalDataLocation)[0], "plugins").absoluteFilePath(); } QStringList StreamingServiceLoader::getSearchPaths() const @@ -156,8 +150,7 @@ QStringList StreamingServiceLoader::getSearchPaths() const return paths; } -bool StreamingServiceLoader::containsService(const QList> &services, - shared_ptr &toCheck) const +bool StreamingServiceLoader::containsService(const QList> &services, shared_ptr &toCheck) const { for (auto service : services) { if (*toCheck == *service) diff --git a/lib/MellowPlayer/Infrastructure/StreamingServices/StreamingServiceWatcher.cpp b/lib/MellowPlayer/Infrastructure/StreamingServices/StreamingServiceWatcher.cpp index fdf54f1f..cca7fce1 100644 --- a/lib/MellowPlayer/Infrastructure/StreamingServices/StreamingServiceWatcher.cpp +++ b/lib/MellowPlayer/Infrastructure/StreamingServices/StreamingServiceWatcher.cpp @@ -6,8 +6,7 @@ using namespace std; using namespace MellowPlayer::Application; using namespace MellowPlayer::Infrastructure; -StreamingServiceWatcher::StreamingServiceWatcher() - : logger(LoggingManager::instance().getLogger("StreamingServiceWatcher")) +StreamingServiceWatcher::StreamingServiceWatcher() : logger(LoggingManager::instance().getLogger("StreamingServiceWatcher")) { connect(&fileSystemWatcher, &QFileSystemWatcher::fileChanged, this, &StreamingServiceWatcher::onFileChanged); } diff --git a/lib/MellowPlayer/Presentation/Converters/UpdaterStatusConverter.cpp b/lib/MellowPlayer/Presentation/Converters/UpdaterStatusConverter.cpp index 2b8e7f53..ce9dd577 100644 --- a/lib/MellowPlayer/Presentation/Converters/UpdaterStatusConverter.cpp +++ b/lib/MellowPlayer/Presentation/Converters/UpdaterStatusConverter.cpp @@ -5,16 +5,22 @@ using namespace MellowPlayer::Application; using namespace MellowPlayer::Presentation; const QString UpdaterStatusConverter::NONE = ""; -const QString UpdaterStatusConverter::CHECKING = "Checking for update"; -const QString UpdaterStatusConverter::DOWNLOADING = "Downloading update"; -const QString UpdaterStatusConverter::INSTALLING = "Installing update"; +const QString UpdaterStatusConverter::CHECKING = "Checking for update..."; +const QString UpdaterStatusConverter::UPDATE = "An update is available..."; +const QString UpdaterStatusConverter::DOWNLOADING = "Downloading update..."; +const QString UpdaterStatusConverter::INSTALLING = "Installing update..."; +const QString UpdaterStatusConverter::INSTALLED = "Update installed, you can now restart the application..."; +const QString UpdaterStatusConverter::FAILURE = "Failed to install update, check logs for warning and errors and try again..."; QString UpdaterStatusConverter::toString(Updater::Status status) { static QMap map = {{Updater::Status::None, NONE}, {Updater::Status::Checking, CHECKING}, + {Updater::Status::UpdateAvailable, UPDATE}, {Updater::Status::Downloading, DOWNLOADING}, - {Updater::Status::Installing, INSTALLING}}; + {Updater::Status::Installing, INSTALLING}, + {Updater::Status::Installed, INSTALLED}, + {Updater::Status::Failure, FAILURE}}; return map[status]; } @@ -23,8 +29,11 @@ Updater::Status UpdaterStatusConverter::fromString(const QString &string) { static QMap map = {{NONE, Updater::Status::None}, {CHECKING, Updater::Status::Checking}, + {UPDATE, Updater::Status::UpdateAvailable}, {DOWNLOADING, Updater::Status::Downloading}, - {INSTALLING, Updater::Status::Installing}}; + {INSTALLING, Updater::Status::Installing}, + {INSTALLED, Updater::Status::Installed}, + {FAILURE, Updater::Status::Failure}}; if (map.contains(string)) return map[string]; diff --git a/lib/MellowPlayer/Presentation/Converters/UpdaterStatusConverter.hpp b/lib/MellowPlayer/Presentation/Converters/UpdaterStatusConverter.hpp index c3cdf738..fa254be1 100644 --- a/lib/MellowPlayer/Presentation/Converters/UpdaterStatusConverter.hpp +++ b/lib/MellowPlayer/Presentation/Converters/UpdaterStatusConverter.hpp @@ -12,7 +12,10 @@ namespace MellowPlayer::Presentation static const QString NONE; static const QString CHECKING; + static const QString UPDATE; static const QString DOWNLOADING; static const QString INSTALLING; + static const QString INSTALLED; + static const QString FAILURE; }; } diff --git a/lib/MellowPlayer/Presentation/IconProvider.cpp b/lib/MellowPlayer/Presentation/IconProvider.cpp index c352e038..2c8bf952 100644 --- a/lib/MellowPlayer/Presentation/IconProvider.cpp +++ b/lib/MellowPlayer/Presentation/IconProvider.cpp @@ -44,6 +44,5 @@ QIcon IconProvider::previous() QIcon IconProvider::quit() { - return QIcon::fromTheme("application-exit", - QIcon("://MellowPlayer/Presentation/Resources/icons/application-exit.png")); + return QIcon::fromTheme("application-exit", QIcon("://MellowPlayer/Presentation/Resources/icons/application-exit.png")); } diff --git a/lib/MellowPlayer/Presentation/Models/ListeningHistoryProxyListModel.cpp b/lib/MellowPlayer/Presentation/Models/ListeningHistoryProxyListModel.cpp index 217559fa..7b87c351 100644 --- a/lib/MellowPlayer/Presentation/Models/ListeningHistoryProxyListModel.cpp +++ b/lib/MellowPlayer/Presentation/Models/ListeningHistoryProxyListModel.cpp @@ -2,8 +2,7 @@ using namespace MellowPlayer::Presentation; -ListeningHistoryProxyListModel::ListeningHistoryProxyListModel( -QQmlObjectListModel *sourceModel) +ListeningHistoryProxyListModel::ListeningHistoryProxyListModel(QQmlObjectListModel *sourceModel) : sourceModel(sourceModel) { setSourceModel(sourceModel); diff --git a/lib/MellowPlayer/Presentation/Models/QQmlObjectListModel.hpp b/lib/MellowPlayer/Presentation/Models/QQmlObjectListModel.hpp index 87fb8729..e2e6940a 100644 --- a/lib/MellowPlayer/Presentation/Models/QQmlObjectListModel.hpp +++ b/lib/MellowPlayer/Presentation/Models/QQmlObjectListModel.hpp @@ -41,8 +41,8 @@ QVariantList qListToVariant(const QList &list) } // custom foreach for QList, which uses no copy and check pointer non-null -#define FOREACH_PTR_IN_QLIST(_type_, _var_, _list_) \ - for (typename QList<_type_ *>::const_iterator it = _list_.begin(); it != _list_.end(); ++it) \ +#define FOREACH_PTR_IN_QLIST(_type_, _var_, _list_) \ + for (typename QList<_type_ *>::const_iterator it = _list_.begin(); it != _list_.end(); ++it) \ for (_type_ *_var_ = static_cast<_type_ *>(*it); _var_ != Q_NULLPTR; _var_ = Q_NULLPTR) class QQmlObjectListModelBase : public QAbstractListModel @@ -86,18 +86,13 @@ template class QQmlObjectListModel : public QQmlObjectListModelBase { public: - explicit QQmlObjectListModel(QObject *parent = Q_NULLPTR, const QByteArray &displayRole = QByteArray(), - const QByteArray &uidRole = QByteArray()) - : QQmlObjectListModelBase(parent), - m_count(0), - m_uidRoleName(uidRole), - m_dispRoleName(displayRole), - m_metaObj(ItemType::staticMetaObject) + explicit QQmlObjectListModel(QObject *parent = Q_NULLPTR, const QByteArray &displayRole = QByteArray(), const QByteArray &uidRole = QByteArray()) + : QQmlObjectListModelBase(parent), m_count(0), m_uidRoleName(uidRole), m_dispRoleName(displayRole), m_metaObj(ItemType::staticMetaObject) { static QSet roleNamesBlacklist; if (roleNamesBlacklist.isEmpty()) { - roleNamesBlacklist << QByteArrayLiteral("id") << QByteArrayLiteral("index") << QByteArrayLiteral("class") - << QByteArrayLiteral("model") << QByteArrayLiteral("modelData"); + roleNamesBlacklist << QByteArrayLiteral("id") << QByteArrayLiteral("index") << QByteArrayLiteral("class") << QByteArrayLiteral("model") + << QByteArrayLiteral("modelData"); } static const char *HANDLER = "onItemPropertyChanged()"; m_handler = metaObject()->method(metaObject()->indexOfMethod(HANDLER)); @@ -115,8 +110,7 @@ class QQmlObjectListModel : public QQmlObjectListModelBase m_signalIdxToRole.insert(metaProp.notifySignalIndex(), role); } } else { - static const QByteArray CLASS_NAME = - (QByteArrayLiteral("QQmlObjectListModel<") % m_metaObj.className() % '>'); + static const QByteArray CLASS_NAME = (QByteArrayLiteral("QQmlObjectListModel<") % m_metaObj.className() % '>'); qWarning() << "Can't have" << propName << "as a role name in" << qPrintable(CLASS_NAME); } } @@ -137,8 +131,7 @@ class QQmlObjectListModel : public QQmlObjectListModelBase ItemType *item = at(index.row()); const QByteArray rolename = (role != Qt::DisplayRole ? m_roles.value(role, emptyBA()) : m_dispRoleName); if (item != Q_NULLPTR && !rolename.isEmpty()) { - ret.setValue(role != baseRole() ? item->property(rolename) - : QVariant::fromValue(static_cast(item))); + ret.setValue(role != baseRole() ? item->property(rolename) : QVariant::fromValue(static_cast(item))); } return ret; } @@ -501,18 +494,18 @@ class QQmlObjectListModel : public QQmlObjectListModelBase QHash m_indexByUid; }; -#define QML_OBJMODEL_PROPERTY(type, name) \ -protected: \ - Q_PROPERTY(QQmlObjectListModelBase *name READ get_##name CONSTANT) \ -private: \ - QQmlObjectListModel *m_##name; \ - \ -public: \ - QQmlObjectListModel *get_##name(void) const \ - { \ - return m_##name; \ - } \ - \ +#define QML_OBJMODEL_PROPERTY(type, name) \ +protected: \ + Q_PROPERTY(QQmlObjectListModelBase *name READ get_##name CONSTANT) \ +private: \ + QQmlObjectListModel *m_##name; \ + \ +public: \ + QQmlObjectListModel *get_##name(void) const \ + { \ + return m_##name; \ + } \ + \ private: #endif // QQMLOBJECTLISTMODEL_H diff --git a/lib/MellowPlayer/Presentation/Models/StreamingServiceProxyListModel.cpp b/lib/MellowPlayer/Presentation/Models/StreamingServiceProxyListModel.cpp index 403b1b0a..a5b3bec2 100644 --- a/lib/MellowPlayer/Presentation/Models/StreamingServiceProxyListModel.cpp +++ b/lib/MellowPlayer/Presentation/Models/StreamingServiceProxyListModel.cpp @@ -2,8 +2,7 @@ using namespace MellowPlayer::Presentation; -StreamingServiceProxyListModel::StreamingServiceProxyListModel(StreamingServiceListModel *sourceListModel) - : sourceListModel(sourceListModel) +StreamingServiceProxyListModel::StreamingServiceProxyListModel(StreamingServiceListModel *sourceListModel) : sourceListModel(sourceListModel) { setDynamicSortFilter(false); setSourceModel(sourceListModel); @@ -20,8 +19,7 @@ bool StreamingServiceProxyListModel::filterAcceptsRow(int sourceRow, const QMode return sourceListModel->at(sourceRow)->isEnabled(); } -bool MellowPlayer::Presentation::StreamingServiceProxyListModel::lessThan(const QModelIndex &sourceLeft, - const QModelIndex &sourceRight) const +bool MellowPlayer::Presentation::StreamingServiceProxyListModel::lessThan(const QModelIndex &sourceLeft, const QModelIndex &sourceRight) const { StreamingServiceViewModel *left = sourceListModel->at(sourceLeft.row()); StreamingServiceViewModel *right = sourceListModel->at(sourceRight.row()); diff --git a/lib/MellowPlayer/Presentation/Notifications/NotificationFactory.cpp b/lib/MellowPlayer/Presentation/Notifications/NotificationFactory.cpp index 104bb0bb..c2ae6f84 100644 --- a/lib/MellowPlayer/Presentation/Notifications/NotificationFactory.cpp +++ b/lib/MellowPlayer/Presentation/Notifications/NotificationFactory.cpp @@ -6,11 +6,9 @@ using namespace MellowPlayer::Application; using namespace MellowPlayer::Application; using namespace MellowPlayer::Presentation; -Notification NotificationFactory::createSongNotification(const QString &serviceName, Song *song, - const QString &albumArtUrl, bool resumed) +Notification NotificationFactory::createSongNotification(const QString &serviceName, Song *song, const QString &albumArtUrl, bool resumed) { - return Notification{serviceName, song->toString(), albumArtUrl, - resumed ? NotificationType::Resumed : NotificationType::NewSong}; + return Notification{serviceName, song->toString(), albumArtUrl, resumed ? NotificationType::Resumed : NotificationType::NewSong}; } Notification NotificationFactory::createPausedNotification(const QString &serviceName, const QString &serviceLogo) diff --git a/lib/MellowPlayer/Presentation/Notifications/NotificationFactory.hpp b/lib/MellowPlayer/Presentation/Notifications/NotificationFactory.hpp index a35fb2fc..39d30f43 100644 --- a/lib/MellowPlayer/Presentation/Notifications/NotificationFactory.hpp +++ b/lib/MellowPlayer/Presentation/Notifications/NotificationFactory.hpp @@ -12,8 +12,8 @@ namespace MellowPlayer::Presentation class NotificationFactory { public: - Application::Notification createSongNotification(const QString &serviceName, Application::Song *song, - const QString &albumArtUrl, bool resumed = false); + Application::Notification createSongNotification(const QString &serviceName, Application::Song *song, const QString &albumArtUrl, + bool resumed = false); Application::Notification createPausedNotification(const QString &serviceName, const QString &serviceLogo); }; } diff --git a/lib/MellowPlayer/Presentation/Notifications/Notifier.hpp b/lib/MellowPlayer/Presentation/Notifications/Notifier.hpp index ea61d6f1..59b33e14 100644 --- a/lib/MellowPlayer/Presentation/Notifications/Notifier.hpp +++ b/lib/MellowPlayer/Presentation/Notifications/Notifier.hpp @@ -20,8 +20,7 @@ namespace MellowPlayer::Presentation { Q_OBJECT public: - Notifier(Application::IPlayer &player, Application::ILocalAlbumArt &localAlbumArtService, - Application::INotificationPresenter &presenter, + Notifier(Application::IPlayer &player, Application::ILocalAlbumArt &localAlbumArtService, Application::INotificationPresenter &presenter, Application::StreamingServicesController &streamingServices, Application::Settings &settings); void initialize() override; diff --git a/lib/MellowPlayer/Presentation/Notifications/Presenters/LibnotifyPresenter.cpp b/lib/MellowPlayer/Presentation/Notifications/Presenters/LibnotifyPresenter.cpp index 3f99b32e..6cf56333 100644 --- a/lib/MellowPlayer/Presentation/Notifications/Presenters/LibnotifyPresenter.cpp +++ b/lib/MellowPlayer/Presentation/Notifications/Presenters/LibnotifyPresenter.cpp @@ -16,9 +16,7 @@ void notify_action_callback(NotifyNotification *, char *, gpointer) } LibnotifyPresenter::LibnotifyPresenter(IMainWindow &mainWindow) - : logger(LoggingManager::instance().getLogger("LibnotifyPresenter")), - mainWindow(mainWindow), - previousNotification(nullptr) + : logger(LoggingManager::instance().getLogger("LibnotifyPresenter")), mainWindow(mainWindow), previousNotification(nullptr) { instance = this; } @@ -35,8 +33,7 @@ bool LibnotifyPresenter::display(const Notification ¬ification) notify_notification_close(previousNotification, 0); QString title = "MellowPlayer - " + notification.title; NotifyNotification *n = - notify_notification_new(title.toStdString().c_str(), notification.description.toStdString().c_str(), - notification.icon.toStdString().c_str()); + notify_notification_new(title.toStdString().c_str(), notification.description.toStdString().c_str(), notification.icon.toStdString().c_str()); notify_notification_set_timeout(n, 5000); notify_notification_add_action(n, "open", "Open", (NotifyActionCallback)notify_action_callback, nullptr, nullptr); bool success = static_cast(notify_notification_show(n, 0)); diff --git a/lib/MellowPlayer/Presentation/Notifications/SystemTrayIcon.cpp b/lib/MellowPlayer/Presentation/Notifications/SystemTrayIcon.cpp index 6f0ecb9b..8d9e6605 100644 --- a/lib/MellowPlayer/Presentation/Notifications/SystemTrayIcon.cpp +++ b/lib/MellowPlayer/Presentation/Notifications/SystemTrayIcon.cpp @@ -10,8 +10,7 @@ using namespace MellowPlayer::Application; using namespace MellowPlayer::Presentation; -SystemTrayIcon::SystemTrayIcon(IPlayer &player, IMainWindow &mainWindow, IQtApplication &qtApplication, - Settings &settings) +SystemTrayIcon::SystemTrayIcon(IPlayer &player, IMainWindow &mainWindow, IQtApplication &qtApplication, Settings &settings) : QObject(), logger(LoggingManager::instance().getLogger("SystemTrayIcon")), player(player), diff --git a/lib/MellowPlayer/Presentation/Notifications/SystemTrayIcon.hpp b/lib/MellowPlayer/Presentation/Notifications/SystemTrayIcon.hpp index afde308f..13b19296 100644 --- a/lib/MellowPlayer/Presentation/Notifications/SystemTrayIcon.hpp +++ b/lib/MellowPlayer/Presentation/Notifications/SystemTrayIcon.hpp @@ -21,8 +21,8 @@ namespace MellowPlayer::Presentation { Q_OBJECT public: - SystemTrayIcon(Application::IPlayer &player, Application::IMainWindow &mainWindow, - Application::IQtApplication &qtApplication, Application::Settings &settings); + SystemTrayIcon(Application::IPlayer &player, Application::IMainWindow &mainWindow, Application::IQtApplication &qtApplication, + Application::Settings &settings); void show() override; void hide() override; void showMessage(const QString &title, const QString &message) override; diff --git a/lib/MellowPlayer/Presentation/ViewModels/ApplicationViewModel.cpp b/lib/MellowPlayer/Presentation/ViewModels/ApplicationViewModel.cpp index 19663551..8f45d0a7 100644 --- a/lib/MellowPlayer/Presentation/ViewModels/ApplicationViewModel.cpp +++ b/lib/MellowPlayer/Presentation/ViewModels/ApplicationViewModel.cpp @@ -110,8 +110,7 @@ static QString compilerString() #if defined(__apple_build_version__) // Apple clang has other version numbers isAppleString = QLatin1String(" (Apple)"); #endif - return QLatin1String("Clang ") + QString::number(__clang_major__) + QLatin1Char('.') - + QString::number(__clang_minor__) + isAppleString; + return QLatin1String("Clang ") + QString::number(__clang_major__) + QLatin1Char('.') + QString::number(__clang_minor__) + isAppleString; #elif defined(Q_CC_GNU) return QLatin1String("GCC ") + QLatin1String(__VERSION__); #elif defined(Q_CC_MSVC) @@ -128,8 +127,7 @@ QString ApplicationViewModel::getBuildInfo() const { return QObject::tr("Built on %1 at %2 (%3, %4 bit) with Qt %5") - .arg(QString(__DATE__), QString(__TIME__), compilerString(), QString::number(QSysInfo::WordSize), - QString(QT_VERSION_STR)); + .arg(QString(__DATE__), QString(__TIME__), compilerString(), QString::number(QSysInfo::WordSize), QString(QT_VERSION_STR)); } bool ApplicationViewModel::restartRequested() const diff --git a/lib/MellowPlayer/Presentation/ViewModels/ListeningHistory/ListeningHistoryEntryViewModel.cpp b/lib/MellowPlayer/Presentation/ViewModels/ListeningHistory/ListeningHistoryEntryViewModel.cpp index a0b586b7..e2aac1a4 100644 --- a/lib/MellowPlayer/Presentation/ViewModels/ListeningHistory/ListeningHistoryEntryViewModel.cpp +++ b/lib/MellowPlayer/Presentation/ViewModels/ListeningHistory/ListeningHistoryEntryViewModel.cpp @@ -3,8 +3,7 @@ using namespace MellowPlayer::Application; using namespace MellowPlayer::Presentation; -ListeningHistoryEntryViewModel::ListeningHistoryEntryViewModel(const ListeningHistoryEntry &entry, QObject *parent) - : QObject(parent), entry(entry) +ListeningHistoryEntryViewModel::ListeningHistoryEntryViewModel(const ListeningHistoryEntry &entry, QObject *parent) : QObject(parent), entry(entry) { } diff --git a/lib/MellowPlayer/Presentation/ViewModels/ListeningHistory/ListeningHistoryViewModel.cpp b/lib/MellowPlayer/Presentation/ViewModels/ListeningHistory/ListeningHistoryViewModel.cpp index 096ab7f7..b5fe7a6e 100644 --- a/lib/MellowPlayer/Presentation/ViewModels/ListeningHistory/ListeningHistoryViewModel.cpp +++ b/lib/MellowPlayer/Presentation/ViewModels/ListeningHistory/ListeningHistoryViewModel.cpp @@ -31,8 +31,7 @@ void ListeningHistoryViewModel::onEntryRemoved(int entryId) void ListeningHistoryViewModel::initialize() { connect(&listeningHistoryService, &ListeningHistory::entryAdded, this, &ListeningHistoryViewModel::onEntryAdded); - connect(&listeningHistoryService, &ListeningHistory::entryRemoved, this, - &ListeningHistoryViewModel::onEntryRemoved); + connect(&listeningHistoryService, &ListeningHistory::entryRemoved, this, &ListeningHistoryViewModel::onEntryRemoved); listeningHistoryService.initialize(); for (auto entry : listeningHistoryService.getEntries()) onEntryAdded(entry); diff --git a/lib/MellowPlayer/Presentation/ViewModels/MainWindowViewModel.cpp b/lib/MellowPlayer/Presentation/ViewModels/MainWindowViewModel.cpp index b5038719..29c2e36c 100644 --- a/lib/MellowPlayer/Presentation/ViewModels/MainWindowViewModel.cpp +++ b/lib/MellowPlayer/Presentation/ViewModels/MainWindowViewModel.cpp @@ -17,9 +17,8 @@ using namespace MellowPlayer::Application; using namespace MellowPlayer::Presentation; MainWindowViewModel::MainWindowViewModel(StreamingServicesControllerViewModel &streamingServicesModel, - ListeningHistoryViewModel &listeningHistoryModel, - ThemeViewModel &themeViewModel, UpdaterViewModel &updaterViewModel, - IQtApplication &qtApp, IPlayer &player, Settings &settings) + ListeningHistoryViewModel &listeningHistoryModel, ThemeViewModel &themeViewModel, + UpdaterViewModel &updaterViewModel, IQtApplication &qtApp, IPlayer &player, Settings &settings) : logger(LoggingManager::instance().getLogger("MainWindowViewModel")), settings(settings), streamingServices(streamingServicesModel), @@ -28,10 +27,8 @@ MainWindowViewModel::MainWindowViewModel(StreamingServicesControllerViewModel &s updaterViewModel(updaterViewModel) { qmlRegisterUncreatableType("MellowPlayer", 3, 0, "Player", "Player cannot be instantiated from QML"); - qmlRegisterUncreatableType("MellowPlayer", 3, 0, "SettingKey", - "SettingKey cannot be instantiated from QML"); - qmlRegisterUncreatableType("MellowPlayer", 3, 0, "MainPageViewModel", - "MainPageViewModel cannot be instantiated from QML"); + qmlRegisterUncreatableType("MellowPlayer", 3, 0, "SettingKey", "SettingKey cannot be instantiated from QML"); + qmlRegisterUncreatableType("MellowPlayer", 3, 0, "MainPageViewModel", "MainPageViewModel cannot be instantiated from QML"); auto context = qmlApplicationEngine.rootContext(); context->setContextProperty("_streamingServices", &streamingServicesModel); context->setContextProperty("_listeningHistory", &listeningHistoryModel); diff --git a/lib/MellowPlayer/Presentation/ViewModels/MainWindowViewModel.hpp b/lib/MellowPlayer/Presentation/ViewModels/MainWindowViewModel.hpp index ed1c3bbd..0dc95b4d 100644 --- a/lib/MellowPlayer/Presentation/ViewModels/MainWindowViewModel.hpp +++ b/lib/MellowPlayer/Presentation/ViewModels/MainWindowViewModel.hpp @@ -26,9 +26,8 @@ namespace MellowPlayer::Presentation Q_OBJECT Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) public: - MainWindowViewModel(StreamingServicesControllerViewModel &streamingServicesModel, - ListeningHistoryViewModel &listeningHistoryModel, ThemeViewModel &themeViewModel, - UpdaterViewModel &updaterViewModel, Application::IQtApplication &qtApp, + MainWindowViewModel(StreamingServicesControllerViewModel &streamingServicesModel, ListeningHistoryViewModel &listeningHistoryModel, + ThemeViewModel &themeViewModel, UpdaterViewModel &updaterViewModel, Application::IQtApplication &qtApp, Application::IPlayer &player, Application::Settings &settings); bool load() override; void show() override; diff --git a/lib/MellowPlayer/Presentation/ViewModels/Settings/SettingsCategoryViewModel.cpp b/lib/MellowPlayer/Presentation/ViewModels/Settings/SettingsCategoryViewModel.cpp index 344ef239..87a0cedf 100644 --- a/lib/MellowPlayer/Presentation/ViewModels/Settings/SettingsCategoryViewModel.cpp +++ b/lib/MellowPlayer/Presentation/ViewModels/Settings/SettingsCategoryViewModel.cpp @@ -3,8 +3,7 @@ using namespace MellowPlayer::Application; using namespace MellowPlayer::Presentation; -SettingsCategoryViewModel::SettingsCategoryViewModel(ThemeViewModel &themeViewModel, SettingsCategory *settingsCategory, - QObject *parent) +SettingsCategoryViewModel::SettingsCategoryViewModel(ThemeViewModel &themeViewModel, SettingsCategory *settingsCategory, QObject *parent) : QObject(parent), settingsCategory(settingsCategory), settingsListModel(new SettingListModel(this, "name")), @@ -41,8 +40,7 @@ void SettingsCategoryViewModel::restoreDefaults() settingsCategory->restoreDefaults(); } -CustomSettingsCategoryViewModel::CustomSettingsCategoryViewModel(const QString &name, const QString &icon, - const QString &qmlComponent, +CustomSettingsCategoryViewModel::CustomSettingsCategoryViewModel(const QString &name, const QString &icon, const QString &qmlComponent, ThemeViewModel &themeViewModel, QObject *parent) : SettingsCategoryViewModel(themeViewModel, nullptr, parent), name(name), icon(icon), qmlComponent(qmlComponent) { diff --git a/lib/MellowPlayer/Presentation/ViewModels/Settings/SettingsCategoryViewModel.hpp b/lib/MellowPlayer/Presentation/ViewModels/Settings/SettingsCategoryViewModel.hpp index c2548baf..c714cd37 100644 --- a/lib/MellowPlayer/Presentation/ViewModels/Settings/SettingsCategoryViewModel.hpp +++ b/lib/MellowPlayer/Presentation/ViewModels/Settings/SettingsCategoryViewModel.hpp @@ -18,8 +18,8 @@ namespace MellowPlayer::Presentation Q_PROPERTY(QString qmlComponent READ getQmlComponent CONSTANT) Q_PROPERTY(QAbstractItemModel *settings READ getSettingsModel CONSTANT) public: - SettingsCategoryViewModel(ThemeViewModel &themeViewModel, - Application::SettingsCategory *settingsCategory = nullptr, QObject *parent = nullptr); + SettingsCategoryViewModel(ThemeViewModel &themeViewModel, Application::SettingsCategory *settingsCategory = nullptr, + QObject *parent = nullptr); virtual QString getName() const; virtual QString getIcon() const; @@ -39,8 +39,8 @@ namespace MellowPlayer::Presentation { Q_OBJECT public: - CustomSettingsCategoryViewModel(const QString &name, const QString &icon, const QString &qmlComponent, - ThemeViewModel &themeViewModel, QObject *parent = nullptr); + CustomSettingsCategoryViewModel(const QString &name, const QString &icon, const QString &qmlComponent, ThemeViewModel &themeViewModel, + QObject *parent = nullptr); QString getName() const override; QString getIcon() const override; diff --git a/lib/MellowPlayer/Presentation/ViewModels/Settings/SettingsViewModel.cpp b/lib/MellowPlayer/Presentation/ViewModels/Settings/SettingsViewModel.cpp index 24134d14..9e6cfe6b 100644 --- a/lib/MellowPlayer/Presentation/ViewModels/Settings/SettingsViewModel.cpp +++ b/lib/MellowPlayer/Presentation/ViewModels/Settings/SettingsViewModel.cpp @@ -6,23 +6,18 @@ using namespace MellowPlayer::Application; using namespace MellowPlayer::Presentation; SettingsViewModel::SettingsViewModel(Settings &settings, ThemeViewModel &themeViewModel, QObject *parent) - : QObject(parent), - settings(settings), - settingViewModelFactory(themeViewModel), - categories(new SettingsCategoryListModel(this, "name")) + : QObject(parent), settings(settings), settingViewModelFactory(themeViewModel), categories(new SettingsCategoryListModel(this, "name")) { for (SettingsCategory *category : settings.getCategories()) { if (category->getKey() != "private") categories->append(new SettingsCategoryViewModel(themeViewModel, category, this)); } - categories->append(new CustomSettingsCategoryViewModel("Services", u8"\ue405", - "qrc:/MellowPlayer/Presentation/Views/" - "MellowPlayer/SettingsPages/" - "ServiceSettingsPage.qml", + categories->append(new CustomSettingsCategoryViewModel("Services", u8"\ue405", "qrc:/MellowPlayer/Presentation/Views/" + "MellowPlayer/SettingsPages/" + "ServiceSettingsPage.qml", themeViewModel, this)); - categories->append(new CustomSettingsCategoryViewModel("Cache", u8"\ue872", - "qrc:/MellowPlayer/Presentation/Views/MellowPlayer/" - "SettingsPages/CacheSettingsPage.qml", + categories->append(new CustomSettingsCategoryViewModel("Cache", u8"\ue872", "qrc:/MellowPlayer/Presentation/Views/MellowPlayer/" + "SettingsPages/CacheSettingsPage.qml", themeViewModel, this)); } diff --git a/lib/MellowPlayer/Presentation/ViewModels/Settings/Types/ShortcutSettingViewModel.cpp b/lib/MellowPlayer/Presentation/ViewModels/Settings/Types/ShortcutSettingViewModel.cpp index b4384f12..6f76cbb0 100644 --- a/lib/MellowPlayer/Presentation/ViewModels/Settings/Types/ShortcutSettingViewModel.cpp +++ b/lib/MellowPlayer/Presentation/ViewModels/Settings/Types/ShortcutSettingViewModel.cpp @@ -5,8 +5,7 @@ using namespace MellowPlayer::Presentation; using namespace MellowPlayer::Application; -ShortcutSettingViewModel::ShortcutSettingViewModel(Setting &setting, QObject *parent) - : SettingViewModel(setting, parent) +ShortcutSettingViewModel::ShortcutSettingViewModel(Setting &setting, QObject *parent) : SettingViewModel(setting, parent) { } diff --git a/lib/MellowPlayer/Presentation/ViewModels/Settings/Types/TimeLimitSettingViewModel.cpp b/lib/MellowPlayer/Presentation/ViewModels/Settings/Types/TimeLimitSettingViewModel.cpp index 83ae6506..a76ee8b0 100644 --- a/lib/MellowPlayer/Presentation/ViewModels/Settings/Types/TimeLimitSettingViewModel.cpp +++ b/lib/MellowPlayer/Presentation/ViewModels/Settings/Types/TimeLimitSettingViewModel.cpp @@ -3,8 +3,7 @@ using namespace MellowPlayer::Presentation; using namespace MellowPlayer::Application; -TimeLimitSettingViewModel::TimeLimitSettingViewModel(Setting &setting, QObject *parent) - : SettingViewModel(setting, parent) +TimeLimitSettingViewModel::TimeLimitSettingViewModel(Setting &setting, QObject *parent) : SettingViewModel(setting, parent) { registerEnumTranslation(TimeLimits::Today, tr("Today")); registerEnumTranslation(TimeLimits::Yesterday, tr("Yesterday")); diff --git a/lib/MellowPlayer/Presentation/ViewModels/StreamingServices/StreamingServiceViewModel.cpp b/lib/MellowPlayer/Presentation/ViewModels/StreamingServices/StreamingServiceViewModel.cpp index b4931deb..597c7edc 100644 --- a/lib/MellowPlayer/Presentation/ViewModels/StreamingServices/StreamingServiceViewModel.cpp +++ b/lib/MellowPlayer/Presentation/ViewModels/StreamingServices/StreamingServiceViewModel.cpp @@ -7,12 +7,9 @@ using namespace MellowPlayer::Application; using namespace MellowPlayer::Application; using namespace MellowPlayer::Presentation; -StreamingServiceViewModel::StreamingServiceViewModel(StreamingService &streamingService, ISettingsProvider &settings, - Players &players, QObject *parent) - : QObject(parent), - streamingService(streamingService), - settingsProvider(settings), - player(players.get(streamingService.getName())) +StreamingServiceViewModel::StreamingServiceViewModel(StreamingService &streamingService, ISettingsProvider &settings, Players &players, + QObject *parent) + : QObject(parent), streamingService(streamingService), settingsProvider(settings), player(players.get(streamingService.getName())) { } diff --git a/lib/MellowPlayer/Presentation/ViewModels/StreamingServices/StreamingServiceViewModel.hpp b/lib/MellowPlayer/Presentation/ViewModels/StreamingServices/StreamingServiceViewModel.hpp index 0629a4cd..4b9f8f00 100644 --- a/lib/MellowPlayer/Presentation/ViewModels/StreamingServices/StreamingServiceViewModel.hpp +++ b/lib/MellowPlayer/Presentation/ViewModels/StreamingServices/StreamingServiceViewModel.hpp @@ -27,9 +27,8 @@ namespace MellowPlayer::Presentation Q_PROPERTY(int sortOrder READ getSortOrder WRITE setSortOrder NOTIFY sortOrderChanged) Q_PROPERTY(bool isRunning READ isRunning NOTIFY isRunningChanged) public: - StreamingServiceViewModel(Application::StreamingService &streamingService, - Application::ISettingsProvider &settings, Application::Players &players, - QObject *parent = nullptr); + StreamingServiceViewModel(Application::StreamingService &streamingService, Application::ISettingsProvider &settings, + Application::Players &players, QObject *parent = nullptr); QString getLogo() const; QString getName() const; diff --git a/lib/MellowPlayer/Presentation/ViewModels/StreamingServices/StreamingServicesControllerViewModel.cpp b/lib/MellowPlayer/Presentation/ViewModels/StreamingServices/StreamingServicesControllerViewModel.cpp index a9d808f6..4be984ef 100644 --- a/lib/MellowPlayer/Presentation/ViewModels/StreamingServices/StreamingServicesControllerViewModel.cpp +++ b/lib/MellowPlayer/Presentation/ViewModels/StreamingServices/StreamingServicesControllerViewModel.cpp @@ -15,9 +15,10 @@ using namespace MellowPlayer::Application; using namespace MellowPlayer::Application; using namespace MellowPlayer::Presentation; -StreamingServicesControllerViewModel::StreamingServicesControllerViewModel( -StreamingServicesController &streamingServices, Players &players, Settings &settings, IWorkDispatcher &workDispatcher, -IStreamingServiceCreator &streamingServiceCreator, ICommandLineParser &commandLineParser) +StreamingServicesControllerViewModel::StreamingServicesControllerViewModel(StreamingServicesController &streamingServices, Players &players, + Settings &settings, IWorkDispatcher &workDispatcher, + IStreamingServiceCreator &streamingServiceCreator, + ICommandLineParser &commandLineParser) : QObject(), streamingServices(streamingServices), players(players), @@ -30,8 +31,7 @@ IStreamingServiceCreator &streamingServiceCreator, ICommandLineParser &commandLi enabledServices(allServices) { - connect(&streamingServices, &StreamingServicesController::added, this, - &StreamingServicesControllerViewModel::onServiceAdded); + connect(&streamingServices, &StreamingServicesController::added, this, &StreamingServicesControllerViewModel::onServiceAdded); for (auto &service : streamingServices.getAll()) { onServiceAdded(service.get()); @@ -103,8 +103,7 @@ void StreamingServicesControllerViewModel::onServiceAdded(StreamingService *stre auto *sv = new StreamingServiceViewModel(*streamingService, settings.getSettingsProvider(), players, this); Player *player = sv->getPlayer(); connect(player, &Player::isRunningChanged, this, &StreamingServicesControllerViewModel::onPlayerRunningChanged); - connect(sv, &StreamingServiceViewModel::isEnabledChanged, this, - &StreamingServicesControllerViewModel::onServiceEnabledChanged); + connect(sv, &StreamingServiceViewModel::isEnabledChanged, this, &StreamingServicesControllerViewModel::onServiceEnabledChanged); allServices->append(sv); } @@ -136,8 +135,8 @@ void StreamingServicesControllerViewModel::previous() } } -void StreamingServicesControllerViewModel::createService(const QString &serviceName, const QString &serviceUrl, - const QString &authorName, const QString &authorWebsite) +void StreamingServicesControllerViewModel::createService(const QString &serviceName, const QString &serviceUrl, const QString &authorName, + const QString &authorWebsite) { workDispatcher.invoke([=]() { QString pluginDir = streamingServiceCreator.create(serviceName, serviceUrl, authorName, authorWebsite); diff --git a/lib/MellowPlayer/Presentation/ViewModels/StreamingServices/StreamingServicesControllerViewModel.hpp b/lib/MellowPlayer/Presentation/ViewModels/StreamingServices/StreamingServicesControllerViewModel.hpp index 0ef7214b..1e75166e 100644 --- a/lib/MellowPlayer/Presentation/ViewModels/StreamingServices/StreamingServicesControllerViewModel.hpp +++ b/lib/MellowPlayer/Presentation/ViewModels/StreamingServices/StreamingServicesControllerViewModel.hpp @@ -31,9 +31,8 @@ namespace MellowPlayer::Presentation Q_PROPERTY(int currentIndex READ getCurrentIndex NOTIFY currentIndexChanged) Q_PROPERTY(bool isCurrentServiceRunning READ isCurrentServiceRunning NOTIFY isCurrentServiceRunningChanged) public: - StreamingServicesControllerViewModel(Application::StreamingServicesController &streamingServices, - Application::Players &players, Application::Settings &settings, - Application::IWorkDispatcher &workDispatcher, + StreamingServicesControllerViewModel(Application::StreamingServicesController &streamingServices, Application::Players &players, + Application::Settings &settings, Application::IWorkDispatcher &workDispatcher, Application::IStreamingServiceCreator &streamingServiceCreator, Application::ICommandLineParser &commandLineParser); void initialize(); diff --git a/lib/MellowPlayer/Presentation/ViewModels/ThemeViewModel.cpp b/lib/MellowPlayer/Presentation/ViewModels/ThemeViewModel.cpp index 526501ba..3d743761 100644 --- a/lib/MellowPlayer/Presentation/ViewModels/ThemeViewModel.cpp +++ b/lib/MellowPlayer/Presentation/ViewModels/ThemeViewModel.cpp @@ -11,8 +11,7 @@ using namespace MellowPlayer::Application; using namespace MellowPlayer::Application; using namespace MellowPlayer::Presentation; -ThemeViewModel::ThemeViewModel(StreamingServicesController &streamingServices, Settings &settings, - IThemeLoader &themeLoader) +ThemeViewModel::ThemeViewModel(StreamingServicesController &streamingServices, Settings &settings, IThemeLoader &themeLoader) : streamingServices(streamingServices), loader(themeLoader), accentColorSetting(settings.get(SettingKey::APPEARANCE_ACCENT)), @@ -25,8 +24,7 @@ ThemeViewModel::ThemeViewModel(StreamingServicesController &streamingServices, S secondaryForegroundSetting(settings.get(SettingKey::APPEARANCE_SECONDARY_FOREGROUND)), currentTheme(getCustomTheme()) { - connect(&streamingServices, &StreamingServicesController::currentChanged, this, - &ThemeViewModel::onCurrentServiceChanged); + connect(&streamingServices, &StreamingServicesController::currentChanged, this, &ThemeViewModel::onCurrentServiceChanged); connect(&accentColorSetting, &Setting::valueChanged, this, &ThemeViewModel::update); connect(&themeSetting, &Setting::valueChanged, this, &ThemeViewModel::update); connect(&backgroundSetting, &Setting::valueChanged, this, &ThemeViewModel::update); diff --git a/lib/MellowPlayer/Presentation/ViewModels/UpdaterViewModel.cpp b/lib/MellowPlayer/Presentation/ViewModels/UpdaterViewModel.cpp index c7f5da2c..8db382db 100644 --- a/lib/MellowPlayer/Presentation/ViewModels/UpdaterViewModel.cpp +++ b/lib/MellowPlayer/Presentation/ViewModels/UpdaterViewModel.cpp @@ -10,16 +10,12 @@ UpdaterViewModel::UpdaterViewModel(Updater &updater) : updater_(updater) connect(&updater, &Updater::noUpdateAvailable, this, &UpdaterViewModel::onNoUpdateAvailable); connect(&updater, &Updater::statusChanged, this, &UpdaterViewModel::statusChanged); connect(&updater, &Updater::statusChanged, this, &UpdaterViewModel::busyChanged); - connect(&updater, &Updater::statusChanged, this, &UpdaterViewModel::updateMessage); + connect(&updater, &Updater::progressUpdated, this, &UpdaterViewModel::onProgressUpdated); + connect(&updater, &Updater::installed, this, &UpdaterViewModel::onInstalled); emit statusChanged(); emit busyChanged(); } -QString UpdaterViewModel::getMessage() const -{ - return message_; -} - bool UpdaterViewModel::isVisible() const { return visible_; @@ -30,7 +26,7 @@ bool UpdaterViewModel::isInstallEnabled() const return installEnabled_; } -int UpdaterViewModel::getProgress() const +double UpdaterViewModel::getProgress() const { return progress_; } @@ -49,10 +45,20 @@ void UpdaterViewModel::check() void UpdaterViewModel::install() { setInstallEnabled(false); + setRestartEnabled(false); setProgress(-1); updater_.install(); } +void UpdaterViewModel::restart() +{ + setInstallEnabled(false); + setRestartEnabled(false); + setProgress(-1); + setVisible(false); + updater_.restart(); +} + void UpdaterViewModel::setVisible(bool visible) { if (visible_ == visible) @@ -71,7 +77,7 @@ void UpdaterViewModel::setInstallEnabled(bool enabled) emit installEnabledChanged(); } -void UpdaterViewModel::setProgress(int progress) +void UpdaterViewModel::setProgress(double progress) { if (progress_ == progress) return; @@ -83,25 +89,18 @@ void UpdaterViewModel::setProgress(int progress) void UpdaterViewModel::onUpdateAvailable() { setInstallEnabled(updater_.canInstall()); + setRestartEnabled(false); setProgress(-1); setVisible(true); - updateMessage(); + ; } void UpdaterViewModel::onNoUpdateAvailable() { setInstallEnabled(false); + setRestartEnabled(false); setProgress(-1); setVisible(false); - updateMessage(); -} - -void UpdaterViewModel::setMessage(const QString &message) -{ - if (message_ == message) - return; - message_ = message; - emit messageChanged(); } QString UpdaterViewModel::getUrl() const @@ -119,14 +118,27 @@ QString UpdaterViewModel::getStatusString() const bool UpdaterViewModel::isBusy() const { - return updater_.getStatus() != Updater::Status::None; + return updater_.getStatus() == Updater::Status::Checking || updater_.getStatus() == Updater::Status::Downloading + || updater_.getStatus() == Updater::Status::Installing; } -void UpdaterViewModel::updateMessage() +void UpdaterViewModel::onProgressUpdated(double progress) +{ + setProgress(progress); +} +bool UpdaterViewModel::isRestartEnabled() const { - if (updater_.getStatus() == Updater::Status::None && updater_.isUpdateAvailable()) { - setMessage( - tr("A new version of MellowPlayer is available (%1)").arg(updater_.getLatestRelease()->getName())); - } else - setMessage(getStatusString()); + return restartEnabled_; +} +void UpdaterViewModel::setRestartEnabled(bool enabled) +{ + if (restartEnabled_ != enabled) { + restartEnabled_ = enabled; + emit restartEnabledChanged(); + } +} +void UpdaterViewModel::onInstalled() +{ + setInstallEnabled(false); + setRestartEnabled(true); } diff --git a/lib/MellowPlayer/Presentation/ViewModels/UpdaterViewModel.hpp b/lib/MellowPlayer/Presentation/ViewModels/UpdaterViewModel.hpp index d289b9c4..6dcda3d9 100644 --- a/lib/MellowPlayer/Presentation/ViewModels/UpdaterViewModel.hpp +++ b/lib/MellowPlayer/Presentation/ViewModels/UpdaterViewModel.hpp @@ -8,51 +8,52 @@ namespace MellowPlayer::Presentation class UpdaterViewModel : public QObject { Q_OBJECT - Q_PROPERTY(QString message READ getMessage NOTIFY messageChanged) Q_PROPERTY(QString url READ getUrl CONSTANT) Q_PROPERTY(QString status READ getStatusString NOTIFY statusChanged) Q_PROPERTY(bool busy READ isBusy NOTIFY busyChanged) Q_PROPERTY(bool visible READ isVisible NOTIFY visibleChanged) Q_PROPERTY(bool installEnabled READ isInstallEnabled NOTIFY installEnabledChanged) - Q_PROPERTY(int progress READ getProgress NOTIFY progressChanged) + Q_PROPERTY(bool restartEnabled READ isRestartEnabled NOTIFY restartEnabledChanged) + Q_PROPERTY(double progress READ getProgress NOTIFY progressChanged) public: UpdaterViewModel(Application::Updater &updater); - QString getMessage() const; QString getUrl() const; QString getStatusString() const; bool isBusy() const; bool isVisible() const; bool isInstallEnabled() const; - int getProgress() const; + bool isRestartEnabled() const; + double getProgress() const; Q_INVOKABLE void close(); Q_INVOKABLE void check(); Q_INVOKABLE void install(); + Q_INVOKABLE void restart(); signals: - void messageChanged(); void visibleChanged(); void installEnabledChanged(); + void restartEnabledChanged(); void progressChanged(); void statusChanged(); void busyChanged(); private slots: - void setMessage(const QString &message); void setVisible(bool visible); void setInstallEnabled(bool enabled); - void setProgress(int progress); + void setRestartEnabled(bool enabled); + void setProgress(double progress); void onUpdateAvailable(); void onNoUpdateAvailable(); - void updateMessage(); + void onProgressUpdated(double progress); + void onInstalled(); private: Application::Updater &updater_; - QString message_; bool visible_ = false; bool installEnabled_ = false; - int progress_ = -1; - bool progressVisible_ = false; + bool restartEnabled_ = false; + double progress_ = -1; }; } diff --git a/lib/MellowPlayer/Presentation/Views/MellowPlayer/Controls/MainToolBar.qml b/lib/MellowPlayer/Presentation/Views/MellowPlayer/Controls/MainToolBar.qml index 1a626948..16bd7128 100644 --- a/lib/MellowPlayer/Presentation/Views/MellowPlayer/Controls/MainToolBar.qml +++ b/lib/MellowPlayer/Presentation/Views/MellowPlayer/Controls/MainToolBar.qml @@ -371,6 +371,8 @@ ToolBar { ProgressBar { anchors{ bottom: parent.bottom; horizontalCenter: parent.left; right: parent.right } indeterminate: _updater.progress == -1 + from: 0; to: 100 + value: _updater.progress visible: _updater.busy } } diff --git a/lib/MellowPlayer/Presentation/Views/MellowPlayer/Controls/UpdateToolBar.qml b/lib/MellowPlayer/Presentation/Views/MellowPlayer/Controls/UpdateToolBar.qml index c6d98e44..0a879352 100644 --- a/lib/MellowPlayer/Presentation/Views/MellowPlayer/Controls/UpdateToolBar.qml +++ b/lib/MellowPlayer/Presentation/Views/MellowPlayer/Controls/UpdateToolBar.qml @@ -8,7 +8,6 @@ import MellowPlayer 3.0 ToolBar { id: updateToolBar - enabled: !_updater.busy height: 0 transform: Scale { id: scaleTransform @@ -44,7 +43,7 @@ ToolBar { } Label { - text: _updater.message + text: _updater.status font.pixelSize: 16 } @@ -61,10 +60,18 @@ ToolBar { ToolButton { highlighted: true text: "Install" + enabled: !_updater.busy onClicked: _updater.install() visible: _updater.installEnabled } + ToolButton { + highlighted: true + text: "Restart" + onClicked: _updater.restart() + visible: _updater.restartEnabled + } + ToolButton { hoverEnabled: true text: MaterialIcons.icon_close @@ -79,6 +86,8 @@ ToolBar { ProgressBar { anchors{ bottom: parent.bottom; left: parent.left; right: parent.right } indeterminate: _updater.progress == -1 + from: 0; to: 100 + value: _updater.progress visible: _updater.busy } } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 887d8679..6e7fa5ca 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -21,7 +21,7 @@ elseif(UNIX) find_package(X11) target_link_libraries(${PROJECT_NAME} ${X11_LIBRARIES} Qt5::DBus) if (STATIC_LIBSTDCPP) - message(WARNING "Linking statically to libgcc and libstdc++") + message(STATUS "Linking statically to libgcc and libstdc++") set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++") endif() if(USE_LIBNOTIFY) diff --git a/src/DI.hpp b/src/DI.hpp index 0cc7bf03..1b21c8a8 100644 --- a/src/DI.hpp +++ b/src/DI.hpp @@ -57,6 +57,7 @@ #ifdef Q_OS_LINUX #include #include +#include #endif using namespace MellowPlayer::Application; @@ -79,10 +80,8 @@ class ScopedScope template using is_referable = typename di::wrappers::shared::template is_referable; - template ().get())>> - static decltype(di::wrappers::shared{ - std::shared_ptr{std::shared_ptr{di::aux::declval().get()}}}) + template ().get())>> + static decltype(di::wrappers::shared{std::shared_ptr{std::shared_ptr{di::aux::declval().get()}}}) try_create(const TProvider &); template @@ -120,9 +119,7 @@ template struct constructor_impl { template ::value, - int> = 0> + std::enable_if_t::value, int> = 0> auto operator()(const TInjector &injector, const T &) const { return new typename T::expected{injector.template create()...}; @@ -137,29 +134,23 @@ struct constructor : constructor_impl auto defaultInjector = [](ScopedScope &scope) { return di::make_injector( - di::bind().to().in(scope), - di::bind().in(di::singleton).to(), + di::bind().to().in(scope), di::bind().in(di::singleton).to(), di::bind().to().in(scope), - di::bind().to().in(scope), - di::bind().to().in(scope), - di::bind().to().in(scope), - di::bind().to().in(scope), - di::bind().to().in(scope), - di::bind().to().in(scope), di::bind().to().in(scope), - di::bind().to().in(scope), + di::bind().to().in(scope), di::bind().to().in(scope), + di::bind().to().in(scope), di::bind().to().in(scope), + di::bind().to().in(scope), di::bind().to().in(scope), + di::bind().to().in(scope), di::bind().to().in(scope), di::bind().to().in(scope), di::bind().to().in(scope), - di::bind().to().in(scope), - di::bind().to().in(scope), - di::bind().to().in(scope), - di::bind().to().in(scope), di::bind().to().in(scope), - di::bind().to().in(scope)); + di::bind().to().in(scope), di::bind().to().in(scope), + di::bind().to().in(scope), di::bind().to().in(scope), + di::bind().to().in(scope)); }; auto platformInjector = [](ScopedScope &scope) { #ifdef Q_OS_LINUX - return di::make_injector(di::bind().to().in(scope), - di::bind().to().in(scope)); + return di::make_injector(di::bind().to().in(scope), di::bind().to().in(scope), + di::bind().to().in(scope)); #else return di::make_injector(di::bind().to().in(scope)); #endif diff --git a/src/main.cpp b/src/main.cpp index 13b0eebb..0815d3d8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -38,9 +38,8 @@ int main(int argc, char **argv) LOG_INFO(LoggingManager::instance().getLogger("main"), QString("MellowPlayer %1 - %2").arg(QString(MELLOWPLAYER_VERSION)).arg(qtApp.getBuildInfo())); - auto injector = - di::make_injector(di::bind().to(qtApp), di::bind().to(commandLineParser), - defaultInjector(scope), platformInjector(scope), notificationPresenterInjector(scope)); + auto injector = di::make_injector(di::bind().to(qtApp), di::bind().to(commandLineParser), + defaultInjector(scope), platformInjector(scope), notificationPresenterInjector(scope)); #ifdef QT_DEBUG IApplication &app = injector.create(); diff --git a/tests/IntegrationTests/Infrastructure/AlbumArt/AlbumArtDownloaderTests.cpp b/tests/IntegrationTests/Infrastructure/AlbumArt/AlbumArtDownloaderTests.cpp index 38dfa031..a5dd9b8f 100644 --- a/tests/IntegrationTests/Infrastructure/AlbumArt/AlbumArtDownloaderTests.cpp +++ b/tests/IntegrationTests/Infrastructure/AlbumArt/AlbumArtDownloaderTests.cpp @@ -13,8 +13,7 @@ TEST_CASE("AlbumArtDownloaderTests") SECTION("download will take some time and a file will be created") { - REQUIRE(albumArtDownloader.download("https://gitlab.com/uploads/project/avatar/2312266/mellowplayer.svg", - "mellowplayer.svg")); + REQUIRE(albumArtDownloader.download("https://gitlab.com/uploads/project/avatar/2312266/mellowplayer.svg", "mellowplayer.svg")); if (downloadFinishedSpy.wait(2000)) { REQUIRE(downloadFinishedSpy.count() == 1); auto path = downloadFinishedSpy[0][0].toString(); diff --git a/tests/IntegrationTests/Infrastructure/QtConcurrentWorkDispatcherTests.cpp b/tests/IntegrationTests/Infrastructure/QtConcurrentWorkDispatcherTests.cpp index 543607dd..24023005 100644 --- a/tests/IntegrationTests/Infrastructure/QtConcurrentWorkDispatcherTests.cpp +++ b/tests/IntegrationTests/Infrastructure/QtConcurrentWorkDispatcherTests.cpp @@ -26,7 +26,7 @@ TEST_CASE("QtConcurrentWorkDispatcherTests") bool finished = false; workDispatcher.delayInvoke(100, [&]() { finished = true; }); REQUIRE(!finished); - QTest::qWait(200); + QTest::qWait(1000); REQUIRE(finished); } } diff --git a/tests/IntegrationTests/Infrastructure/StreamingServices/StreamingServiceWatcherTests.cpp b/tests/IntegrationTests/Infrastructure/StreamingServices/StreamingServiceWatcherTests.cpp index 63ac0fe5..e312739f 100644 --- a/tests/IntegrationTests/Infrastructure/StreamingServices/StreamingServiceWatcherTests.cpp +++ b/tests/IntegrationTests/Infrastructure/StreamingServices/StreamingServiceWatcherTests.cpp @@ -13,8 +13,7 @@ using namespace MellowPlayer::Infrastructure; TEST_CASE("StreamingServiceWatcherTests") { StreamingServiceCreator creator; - auto pluginDir = creator.create("TestService", "https://test-service.com", "MellowPlayer.Tests", - "https://travis-ci.org/MellowPlayer"); + auto pluginDir = creator.create("TestService", "https://test-service.com", "MellowPlayer.Tests", "https://travis-ci.org/MellowPlayer"); REQUIRE(QDir(pluginDir).exists()); StreamingServiceMetadata metadata; diff --git a/tests/Mocks/FakePlatformUpdater.hpp b/tests/Mocks/FakePlatformUpdater.hpp index 1156c2ee..43724927 100644 --- a/tests/Mocks/FakePlatformUpdater.hpp +++ b/tests/Mocks/FakePlatformUpdater.hpp @@ -7,8 +7,7 @@ namespace MellowPlayer::Tests class FakePlatformUpdater : public Application::AbstractPlatformUpdater { public: - FakePlatformUpdater(Application::IFileDownloader &fileDownloader) - : Application::AbstractPlatformUpdater(fileDownloader) + FakePlatformUpdater(Application::IFileDownloader &fileDownloader) : Application::AbstractPlatformUpdater(fileDownloader) { } diff --git a/tests/Mocks/InMemoryListeningHistoryDataProvider.hpp b/tests/Mocks/InMemoryListeningHistoryDataProvider.hpp index a489240b..3a424aea 100644 --- a/tests/Mocks/InMemoryListeningHistoryDataProvider.hpp +++ b/tests/Mocks/InMemoryListeningHistoryDataProvider.hpp @@ -31,8 +31,7 @@ class InMemoryListeningHistoryDataProvider : public MellowPlayer::Application::I QList toRemove; for (int i = 0; i < entries.count(); ++i) { auto &entry = entries.at(i); - if ((filterKey == "id" && entry.id == filterValue.toInt()) - || (filterKey == "serviceName" && entry.serviceName == filterValue)) + if ((filterKey == "id" && entry.id == filterValue.toInt()) || (filterKey == "serviceName" && entry.serviceName == filterValue)) toRemove.append(entry); } for (auto &entry : toRemove) diff --git a/tests/Mocks/StreamingServiceLoaderMock.cpp b/tests/Mocks/StreamingServiceLoaderMock.cpp index 59ab53c3..98668b66 100644 --- a/tests/Mocks/StreamingServiceLoaderMock.cpp +++ b/tests/Mocks/StreamingServiceLoaderMock.cpp @@ -1,4 +1,3 @@ #include "StreamingServiceLoaderMock.hpp" -Theme StreamingServiceLoaderMock::DEFAULT_theme = {"#ff00ff", "#00ff00", "#ff0000", "#ffff00", - "#faebdc", "#fedcba", "#abcdef"}; \ No newline at end of file +Theme StreamingServiceLoaderMock::DEFAULT_theme = {"#ff00ff", "#00ff00", "#ff0000", "#ffff00", "#faebdc", "#fedcba", "#abcdef"}; \ No newline at end of file diff --git a/tests/UnitTests/Application/Updater/Github/GithubReleaseQuerierTests.cpp b/tests/UnitTests/Application/Updater/Github/GithubReleaseQuerierTests.cpp index a0210f2b..a2441761 100644 --- a/tests/UnitTests/Application/Updater/Github/GithubReleaseQuerierTests.cpp +++ b/tests/UnitTests/Application/Updater/Github/GithubReleaseQuerierTests.cpp @@ -13,8 +13,7 @@ SCENARIO("get latest github release") querier.setChannel(UpdateChannel::Stable); const Release *latestRelease = nullptr; - QObject::connect(&querier, &GithubReleaseQuerier::latestReceived, - [&](const Release *release) { latestRelease = release; }); + QObject::connect(&querier, &GithubReleaseQuerier::latestReceived, [&](const Release *release) { latestRelease = release; }); REQUIRE(latestRelease == nullptr); WHEN("getLatest is called") @@ -36,8 +35,7 @@ SCENARIO("get latest github release") querier.setChannel(UpdateChannel::Beta); const Release *latestRelease = nullptr; - QObject::connect(&querier, &GithubReleaseQuerier::latestReceived, - [&](const Release *release) { latestRelease = release; }); + QObject::connect(&querier, &GithubReleaseQuerier::latestReceived, [&](const Release *release) { latestRelease = release; }); REQUIRE(latestRelease == nullptr); WHEN("getLatest is called") @@ -59,8 +57,7 @@ SCENARIO("get latest github release") querier.setChannel(UpdateChannel::Continuous); const Release *latestRelease = nullptr; - QObject::connect(&querier, &GithubReleaseQuerier::latestReceived, - [&](const Release *release) { latestRelease = release; }); + QObject::connect(&querier, &GithubReleaseQuerier::latestReceived, [&](const Release *release) { latestRelease = release; }); REQUIRE(latestRelease == nullptr); WHEN("getLatest is called") diff --git a/tests/UnitTests/Application/Updater/ReleaseTests.cpp b/tests/UnitTests/Application/Updater/ReleaseTests.cpp index 60af5e2e..b2267da6 100644 --- a/tests/UnitTests/Application/Updater/ReleaseTests.cpp +++ b/tests/UnitTests/Application/Updater/ReleaseTests.cpp @@ -53,8 +53,8 @@ SCENARIO("releases validity can be tested") GIVEN("a release with a version, a valid date, a description but no assets") { - Release release("https://github.com/ColinDuquesnoy/MellowPlayer/releases/tag/2.95.0", "2.95.0", - QDate::fromString("2117-07-15", Qt::ISODate), AssetList()); + Release release("https://github.com/ColinDuquesnoy/MellowPlayer/releases/tag/2.95.0", "2.95.0", QDate::fromString("2117-07-15", Qt::ISODate), + AssetList()); WHEN("isValid is called") { @@ -74,8 +74,8 @@ SCENARIO("releases validity can be tested") assets << Asset("MellowPlayer.AppImage", "MellowPlayer.AppImage"); assets << Asset("MellowPlayer.dmg", "MellowPlayer.dmg"); // windows installer is missing. - Release release("https://github.com/ColinDuquesnoy/MellowPlayer/releases/tag/2.95.0", "2.95.0", - QDate::fromString("2117-07-15", Qt::ISODate), assets); + Release release("https://github.com/ColinDuquesnoy/MellowPlayer/releases/tag/2.95.0", "2.95.0", QDate::fromString("2117-07-15", Qt::ISODate), + assets); REQUIRE(release.getAssets().count() == 2); WHEN("isValid is called") @@ -100,8 +100,8 @@ SCENARIO("releases validity can be tested") "MellowPlayer.dmg"); assets << Asset("MellowPlayer_Setup.exe", "https://github.com/ColinDuquesnoy/MellowPlayer/releases/" "tag/2.95.0/MellowPlayer_Setup.exe"); - Release release("https://github.com/ColinDuquesnoy/MellowPlayer/releases/tag/2.95.0", "2.95.0", - QDate::fromString("2017-07-15", Qt::ISODate), assets); + Release release("https://github.com/ColinDuquesnoy/MellowPlayer/releases/tag/2.95.0", "2.95.0", QDate::fromString("2017-07-15", Qt::ISODate), + assets); WHEN("isValid is called") { diff --git a/tests/UnitTests/Application/Updater/UpdaterTests.cpp b/tests/UnitTests/Application/Updater/UpdaterTests.cpp index 88573ecf..3e4433a6 100644 --- a/tests/UnitTests/Application/Updater/UpdaterTests.cpp +++ b/tests/UnitTests/Application/Updater/UpdaterTests.cpp @@ -32,7 +32,7 @@ SCENARIO("check for stable updates") THEN("update to version version 2.2.5 is available") { - REQUIRE(updater.getStatus() == Updater::Status::None); + REQUIRE(updater.getStatus() == Updater::Status::UpdateAvailable); REQUIRE(updater.isUpdateAvailable()); REQUIRE(updater.getLatestRelease()->getName() == "2.2.5"); REQUIRE(updateAvailableSpy.count() == 1); diff --git a/tests/UnitTests/Infrastructure/Applications/CoreApplicationTests.cpp b/tests/UnitTests/Infrastructure/Applications/CoreApplicationTests.cpp index b36b13a2..3b984948 100644 --- a/tests/UnitTests/Infrastructure/Applications/CoreApplicationTests.cpp +++ b/tests/UnitTests/Infrastructure/Applications/CoreApplicationTests.cpp @@ -22,8 +22,8 @@ TEST_CASE("CoreApplicationTests", "[UnitTest]") auto serviceLoaderMock = StreamingServiceLoaderMock::get(); auto watcherMock = StreamingServiceWatcherMock::get(); StreamingServicesController streamingServices(serviceLoaderMock.get(), watcherMock.get()); - CoreApplication app(qtAppMock.get(), mainWindowMock.get(), streamingServices, hotkeysMock.get(), - systemTrayIconMock.get(), notificationServiceMock.get()); + CoreApplication app(qtAppMock.get(), mainWindowMock.get(), streamingServices, hotkeysMock.get(), systemTrayIconMock.get(), + notificationServiceMock.get()); SECTION("initialize") { diff --git a/tests/UnitTests/Infrastructure/Applications/LinuxApplicationTest.cpp b/tests/UnitTests/Infrastructure/Applications/LinuxApplicationTest.cpp index 934f9de6..624b1da7 100644 --- a/tests/UnitTests/Infrastructure/Applications/LinuxApplicationTest.cpp +++ b/tests/UnitTests/Infrastructure/Applications/LinuxApplicationTest.cpp @@ -26,8 +26,8 @@ TEST_CASE("LinuxApplicationTests", "[UnitTest]") auto watcherMock = StreamingServiceWatcherMock::get(); StreamingServicesController streamingServices(serviceLoaderMock.get(), watcherMock.get()); auto systemTrayIconMock = SystemTrayIconMock::get(); - LinuxApplication app(qtAppMock.get(), mainWindowMock.get(), streamingServices, hotkeysMock.get(), - systemTrayIconMock.get(), notificationServiceMock.get(), mprisMock.get()); + LinuxApplication app(qtAppMock.get(), mainWindowMock.get(), streamingServices, hotkeysMock.get(), systemTrayIconMock.get(), + notificationServiceMock.get(), mprisMock.get()); SECTION("initialize") { diff --git a/tests/UnitTests/Infrastructure/StreamingServices/StreamingServiceCreatorTests.cpp b/tests/UnitTests/Infrastructure/StreamingServices/StreamingServiceCreatorTests.cpp index dff03a67..0fb30b0d 100644 --- a/tests/UnitTests/Infrastructure/StreamingServices/StreamingServiceCreatorTests.cpp +++ b/tests/UnitTests/Infrastructure/StreamingServices/StreamingServiceCreatorTests.cpp @@ -11,8 +11,7 @@ using namespace MellowPlayer::Infrastructure; TEST_CASE("StreamingServiceCreatorTests") { StreamingServiceCreator creator; - auto pluginDir = creator.create("TestService", "https://test-service.com", "MellowPlayer.Tests", - "https://travis-ci.org/MellowPlayer"); + auto pluginDir = creator.create("TestService", "https://test-service.com", "MellowPlayer.Tests", "https://travis-ci.org/MellowPlayer"); REQUIRE(QDir(pluginDir).exists()); QList files; files.append(QFileInfo(pluginDir + "/" + "integration.js")); diff --git a/tests/UnitTests/Presentation/ViewModels/StreamingServices/StreamingServicesControllerViewModelTests.cpp b/tests/UnitTests/Presentation/ViewModels/StreamingServices/StreamingServicesControllerViewModelTests.cpp index 4157eeb2..ace1d190 100644 --- a/tests/UnitTests/Presentation/ViewModels/StreamingServices/StreamingServicesControllerViewModelTests.cpp +++ b/tests/UnitTests/Presentation/ViewModels/StreamingServices/StreamingServicesControllerViewModelTests.cpp @@ -25,8 +25,8 @@ TEST_CASE("StreamingServicesControllerViewModel", "[UnitTest]") IWorkDispatcher &workDispatcher = pool.getWorkDispatcher(); auto creatorMock = StreamingServiceCreatorMock::get(); auto commandLineParserMock = CommandLineParserMock::get(); - StreamingServicesControllerViewModel viewModel(streamingServices, players, settings, workDispatcher, - creatorMock.get(), commandLineParserMock.get()); + StreamingServicesControllerViewModel viewModel(streamingServices, players, settings, workDispatcher, creatorMock.get(), + commandLineParserMock.get()); viewModel.initialize(); viewModel.reload(); @@ -110,8 +110,8 @@ TEST_CASE("StreamingServicesControllerViewModel", "[UnitTest]") { settings.get(SettingKey::PRIVATE_CURRENT_SERVICE).setValue(""); When(Method(commandLineParserMock, getService)).AlwaysReturn("Deezer"); - StreamingServicesControllerViewModel viewModelWithCmdLine(streamingServices, players, settings, workDispatcher, - creatorMock.get(), commandLineParserMock.get()); + StreamingServicesControllerViewModel viewModelWithCmdLine(streamingServices, players, settings, workDispatcher, creatorMock.get(), + commandLineParserMock.get()); REQUIRE(viewModelWithCmdLine.getCurrentIndex() == -1); viewModelWithCmdLine.initialize(); viewModelWithCmdLine.reload(); diff --git a/tests/UnitTests/Presentation/ViewModels/UpdaterViewModelTests.cpp b/tests/UnitTests/Presentation/ViewModels/UpdaterViewModelTests.cpp index d25545a8..1f76de66 100644 --- a/tests/UnitTests/Presentation/ViewModels/UpdaterViewModelTests.cpp +++ b/tests/UnitTests/Presentation/ViewModels/UpdaterViewModelTests.cpp @@ -19,7 +19,6 @@ SCENARIO("check for updates") REQUIRE(!viewModel.isBusy()); REQUIRE(!viewModel.isVisible()); - REQUIRE(viewModel.getMessage().isEmpty()); REQUIRE(viewModel.getUrl().isEmpty()); REQUIRE(viewModel.getStatusString().isEmpty()); REQUIRE(!viewModel.isInstallEnabled()); @@ -33,7 +32,6 @@ SCENARIO("check for updates") THEN("an update is available") { REQUIRE(viewModel.isVisible()); - REQUIRE(!viewModel.getMessage().isEmpty()); REQUIRE(!viewModel.getUrl().isEmpty()); AND_WHEN("closing the pane") @@ -44,7 +42,6 @@ SCENARIO("check for updates") { REQUIRE(!viewModel.isVisible()); - REQUIRE(!viewModel.getMessage().isEmpty()); REQUIRE(!viewModel.getUrl().isEmpty()); } } @@ -69,7 +66,6 @@ SCENARIO("check for updates") REQUIRE(!viewModel.isBusy()); REQUIRE(!viewModel.isVisible()); - REQUIRE(viewModel.getMessage().isEmpty()); REQUIRE(viewModel.getUrl().isEmpty()); REQUIRE(viewModel.getStatusString().isEmpty()); REQUIRE(!viewModel.isInstallEnabled()); @@ -83,7 +79,6 @@ SCENARIO("check for updates") THEN("no update is available") { REQUIRE(!viewModel.isVisible()); - REQUIRE(viewModel.getMessage().isEmpty()); REQUIRE(viewModel.getUrl().isEmpty()); } } diff --git a/tests/Utils/DependencyPool.cpp b/tests/Utils/DependencyPool.cpp index 056a323c..1f408b30 100644 --- a/tests/Utils/DependencyPool.cpp +++ b/tests/Utils/DependencyPool.cpp @@ -55,8 +55,7 @@ StreamingServicesController &DependencyPool::getStreamingServicesController() static auto streamingServiceLoaderMock = StreamingServiceLoaderMock::get(); static auto streamingServiceWatcherMock = StreamingServiceWatcherMock::get(); if (pStreamingServicesController == nullptr) { - pStreamingServicesController = - make_unique(streamingServiceLoaderMock.get(), streamingServiceWatcherMock.get()); + pStreamingServicesController = make_unique(streamingServiceLoaderMock.get(), streamingServiceWatcherMock.get()); pStreamingServicesController->load(); } return *pStreamingServicesController; @@ -66,8 +65,7 @@ StreamingServicesControllerViewModel &DependencyPool::getStreamingServicesContro { if (pStreamingServicesControllerViewModel == nullptr) pStreamingServicesControllerViewModel = make_unique( - getStreamingServicesController(), getPlayers(), getSettings(), getWorkDispatcher(), - getStreamingServicesCreator(), getCommandLineParser()); + getStreamingServicesController(), getPlayers(), getSettings(), getWorkDispatcher(), getStreamingServicesCreator(), getCommandLineParser()); return *pStreamingServicesControllerViewModel; } @@ -117,8 +115,7 @@ ListeningHistoryViewModel &DependencyPool::getListeningHistoryViewModel() ListeningHistory &DependencyPool::getListeningHistory() { if (pListeningHistory == nullptr) - pListeningHistory = - make_unique(*dataProvider, getCurrentPlayer(), getWorkDispatcher(), getSettings()); + pListeningHistory = make_unique(*dataProvider, getCurrentPlayer(), getWorkDispatcher(), getSettings()); return *pListeningHistory; } @@ -169,8 +166,7 @@ MainWindowViewModel &DependencyPool::getMainWindowViewModel() auto ¤tPlayer = getCurrentPlayer(); auto &settings = getSettings(); - pMainWindowViewModel = make_unique(streamingServices, listeningHistory, theme, updater, - qtApp, currentPlayer, settings); + pMainWindowViewModel = make_unique(streamingServices, listeningHistory, theme, updater, qtApp, currentPlayer, settings); } return *pMainWindowViewModel; @@ -179,8 +175,8 @@ MainWindowViewModel &DependencyPool::getMainWindowViewModel() Notifier &DependencyPool::getNotifier() { if (pNotifier == nullptr) - pNotifier = make_unique(getCurrentPlayer(), getLocalAlbumArt(), getNotificationPresenter(), - getStreamingServicesController(), getSettings()); + pNotifier = + make_unique(getCurrentPlayer(), getLocalAlbumArt(), getNotificationPresenter(), getStreamingServicesController(), getSettings()); return *pNotifier; }