Make RoomSidePane follow buttons size again

Also add selected button color
This commit is contained in:
miruka 2019-05-13 10:52:26 -04:00
parent ca6c55a3e7
commit 125a70bea6
4 changed files with 15 additions and 23 deletions

View File

@ -14,6 +14,7 @@ Button {
property int fontSize: HStyle.fontSize.normal
property color backgroundColor: HStyle.controls.button.background
property alias overlayOpacity: buttonBackgroundOverlay.opacity
property bool checkedLightens: false
property bool loading: false
@ -40,7 +41,9 @@ Button {
background: Rectangle {
id: buttonBackground
color: Qt.lighter(backgroundColor, checked ? 1.3 : 1.0)
color: Qt.lighter(
backgroundColor, checked ? (checkedLightens ? 1.3 : 0.7) : 1.0
)
radius: circle ? height : 0
Rectangle {
@ -106,7 +109,7 @@ Button {
onClicked: button.clicked()
onDoubleClicked: button.doubleClicked()
onEntered: {
overlayOpacity = checked ? 0 : 0.2
overlayOpacity = checked ? 0 : 0.15
button.entered()
}
onExited: {
@ -115,12 +118,12 @@ Button {
}
onPressAndHold: button.pressAndHold()
onPressed: {
overlayOpacity += 0.2
overlayOpacity += 0.15
button.pressed()
}
onReleased: {
if (checkable) { checked = ! checked }
overlayOpacity = checked ? 0 : 0.2
overlayOpacity = checked ? 0 : 0.15
button.released()
}
}

View File

@ -82,28 +82,13 @@ HColumnLayout {
collapsed: width < Layout.minimumWidth + 8
property int parentWidth: parent.width
property int collapseBelow: 120
property int referenceWidth: roomHeader.buttonsWidth
onReferenceWidthChanged:
if (chatSplitView.canAutoSize) { width = referenceWidth }
function set_width() {
width = parent.width * 0.3 < collapseBelow ?
Layout.minimumWidth :
Math.min(parent.width * 0.3,
roomHeader.buttonsImplicitWidth)
}
onParentWidthChanged:
if (chatSplitView.canAutoSize) { set_width() }
width: set_width() // Initial width
width: referenceWidth // Initial width
Layout.minimumWidth: HStyle.avatar.size
Layout.maximumWidth: parent.width
Behavior on width {
NumberAnimation {
duration: chatSplitView.canAutoSize ? 120 : 0
}
}
}
}
}

View File

@ -7,6 +7,7 @@ HRectangle {
property string topic: ""
property alias buttonsImplicitWidth: viewButtons.implicitWidth
property int buttonsWidth: viewButtons.Layout.preferredWidth
property bool collapseButtons: width < 400
@ -69,6 +70,8 @@ HRectangle {
HButton {
iconName: "room_view_" + modelData
iconDimension: 22
autoExclusive: true
checked: modelData == "members" // TODO
}
}

View File

@ -51,6 +51,7 @@ Item {
circle: true
checked: loginWith == modelData
autoExclusive: true
checkedLightens: true
onClicked: loginWith = modelData
}
}