mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-22 13:05:51 +03:00
Merge pull request #4616 from nextcloud/bugfix/user-status-selector-crash
Fix crashing when selecting user status and predefined statuses not appearing
This commit is contained in:
commit
d23305f1fa
4 changed files with 32 additions and 15 deletions
|
@ -4,10 +4,14 @@ import com.nextcloud.desktopclient 1.0 as NC
|
|||
|
||||
Window {
|
||||
id: dialog
|
||||
|
||||
title: qsTr("Set user status")
|
||||
|
||||
property NC.UserStatusSelectorModel model: NC.UserStatusSelectorModel {
|
||||
onFinished: dialog.close()
|
||||
}
|
||||
property int userIndex
|
||||
onUserIndexChanged: model.load(userIndex)
|
||||
|
||||
minimumWidth: view.implicitWidth
|
||||
minimumHeight: view.implicitHeight
|
||||
|
|
|
@ -184,10 +184,7 @@ MenuItem {
|
|||
font.pixelSize: Style.topLinePixelSize
|
||||
palette.windowText: Style.ncTextColor
|
||||
hoverEnabled: true
|
||||
onClicked: {
|
||||
showUserStatusSelectorDialog(index)
|
||||
accountMenu.close()
|
||||
}
|
||||
onClicked: showUserStatusSelectorDialog(index)
|
||||
|
||||
background: Item {
|
||||
height: parent.height
|
||||
|
|
|
@ -175,10 +175,6 @@ Window {
|
|||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: userStatusSelectorDialogLoader
|
||||
}
|
||||
|
||||
Menu {
|
||||
id: accountMenu
|
||||
|
||||
|
@ -221,15 +217,36 @@ Window {
|
|||
userLineInstantiator.active = true;
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: userStatusSelectorDialogLoader
|
||||
|
||||
property int userIndex
|
||||
|
||||
function openDialog(newUserIndex) {
|
||||
console.log(`About to show dialog for user with index ${newUserIndex}`);
|
||||
userIndex = newUserIndex;
|
||||
active = true;
|
||||
item.show();
|
||||
}
|
||||
|
||||
active: false
|
||||
sourceComponent: UserStatusSelectorDialog {
|
||||
userIndex: userStatusSelectorDialogLoader.userIndex
|
||||
}
|
||||
|
||||
onLoaded: {
|
||||
item.model.load(userIndex);
|
||||
item.show();
|
||||
}
|
||||
}
|
||||
|
||||
Instantiator {
|
||||
id: userLineInstantiator
|
||||
model: UserModel
|
||||
delegate: UserLine {
|
||||
onShowUserStatusSelectorDialog: {
|
||||
userStatusSelectorDialogLoader.source = "qrc:/qml/src/gui/UserStatusSelectorDialog.qml"
|
||||
userStatusSelectorDialogLoader.item.title = qsTr("Set user status")
|
||||
userStatusSelectorDialogLoader.item.model.load(index)
|
||||
userStatusSelectorDialogLoader.item.show()
|
||||
userStatusSelectorDialogLoader.openDialog(model.index);
|
||||
accountMenu.close();
|
||||
}
|
||||
}
|
||||
onObjectAdded: accountMenu.insertItem(index, object)
|
||||
|
|
|
@ -79,6 +79,7 @@ UserStatusSelectorModel::UserStatusSelectorModel(const UserStatus &userStatus,
|
|||
void UserStatusSelectorModel::load(int id)
|
||||
{
|
||||
reset();
|
||||
qCDebug(lcUserStatusDialogModel) << "Loading user status connector for user with index: " << id;
|
||||
_userStatusConnector = UserModel::instance()->userStatusConnector(id);
|
||||
init();
|
||||
}
|
||||
|
@ -177,7 +178,7 @@ void UserStatusSelectorModel::clearError()
|
|||
|
||||
void UserStatusSelectorModel::setOnlineStatus(UserStatus::OnlineStatus status)
|
||||
{
|
||||
if (status == _userStatus.state()) {
|
||||
if (!_userStatusConnector || status == _userStatus.state()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -300,7 +301,6 @@ Optional<ClearAt> UserStatusSelectorModel::clearStageTypeToDateTime(ClearStageTy
|
|||
|
||||
void UserStatusSelectorModel::setUserStatus()
|
||||
{
|
||||
Q_ASSERT(_userStatusConnector);
|
||||
if (!_userStatusConnector) {
|
||||
return;
|
||||
}
|
||||
|
@ -311,7 +311,6 @@ void UserStatusSelectorModel::setUserStatus()
|
|||
|
||||
void UserStatusSelectorModel::clearUserStatus()
|
||||
{
|
||||
Q_ASSERT(_userStatusConnector);
|
||||
if (!_userStatusConnector) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue