Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(StatusMenu): StatusSuccessAction is not taken into account for Menu width #16357

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletions storybook/pages/LoginViewPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ SplitView {

startupStore: StartupStore {
readonly property QtObject startupModuleInst: QtObject {
readonly property int remainingAttempts: 5

signal accountLoginError
signal obtainingPasswordSuccess
signal obtainingPasswordError
Expand All @@ -34,33 +36,46 @@ SplitView {
colorHash: "0xAB34"
username: "Bob"
thumbnailImage: ""
icon: ""
keyUid: "uid_1"
}
ListElement {
keycardCreatedAccount: false
colorId: 2
colorHash: "0xAB34"
colorHash: "0xAB35"
username: "John"
thumbnailImage: ""
icon: ""
keyUid: "uid_2"
}
ListElement {
keycardCreatedAccount: true
keycardCreatedAccount: false
colorId: 3
colorHash: "0xAB38"
username: "8️⃣6️⃣.eth"
thumbnailImage: ""
icon: ""
keyUid: "uid_4"
}
ListElement {
keycardCreatedAccount: true
colorId: 4
colorHash: "0xAB37"
username: "Very long username that should eventually elide on the right side"
thumbnailImage: ""
icon: ""
keyUid: "uid_3"
}
}
}

readonly property QtObject selectedLoginAccount: QtObject {
readonly property bool keycardCreatedAccount: false
readonly property int colorId: 0
readonly property int colorId: 3
readonly property string username: "8️⃣6️⃣.eth"
readonly property string thumbnailImage: ""
readonly property string keyUid: "uid_3"
readonly property string keyUid: "uid_4"
readonly property string icon: ""
}

readonly property QtObject currentStartupState: QtObject {
Expand Down Expand Up @@ -110,13 +125,6 @@ SplitView {
logsView.logText: logs.logText
}
}

Control {
SplitView.minimumWidth: 300
SplitView.preferredWidth: 300

// model editor will go here
}
}

// category: Views
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/gui/objects_map/names.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
generalView_StatusScrollView = {"container": statusDesktop_mainWindow_overlay, "id": "generalView", "type": "StatusScrollView", "unnamed": 1, "visible": True}

# Context Menu
o_StatusListView = {"container": statusDesktop_mainWindow_overlay, "type": "StatusListView", "unnamed": 1, "visible": True}
o_StatusListView = {"container": statusDesktop_mainWindow_overlay, "type": "PopupItem", "unnamed": 1, "visible": True}

# COMPONENT NAMES

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/gui/objects_map/onboarding_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
accountsView_accountListPanel = {"container": statusDesktop_mainWindow, "objectName": "LoginView_AccountsRepeater", "type": "Repeater", "visible": True}
mainWindow_txtPassword_Input = {"container": statusDesktop_mainWindow, "id": "txtPassword", "type": "Input", "unnamed": 1, "visible": True}
loginView_addNewUserItem_AccountMenuItemPanel = {"container": statusDesktop_mainWindow_overlay, "index": 0, "objectName": "LoginView_addNewUserItem", "type": "AccountMenuItemPanel", "visible": True}
o_AccountMenuItemPanel = {"container": statusDesktop_mainWindow_overlay, "index": 1, "type": "AccountMenuItemPanel", "unnamed": 1, "visible": True}
loginView_addExistingUserItem_AccountMenuItemPanel = {"container": statusDesktop_mainWindow_overlay, "objectName": "LoginView_addExistingUserItem", "type": "AccountMenuItemPanel", "visible": True}
mainWindowUsePasswordInsteadStatusBaseText = {"container": statusDesktop_mainWindow, "text": "Use password instead", "type": "StatusBaseText", "unnamed": 1, "visible": True}

# Touch ID Auth View
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/gui/screens/onboarding.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ def __init__(self):
self._accounts_combobox = QObject(onboarding_names.accountsView_accountListPanel)
self._password_object = QObject(onboarding_names.mainWindow_txtPassword_Input)
self._add_new_user_item = QObject(onboarding_names.loginView_addNewUserItem_AccountMenuItemPanel)
self._add_existing_user_item = QObject(onboarding_names.o_AccountMenuItemPanel)
self._add_existing_user_item = QObject(onboarding_names.loginView_addExistingUserItem_AccountMenuItemPanel)
self._use_password_instead = QObject(onboarding_names.mainWindowUsePasswordInsteadStatusBaseText)

@property
Expand Down
41 changes: 14 additions & 27 deletions ui/StatusQ/src/StatusQ/Popups/StatusMenu.qml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import QtQuick 2.15
import QtQml 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import QtGraphicalEffects 1.15

import StatusQ.Core 0.1
Expand Down Expand Up @@ -67,22 +68,11 @@ Menu {
property var openHandler
property var closeHandler

function checkIfEmpty() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dead code

for (let i = 0; i < root.contentItem.count; ++i) {
const menuItem = root.contentItem.itemAtIndex(i)
if (menuItem.text !== undefined && menuItem.enabled) { // skip menu separators
return false
}
}
return true
}

dim: false
closePolicy: Popup.CloseOnPressOutside | Popup.CloseOnEscape
topPadding: 8
bottomPadding: 8
margins: 16
width: Math.min(implicitWidth, root.maxImplicitWidth)

onOpened: {
if (typeof openHandler === "function") {
Expand All @@ -96,27 +86,24 @@ Menu {
}
}

QtObject {
id: d
//helper property to get the max implicit width of the delegate
property real maxDelegateImplWidth: 0
}

delegate: StatusMenuItem {
visible: root.hideDisabledItems && !visibleOnDisabled ? enabled : true
height: visible ? implicitHeight : 0
onImplicitWidthChanged: {
if (visible)
d.maxDelegateImplWidth = Math.max(d.maxDelegateImplWidth, implicitWidth)
}
}

contentItem: StatusListView {
currentIndex: root.currentIndex
implicitHeight: contentHeight
implicitWidth: d.maxDelegateImplWidth
interactive: contentHeight > availableHeight
model: root.contentModel
contentItem: StatusScrollView {
padding: 0

ColumnLayout {
Repeater {
model: root.contentModel

onItemAdded: {
item.Layout.fillWidth = true
item.Layout.maximumWidth = root.maxImplicitWidth
}
}
}
}

background: Rectangle {
Expand Down
4 changes: 2 additions & 2 deletions ui/StatusQ/src/StatusQ/Popups/StatusMenuItem.qml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import QtQuick 2.13
import QtQuick.Controls 2.13
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15

import StatusQ.Core 0.1
Expand Down
16 changes: 8 additions & 8 deletions ui/StatusQ/src/StatusQ/Popups/StatusSuccessAction.qml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import QtQuick 2.14
import QtQuick 2.15

import StatusQ.Popups 0.1

Expand All @@ -9,7 +9,7 @@ import StatusQ.Popups 0.1
\since StatusQ.Popups 0.1
\brief Menu action displaying success state.
The \c StatusSuccessAction visually indicate a success state after being triggered.
The \c StatusSuccessAction visually indicates a success state after being triggered.
Success state is showed by changing action type to \c{Success}.
\qml
Expand All @@ -27,31 +27,31 @@ StatusMenuItem {
id: root

/*!
\qmlproperty bool StatusSuccessAction.qml::success
\qmlproperty bool StatusSuccessAction::success
This property holds state of the action.
*/
property bool success: false
/*!
\qmlproperty string StatusSuccessAction.qml::successText
\qmlproperty string StatusSuccessAction::successText
This property holds success text displayed on success state.
Default value is binded to \c{text}.
Default value is bound to \c{text}.
*/
property string successText: text
/*!
\qmlproperty string StatusSuccessAction.qml::successIconName
\qmlproperty string StatusSuccessAction::successIconName
This property holds icon name displayed on success state.
Default value is \c{tiny/checkmark}.
*/
property string successIconName: "tiny/checkmark"
/*!
\qmlproperty bool StatusSuccessAction.qml::autoDismissMenu
\qmlproperty bool StatusSuccessAction::autoDismissMenu
This property enable menu closing on click.
*/
property bool autoDismissMenu: false
/*!
\qmlproperty int StatusSuccessAction.qml::timeout
\qmlproperty int StatusSuccessAction::timeout
This property controls how long success state is showed.
*/
property int timeout: 2000
Expand Down
10 changes: 5 additions & 5 deletions ui/app/AppLayouts/Onboarding/panels/AccountMenuItemPanel.qml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import QtQuick 2.13
import QtQuick.Controls 2.13
import QtQuick.Dialogs 1.3
import QtQuick 2.15
import QtQuick.Controls 2.15

import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
Expand All @@ -21,12 +20,12 @@ Item {
property bool keycardCreatedAccount: false

property StatusAssetSettings asset: StatusAssetSettings {
name: "add"
name: "add"
}

signal clicked()

width: parent.width
implicitWidth: parent.width
height: 64

Rectangle {
Expand Down Expand Up @@ -68,6 +67,7 @@ Item {
anchors.left: userImageOrIcon.right
anchors.right: root.keycardCreatedAccount? keycardIcon.left : parent.right
anchors.leftMargin: Style.current.padding
anchors.rightMargin: root.keycardCreatedAccount ? 0 : Style.current.padding
color: !!root.colorId ? Theme.palette.directColor1 : Theme.palette.primaryColor1
elide: Text.ElideRight
}
Expand Down
2 changes: 1 addition & 1 deletion ui/app/AppLayouts/Onboarding/views/LoginView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ Item {
if (model.username === Constants.appTranslatableConstants.loginAccountsListAddNewUser) {
return "LoginView_addNewUserItem"
}
return ""
return "LoginView_addExistingUserItem"
}
label: {
if (model.username === Constants.appTranslatableConstants.loginAccountsListAddNewUser ||
Expand Down
3 changes: 2 additions & 1 deletion ui/imports/shared/controls/chat/UserImage.qml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import QtQuick 2.3
import QtQuick 2.15

import shared 1.0
import shared.panels 1.0

Expand Down