Skip to content

Commit 4da94f8

Browse files
committed
Make UserStatusSelector a modal popup
Signed-off-by: Claudio Cambra <claudio.cambra@gmail.com>
1 parent d3c09b7 commit 4da94f8

6 files changed

Lines changed: 82 additions & 63 deletions

File tree

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/UserStatusSelectorPopup.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/UserStatusSelectorDialog.qml

Lines changed: 0 additions & 33 deletions
This file was deleted.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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+
Popup {
22+
id: popup
23+
24+
property NC.UserStatusSelectorModel model: NC.UserStatusSelectorModel {
25+
onFinished: popup.close()
26+
}
27+
28+
property int userIndex
29+
onUserIndexChanged: model.load(userIndex)
30+
31+
property int totalImplicitWidth: userStatusSelector.implicitHeight +
32+
scrollView.leftPadding +
33+
scrollView.rightPadding +
34+
leftPadding +
35+
rightPadding
36+
37+
property int totalImplicitHeight: userStatusSelector.implicitHeight +
38+
scrollView.topPadding +
39+
scrollView.bottomPadding +
40+
topPadding +
41+
bottomPadding
42+
43+
width: Math.min(totalImplicitWidth, Style.trayModalWidth)
44+
height: Math.min(totalImplicitHeight, Style.trayModalHeight)
45+
modal: true
46+
clip: true
47+
48+
background: Rectangle {
49+
color: Style.backgroundColor
50+
radius: Style.trayWindowRadius
51+
}
52+
53+
contentItem: ScrollView {
54+
id: scrollView
55+
contentWidth: availableWidth
56+
57+
UserStatusSelector {
58+
id: userStatusSelector
59+
width: scrollView.availableWidth
60+
userStatusSelectorModel: model
61+
}
62+
}
63+
}

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 showUserStatusSelectorPopup(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: showUserStatusSelectorPopup(index)
187187

188188
background: Item {
189189
height: parent.height

src/gui/tray/Window.qml

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,19 @@ Window {
108108
}
109109
}
110110

111+
UserStatusSelectorPopup {
112+
id: userStatusSelectorPopup
113+
anchors.centerIn: parent
114+
115+
function openPopup(newUserIndex) {
116+
console.log(`About to show popup for user with index ${newUserIndex}`);
117+
userIndex = newUserIndex;
118+
model.load(userIndex);
119+
accountMenu.close();
120+
open();
121+
}
122+
}
123+
111124
Rectangle {
112125
id: trayWindowBackground
113126

@@ -206,37 +219,11 @@ Window {
206219
userLineInstantiator.active = true;
207220
}
208221

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-
232222
Instantiator {
233223
id: userLineInstantiator
234224
model: UserModel
235225
delegate: UserLine {
236-
onShowUserStatusSelectorDialog: {
237-
userStatusSelectorDialogLoader.openDialog(model.index);
238-
accountMenu.close();
239-
}
226+
onShowUserStatusSelectorPopup: userStatusSelectorPopup.openPopup(model.index);
240227
}
241228
onObjectAdded: accountMenu.insertItem(index, object)
242229
onObjectRemoved: accountMenu.removeItem(object)

theme/Style/Style.qml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ QtObject {
3434
property int trayWindowBorderWidth: variableSize(1)
3535
property int trayWindowHeaderHeight: variableSize(60)
3636
property int trayHorizontalMargin: 10
37+
property int trayModalWidth: trayWindowWidth * 0.85
38+
property int trayModalHeight: trayWindowHeight * 0.85
3739
property int trayListItemIconSize: accountAvatarSize
3840
property real thumbnailImageSizeReduction: 0.2 // We reserve some space within the thumbnail "item", here about 20%.
3941
// This is because we need to also add the added/modified icon and we

0 commit comments

Comments
 (0)