Skip to content

Commit e92aa62

Browse files
authored
Merge pull request #4760 from nextcloud/feature/modal-userstatusselector
Make UserStatusSelector a dismissible page pushed onto the tray window
2 parents b90e79a + d86f25d commit e92aa62

10 files changed

Lines changed: 417 additions & 353 deletions

resources.qrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<RCC>
22
<qresource prefix="/qml">
33
<file>src/gui/UserStatusSelector.qml</file>
4-
<file>src/gui/UserStatusSelectorDialog.qml</file>
4+
<file>src/gui/UserStatusSelectorPage.qml</file>
55
<file>src/gui/EmojiPicker.qml</file>
66
<file>src/gui/UserStatusSelectorButton.qml</file>
77
<file>src/gui/PredefinedStatusButton.qml</file>

src/gui/UserStatusSelector.qml

Lines changed: 256 additions & 241 deletions
Large diffs are not rendered by default.

src/gui/UserStatusSelectorDialog.qml

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/gui/UserStatusSelectorPage.qml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (C) 2022 by Claudio Cambra <claudio.cambra@nextcloud.com>
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 2 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful, but
10+
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11+
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* for more details.
13+
*/
14+
15+
import QtQuick 2.15
16+
import QtQuick.Controls 2.15
17+
import Style 1.0
18+
19+
import com.nextcloud.desktopclient 1.0 as NC
20+
21+
Page {
22+
id: page
23+
24+
signal finished
25+
26+
property int userIndex: -1
27+
property NC.UserStatusSelectorModel model: NC.UserStatusSelectorModel {
28+
userIndex: page.userIndex
29+
onFinished: page.finished()
30+
}
31+
32+
padding: Style.standardSpacing * 2
33+
34+
background: Rectangle {
35+
color: Style.backgroundColor
36+
radius: Style.trayWindowRadius
37+
}
38+
39+
contentItem: UserStatusSelector {
40+
id: userStatusSelector
41+
userStatusSelectorModel: model
42+
onImplicitHeightChanged: implicitHeight > page.availableHeight ?
43+
spacing = Style.standardSpacing : spacing = Style.standardSpacing * 2
44+
}
45+
}

src/gui/tray/UserLine.qml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ MenuItem {
1818
property variant comp;
1919
activeFocusOnTab: false
2020

21-
signal showUserStatusSelectorDialog(int id)
21+
signal showUserStatusSelector(int id)
2222

2323
RowLayout {
2424
id: userLineLayout
@@ -183,7 +183,7 @@ MenuItem {
183183
font.pixelSize: Style.topLinePixelSize
184184
palette.windowText: Style.ncTextColor
185185
hoverEnabled: true
186-
onClicked: showUserStatusSelectorDialog(index)
186+
onClicked: showUserStatusSelector(index)
187187

188188
background: Item {
189189
height: parent.height

src/gui/tray/Window.qml

Lines changed: 77 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import QtQml 2.12
2-
import QtQml.Models 2.1
31
import QtQuick 2.15
42
import QtQuick.Window 2.3
53
import QtQuick.Controls 2.3
@@ -13,7 +11,7 @@ import Style 1.0
1311

1412
import com.nextcloud.desktopclient 1.0
1513

16-
Window {
14+
ApplicationWindow {
1715
id: trayWindow
1816

1917
title: Systray.windowTitle
@@ -53,6 +51,13 @@ Window {
5351
syncStatus.model.load();
5452
}
5553

54+
background: Rectangle {
55+
radius: Systray.useNormalWindow ? 0.0 : Style.trayWindowRadius
56+
border.width: Style.trayWindowBorderWidth
57+
border.color: Style.menuBorder
58+
color: Style.backgroundColor
59+
}
60+
5661
Connections {
5762
target: UserModel
5863
function onCurrentUserChanged() {
@@ -78,6 +83,8 @@ Window {
7883
target: Systray
7984

8085
function onIsOpenChanged() {
86+
userStatusDrawer.close()
87+
8188
if(Systray.isOpen) {
8289
accountMenu.close();
8390
appsMenu.close();
@@ -98,39 +105,72 @@ Window {
98105
OpacityMask {
99106
anchors.fill: parent
100107
source: ShaderEffectSource {
101-
sourceItem: trayWindowBackground
108+
sourceItem: trayWindowMainItem
102109
hideSource: true
103110
}
104111
maskSource: Rectangle {
105-
width: trayWindowBackground.width
106-
height: trayWindowBackground.height
112+
width: trayWindow.width
113+
height: trayWindow.height
107114
radius: Systray.useNormalWindow ? 0.0 : Style.trayWindowRadius
108115
}
109116
}
110117

111-
Rectangle {
112-
id: trayWindowBackground
118+
Drawer {
119+
id: userStatusDrawer
120+
width: parent.width
121+
height: parent.height
122+
padding: 0
123+
edge: Qt.BottomEdge
124+
modal: false
125+
visible: false
126+
127+
background: Rectangle {
128+
radius: Systray.useNormalWindow ? 0.0 : Style.trayWindowRadius
129+
border.width: Style.trayWindowBorderWidth
130+
border.color: Style.menuBorder
131+
color: Style.backgroundColor
132+
}
133+
134+
property int userIndex: 0
135+
136+
function openUserStatusDrawer(index) {
137+
console.log(`About to show dialog for user with index ${index}`);
138+
userIndex = index;
139+
open();
140+
}
141+
142+
Loader {
143+
id: userStatusContents
144+
anchors.fill: parent
145+
active: userStatusDrawer.visible
146+
sourceComponent: UserStatusSelectorPage {
147+
anchors.fill: parent
148+
userIndex: userStatusDrawer.userIndex
149+
onFinished: userStatusDrawer.close()
150+
}
151+
}
152+
}
153+
154+
Item {
155+
id: trayWindowMainItem
113156

114157
property bool isUnifiedSearchActive: unifiedSearchResultsListViewSkeletonLoader.active
115158
|| unifiedSearchResultNothingFound.visible
116159
|| unifiedSearchResultsErrorLabel.visible
117160
|| unifiedSearchResultsListView.visible
118161

119162
anchors.fill: parent
120-
radius: Systray.useNormalWindow ? 0.0 : Style.trayWindowRadius
121-
border.width: Style.trayWindowBorderWidth
122-
border.color: Style.menuBorder
123-
color: Style.backgroundColor
163+
clip: true
124164

125165
Accessible.role: Accessible.Grouping
126166
Accessible.name: qsTr("Nextcloud desktop main dialog")
127167

128168
Rectangle {
129169
id: trayWindowHeaderBackground
130170

131-
anchors.left: trayWindowBackground.left
132-
anchors.right: trayWindowBackground.right
133-
anchors.top: trayWindowBackground.top
171+
anchors.left: trayWindowMainItem.left
172+
anchors.right: trayWindowMainItem.right
173+
anchors.top: trayWindowMainItem.top
134174
height: Style.trayWindowHeaderHeight
135175
color: UserModel.currentUser.headerColor
136176

@@ -206,35 +246,12 @@ Window {
206246
userLineInstantiator.active = true;
207247
}
208248

209-
Loader {
210-
id: userStatusSelectorDialogLoader
211-
212-
property int userIndex
213-
214-
function openDialog(newUserIndex) {
215-
console.log(`About to show dialog for user with index ${newUserIndex}`);
216-
userIndex = newUserIndex;
217-
active = true;
218-
item.show();
219-
}
220-
221-
active: false
222-
sourceComponent: UserStatusSelectorDialog {
223-
userIndex: userStatusSelectorDialogLoader.userIndex
224-
}
225-
226-
onLoaded: {
227-
item.model.load(userIndex);
228-
item.show();
229-
}
230-
}
231-
232249
Instantiator {
233250
id: userLineInstantiator
234251
model: UserModel
235252
delegate: UserLine {
236-
onShowUserStatusSelectorDialog: {
237-
userStatusSelectorDialogLoader.openDialog(model.index);
253+
onShowUserStatusSelector: {
254+
userStatusDrawer.openUserStatusDrawer(model.index);
238255
accountMenu.close();
239256
}
240257
}
@@ -661,8 +678,8 @@ Window {
661678

662679
anchors {
663680
top: trayWindowHeaderBackground.bottom
664-
left: trayWindowBackground.left
665-
right: trayWindowBackground.right
681+
left: trayWindowMainItem.left
682+
right: trayWindowMainItem.right
666683

667684
topMargin: Style.trayHorizontalMargin + controlRoot.padding
668685
leftMargin: Style.trayHorizontalMargin + controlRoot.padding
@@ -681,17 +698,17 @@ Window {
681698
visible: UserModel.currentUser.unifiedSearchResultsListModel.errorString && !unifiedSearchResultsListView.visible && ! UserModel.currentUser.unifiedSearchResultsListModel.isSearchInProgress && ! UserModel.currentUser.unifiedSearchResultsListModel.currentFetchMoreInProgressProviderId
682699
text: UserModel.currentUser.unifiedSearchResultsListModel.errorString
683700
anchors.top: trayWindowUnifiedSearchInputContainer.bottom
684-
anchors.left: trayWindowBackground.left
685-
anchors.right: trayWindowBackground.right
701+
anchors.left: trayWindowMainItem.left
702+
anchors.right: trayWindowMainItem.right
686703
anchors.margins: Style.trayHorizontalMargin
687704
}
688705

689706
UnifiedSearchResultNothingFound {
690707
id: unifiedSearchResultNothingFound
691708
visible: false
692709
anchors.top: trayWindowUnifiedSearchInputContainer.bottom
693-
anchors.left: trayWindowBackground.left
694-
anchors.right: trayWindowBackground.right
710+
anchors.left: trayWindowMainItem.left
711+
anchors.right: trayWindowMainItem.right
695712
anchors.topMargin: Style.trayHorizontalMargin
696713

697714
text: UserModel.currentUser.unifiedSearchResultsListModel.searchTerm
@@ -724,9 +741,9 @@ Window {
724741
Loader {
725742
id: unifiedSearchResultsListViewSkeletonLoader
726743
anchors.top: trayWindowUnifiedSearchInputContainer.bottom
727-
anchors.left: trayWindowBackground.left
728-
anchors.right: trayWindowBackground.right
729-
anchors.bottom: trayWindowBackground.bottom
744+
anchors.left: trayWindowMainItem.left
745+
anchors.right: trayWindowMainItem.right
746+
anchors.bottom: trayWindowMainItem.bottom
730747

731748
active: !unifiedSearchResultNothingFound.visible &&
732749
!unifiedSearchResultsListView.visible &&
@@ -752,9 +769,9 @@ Window {
752769
visible: unifiedSearchResultsListView.count > 0
753770

754771
anchors.top: trayWindowUnifiedSearchInputContainer.bottom
755-
anchors.left: trayWindowBackground.left
756-
anchors.right: trayWindowBackground.right
757-
anchors.bottom: trayWindowBackground.bottom
772+
anchors.left: trayWindowMainItem.left
773+
anchors.right: trayWindowMainItem.right
774+
anchors.bottom: trayWindowMainItem.bottom
758775

759776
ListView {
760777
id: unifiedSearchResultsListView
@@ -791,19 +808,19 @@ Window {
791808
SyncStatus {
792809
id: syncStatus
793810

794-
visible: !trayWindowBackground.isUnifiedSearchActive
811+
visible: !trayWindowMainItem.isUnifiedSearchActive
795812

796813
anchors.top: trayWindowUnifiedSearchInputContainer.bottom
797-
anchors.left: trayWindowBackground.left
798-
anchors.right: trayWindowBackground.right
814+
anchors.left: trayWindowMainItem.left
815+
anchors.right: trayWindowMainItem.right
799816
}
800817

801818
ActivityList {
802-
visible: !trayWindowBackground.isUnifiedSearchActive
819+
visible: !trayWindowMainItem.isUnifiedSearchActive
803820
anchors.top: syncStatus.bottom
804-
anchors.left: trayWindowBackground.left
805-
anchors.right: trayWindowBackground.right
806-
anchors.bottom: trayWindowBackground.bottom
821+
anchors.left: trayWindowMainItem.left
822+
anchors.right: trayWindowMainItem.right
823+
anchors.bottom: trayWindowMainItem.bottom
807824

808825
activeFocusOnTab: true
809826
model: activityModel
@@ -833,5 +850,5 @@ Window {
833850

834851
onLoaded: refresh()
835852
}
836-
} // Rectangle trayWindowBackground
853+
} // Item trayWindowMainItem
837854
}

0 commit comments

Comments
 (0)