-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
To be able to handle clicks outside the search box, we now have a catch-all mouse area. This area does not accept any events but always focuses the comment table. It also overrides all mouse cursors in the main view. The split view drag handle is the only other area where the user expects a different mouse handle. Since listening to the hovered state change is not officially supported, we introduce a workaround that emits a signal whenever the mouse enters or leaves a split view drag handle.
- Loading branch information
Showing
5 changed files
with
126 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
mpvQC | ||
Copyright (C) 2022 mpvQC developers | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import QtQuick | ||
|
||
|
||
MouseArea { | ||
id: root | ||
|
||
required property var mpvqcApplication | ||
|
||
readonly property var mpvqcSettings: mpvqcApplication.mpvqcSettings | ||
|
||
propagateComposedEvents: true | ||
|
||
signal afterPressed() | ||
|
||
function splitViewHandleHovered(state: bool): void { | ||
if (!state) { | ||
cursorShape = Qt.ArrowCursor | ||
} else if (mpvqcSettings.layoutOrientation === Qt.Vertical) { | ||
cursorShape = Qt.SizeVerCursor | ||
} else { | ||
cursorShape = Qt.SizeHorCursor | ||
} | ||
} | ||
|
||
onPressed: (event) => { | ||
event.accepted = false | ||
root.afterPressed() | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright (C) 2018 The Qt Company Ltd. | ||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only | ||
|
||
// Adapted from qtdeclarative/qml/QtQuick/Controls/Material/SplitView.qml | ||
// SplitHandles should be purely visual but we need to detect when the mouse hovers the handle | ||
|
||
import QtQuick | ||
import QtQuick.Templates as T | ||
import QtQuick.Controls.impl | ||
import QtQuick.Controls.Material | ||
|
||
Rectangle { | ||
id: root | ||
|
||
required property var control | ||
|
||
implicitWidth: control.orientation === Qt.Horizontal ? 6 : control.width | ||
implicitHeight: control.orientation === Qt.Horizontal ? control.height : 6 | ||
color: T.SplitHandle.pressed ? control.Material.background | ||
: Qt.lighter(control.Material.background, T.SplitHandle.hovered ? 1.2 : 1.1) | ||
|
||
Rectangle { | ||
color: control.Material.secondaryTextColor | ||
width: control.orientation === Qt.Horizontal ? thickness : length | ||
height: control.orientation === Qt.Horizontal ? length : thickness | ||
radius: thickness | ||
x: (parent.width - width) / 2 | ||
y: (parent.height - height) / 2 | ||
|
||
property int length: parent.T.SplitHandle.pressed ? 3 : 8 | ||
readonly property int thickness: parent.T.SplitHandle.pressed ? 3 : 1 | ||
|
||
Behavior on length { | ||
NumberAnimation { | ||
duration: 100 | ||
} | ||
} | ||
|
||
// Begin: Listen to hover changes | ||
property var hoveredd: parent.T.SplitHandle.hovered | ||
|
||
onHovereddChanged: { | ||
root.hovered = hoveredd | ||
} | ||
// End: Listen to hover changes | ||
} | ||
|
||
// Begin: Listen to hover changes | ||
property var hovered: false | ||
// End: Listen to hover changes | ||
} |