Hello System update features
This commit is contained in:
parent
afc0332e74
commit
7f17328dd2
@ -108,7 +108,7 @@ void ZeroconfDiscovery::serviceEntryAdded(const QZeroConfService &entry)
|
||||
if (!host) {
|
||||
host = new NymeaHost(m_nymeaHosts);
|
||||
host->setUuid(uuid);
|
||||
qDebug() << "ZeroConf: Adding new host:" << serverName << uuid;
|
||||
// qDebug() << "ZeroConf: Adding new host:" << serverName << uuid;
|
||||
m_nymeaHosts->addHost(host);
|
||||
}
|
||||
host->setName(serverName);
|
||||
@ -124,13 +124,13 @@ void ZeroconfDiscovery::serviceEntryAdded(const QZeroConfService &entry)
|
||||
url.setPort(entry.port());
|
||||
Connection *connection = host->connections()->find(url);
|
||||
if (!connection) {
|
||||
qDebug() << "Zeroconf: Adding new connection to host:" << host->name() << url.toString();
|
||||
// qDebug() << "Zeroconf: Adding new connection to host:" << host->name() << url.toString();
|
||||
QString displayName = QString("%1:%2").arg(url.host()).arg(url.port());
|
||||
connection = new Connection(url, Connection::BearerTypeLan, sslEnabled, displayName);
|
||||
connection->setOnline(true);
|
||||
host->connections()->addConnection(connection);
|
||||
} else {
|
||||
qDebug() << "Zeroconf: Setting connection online:" << host->name() << url.toString();
|
||||
// qDebug() << "Zeroconf: Setting connection online:" << host->name() << url.toString();
|
||||
connection->setOnline(true);
|
||||
}
|
||||
}
|
||||
@ -183,7 +183,7 @@ void ZeroconfDiscovery::serviceEntryRemoved(const QZeroConfService &entry)
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "Zeroconf: Setting connection offline:" << host->name() << url.toString();
|
||||
// qDebug() << "Zeroconf: Setting connection offline:" << host->name() << url.toString();
|
||||
connection->setOnline(false);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -304,7 +304,7 @@ void JsonRpcClient::sendRequest(const QVariantMap &request)
|
||||
{
|
||||
QVariantMap newRequest = request;
|
||||
newRequest.insert("token", m_token);
|
||||
qDebug() << "Sending request" << qUtf8Printable(QJsonDocument::fromVariant(newRequest).toJson());
|
||||
// qDebug() << "Sending request" << qUtf8Printable(QJsonDocument::fromVariant(newRequest).toJson());
|
||||
m_connection->sendData(QJsonDocument::fromVariant(newRequest).toJson(QJsonDocument::Compact) + "\n");
|
||||
}
|
||||
|
||||
|
||||
@ -57,6 +57,11 @@
|
||||
#include "connection/awsclient.h"
|
||||
#include "models/devicemodel.h"
|
||||
#include "system/systemcontroller.h"
|
||||
#include "types/package.h"
|
||||
#include "types/packages.h"
|
||||
#include "types/repository.h"
|
||||
#include "types/repositories.h"
|
||||
#include "models/packagesfiltermodel.h"
|
||||
|
||||
#include <QtQml/qqml.h>
|
||||
|
||||
@ -202,6 +207,11 @@ void registerQmlTypes() {
|
||||
qmlRegisterUncreatableType<RuleActionParamTemplate>(uri, 1, 0, "RuleActionParamTemplate", "Get it from RuleActionParamTemplates");
|
||||
|
||||
qmlRegisterUncreatableType<SystemController>(uri, 1, 0, "SystemController", "Get it from Engine");
|
||||
qmlRegisterUncreatableType<Packages>(uri, 1, 0, "Packages", "Get it from SystemController");
|
||||
qmlRegisterUncreatableType<Package>(uri, 1, 0, "Package", "Get it from Packages");
|
||||
qmlRegisterUncreatableType<Repositories>(uri, 1, 0, "Repositories", "Get it from SystemController");
|
||||
qmlRegisterUncreatableType<Repository>(uri, 1, 0, "Repository", "Get it from Repositories");
|
||||
qmlRegisterType<PackagesFilterModel>(uri, 1, 0, "PackagesFilterModel");
|
||||
}
|
||||
|
||||
#endif // LIBNYMEAAPPCORE_H
|
||||
|
||||
@ -46,6 +46,7 @@ SOURCES += \
|
||||
deviceclasses.cpp \
|
||||
deviceclassesproxy.cpp \
|
||||
devicediscovery.cpp \
|
||||
models/packagesfiltermodel.cpp \
|
||||
vendorsproxy.cpp \
|
||||
pluginsproxy.cpp \
|
||||
interfacesmodel.cpp \
|
||||
@ -108,6 +109,7 @@ HEADERS += \
|
||||
deviceclasses.h \
|
||||
deviceclassesproxy.h \
|
||||
devicediscovery.h \
|
||||
models/packagesfiltermodel.h \
|
||||
vendorsproxy.h \
|
||||
pluginsproxy.h \
|
||||
interfacesmodel.h \
|
||||
|
||||
55
libnymea-app-core/models/packagesfiltermodel.cpp
Normal file
55
libnymea-app-core/models/packagesfiltermodel.cpp
Normal file
@ -0,0 +1,55 @@
|
||||
#include "packagesfiltermodel.h"
|
||||
#include "types/package.h"
|
||||
|
||||
PackagesFilterModel::PackagesFilterModel(QObject *parent): QSortFilterProxyModel(parent)
|
||||
{
|
||||
setSortRole(Packages::RoleDisplayName);
|
||||
sort(0);
|
||||
}
|
||||
|
||||
Packages *PackagesFilterModel::packages() const
|
||||
{
|
||||
return m_packages;
|
||||
}
|
||||
|
||||
void PackagesFilterModel::setPackages(Packages *packages)
|
||||
{
|
||||
if (m_packages != packages) {
|
||||
m_packages = packages;
|
||||
setSourceModel(packages);
|
||||
connect(packages, &Packages::countChanged, this, &PackagesFilterModel::countChanged);
|
||||
emit packagesChanged();
|
||||
emit countChanged();
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
bool PackagesFilterModel::updatesOnly() const
|
||||
{
|
||||
return m_updatesOnly;
|
||||
}
|
||||
|
||||
void PackagesFilterModel::setUpdatesOnly(bool updatesOnly)
|
||||
{
|
||||
if (m_updatesOnly != updatesOnly) {
|
||||
m_updatesOnly = updatesOnly;
|
||||
emit updatesOnlyChanged();
|
||||
invalidateFilter();
|
||||
emit countChanged();
|
||||
}
|
||||
}
|
||||
|
||||
Package *PackagesFilterModel::get(int index) const
|
||||
{
|
||||
return m_packages->get(mapToSource(this->index(index, 0)).row());
|
||||
}
|
||||
|
||||
bool PackagesFilterModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
|
||||
{
|
||||
if (m_updatesOnly) {
|
||||
if (!m_packages->get(source_row)->updateAvailable()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
39
libnymea-app-core/models/packagesfiltermodel.h
Normal file
39
libnymea-app-core/models/packagesfiltermodel.h
Normal file
@ -0,0 +1,39 @@
|
||||
#ifndef PACKAGESFILTERMODEL_H
|
||||
#define PACKAGESFILTERMODEL_H
|
||||
|
||||
#include <QSortFilterProxyModel>
|
||||
#include "types/packages.h"
|
||||
|
||||
class PackagesFilterModel : public QSortFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(Packages* packages READ packages WRITE setPackages NOTIFY packagesChanged)
|
||||
Q_PROPERTY(bool updatesOnly READ updatesOnly WRITE setUpdatesOnly NOTIFY updatesOnlyChanged)
|
||||
Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
|
||||
|
||||
public:
|
||||
explicit PackagesFilterModel(QObject *parent = nullptr);
|
||||
|
||||
Packages* packages() const;
|
||||
void setPackages(Packages *packages);
|
||||
|
||||
bool updatesOnly() const;
|
||||
void setUpdatesOnly(bool updatesOnly);
|
||||
|
||||
Q_INVOKABLE Package* get(int index) const;
|
||||
|
||||
protected:
|
||||
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
|
||||
|
||||
signals:
|
||||
void countChanged();
|
||||
void packagesChanged();
|
||||
void updatesOnlyChanged();
|
||||
|
||||
private:
|
||||
Packages *m_packages;
|
||||
|
||||
bool m_updatesOnly = false;
|
||||
};
|
||||
|
||||
#endif // PACKAGESFILTERMODEL_H
|
||||
@ -1,14 +1,23 @@
|
||||
#include "systemcontroller.h"
|
||||
|
||||
#include "types/package.h"
|
||||
#include "types/repository.h"
|
||||
#include "types/packages.h"
|
||||
#include "types/repositories.h"
|
||||
|
||||
SystemController::SystemController(JsonRpcClient *jsonRpcClient, QObject *parent):
|
||||
JsonHandler(parent),
|
||||
m_jsonRpcClient(jsonRpcClient)
|
||||
{
|
||||
m_jsonRpcClient->registerNotificationHandler(this, "notificationReceived");
|
||||
m_packages = new Packages(this);
|
||||
m_repositories = new Repositories(this);
|
||||
}
|
||||
|
||||
void SystemController::init()
|
||||
{
|
||||
m_packages->clear();
|
||||
m_repositories->clear();
|
||||
if (m_jsonRpcClient->ensureServerVersion("2.0")) {
|
||||
m_jsonRpcClient->sendCommand("System.GetCapabilities", this, "getCapabilitiesResponse");
|
||||
} else {
|
||||
@ -31,48 +40,6 @@ bool SystemController::updateManagementAvailable() const
|
||||
return m_updateManagementAvailable;
|
||||
}
|
||||
|
||||
bool SystemController::updateAvailable() const
|
||||
{
|
||||
return m_updateAvailable;
|
||||
}
|
||||
|
||||
QString SystemController::currentVersion() const
|
||||
{
|
||||
return m_currentVersion;
|
||||
}
|
||||
|
||||
QString SystemController::candidateVersion() const
|
||||
{
|
||||
return m_candidateVersion;
|
||||
}
|
||||
|
||||
QStringList SystemController::availableChannels() const
|
||||
{
|
||||
return m_availableChannels;
|
||||
}
|
||||
|
||||
QString SystemController::currentChannel() const
|
||||
{
|
||||
return m_currentChannel;
|
||||
}
|
||||
|
||||
bool SystemController::updateInProgress() const
|
||||
{
|
||||
return m_updareInProgress;
|
||||
}
|
||||
|
||||
void SystemController::startUpdate()
|
||||
{
|
||||
m_jsonRpcClient->sendCommand("System.StartUpdate");
|
||||
}
|
||||
|
||||
void SystemController::selectChannel(const QString &channel)
|
||||
{
|
||||
QVariantMap params;
|
||||
params.insert("channel", channel);
|
||||
m_jsonRpcClient->sendCommand("System.SelectChannel", params, this, "selectChannelResponse");
|
||||
}
|
||||
|
||||
void SystemController::reboot()
|
||||
{
|
||||
m_jsonRpcClient->sendCommand("System.Reboot");
|
||||
@ -83,6 +50,47 @@ void SystemController::shutdown()
|
||||
m_jsonRpcClient->sendCommand("System.Shutdown");
|
||||
}
|
||||
|
||||
bool SystemController::updateRunning() const
|
||||
{
|
||||
return m_updateRunning;
|
||||
}
|
||||
|
||||
Packages *SystemController::packages() const
|
||||
{
|
||||
return m_packages;
|
||||
}
|
||||
|
||||
void SystemController::updatePackages(const QString packageId)
|
||||
{
|
||||
QVariantMap params;
|
||||
if (!packageId.isEmpty()) {
|
||||
params.insert("packageIds", QStringList() << packageId);
|
||||
}
|
||||
m_jsonRpcClient->sendCommand("System.UpdatePackages", params);
|
||||
}
|
||||
|
||||
void SystemController::removePackages(const QString packageId)
|
||||
{
|
||||
QVariantMap params;
|
||||
if (!packageId.isEmpty()) {
|
||||
params.insert("packageIds", QStringList() << packageId);
|
||||
}
|
||||
m_jsonRpcClient->sendCommand("System.RemovePackages", params, this, "removePackageResponse");
|
||||
}
|
||||
|
||||
Repositories *SystemController::repositories() const
|
||||
{
|
||||
return m_repositories;
|
||||
}
|
||||
|
||||
void SystemController::enableRepository(const QString &id, bool enabled)
|
||||
{
|
||||
QVariantMap params;
|
||||
params.insert("repositoryId", id);
|
||||
params.insert("enabled", enabled);
|
||||
m_jsonRpcClient->sendCommand("System.EnableRepository", params);
|
||||
}
|
||||
|
||||
void SystemController::getCapabilitiesResponse(const QVariantMap &data)
|
||||
{
|
||||
qDebug() << "capabilities received" << data;
|
||||
@ -94,36 +102,104 @@ void SystemController::getCapabilitiesResponse(const QVariantMap &data)
|
||||
|
||||
if (m_updateManagementAvailable) {
|
||||
m_jsonRpcClient->sendCommand("System.GetUpdateStatus", this, "getUpdateStatusResponse");
|
||||
m_jsonRpcClient->sendCommand("System.GetPackages", this, "getPackagesResponse");
|
||||
m_jsonRpcClient->sendCommand("System.GetRepositories", this, "getRepositoriesResponse");
|
||||
}
|
||||
}
|
||||
|
||||
void SystemController::getUpdateStatusResponse(const QVariantMap &data)
|
||||
{
|
||||
qDebug() << "Update status:" << data;
|
||||
m_currentVersion = data.value("params").toMap().value("currentVersion").toString();
|
||||
m_candidateVersion = data.value("params").toMap().value("candidateVersion").toString();
|
||||
m_availableChannels = data.value("params").toMap().value("availableChannels").toStringList();
|
||||
m_currentChannel = data.value("params").toMap().value("currentChannel").toString();
|
||||
m_updareInProgress = data.value("params").toMap().value("updateInProgress").toBool();
|
||||
m_updateAvailable = data.value("params").toMap().value("updateAvailable").toBool();
|
||||
emit updateStatusChanged();
|
||||
m_updateRunning = data.value("params").toMap().value("updateRunning").toBool();
|
||||
emit updateRunningChanged();
|
||||
}
|
||||
|
||||
void SystemController::selectChannelResponse(const QVariantMap &data)
|
||||
void SystemController::getPackagesResponse(const QVariantMap &data)
|
||||
{
|
||||
qDebug() << "Select channel response" << data;
|
||||
foreach (const QVariant &packageVariant, data.value("params").toMap().value("packages").toList()) {
|
||||
QString id = packageVariant.toMap().value("id").toString();
|
||||
QString displayName = packageVariant.toMap().value("displayName").toString();
|
||||
Package *p = new Package(id, displayName);
|
||||
p->setInstalledVersion(packageVariant.toMap().value("installedVersion").toString());
|
||||
p->setCandidateVersion(packageVariant.toMap().value("candidateVersion").toString());
|
||||
p->setChangelog(packageVariant.toMap().value("changelog").toString());
|
||||
p->setUpdateAvailable(packageVariant.toMap().value("updateAvailable").toBool());
|
||||
p->setRollbackAvailable(packageVariant.toMap().value("rollbackAvailable").toBool());
|
||||
p->setCanRemove(packageVariant.toMap().value("canRemove").toBool());
|
||||
m_packages->addPackage(p);
|
||||
}
|
||||
}
|
||||
|
||||
void SystemController::getRepositoriesResponse(const QVariantMap &data)
|
||||
{
|
||||
qDebug() << "******** Repos" << data;
|
||||
foreach (const QVariant &repoVariant, data.value("params").toMap().value("repositories").toList()) {
|
||||
QString id = repoVariant.toMap().value("id").toString();
|
||||
QString displayName = repoVariant.toMap().value("displayName").toString();
|
||||
Repository *repo = new Repository(id, displayName);
|
||||
repo->setEnabled(repoVariant.toMap().value("enabled").toBool());
|
||||
m_repositories->addRepository(repo);
|
||||
}
|
||||
}
|
||||
|
||||
void SystemController::removePackageResponse(const QVariantMap ¶ms)
|
||||
{
|
||||
qDebug() << "Remove result" << params;
|
||||
}
|
||||
|
||||
void SystemController::notificationReceived(const QVariantMap &data)
|
||||
{
|
||||
if (data.value("notification").toString() == "System.UpdateStatusChanged") {
|
||||
qDebug() << "Update status changed:" << data;
|
||||
m_currentVersion = data.value("params").toMap().value("currentVersion").toString();
|
||||
m_candidateVersion = data.value("params").toMap().value("candidateVersion").toString();
|
||||
m_availableChannels = data.value("params").toMap().value("availableChannels").toStringList();
|
||||
m_currentChannel = data.value("params").toMap().value("currentChannel").toString();
|
||||
m_updareInProgress = data.value("params").toMap().value("updateInProgress").toBool();
|
||||
m_updateAvailable = data.value("params").toMap().value("updateAvailable").toBool();
|
||||
emit updateStatusChanged();
|
||||
qDebug() << "System Notification" << data.value("notification");
|
||||
QString notification = data.value("notification").toString();
|
||||
if (notification == "System.UpdateStatusChanged") {
|
||||
m_updateRunning = data.value("params").toMap().value("updateRunning").toBool();
|
||||
emit updateRunningChanged();
|
||||
} else if (notification == "System.PackageAdded") {
|
||||
QVariantMap packageMap = data.value("params").toMap().value("package").toMap();
|
||||
QString id = packageMap.value("id").toString();
|
||||
QString displayName = packageMap.value("displayName").toString();
|
||||
Package *p = new Package(id, displayName);
|
||||
p->setInstalledVersion(packageMap.value("installedVersion").toString());
|
||||
p->setCandidateVersion(packageMap.value("candidateVersion").toString());
|
||||
p->setChangelog(packageMap.value("changelog").toString());
|
||||
p->setUpdateAvailable(packageMap.value("updateAvailable").toBool());
|
||||
p->setRollbackAvailable(packageMap.value("rollbackAvailable").toBool());
|
||||
p->setCanRemove(packageMap.value("canRemove").toBool());
|
||||
m_packages->addPackage(p);
|
||||
} else if (notification == "System.PackageChanged") {
|
||||
QVariantMap packageMap = data.value("params").toMap().value("package").toMap();
|
||||
QString id = packageMap.value("id").toString();
|
||||
Package *p = m_packages->getPackage(id);
|
||||
if (!p) {
|
||||
qWarning() << "Received a package update notification for a package we don't know";
|
||||
return;
|
||||
}
|
||||
p->setInstalledVersion(packageMap.value("installedVersion").toString());
|
||||
p->setCandidateVersion(packageMap.value("candidateVersion").toString());
|
||||
p->setChangelog(packageMap.value("changelog").toString());
|
||||
p->setUpdateAvailable(packageMap.value("updateAvailable").toBool());
|
||||
p->setRollbackAvailable(packageMap.value("rollbackAvailable").toBool());
|
||||
p->setCanRemove(packageMap.value("canRemove").toBool());
|
||||
} else if (notification == "System.PackageRemoved") {
|
||||
QString packageId = data.value("params").toMap().value("packageId").toString();
|
||||
m_packages->removePackage(packageId);
|
||||
} else if (notification == "System.RepositoryAdded") {
|
||||
QVariantMap repoMap = data.value("params").toMap().value("repository").toMap();
|
||||
QString id = repoMap.value("id").toString();
|
||||
QString displayName = repoMap.value("displayName").toString();
|
||||
Repository *repo = new Repository(id, displayName);
|
||||
repo->setEnabled(repoMap.value("enabled").toBool());
|
||||
m_repositories->addRepository(repo);
|
||||
} else if (notification == "System.RepositoryChanged") {
|
||||
QVariantMap repoMap = data.value("params").toMap().value("repository").toMap();
|
||||
QString id = repoMap.value("id").toString();
|
||||
Repository *repo = m_repositories->getRepository(id);
|
||||
if (!repo) {
|
||||
qWarning() << "Received a repository update notification for a repository we don't know";
|
||||
return;
|
||||
}
|
||||
repo->setEnabled(repoMap.value("enabled").toBool());
|
||||
} else if (notification == "System.RepositoryRemoved") {
|
||||
QString repositoryId = data.value("params").toMap().value("repositoryId").toString();
|
||||
m_repositories->removeRepository(repositoryId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,6 +5,9 @@
|
||||
|
||||
#include "jsonrpc/jsonrpcclient.h"
|
||||
|
||||
class Repositories;
|
||||
class Packages;
|
||||
|
||||
class SystemController : public JsonHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -12,14 +15,9 @@ class SystemController : public JsonHandler
|
||||
// Whether the update mechanism is available in the connected core
|
||||
Q_PROPERTY(bool updateManagementAvailable READ updateManagementAvailable NOTIFY updateManagementAvailableChanged)
|
||||
|
||||
// Whether there is an update available
|
||||
Q_PROPERTY(bool updateAvailable READ updateAvailable NOTIFY updateStatusChanged)
|
||||
Q_PROPERTY(QString currentVersion READ currentVersion NOTIFY updateStatusChanged)
|
||||
Q_PROPERTY(QString candidateVersion READ candidateVersion NOTIFY updateStatusChanged)
|
||||
Q_PROPERTY(QStringList availableChannels READ availableChannels NOTIFY updateStatusChanged)
|
||||
Q_PROPERTY(QString currentChannel READ currentChannel NOTIFY updateStatusChanged)
|
||||
|
||||
Q_PROPERTY(bool updateInProgress READ updateInProgress NOTIFY updateStatusChanged)
|
||||
Q_PROPERTY(bool updateRunning READ updateRunning NOTIFY updateRunningChanged)
|
||||
Q_PROPERTY(Packages* packages READ packages CONSTANT)
|
||||
Q_PROPERTY(Repositories* repositories READ repositories CONSTANT)
|
||||
|
||||
public:
|
||||
explicit SystemController(JsonRpcClient *jsonRpcClient, QObject *parent = nullptr);
|
||||
@ -28,45 +26,44 @@ public:
|
||||
QString nameSpace() const override;
|
||||
|
||||
bool powerManagementAvailable() const;
|
||||
bool updateManagementAvailable() const;
|
||||
|
||||
Q_INVOKABLE void reboot();
|
||||
Q_INVOKABLE void shutdown();
|
||||
|
||||
bool updateManagementAvailable() const;
|
||||
bool updateAvailable() const;
|
||||
QString currentVersion() const;
|
||||
QString candidateVersion() const;
|
||||
QStringList availableChannels() const;
|
||||
QString currentChannel() const;
|
||||
bool updateRunning() const;
|
||||
|
||||
bool updateInProgress() const;
|
||||
Packages* packages() const;
|
||||
Q_INVOKABLE void updatePackages(const QString packageId = QString());
|
||||
Q_INVOKABLE void removePackages(const QString packageId = QString());
|
||||
|
||||
Repositories* repositories() const;
|
||||
Q_INVOKABLE void enableRepository(const QString &id, bool enabled);
|
||||
|
||||
Q_INVOKABLE void startUpdate();
|
||||
Q_INVOKABLE void selectChannel(const QString &channel);
|
||||
|
||||
signals:
|
||||
void powerManagementAvailableChanged();
|
||||
void updateManagementAvailableChanged();
|
||||
void updateStatusChanged();
|
||||
void updateRunningChanged();
|
||||
|
||||
private slots:
|
||||
void getCapabilitiesResponse(const QVariantMap &data);
|
||||
void getUpdateStatusResponse(const QVariantMap &data);
|
||||
void selectChannelResponse(const QVariantMap &data);
|
||||
void getPackagesResponse(const QVariantMap &data);
|
||||
void getRepositoriesResponse(const QVariantMap &data);
|
||||
void removePackageResponse(const QVariantMap ¶ms);
|
||||
|
||||
void notificationReceived(const QVariantMap &data);
|
||||
|
||||
private:
|
||||
JsonRpcClient *m_jsonRpcClient = nullptr;
|
||||
|
||||
bool m_powerManagementAvailable = false;
|
||||
bool m_updateManagementAvailable = false;
|
||||
|
||||
bool m_updateAvailable = false;
|
||||
QString m_currentVersion;
|
||||
QString m_candidateVersion;
|
||||
QStringList m_availableChannels;
|
||||
QString m_currentChannel;
|
||||
|
||||
bool m_updareInProgress = false;
|
||||
bool m_updateRunning = false;
|
||||
Packages *m_packages = nullptr;
|
||||
Repositories *m_repositories = nullptr;
|
||||
};
|
||||
|
||||
#endif // SYSTEMCONTROLLER_H
|
||||
|
||||
@ -8,6 +8,10 @@ QT -= gui
|
||||
QT += network
|
||||
|
||||
HEADERS += \
|
||||
types/package.h \
|
||||
types/packages.h \
|
||||
types/repositories.h \
|
||||
types/repository.h \
|
||||
types/types.h \
|
||||
types/vendor.h \
|
||||
types/vendors.h \
|
||||
@ -54,6 +58,10 @@ HEADERS += \
|
||||
types/tags.h
|
||||
|
||||
SOURCES += \
|
||||
types/package.cpp \
|
||||
types/packages.cpp \
|
||||
types/repositories.cpp \
|
||||
types/repository.cpp \
|
||||
types/vendor.cpp \
|
||||
types/vendors.cpp \
|
||||
types/deviceclass.cpp \
|
||||
|
||||
97
libnymea-common/types/package.cpp
Normal file
97
libnymea-common/types/package.cpp
Normal file
@ -0,0 +1,97 @@
|
||||
#include "package.h"
|
||||
|
||||
Package::Package(const QString &id, const QString &displayName, QObject *parent):
|
||||
QObject(parent),
|
||||
m_id(id),
|
||||
m_displayName(displayName)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QString Package::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
QString Package::displayName() const
|
||||
{
|
||||
return m_displayName;
|
||||
}
|
||||
|
||||
QString Package::installedVersion() const
|
||||
{
|
||||
return m_installedVersion;
|
||||
}
|
||||
|
||||
void Package::setInstalledVersion(const QString &installedVersion)
|
||||
{
|
||||
if (m_installedVersion != installedVersion) {
|
||||
m_installedVersion = installedVersion;
|
||||
emit installedVersionChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QString Package::candidateVersion() const
|
||||
{
|
||||
return m_candidateVersion;
|
||||
}
|
||||
|
||||
void Package::setCandidateVersion(const QString &candidateVersion)
|
||||
{
|
||||
if (m_candidateVersion != candidateVersion) {
|
||||
m_candidateVersion = candidateVersion;
|
||||
emit candidateVersionChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QString Package::changelog() const
|
||||
{
|
||||
return m_changelog;
|
||||
}
|
||||
|
||||
void Package::setChangelog(const QString &changelog)
|
||||
{
|
||||
if (m_changelog != changelog) {
|
||||
m_changelog = changelog;
|
||||
emit changelogChanged();
|
||||
}
|
||||
}
|
||||
|
||||
bool Package::updateAvailable() const
|
||||
{
|
||||
return m_updateAvailable;
|
||||
}
|
||||
|
||||
void Package::setUpdateAvailable(bool updateAvailable)
|
||||
{
|
||||
if (m_updateAvailable != updateAvailable) {
|
||||
m_updateAvailable = updateAvailable;
|
||||
emit updateAvailableChanged();
|
||||
}
|
||||
}
|
||||
|
||||
bool Package::rollbackAvailable() const
|
||||
{
|
||||
return m_rollbackAvailable;
|
||||
}
|
||||
|
||||
void Package::setRollbackAvailable(bool rollbackAvailable)
|
||||
{
|
||||
if (m_rollbackAvailable != rollbackAvailable) {
|
||||
m_rollbackAvailable = rollbackAvailable;
|
||||
emit rollbackAvailableChanged();
|
||||
}
|
||||
}
|
||||
|
||||
bool Package::canRemove() const
|
||||
{
|
||||
return m_canRemove;
|
||||
}
|
||||
|
||||
void Package::setCanRemove(bool canRemove)
|
||||
{
|
||||
if (m_canRemove != canRemove) {
|
||||
m_canRemove = canRemove;
|
||||
emit canRemoveChanged();
|
||||
}
|
||||
}
|
||||
61
libnymea-common/types/package.h
Normal file
61
libnymea-common/types/package.h
Normal file
@ -0,0 +1,61 @@
|
||||
#ifndef PACKAGE_H
|
||||
#define PACKAGE_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class Package : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString id READ id CONSTANT)
|
||||
Q_PROPERTY(QString displayName READ displayName CONSTANT)
|
||||
Q_PROPERTY(QString installedVersion READ installedVersion NOTIFY installedVersionChanged)
|
||||
Q_PROPERTY(QString candidateVersion READ candidateVersion NOTIFY candidateVersionChanged)
|
||||
Q_PROPERTY(QString changelog READ changelog NOTIFY changelogChanged)
|
||||
Q_PROPERTY(bool updateAvailable READ updateAvailable NOTIFY updateAvailableChanged)
|
||||
Q_PROPERTY(bool rollbackAvailable READ rollbackAvailable NOTIFY rollbackAvailableChanged)
|
||||
Q_PROPERTY(bool canRemove READ canRemove NOTIFY canRemoveChanged)
|
||||
|
||||
public:
|
||||
explicit Package(const QString &id, const QString &displayName, QObject *parent = nullptr);
|
||||
|
||||
QString id() const;
|
||||
QString displayName() const;
|
||||
|
||||
QString installedVersion() const;
|
||||
void setInstalledVersion(const QString &installedVersion);
|
||||
|
||||
QString candidateVersion() const;
|
||||
void setCandidateVersion(const QString &candidateVersion);
|
||||
|
||||
QString changelog() const;
|
||||
void setChangelog(const QString &changelog);
|
||||
|
||||
bool updateAvailable() const;
|
||||
void setUpdateAvailable(bool updateAvailable);
|
||||
|
||||
bool rollbackAvailable() const;
|
||||
void setRollbackAvailable(bool rollbackAvailable);
|
||||
|
||||
bool canRemove() const;
|
||||
void setCanRemove(bool canRemove);
|
||||
|
||||
signals:
|
||||
void installedVersionChanged();
|
||||
void candidateVersionChanged();
|
||||
void changelogChanged();
|
||||
void updateAvailableChanged();
|
||||
void rollbackAvailableChanged();
|
||||
void canRemoveChanged();
|
||||
|
||||
private:
|
||||
QString m_id;
|
||||
QString m_displayName;
|
||||
QString m_installedVersion;
|
||||
QString m_candidateVersion;
|
||||
QString m_changelog;
|
||||
bool m_updateAvailable = false;
|
||||
bool m_rollbackAvailable = false;
|
||||
bool m_canRemove = false;
|
||||
};
|
||||
|
||||
#endif // PACKAGE_H
|
||||
122
libnymea-common/types/packages.cpp
Normal file
122
libnymea-common/types/packages.cpp
Normal file
@ -0,0 +1,122 @@
|
||||
#include "packages.h"
|
||||
#include "package.h"
|
||||
|
||||
Packages::Packages(QObject *parent) : QAbstractListModel(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int Packages::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return m_list.count();
|
||||
}
|
||||
|
||||
QVariant Packages::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
switch (role) {
|
||||
case RoleId:
|
||||
return m_list.at(index.row())->id();
|
||||
case RoleDisplayName:
|
||||
return m_list.at(index.row())->displayName();
|
||||
case RoleInstalledVersion:
|
||||
return m_list.at(index.row())->installedVersion();
|
||||
case RoleCandidateVersion:
|
||||
return m_list.at(index.row())->candidateVersion();
|
||||
case RoleChangelog:
|
||||
return m_list.at(index.row())->changelog();
|
||||
case RoleUpdateAvailable:
|
||||
return m_list.at(index.row())->updateAvailable();
|
||||
case RoleRollbackAvailable:
|
||||
return m_list.at(index.row())->rollbackAvailable();
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> Packages::roleNames() const
|
||||
{
|
||||
QHash<int, QByteArray> roles;
|
||||
roles.insert(RoleId, "id");
|
||||
roles.insert(RoleDisplayName, "displayName");
|
||||
roles.insert(RoleInstalledVersion, "installedVersion");
|
||||
roles.insert(RoleCandidateVersion, "candidateVersion");
|
||||
roles.insert(RoleChangelog, "changelog");
|
||||
roles.insert(RoleUpdateAvailable, "updateAvailable");
|
||||
roles.insert(RoleRollbackAvailable, "rollbackAvailable");
|
||||
return roles;
|
||||
}
|
||||
|
||||
void Packages::addPackage(Package *package)
|
||||
{
|
||||
package->setParent(this);
|
||||
beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
|
||||
m_list.append(package);
|
||||
connect(package, &Package::installedVersionChanged, this, [this, package](){
|
||||
emit dataChanged(index(m_list.indexOf(package)), index(m_list.indexOf(package)), {RoleInstalledVersion});
|
||||
emit countChanged();
|
||||
});
|
||||
connect(package, &Package::candidateVersionChanged, this, [this, package](){
|
||||
emit dataChanged(index(m_list.indexOf(package)), index(m_list.indexOf(package)), {RoleCandidateVersion});
|
||||
emit countChanged();
|
||||
});
|
||||
connect(package, &Package::changelogChanged, this, [this, package](){
|
||||
emit dataChanged(index(m_list.indexOf(package)), index(m_list.indexOf(package)), {RoleChangelog});
|
||||
emit countChanged();
|
||||
});
|
||||
connect(package, &Package::updateAvailableChanged, this, [this, package](){
|
||||
emit dataChanged(index(m_list.indexOf(package)), index(m_list.indexOf(package)), {RoleUpdateAvailable});
|
||||
emit countChanged();
|
||||
});
|
||||
connect(package, &Package::rollbackAvailableChanged, this, [this, package](){
|
||||
emit dataChanged(index(m_list.indexOf(package)), index(m_list.indexOf(package)), {RoleRollbackAvailable});
|
||||
emit countChanged();
|
||||
});
|
||||
endInsertRows();
|
||||
emit countChanged();
|
||||
}
|
||||
|
||||
void Packages::removePackage(const QString &packageId)
|
||||
{
|
||||
int idx = -1;
|
||||
for (int i = 0; i < m_list.count(); i++) {
|
||||
if (m_list.at(i)->id() == packageId) {
|
||||
idx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (idx < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
beginRemoveRows(QModelIndex(), idx, idx);
|
||||
m_list.takeAt(idx)->deleteLater();
|
||||
endRemoveRows();
|
||||
emit countChanged();
|
||||
}
|
||||
|
||||
Package *Packages::get(int index) const
|
||||
{
|
||||
if (index >= 0 && index < m_list.count()) {
|
||||
return m_list.at(index);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Package *Packages::getPackage(const QString &packageId)
|
||||
{
|
||||
foreach (Package *p, m_list) {
|
||||
if (p->id() == packageId) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Packages::clear()
|
||||
{
|
||||
beginResetModel();
|
||||
qDeleteAll(m_list);
|
||||
m_list.clear();
|
||||
endResetModel();
|
||||
emit countChanged();
|
||||
}
|
||||
45
libnymea-common/types/packages.h
Normal file
45
libnymea-common/types/packages.h
Normal file
@ -0,0 +1,45 @@
|
||||
#ifndef PACKAGES_H
|
||||
#define PACKAGES_H
|
||||
|
||||
#include <QAbstractListModel>
|
||||
|
||||
class Package;
|
||||
|
||||
class Packages: public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
|
||||
public:
|
||||
enum Roles {
|
||||
RoleId,
|
||||
RoleDisplayName,
|
||||
RoleInstalledVersion,
|
||||
RoleCandidateVersion,
|
||||
RoleChangelog,
|
||||
RoleUpdateAvailable,
|
||||
RoleRollbackAvailable
|
||||
};
|
||||
Q_ENUM(Roles)
|
||||
|
||||
explicit Packages(QObject *parent = nullptr);
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
QHash<int, QByteArray> roleNames() const override;
|
||||
|
||||
void addPackage(Package *package);
|
||||
void removePackage(const QString &packageId);
|
||||
|
||||
Q_INVOKABLE Package* get(int index) const;
|
||||
Q_INVOKABLE Package* getPackage(const QString &packageId);
|
||||
|
||||
void clear();
|
||||
|
||||
signals:
|
||||
void countChanged();
|
||||
|
||||
private:
|
||||
QList<Package*> m_list;
|
||||
};
|
||||
|
||||
#endif // PACKAGES_H
|
||||
94
libnymea-common/types/repositories.cpp
Normal file
94
libnymea-common/types/repositories.cpp
Normal file
@ -0,0 +1,94 @@
|
||||
#include "repositories.h"
|
||||
#include "repository.h"
|
||||
|
||||
Repositories::Repositories(QObject *parent): QAbstractListModel(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int Repositories::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return m_list.count();
|
||||
}
|
||||
|
||||
QVariant Repositories::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
switch (role) {
|
||||
case RoleId:
|
||||
return m_list.at(index.row())->id();
|
||||
case RoleDisplayName:
|
||||
return m_list.at(index.row())->displayName();
|
||||
case RoleEnabled:
|
||||
return m_list.at(index.row())->enabled();
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> Repositories::roleNames() const
|
||||
{
|
||||
QHash<int, QByteArray> roles;
|
||||
roles.insert(RoleId, "id");
|
||||
roles.insert(RoleDisplayName, "displayName");
|
||||
roles.insert(RoleEnabled, "enabled");
|
||||
return roles;
|
||||
}
|
||||
|
||||
Repository *Repositories::get(int index) const
|
||||
{
|
||||
if (index >= 0 && index < m_list.count()) {
|
||||
return m_list.at(index);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Repository *Repositories::getRepository(const QString &id) const
|
||||
{
|
||||
foreach (Repository *repo, m_list) {
|
||||
if (repo->id() == id) {
|
||||
return repo;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Repositories::addRepository(Repository *repository)
|
||||
{
|
||||
repository->setParent(this);
|
||||
beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
|
||||
m_list.append(repository);
|
||||
connect(repository, &Repository::enabledChanged, this, [this, repository](){
|
||||
QModelIndex idx = index(m_list.indexOf(repository));
|
||||
emit dataChanged(idx, idx, {RoleEnabled});
|
||||
});
|
||||
endInsertRows();
|
||||
emit countChanged();
|
||||
}
|
||||
|
||||
void Repositories::removeRepository(const QString &repositoryId)
|
||||
{
|
||||
int idx = -1;
|
||||
for (int i = 0; i < m_list.count(); i++) {
|
||||
if (m_list.at(i)->id() == repositoryId) {
|
||||
idx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (idx < 0) {
|
||||
return;
|
||||
}
|
||||
beginRemoveRows(QModelIndex(), idx, idx);
|
||||
m_list.takeAt(idx)->deleteLater();
|
||||
endRemoveRows();
|
||||
emit countChanged();
|
||||
|
||||
}
|
||||
|
||||
void Repositories::clear()
|
||||
{
|
||||
beginResetModel();
|
||||
qDeleteAll(m_list);
|
||||
m_list.clear();
|
||||
endResetModel();
|
||||
emit countChanged();
|
||||
}
|
||||
40
libnymea-common/types/repositories.h
Normal file
40
libnymea-common/types/repositories.h
Normal file
@ -0,0 +1,40 @@
|
||||
#ifndef REPOSITORIES_H
|
||||
#define REPOSITORIES_H
|
||||
|
||||
#include <QAbstractListModel>
|
||||
|
||||
class Repository;
|
||||
|
||||
class Repositories : public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
|
||||
public:
|
||||
enum Roles {
|
||||
RoleId,
|
||||
RoleDisplayName,
|
||||
RoleEnabled
|
||||
};
|
||||
Q_ENUM(Roles)
|
||||
|
||||
explicit Repositories(QObject *parent = nullptr);
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
QHash<int, QByteArray> roleNames() const override;
|
||||
|
||||
Q_INVOKABLE Repository* get(int index) const;
|
||||
Q_INVOKABLE Repository* getRepository(const QString &id) const;
|
||||
|
||||
void addRepository(Repository* repository);
|
||||
void removeRepository(const QString &repositoryId);
|
||||
void clear();
|
||||
|
||||
signals:
|
||||
void countChanged();
|
||||
|
||||
private:
|
||||
QList<Repository*> m_list;
|
||||
};
|
||||
|
||||
#endif // REPOSITORIES_H
|
||||
32
libnymea-common/types/repository.cpp
Normal file
32
libnymea-common/types/repository.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
#include "repository.h"
|
||||
|
||||
Repository::Repository(const QString &id, const QString &displayName, QObject *parent):
|
||||
QObject(parent),
|
||||
m_id(id),
|
||||
m_displayName(displayName)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QString Repository::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
QString Repository::displayName() const
|
||||
{
|
||||
return m_displayName;
|
||||
}
|
||||
|
||||
bool Repository::enabled() const
|
||||
{
|
||||
return m_enabled;
|
||||
}
|
||||
|
||||
void Repository::setEnabled(bool enabled)
|
||||
{
|
||||
if (m_enabled != enabled) {
|
||||
m_enabled = enabled;
|
||||
emit enabledChanged();
|
||||
}
|
||||
}
|
||||
31
libnymea-common/types/repository.h
Normal file
31
libnymea-common/types/repository.h
Normal file
@ -0,0 +1,31 @@
|
||||
#ifndef REPOSITORY_H
|
||||
#define REPOSITORY_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class Repository : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString id READ id CONSTANT)
|
||||
Q_PROPERTY(QString displayName READ displayName CONSTANT)
|
||||
Q_PROPERTY(bool enabled READ enabled NOTIFY enabledChanged)
|
||||
|
||||
public:
|
||||
explicit Repository(const QString &id, const QString &displayName, QObject *parent = nullptr);
|
||||
|
||||
QString id() const;
|
||||
QString displayName() const;
|
||||
|
||||
bool enabled() const;
|
||||
void setEnabled(bool enabled);
|
||||
|
||||
signals:
|
||||
void enabledChanged();
|
||||
|
||||
private:
|
||||
QString m_id;
|
||||
QString m_displayName;
|
||||
bool m_enabled = false;
|
||||
};
|
||||
|
||||
#endif // REPOSITORY_H
|
||||
@ -181,5 +181,6 @@
|
||||
<file>ui/appsettings/AppLogPage.qml</file>
|
||||
<file>ui/magic/SelectStatePage.qml</file>
|
||||
<file>ui/system/SystemUpdatePage.qml</file>
|
||||
<file>ui/components/UpdateRunningOverlay.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
44
nymea-app/ui/components/UpdateRunningOverlay.qml
Normal file
44
nymea-app/ui/components/UpdateRunningOverlay.qml
Normal file
@ -0,0 +1,44 @@
|
||||
import QtQuick 2.9
|
||||
import QtQuick.Controls 2.2
|
||||
import QtQuick.Layouts 1.2
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: "#99000000"
|
||||
visible: shown
|
||||
|
||||
property bool shown: false
|
||||
// Event eater
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
anchors.centerIn: parent
|
||||
width: parent.width
|
||||
|
||||
ColorIcon {
|
||||
height: app.iconSize * 3
|
||||
width: height
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
name: Qt.resolvedUrl("../images/system-update.svg")
|
||||
color: app.accentColor
|
||||
PropertyAnimation on rotation {
|
||||
from: 0; to: 360;
|
||||
duration: 2000
|
||||
loops: Animation.Inifinite
|
||||
onStopped: start(); // No clue why loops won't work
|
||||
}
|
||||
}
|
||||
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
Layout.margins: app.margins * 2
|
||||
text: qsTr("An update operation is currently running.\nPlease wait for it to complete.")
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
wrapMode: Text.WordWrap
|
||||
font.pixelSize: app.largeFont
|
||||
color: "white"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -11,102 +11,256 @@ Page {
|
||||
text: qsTr("System update")
|
||||
backButtonVisible: true
|
||||
onBackPressed: pageStack.pop()
|
||||
}
|
||||
|
||||
// HeaderButton {
|
||||
// imageSource: "../images/configure.svg"
|
||||
// color: pluginsProxy.showOnlyConfigurable ? app.accentColor : keyColor
|
||||
// onClicked: {
|
||||
// pluginsProxy.showOnlyConfigurable = !pluginsProxy.showOnlyConfigurable
|
||||
// }
|
||||
// }
|
||||
PackagesFilterModel {
|
||||
id: updatesModel
|
||||
packages: engine.systemController.packages
|
||||
updatesOnly: true
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
anchors { left: parent.left; top: parent.top; right: parent.right }
|
||||
id: contentColumn
|
||||
anchors.fill: parent
|
||||
|
||||
MeaListItemDelegate {
|
||||
Layout.fillWidth: true
|
||||
text: qsTr("Configure updates")
|
||||
onClicked: {
|
||||
pageStack.push(repositoryListComponent)
|
||||
}
|
||||
}
|
||||
|
||||
MeaListItemDelegate {
|
||||
Layout.fillWidth: true
|
||||
text: qsTr("Show all packages")
|
||||
onClicked: {
|
||||
pageStack.push(packageListComponent, {packages: engine.systemController.packages})
|
||||
}
|
||||
}
|
||||
|
||||
ThinDivider {}
|
||||
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
Layout.margins: app.margins
|
||||
text: qsTr("Your %1 system is up to date.").arg(app.systemName)
|
||||
visible: !engine.systemController.updateAvailable
|
||||
}
|
||||
|
||||
MeaListItemDelegate {
|
||||
Layout.fillWidth: true
|
||||
progressive: false
|
||||
text: qsTr("Installed version")
|
||||
subText: engine.systemController.currentVersion
|
||||
}
|
||||
MeaListItemDelegate {
|
||||
Layout.fillWidth: true
|
||||
progressive: false
|
||||
text: qsTr("Candidate version")
|
||||
subText: engine.systemController.candidateVersion
|
||||
visible: engine.systemController.updateAvailable
|
||||
elide: Text.ElideRight
|
||||
text: updatesModel.count === 0 ? qsTr("Your system is up to date.") : qsTr("There are %1 updates available.").arg(updatesModel.count)
|
||||
}
|
||||
|
||||
Button {
|
||||
Layout.fillWidth: true
|
||||
Layout.leftMargin: app.margins
|
||||
Layout.rightMargin: app.margins
|
||||
text: qsTr("Update system")
|
||||
visible: engine.systemController.updateAvailable
|
||||
Layout.margins: app.margins
|
||||
text: qsTr("Update all")
|
||||
visible: updatesModel.count > 0
|
||||
onClicked: {
|
||||
var dialog = Qt.createComponent(Qt.resolvedUrl("../components/MeaDialog.qml"));
|
||||
var text = settings.showHiddenOptions
|
||||
? qsTr("Developer options are now enabled. If you have found this by accident, it is most likely not of any use for you. It will just enable some nerdy developer gibberish in the app. Tap the icon another 10 times to disable it again.")
|
||||
: qsTr("Developer options are now disabled.")
|
||||
var popup = dialog.createObject(app, {headerIcon: "../images/dialog-warning-symbolic.svg", title: qsTr("Howdy cowboy!"), text: text})
|
||||
var text = qsTr("This will start a system update. Note that the update might take several minutes and your %1:core might not be functioning properly during this time and restart during the process.\nDo you want to proceed?").arg(app.systemName)
|
||||
var popup = dialog.createObject(app,
|
||||
{
|
||||
headerIcon: "../images/system-update.svg",
|
||||
title: qsTr("System update"),
|
||||
text: text,
|
||||
standardButtons: Dialog.Ok | Dialog.Cancel
|
||||
});
|
||||
popup.open();
|
||||
popup.accepted.connect(function() {
|
||||
engine.systemController.startUpdate()
|
||||
engine.systemController.updatePackages()
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
ThinDivider {
|
||||
visible: settings.showHiddenOptions
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
ListView {
|
||||
Layout.fillWidth: true
|
||||
Layout.leftMargin: app.margins
|
||||
Layout.rightMargin: app.margins
|
||||
spacing: app.margins
|
||||
visible: settings.showHiddenOptions
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
text: qsTr("Update channel")
|
||||
}
|
||||
ComboBox {
|
||||
Layout.minimumWidth: 200
|
||||
model: engine.systemController.availableChannels
|
||||
currentIndex: model.indexOf(engine.systemController.currentChannel)
|
||||
onActivated: {
|
||||
var dialog = Qt.createComponent(Qt.resolvedUrl("../components/MeaDialog.qml"));
|
||||
var text = qsTr("Changing the update channel allows to install unreleased software. This can potentially harm your system and lead to problems. Please only use this if you are sure you want this and consider reporting the issues you find when testing unreleased channels. Thank you.")
|
||||
var popup = dialog.createObject(app,
|
||||
{
|
||||
headerIcon: "../images/dialog-warning-symbolic.svg",
|
||||
title: qsTr("Switch update channel"),
|
||||
text: text,
|
||||
standardButtons: Dialog.Ok | Dialog.Cancel
|
||||
});
|
||||
popup.open();
|
||||
popup.accepted.connect(function() {
|
||||
engine.systemController.selectChannel(model[index])
|
||||
})
|
||||
popup.rejected.connect(function() {
|
||||
currentIndex = model.indexOf(engine.systemController.currentChannel)
|
||||
})
|
||||
|
||||
Layout.fillHeight: true
|
||||
model: updatesModel
|
||||
clip: true
|
||||
delegate: MeaListItemDelegate {
|
||||
width: parent.width
|
||||
text: model.displayName
|
||||
subText: model.candidateVersion
|
||||
prominentSubText: false
|
||||
iconName: model.updateAvailable
|
||||
? Qt.resolvedUrl("../images/system-update.svg")
|
||||
: Qt.resolvedUrl("../images/view-" + (model.installedVersion.length > 0 ? "expand" : "collapse") + ".svg")
|
||||
iconColor: model.updateAvailable
|
||||
? "green"
|
||||
: model.installedVersion.length > 0 ? "blue" : iconKeyColor
|
||||
onClicked: {
|
||||
pageStack.push(packageDetailsComponent, {pkg: updatesModel.get(index)})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BusyOverlay {
|
||||
visible: engine.systemController.updateInProgress
|
||||
Component {
|
||||
id: repositoryListComponent
|
||||
Page {
|
||||
id: repositoryListPage
|
||||
header: GuhHeader {
|
||||
text: qsTr("Configure update sources")
|
||||
onBackPressed: pageStack.pop()
|
||||
}
|
||||
ListView {
|
||||
anchors.fill: parent
|
||||
model: engine.systemController.repositories
|
||||
delegate: CheckDelegate {
|
||||
width: parent.width
|
||||
text: model.displayName
|
||||
checked: model.enabled
|
||||
onClicked: {
|
||||
if (checked) {
|
||||
var dialog = Qt.createComponent(Qt.resolvedUrl("../components/MeaDialog.qml"));
|
||||
var text = qsTr("Enabling additional software sources allows to install unreleased %1:core packages.\nThis can potentially break your system and lead to problems.\nPlease only use this if you are sure you want this and consider reporting the issues you find when testing unreleased channels.").arg(app.systemName)
|
||||
var popup = dialog.createObject(app,
|
||||
{
|
||||
headerIcon: "../images/dialog-warning-symbolic.svg",
|
||||
title: qsTr("Enable package source"),
|
||||
text: text,
|
||||
standardButtons: Dialog.Ok | Dialog.Cancel
|
||||
});
|
||||
popup.open();
|
||||
popup.accepted.connect(function() {
|
||||
engine.systemController.enableRepository(model.id, true)
|
||||
})
|
||||
popup.rejected.connect(function() {
|
||||
checked = false
|
||||
})
|
||||
} else {
|
||||
engine.systemController.enableRepository(model.id, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
UpdateRunningOverlay {
|
||||
visible: engine.systemController.updateRunning
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: packageListComponent
|
||||
Page {
|
||||
id: packageListPage
|
||||
|
||||
property var packages: null
|
||||
|
||||
header: GuhHeader {
|
||||
text: qsTr("All packages")
|
||||
onBackPressed: pageStack.pop()
|
||||
}
|
||||
|
||||
ListView {
|
||||
anchors.fill: parent
|
||||
model: PackagesFilterModel {
|
||||
id: filterModel
|
||||
packages: packageListPage.packages
|
||||
}
|
||||
delegate: MeaListItemDelegate {
|
||||
width: parent.width
|
||||
text: model.displayName
|
||||
subText: model.candidateVersion
|
||||
prominentSubText: false
|
||||
iconName: model.updateAvailable
|
||||
? Qt.resolvedUrl("../images/system-update.svg")
|
||||
: Qt.resolvedUrl("../images/view-" + (model.installedVersion.length > 0 ? "expand" : "collapse") + ".svg")
|
||||
iconColor: model.updateAvailable
|
||||
? "green"
|
||||
: model.installedVersion.length > 0 ? "blue" : iconKeyColor
|
||||
onClicked: {
|
||||
pageStack.push(packageDetailsComponent, {pkg: filterModel.get(index)})
|
||||
}
|
||||
}
|
||||
}
|
||||
UpdateRunningOverlay {
|
||||
visible: engine.systemController.updateRunning
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: packageDetailsComponent
|
||||
Page {
|
||||
id: packageDetailsPage
|
||||
|
||||
property Package pkg: null
|
||||
|
||||
header: GuhHeader {
|
||||
text: pkg.displayName
|
||||
onBackPressed: pageStack.pop()
|
||||
}
|
||||
|
||||
GridLayout {
|
||||
anchors { left: parent.left; top: parent.top; right: parent.right }
|
||||
columns: app.landscape ? 2 : 1
|
||||
MeaListItemDelegate {
|
||||
Layout.fillWidth: true
|
||||
text: qsTr("Installed version:")
|
||||
subText: packageDetailsPage.pkg.installedVersion
|
||||
progressive: false
|
||||
}
|
||||
|
||||
MeaListItemDelegate {
|
||||
Layout.fillWidth: true
|
||||
text: qsTr("Candidate version:")
|
||||
subText: packageDetailsPage.pkg.candidateVersion
|
||||
visible: packageDetailsPage.pkg.updateAvailable || packageDetailsPage.pkg.installedVersion.length === 0
|
||||
progressive: false
|
||||
}
|
||||
Button {
|
||||
Layout.fillWidth: true
|
||||
Layout.margins: app.margins
|
||||
visible: packageDetailsPage.pkg.updateAvailable || packageDetailsPage.pkg.installedVersion.length === 0
|
||||
text: packageDetailsPage.pkg.updateAvailable ? qsTr("Update") : qsTr("Install")
|
||||
onClicked: {
|
||||
var dialog = Qt.createComponent(Qt.resolvedUrl("../components/MeaDialog.qml"));
|
||||
var text = qsTr("This will start a system update. Note that the update might take several minutes and your %1:core might not be functioning properly during this time and restart during the process.\nDo you want to proceed?").arg(app.systemName)
|
||||
var popup = dialog.createObject(app,
|
||||
{
|
||||
headerIcon: "../images/system-update.svg",
|
||||
title: qsTr("Start update"),
|
||||
text: text,
|
||||
standardButtons: Dialog.Ok | Dialog.Cancel
|
||||
});
|
||||
popup.open();
|
||||
popup.accepted.connect(function() {
|
||||
engine.systemController.updatePackages(packageDetailsPage.pkg.id)
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
Button {
|
||||
Layout.fillWidth: true
|
||||
Layout.margins: app.margins
|
||||
text: qsTr("Remove")
|
||||
visible: packageDetailsPage.pkg.canRemove
|
||||
onClicked: {
|
||||
var dialog = Qt.createComponent(Qt.resolvedUrl("../components/MeaDialog.qml"));
|
||||
var text = qsTr("This will start a system update. Note that the update might take several minutes and your %1:core might not be functioning properly during this time and restart during the process.\nDo you want to proceed?").arg(app.systemName)
|
||||
var popup = dialog.createObject(app,
|
||||
{
|
||||
headerIcon: "../images/system-update.svg",
|
||||
title: qsTr("Remove package"),
|
||||
text: text,
|
||||
standardButtons: Dialog.Ok | Dialog.Cancel
|
||||
});
|
||||
popup.open();
|
||||
popup.accepted.connect(function() {
|
||||
engine.systemController.removePackages(packageDetailsPage.pkg.id)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
UpdateRunningOverlay {
|
||||
visible: engine.systemController.updateRunning
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
UpdateRunningOverlay {
|
||||
visible: engine.systemController.updateRunning
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user