Inform about updates
This commit is contained in:
parent
493262876f
commit
3847c8d61b
@ -51,6 +51,10 @@ Manager::Manager()
|
|||||||
tray_.get(), [this] {
|
tray_.get(), [this] {
|
||||||
tray_->showInformation(QObject::tr("Update completed"));
|
tray_->showInformation(QObject::tr("Update completed"));
|
||||||
});
|
});
|
||||||
|
QObject::connect(updater_.get(), &update::Loader::updatesAvailable, //
|
||||||
|
tray_.get(), [this] {
|
||||||
|
tray_->showInformation(QObject::tr("Updates available"));
|
||||||
|
});
|
||||||
#ifdef DEVELOP
|
#ifdef DEVELOP
|
||||||
updater_->checkForUpdates();
|
updater_->checkForUpdates();
|
||||||
#endif
|
#endif
|
||||||
|
@ -133,6 +133,8 @@ void Loader::handleReply(QNetworkReply *reply)
|
|||||||
if (isUpdatesReply) {
|
if (isUpdatesReply) {
|
||||||
SOFT_ASSERT(model_, return );
|
SOFT_ASSERT(model_, return );
|
||||||
model_->parse(replyData);
|
model_->parse(replyData);
|
||||||
|
if (model_->hasUpdates())
|
||||||
|
emit updatesAvailable();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -309,6 +311,22 @@ void Model::updateStates()
|
|||||||
emitColumnsChanged(QModelIndex());
|
emitColumnsChanged(QModelIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Model::hasUpdates() const
|
||||||
|
{
|
||||||
|
if (!root_)
|
||||||
|
return false;
|
||||||
|
return hasUpdates(*root_);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Model::hasUpdates(const Model::Component &component) const
|
||||||
|
{
|
||||||
|
for (const auto &i : component.children) {
|
||||||
|
if (i->state == State::UpdateAvailable || hasUpdates(*i))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void Model::updateState(Model::Component &component)
|
void Model::updateState(Model::Component &component)
|
||||||
{
|
{
|
||||||
if (!component.files.empty()) {
|
if (!component.files.empty()) {
|
||||||
|
@ -47,6 +47,7 @@ public:
|
|||||||
void setExpansions(const std::map<QString, QString>& expansions);
|
void setExpansions(const std::map<QString, QString>& expansions);
|
||||||
UserActions userActions() const;
|
UserActions userActions() const;
|
||||||
void updateStates();
|
void updateStates();
|
||||||
|
bool hasUpdates() const;
|
||||||
|
|
||||||
QModelIndex index(int row, int column,
|
QModelIndex index(int row, int column,
|
||||||
const QModelIndex& parent) const override;
|
const QModelIndex& parent) const override;
|
||||||
@ -74,6 +75,7 @@ private:
|
|||||||
|
|
||||||
std::unique_ptr<Component> parse(const QJsonObject& json) const;
|
std::unique_ptr<Component> parse(const QJsonObject& json) const;
|
||||||
void updateState(Component& component);
|
void updateState(Component& component);
|
||||||
|
bool hasUpdates(const Component& component) const;
|
||||||
void fillUserActions(UserActions& actions, Component& component) const;
|
void fillUserActions(UserActions& actions, Component& component) const;
|
||||||
State currentState(const File& file) const;
|
State currentState(const File& file) const;
|
||||||
QString expanded(const QString& source) const;
|
QString expanded(const QString& source) const;
|
||||||
@ -108,6 +110,7 @@ public:
|
|||||||
Model* model() const;
|
Model* model() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void updatesAvailable();
|
||||||
void updated();
|
void updated();
|
||||||
void error(const QString& error);
|
void error(const QString& error);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user