summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-03-27 09:43:37 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-03-27 09:43:37 +0200
commit5f1cf5b7926c568998f213beba9d7932ef7742ef (patch)
treeeea6dbe854c7161dbf8d28ca6bbc0e0b8b7021de
parent2b0278a02b8bb5de9da79de395942c55449c1c59 (diff)
downloadkube-5f1cf5b7926c568998f213beba9d7932ef7742ef.tar.gz
kube-5f1cf5b7926c568998f213beba9d7932ef7742ef.zip
Use states for the account status icon
-rw-r--r--components/mail/contents/ui/Mail.qml19
-rw-r--r--components/package/contents/ui/AccountSwitcher.qml19
-rw-r--r--framework/accounts/accountsmodel.cpp20
-rw-r--r--framework/accounts/accountsmodel.h12
4 files changed, 51 insertions, 19 deletions
diff --git a/components/mail/contents/ui/Mail.qml b/components/mail/contents/ui/Mail.qml
index c5078877..0643287f 100644
--- a/components/mail/contents/ui/Mail.qml
+++ b/components/mail/contents/ui/Mail.qml
@@ -291,9 +291,24 @@ Controls2.ApplicationWindow {
291 } 291 }
292 292
293 ToolButton { 293 ToolButton {
294 visible: model.showStatus 294 id: statusIcon
295 iconName: model.statusIcon 295 visible: false
296 iconName: ""
296 enabled: false 297 enabled: false
298 states: [
299 State {
300 name: "busy"; when: model.status == KubeAccountsFramework.AccountsModel.BusyStatus
301 PropertyChanges { target: statusIcon; iconName: "view-refresh"; visible: true }
302 },
303 State {
304 name: "error"; when: model.status == KubeAccountsFramework.AccountsModel.ErrorStatus
305 PropertyChanges { target: statusIcon; iconName: "emblem-error"; visible: true }
306 },
307 State {
308 name: "checkmark"; when: model.status == KubeAccountsFramework.AccountsModel.ConnectedStatus
309 PropertyChanges { target: statusIcon; iconName: "checkmark"; visible: true }
310 }
311 ]
297 } 312 }
298 } 313 }
299 } 314 }
diff --git a/components/package/contents/ui/AccountSwitcher.qml b/components/package/contents/ui/AccountSwitcher.qml
index 74b6c1ff..8e82dc03 100644
--- a/components/package/contents/ui/AccountSwitcher.qml
+++ b/components/package/contents/ui/AccountSwitcher.qml
@@ -163,9 +163,24 @@ Controls.ToolButton {
163 } 163 }
164 164
165 Controls.ToolButton { 165 Controls.ToolButton {
166 id: statusIcon
167 visible: false
168 iconName: ""
166 enabled: false 169 enabled: false
167 visible: model.showStatus 170 states: [
168 iconName: model.statusIcon 171 State {
172 name: "busy"; when: model.status == KubeAccountsFramework.AccountsModel.BusyStatus
173 PropertyChanges { target: statusIcon; iconName: "view-refresh"; visible: true }
174 },
175 State {
176 name: "error"; when: model.status == KubeAccountsFramework.AccountsModel.ErrorStatus
177 PropertyChanges { target: statusIcon; iconName: "emblem-error"; visible: true }
178 },
179 State {
180 name: "checkmark"; when: model.status == KubeAccountsFramework.AccountsModel.ConnectedStatus
181 PropertyChanges { target: statusIcon; iconName: "checkmark"; visible: true }
182 }
183 ]
169 } 184 }
170 } 185 }
171 Controls2.Button { 186 Controls2.Button {
diff --git a/framework/accounts/accountsmodel.cpp b/framework/accounts/accountsmodel.cpp
index f0487f4f..d999bdbd 100644
--- a/framework/accounts/accountsmodel.cpp
+++ b/framework/accounts/accountsmodel.cpp
@@ -45,8 +45,6 @@ QHash< int, QByteArray > AccountsModel::roleNames() const
45 roles[Icon] = "icon"; 45 roles[Icon] = "icon";
46 roles[AccountId] = "accountId"; 46 roles[AccountId] = "accountId";
47 roles[Status] = "status"; 47 roles[Status] = "status";
48 roles[StatusIcon] = "statusIcon";
49 roles[ShowStatus] = "showStatus";
50 48
51 return roles; 49 return roles;
52} 50}
@@ -63,17 +61,15 @@ QVariant AccountsModel::data(const QModelIndex &idx, int role) const
63 case AccountId: 61 case AccountId:
64 return account->identifier(); 62 return account->identifier();
65 case Status: 63 case Status:
66 return account->getStatus(); 64 switch (account->getStatus()) {
67 case StatusIcon: 65 case Sink::ApplicationDomain::ErrorStatus:
68 if (account->getStatus() == Sink::ApplicationDomain::ErrorStatus) { 66 return ErrorStatus;
69 return "emblem-error"; 67 case Sink::ApplicationDomain::BusyStatus:
70 } else if (account->getStatus() == Sink::ApplicationDomain::BusyStatus) { 68 return BusyStatus;
71 return "view-refresh"; 69 case Sink::ApplicationDomain::ConnectedStatus:
72 } else if (account->getStatus() == Sink::ApplicationDomain::ConnectedStatus) { 70 return ConnectedStatus;
73 return "checkmark";
74 } 71 }
75 case ShowStatus: 72 return OfflineStatus;
76 return (account->getStatus() != Sink::ApplicationDomain::OfflineStatus);
77 } 73 }
78 return QIdentityProxyModel::data(idx, role); 74 return QIdentityProxyModel::data(idx, role);
79} 75}
diff --git a/framework/accounts/accountsmodel.h b/framework/accounts/accountsmodel.h
index 3a2dd712..a32e2c79 100644
--- a/framework/accounts/accountsmodel.h
+++ b/framework/accounts/accountsmodel.h
@@ -34,6 +34,14 @@ class AccountsModel : public QIdentityProxyModel
34 34
35 Q_PROPERTY (QByteArray accountId READ accountId WRITE setAccountId) 35 Q_PROPERTY (QByteArray accountId READ accountId WRITE setAccountId)
36public: 36public:
37 enum Status {
38 OfflineStatus,
39 ConnectedStatus,
40 BusyStatus,
41 ErrorStatus
42 };
43 Q_ENUMS(Status)
44
37 AccountsModel(QObject *parent = Q_NULLPTR); 45 AccountsModel(QObject *parent = Q_NULLPTR);
38 ~AccountsModel(); 46 ~AccountsModel();
39 47
@@ -43,9 +51,7 @@ public:
43 Name = Qt::UserRole + 1, 51 Name = Qt::UserRole + 1,
44 Icon, 52 Icon,
45 AccountId, 53 AccountId,
46 Status, 54 Status
47 StatusIcon,
48 ShowStatus
49 }; 55 };
50 Q_ENUMS(Roles) 56 Q_ENUMS(Roles)
51 57