Skip to content
Snippets Groups Projects
Commit ddc793e3 authored by Ming Rui Zhang's avatar Ming Rui Zhang
Browse files

aboutPopupButton: make the button width grows with text width

Change-Id: I99d5e01dd7438361a6ddafe2f1d97be1536c288b
parent 24a8631c
No related branches found
No related tags found
No related merge requests found
...@@ -41,7 +41,9 @@ Button { ...@@ -41,7 +41,9 @@ Button {
property var iconPreferredHeight: 18 property var iconPreferredHeight: 18
property var iconPreferredWidth: 18 property var iconPreferredWidth: 18
property bool enableElide: true
property int elide: Text.ElideRight property int elide: Text.ElideRight
property int textActualWidth: buttonTextMetrics.boundingRect.width
font.kerning: true font.kerning: true
font.pointSize: JamiTheme.textFontSize font.pointSize: JamiTheme.textFontSize
...@@ -71,26 +73,9 @@ Button { ...@@ -71,26 +73,9 @@ Button {
visible: animatedImageSource.length !== 0 visible: animatedImageSource.length !== 0
} }
Image { ResponsiveImage {
id: buttonImage id: buttonImage
property real pixelDensity: Screen.pixelDensity
property real isSvg: {
var match = /[^.]+$/.exec(source)
return match !== null && match[0] === 'svg'
}
function setSourceSize() {
if (isSvg) {
sourceSize.width = width
sourceSize.height = height
} else
sourceSize = undefined
}
onPixelDensityChanged: setSourceSize()
Component.onCompleted: setSourceSize()
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: JamiTheme.preferredMarginSize / 2 anchors.leftMargin: JamiTheme.preferredMarginSize / 2
...@@ -99,20 +84,14 @@ Button { ...@@ -99,20 +84,14 @@ Button {
width: iconPreferredWidth width: iconPreferredWidth
visible: source.toString().length !== 0 visible: source.toString().length !== 0
layer { color: {
enabled: true if (!outlined)
effect: ColorOverlay { return "white"
id: overlay if (hovered && root.hoveredColor)
color:{ return root.hoveredColor
if (!outlined) if (checked && root.pressedColor)
return "white" return root.pressedColor
if (hovered && root.hoveredColor) return root.color
return root.hoveredColor
if (checked && root.pressedColor)
return root.pressedColor
return root.color
}
}
} }
} }
...@@ -128,8 +107,15 @@ Button { ...@@ -128,8 +107,15 @@ Button {
JamiTheme.preferredMarginSize / 2 - minimumIconTextSpacing) * 2 JamiTheme.preferredMarginSize / 2 - minimumIconTextSpacing) * 2
} }
TextMetrics {
id: buttonTextMetrics
font: buttonText.font
text: buttonText.text
}
text: root.text text: root.text
elide: root.elide elide: enableElide ? root.elide : Text.ElideNone
color: { color: {
if (!outlined) if (!outlined)
return "white" return "white"
......
...@@ -196,6 +196,7 @@ Item { ...@@ -196,6 +196,7 @@ Item {
property real smartListItemHeight: 64 property real smartListItemHeight: 64
property real smartListAvatarSize: 52 property real smartListAvatarSize: 52
property real avatarSizeInCall: 130 property real avatarSizeInCall: 130
property real aboutButtonPreferredWidth: 150
property real callButtonPreferredSize: 50 property real callButtonPreferredSize: 50
property real contextMenuItemTextPreferredWidth: 142 property real contextMenuItemTextPreferredWidth: 142
property real contextMenuItemTextMaxWidth: 182 property real contextMenuItemTextMaxWidth: 182
......
...@@ -159,14 +159,21 @@ Rectangle { ...@@ -159,14 +159,21 @@ Rectangle {
Layout.alignment: Qt.AlignBottom | Qt.AlignHCenter Layout.alignment: Qt.AlignBottom | Qt.AlignHCenter
Layout.bottomMargin: JamiTheme.preferredMarginSize Layout.bottomMargin: JamiTheme.preferredMarginSize
Layout.preferredWidth: 150 Layout.preferredWidth: JamiTheme.aboutButtonPreferredWidth
Layout.preferredHeight: 30 Layout.preferredHeight: preferredHeight
color: JamiTheme.buttonTintedBlack color: JamiTheme.buttonTintedBlack
enableElide: false
hoveredColor: JamiTheme.buttonTintedBlackHovered hoveredColor: JamiTheme.buttonTintedBlackHovered
pressedColor: JamiTheme.buttonTintedBlackPressed pressedColor: JamiTheme.buttonTintedBlackPressed
outlined: true outlined: true
onTextActualWidthChanged: {
if (textActualWidth > btnAboutPopUp.Layout.preferredWidth)
btnAboutPopUp.Layout.preferredWidth =
textActualWidth + JamiTheme.preferredMarginSize * 2
}
text: JamiStrings.aboutJami text: JamiStrings.aboutJami
onClicked: aboutPopUpDialog.open() onClicked: aboutPopUpDialog.open()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment