Changeset View
Changeset View
Standalone View
Standalone View
src/qtquick/uipackages/default/contents/ViewSwitcher.qml
Show All 9 Lines | |||||
10 | */ | 10 | */ | ||
11 | 11 | | |||
12 | import QtQuick 2.7 | 12 | import QtQuick 2.7 | ||
13 | 13 | | |||
14 | import QtQuick.Controls 2.2 as QQC2 | 14 | import QtQuick.Controls 2.2 as QQC2 | ||
15 | 15 | | |||
16 | import org.kde.kirigami 2.2 as Kirigami | 16 | import org.kde.kirigami 2.2 as Kirigami | ||
17 | 17 | | |||
18 | import org.kde.konversation 1.0 as Konversation | ||||
19 | | ||||
18 | Item { | 20 | Item { | ||
19 | id: viewSwitcher | 21 | id: viewSwitcher | ||
20 | 22 | | |||
21 | readonly property string activityColor: "#008000" // WIPQTQUICK TODO Hard-coded green because Breeze' positiveTextColor is ugly. | 23 | readonly property string activityColor: "#008000" // WIPQTQUICK TODO Hard-coded green because Breeze' positiveTextColor is ugly. | ||
22 | readonly property string mentionColor: "red" // WIPQTQUICK TODO Hard-coded red because Breeze' negativeTextColor is ugly. | 24 | readonly property string mentionColor: "red" // WIPQTQUICK TODO Hard-coded red because Breeze' negativeTextColor is ugly. | ||
23 | 25 | | |||
24 | QQC2.ScrollView { | 26 | QQC2.ScrollView { | ||
25 | anchors.fill: parent | 27 | anchors.fill: parent | ||
▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Line(s) | 29 | ListView { | |||
129 | delegate: ListItem { | 131 | delegate: ListItem { | ||
130 | id: viewListItem | 132 | id: viewListItem | ||
131 | 133 | | |||
132 | width: viewListView.width | 134 | width: viewListView.width | ||
133 | 135 | | |||
134 | readonly property int row: index | 136 | readonly property int row: index | ||
135 | readonly property bool hasActivity: model.HasActivity | 137 | readonly property bool hasActivity: model.HasActivity | ||
136 | readonly property int unreadMentions: model.ViewRole.unreadMentions | 138 | readonly property int unreadMentions: model.ViewRole.unreadMentions | ||
139 | property int connectionState: model.ViewRole ? model.ViewRole.server.connectionState : Konversation.Server.SSNeverConnected | ||||
137 | property Item unreadMentionsCounter: null | 140 | property Item unreadMentionsCounter: null | ||
141 | property Item loadingBar: null | ||||
142 | | ||||
138 | 143 | | |||
139 | text: model.display | 144 | text: model.display | ||
140 | textMarginLeft: model.IsChild ? Kirigami.Units.gridUnit * 2 : Kirigami.Units.gridUnit | 145 | textMarginLeft: model.IsChild ? Kirigami.Units.gridUnit * 2 : Kirigami.Units.gridUnit | ||
141 | textMarginRight: unreadMentionsCounter ? (width - unreadMentionsCounter.x) + Kirigami.Units.smallSpacing : 0 | 146 | textMarginRight: unreadMentionsCounter ? (width - unreadMentionsCounter.x) + Kirigami.Units.smallSpacing : 0 | ||
142 | 147 | | |||
143 | textColor: model.HasActivity ? viewSwitcher.activityColor : Kirigami.Theme.textColor | 148 | textColor: model.HasActivity ? viewSwitcher.activityColor : Kirigami.Theme.textColor | ||
144 | 149 | | |||
145 | onTextColorChanged: Qt.callLater(ListView.view.updateOffViewportOverlay) | 150 | onTextColorChanged: Qt.callLater(ListView.view.updateOffViewportOverlay) | ||
146 | 151 | | |||
147 | onUnreadMentionsChanged: { | 152 | onUnreadMentionsChanged: { | ||
148 | if (!unreadMentions && unreadMentionsCounter) { | 153 | if (!unreadMentions && unreadMentionsCounter) { | ||
149 | unreadMentionsCounter.destroy(); | 154 | unreadMentionsCounter.destroy(); | ||
150 | unreadMentionsCounter = null; | 155 | unreadMentionsCounter = null; | ||
151 | } else if (!unreadMentionsCounter) { | 156 | } else if (!unreadMentionsCounter) { | ||
152 | unreadMentionsCounter = unreadMentionsCounterComponent.createObject(viewListItem); | 157 | unreadMentionsCounter = unreadMentionsCounterComponent.createObject(viewListItem); | ||
153 | } | 158 | } | ||
154 | 159 | | |||
155 | Qt.callLater(ListView.view.updateOffViewportOverlay); | 160 | Qt.callLater(ListView.view.updateOffViewportOverlay); | ||
156 | } | 161 | } | ||
157 | 162 | | |||
163 | onConnectionStateChanged: { | ||||
164 | if (connectionState == Konversation.Server.SSConnecting) { | ||||
165 | console.log("Adding loading bar"); | ||||
166 | loadingBar = loadingBarComponent.createObject(viewListItem); | ||||
167 | } else if (loadingBar) { | ||||
168 | loadingBar.destroy(); | ||||
169 | loadingBar = null; | ||||
170 | } | ||||
171 | } | ||||
172 | | ||||
158 | onClicked: { | 173 | onClicked: { | ||
159 | viewListView.forceActiveFocus(); | 174 | viewListView.forceActiveFocus(); | ||
160 | 175 | | |||
161 | if (mouse.button == Qt.RightButton) { | 176 | if (mouse.button == Qt.RightButton) { | ||
162 | viewModel.showViewContextMenu(viewModel.indexForView(model.ViewRole), | 177 | viewModel.showViewContextMenu(viewModel.indexForView(model.ViewRole), | ||
163 | mapToGlobal(mouse.x, mouse.y)); | 178 | mapToGlobal(mouse.x, mouse.y)); | ||
164 | } else { | 179 | } else { | ||
165 | viewListView.showView(value); | 180 | viewListView.showView(value); | ||
166 | } | 181 | } | ||
167 | } | 182 | } | ||
168 | 183 | | |||
169 | Component { | 184 | Component { | ||
185 | id: loadingBarComponent | ||||
186 | | ||||
187 | QQC2.BusyIndicator { | ||||
188 | id: loadingAnimator | ||||
189 | running: true | ||||
190 | anchors.right: parent.right | ||||
191 | // we assume there won't be intersection with showing busy indicator and unread count | ||||
192 | anchors.rightMargin: verticalScrollbar.visible ? verticalScrollbar.width : Kirigami.Units.smallSpacing | ||||
193 | anchors.verticalCenter: parent.verticalCenter | ||||
194 | height: Kirigami.Units.iconSizes.smallMedium | ||||
195 | width: Kirigami.Units.iconSizes.smallMedium | ||||
196 | contentItem: Kirigami.Icon { | ||||
197 | source: "view-refresh" | ||||
198 | } | ||||
199 | | ||||
200 | RotationAnimator { | ||||
201 | target: loadingAnimator | ||||
202 | running: loadingAnimator.visible && loadingAnimator.running | ||||
203 | from: 360 | ||||
204 | to: 0 | ||||
205 | loops: Animation.Infinite | ||||
206 | duration: 1000 | ||||
207 | } | ||||
208 | | ||||
209 | NumberAnimation { | ||||
210 | id: appear | ||||
211 | target: loadingAnimator | ||||
212 | property: "opacity" | ||||
213 | duration: 1000 | ||||
214 | from: 0.0 | ||||
215 | to: 1.0 | ||||
216 | | ||||
217 | } | ||||
218 | | ||||
219 | Component.onCompleted: appear.running = true | ||||
220 | } | ||||
221 | } | ||||
222 | | ||||
223 | Component { | ||||
170 | id: unreadMentionsCounterComponent | 224 | id: unreadMentionsCounterComponent | ||
171 | 225 | | |||
172 | Rectangle { | 226 | Rectangle { | ||
173 | id: unreadMentionsCounter | 227 | id: unreadMentionsCounter | ||
174 | 228 | | |||
175 | anchors.right: parent.right | 229 | anchors.right: parent.right | ||
176 | anchors.rightMargin: verticalScrollbar.visible ? verticalScrollbar.width : Kirigami.Units.smallSpacing | 230 | anchors.rightMargin: verticalScrollbar.visible ? verticalScrollbar.width : Kirigami.Units.smallSpacing | ||
177 | anchors.verticalCenter: parent.verticalCenter | 231 | anchors.verticalCenter: parent.verticalCenter | ||
▲ Show 20 Lines • Show All 74 Lines • Show Last 20 Lines |