diff options
Diffstat (limited to 'rockwork')
| -rw-r--r-- | rockwork/InfoPage.qml | 12 | ||||
| -rw-r--r-- | rockwork/Main.qml | 50 | ||||
| -rw-r--r-- | rockwork/NotificationsPage.qml | 2 | ||||
| -rw-r--r-- | rockwork/notificationsourcemodel.cpp | 10 | ||||
| -rw-r--r-- | rockwork/notificationsourcemodel.h | 3 | ||||
| -rw-r--r-- | rockwork/pebbles.cpp | 27 | ||||
| -rw-r--r-- | rockwork/pebbles.h | 6 |
7 files changed, 87 insertions, 23 deletions
diff --git a/rockwork/InfoPage.qml b/rockwork/InfoPage.qml index 3eec387..1427380 100644 --- a/rockwork/InfoPage.qml +++ b/rockwork/InfoPage.qml @@ -37,18 +37,6 @@ Page { ThinDivider {} Label { - text: i18n.tr("Contributors") - Layout.fillWidth: true - font.bold: true - } - Label { - text: "Michael Zanetti<br>Brian Douglas<br>Katharine Berry" - Layout.fillWidth: true - } - - ThinDivider {} - - Label { text: i18n.tr("Legal") Layout.fillWidth: true font.bold: true diff --git a/rockwork/Main.qml b/rockwork/Main.qml index 2bdece3..a4726b9 100644 --- a/rockwork/Main.qml +++ b/rockwork/Main.qml @@ -35,11 +35,14 @@ MainView { Pebbles { id: pebbles onCountChanged: loadStack() + onConnectedToServiceChanged: loadStack(); } function loadStack() { pageStack.clear() - if (pebbles.count == 1) { + if (!pebbles.connectedToService) { + pageStack.push(loadingComponent) + } else if (pebbles.count == 1) { pageStack.push(Qt.resolvedUrl("MainMenuPage.qml"), {pebble: pebbles.get(0)}) } else { pageStack.push(Qt.resolvedUrl("PebblesPage.qml")) @@ -50,4 +53,49 @@ MainView { id: pageStack Component.onCompleted: loadStack(); } + + Component { + id: loadingComponent + Page { + title: "RockWork" + + Column { + width: parent.width - units.gu(4) + anchors.centerIn: parent + spacing: units.gu(4) + + Rectangle { + id: upgradeIcon + height: units.gu(10) + width: height + radius: width / 2 + color: UbuntuColors.blue + anchors.horizontalCenter: parent.horizontalCenter + Icon { + anchors.fill: parent + anchors.margins: units.gu(1) + name: "preferences-system-updates-symbolic" + color: "white" + } + + RotationAnimation on rotation { + duration: 2000 + loops: Animation.Infinite + from: 0 + to: 360 + running: upgradeIcon.visible + } + visible: true + } + + Label { + width: parent.width + horizontalAlignment: Text.AlignHCenter + fontSize: "large" + text: i18n.tr("Loading...") + } + } + + } + } } diff --git a/rockwork/NotificationsPage.qml b/rockwork/NotificationsPage.qml index 9802b05..d3c9ff9 100644 --- a/rockwork/NotificationsPage.qml +++ b/rockwork/NotificationsPage.qml @@ -78,7 +78,7 @@ Page { checked: model.enabled SlotsLayout.position: SlotsLayout.Trailing; onClicked: { - root.pebble.setNotificationFilter(model.name, checked) + root.pebble.setNotificationFilter(model.id, checked) } } } diff --git a/rockwork/notificationsourcemodel.cpp b/rockwork/notificationsourcemodel.cpp index cbb75ca..83e87f0 100644 --- a/rockwork/notificationsourcemodel.cpp +++ b/rockwork/notificationsourcemodel.cpp @@ -1,5 +1,8 @@ #include "notificationsourcemodel.h" +#include <QStandardPaths> +#include <QFileInfo> +#include <QDir> #include <QSettings> #include <QDebug> @@ -21,6 +24,8 @@ QVariant NotificationSourceModel::data(const QModelIndex &index, int role) const return item.m_displayName; case RoleEnabled: return item.m_enabled; + case RoleId: + return item.m_id; case RoleIcon: return item.m_icon; } @@ -33,6 +38,7 @@ QHash<int, QByteArray> NotificationSourceModel::roleNames() const roles.insert(RoleName, "name"); roles.insert(RoleEnabled, "enabled"); roles.insert(RoleIcon, "icon"); + roles.insert(RoleId, "id"); return roles; } @@ -59,10 +65,6 @@ void NotificationSourceModel::insert(const QString &sourceId, bool enabled) } } -#include <QStandardPaths> -#include <QFileInfo> -#include <QDir> - NotificationSourceItem NotificationSourceModel::fromDesktopFile(const QString &sourceId) { NotificationSourceItem ret; diff --git a/rockwork/notificationsourcemodel.h b/rockwork/notificationsourcemodel.h index 89fa26f..7349d84 100644 --- a/rockwork/notificationsourcemodel.h +++ b/rockwork/notificationsourcemodel.h @@ -24,7 +24,8 @@ public: enum Roles { RoleName, RoleEnabled, - RoleIcon + RoleIcon, + RoleId }; explicit NotificationSourceModel(QObject *parent = 0); diff --git a/rockwork/pebbles.cpp b/rockwork/pebbles.cpp index e45691e..65eeb6a 100644 --- a/rockwork/pebbles.cpp +++ b/rockwork/pebbles.cpp @@ -16,12 +16,22 @@ Pebbles::Pebbles(QObject *parent): QAbstractListModel(parent) { refresh(); - m_watcher = new QDBusServiceWatcher(ROCKWORK_SERVICE, QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForRegistration, this); + m_watcher = new QDBusServiceWatcher(ROCKWORK_SERVICE, QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForOwnerChange, this); QDBusConnection::sessionBus().connect(ROCKWORK_SERVICE, ROCKWORK_MANAGER_PATH, ROCKWORK_MANAGER_INTERFACE, "PebblesChanged", this, SLOT(refresh())); connect(m_watcher, &QDBusServiceWatcher::serviceRegistered, [this]() { + qDebug() << "service Registered!"; refresh(); QDBusConnection::sessionBus().connect(ROCKWORK_SERVICE, ROCKWORK_MANAGER_PATH, ROCKWORK_MANAGER_INTERFACE, "PebblesChanged", this, SLOT(refresh())); }); + connect(m_watcher, &QDBusServiceWatcher::serviceUnregistered, [this]() { + qDebug() << "service Unregistered!"; + beginResetModel(); + qDeleteAll(m_pebbles); + m_pebbles.clear(); + endResetModel(); + m_connectedToService = false; + emit connectedToServiceChanged(); + }); } int Pebbles::rowCount(const QModelIndex &parent) const @@ -56,6 +66,11 @@ QHash<int, QByteArray> Pebbles::roleNames() const return roles; } +bool Pebbles::connectedToService() +{ + return m_connectedToService; +} + QString Pebbles::version() const { QDBusInterface iface(ROCKWORK_SERVICE, ROCKWORK_MANAGER_PATH, ROCKWORK_MANAGER_INTERFACE); @@ -77,7 +92,10 @@ QString Pebbles::version() const Pebble *Pebbles::get(int index) const { - return m_pebbles.at(index); + if (index >= 0 && index < m_pebbles.count()) { + return m_pebbles.at(index); + } + return nullptr; } int Pebbles::find(const QString &address) const @@ -148,6 +166,11 @@ void Pebbles::refresh() endRemoveRows(); emit countChanged(); } + + if (!m_connectedToService) { + m_connectedToService = true; + emit connectedToServiceChanged(); + } } bool Pebbles::sortPebbles(Pebble *a, Pebble *b) diff --git a/rockwork/pebbles.h b/rockwork/pebbles.h index 0fef3bb..67e4440 100644 --- a/rockwork/pebbles.h +++ b/rockwork/pebbles.h @@ -12,8 +12,8 @@ class QDBusInterface; class Pebbles : public QAbstractListModel { Q_OBJECT + Q_PROPERTY(bool connectedToService READ connectedToService NOTIFY connectedToServiceChanged) Q_PROPERTY(QString version READ version) - Q_PROPERTY(int count READ rowCount NOTIFY countChanged) public: enum Roles { @@ -29,6 +29,7 @@ public: QVariant data(const QModelIndex &index, int role) const override; QHash<int, QByteArray> roleNames() const override; + bool connectedToService(); QString version() const; Q_INVOKABLE Pebble *get(int index) const; @@ -36,6 +37,7 @@ public: signals: + void connectedToServiceChanged(); void countChanged(); private slots: @@ -48,7 +50,7 @@ private: static bool sortPebbles(Pebble *a, Pebble *b); private: - QDBusInterface *m_iface; + bool m_connectedToService = false; QList<Pebble*> m_pebbles; QDBusServiceWatcher *m_watcher; }; |
