Use new Kirigami builtin column resize handle
Use the new Kirigami.ColumnView.interactiveResizeEnabled attached property which allows to have a built in resize handle for ColumnView pages removing the need for a custom handle with resize logic depends from https://invent.kde.org/frameworks/kirigami/-/merge_requests/1795
This commit is contained in:
@@ -41,6 +41,7 @@ Kirigami.ApplicationWindow {
|
|||||||
showExisting: true
|
showExisting: true
|
||||||
onConnectionChosen: root.load()
|
onConnectionChosen: root.load()
|
||||||
}
|
}
|
||||||
|
columnView.columnResizeMode: pageStack.wideMode ? Kirigami.ColumnView.DynamicColumns : Kirigami.ColumnView.SingleColumn
|
||||||
globalToolBar.canContainHandles: true
|
globalToolBar.canContainHandles: true
|
||||||
globalToolBar {
|
globalToolBar {
|
||||||
style: Kirigami.ApplicationHeaderStyle.ToolBar
|
style: Kirigami.ApplicationHeaderStyle.ToolBar
|
||||||
|
|||||||
@@ -17,13 +17,22 @@ import org.kde.neochat
|
|||||||
Kirigami.Page {
|
Kirigami.Page {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
/**
|
Kirigami.ColumnView.interactiveResizeEnabled: true
|
||||||
* @brief The current width of the room list.
|
Kirigami.ColumnView.minimumWidth: _private.collapsedSize + spaceDrawer.width + 1
|
||||||
*
|
Kirigami.ColumnView.maximumWidth: _private.defaultWidth + spaceDrawer.width + 1
|
||||||
* @note Other objects can access the value but the private function makes sure
|
Kirigami.ColumnView.onInteractiveResizingChanged: {
|
||||||
* that only the internal members can modify it.
|
if (!Kirigami.ColumnView.interactiveResizing && collapsed) {
|
||||||
*/
|
Kirigami.ColumnView.preferredWidth = root.Kirigami.ColumnView.minimumWidth;
|
||||||
readonly property int currentWidth: _private.currentWidth + spaceDrawer.width + 1
|
}
|
||||||
|
}
|
||||||
|
Kirigami.ColumnView.preferredWidth: _private.currentWidth + spaceDrawer.width + 1
|
||||||
|
Kirigami.ColumnView.onPreferredWidthChanged: {
|
||||||
|
if (width > _private.collapseWidth) {
|
||||||
|
NeoChatConfig.collapsed = false;
|
||||||
|
} else if (Kirigami.ColumnView.interactiveResizing) {
|
||||||
|
NeoChatConfig.collapsed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
required property NeoChatConnection connection
|
required property NeoChatConnection connection
|
||||||
|
|
||||||
@@ -31,10 +40,6 @@ Kirigami.Page {
|
|||||||
|
|
||||||
signal search
|
signal search
|
||||||
|
|
||||||
onCurrentWidthChanged: pageStack.defaultColumnWidth = root.currentWidth
|
|
||||||
Component.onCompleted: pageStack.defaultColumnWidth = root.currentWidth
|
|
||||||
|
|
||||||
|
|
||||||
onCollapsedChanged: {
|
onCollapsedChanged: {
|
||||||
if (collapsed) {
|
if (collapsed) {
|
||||||
RoomManager.sortFilterRoomTreeModel.filterText = "";
|
RoomManager.sortFilterRoomTreeModel.filterText = "";
|
||||||
@@ -244,49 +249,6 @@ Kirigami.Page {
|
|||||||
sourceComponent: Kirigami.Settings.isMobile ? exploreComponentMobile : userInfoDesktop
|
sourceComponent: Kirigami.Settings.isMobile ? exploreComponentMobile : userInfoDesktop
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
anchors.top: parent.top
|
|
||||||
anchors.bottom: parent.bottom
|
|
||||||
parent: applicationWindow().overlay.parent
|
|
||||||
|
|
||||||
x: root.currentWidth - width / 2
|
|
||||||
width: Kirigami.Units.smallSpacing * 2
|
|
||||||
z: root.z + 1
|
|
||||||
enabled: RoomManager.hasOpenRoom && applicationWindow().width >= Kirigami.Units.gridUnit * 35
|
|
||||||
visible: enabled
|
|
||||||
cursorShape: Qt.SplitHCursor
|
|
||||||
|
|
||||||
property int _lastX
|
|
||||||
|
|
||||||
onPressed: mouse => {
|
|
||||||
_lastX = mouse.x;
|
|
||||||
}
|
|
||||||
onPositionChanged: mouse => {
|
|
||||||
if (_lastX == -1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (mouse.x > _lastX) {
|
|
||||||
// we moved to the right
|
|
||||||
if (_private.currentWidth < _private.collapseWidth && _private.currentWidth + (mouse.x - _lastX) >= _private.collapseWidth) {
|
|
||||||
// Here we get back directly to a more wide mode.
|
|
||||||
_private.currentWidth = _private.defaultWidth;
|
|
||||||
NeoChatConfig.collapsed = false;
|
|
||||||
} else if (_private.currentWidth >= _private.collapseWidth) {
|
|
||||||
// Increase page width
|
|
||||||
_private.currentWidth = Math.min(_private.defaultWidth, _private.currentWidth + (mouse.x - _lastX));
|
|
||||||
}
|
|
||||||
} else if (mouse.x < _lastX) {
|
|
||||||
const tmpWidth = _private.currentWidth - (_lastX - mouse.x);
|
|
||||||
if (tmpWidth < _private.collapseWidth) {
|
|
||||||
_private.currentWidth = Qt.binding(() => _private.collapsedSize);
|
|
||||||
NeoChatConfig.collapsed = true;
|
|
||||||
} else {
|
|
||||||
_private.currentWidth = tmpWidth;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
id: userInfo
|
id: userInfo
|
||||||
UserInfo {
|
UserInfo {
|
||||||
|
|||||||
Reference in New Issue
Block a user