Fix PopupTips height

pull/3/head 0.1
cutefishd 5 years ago
parent f4a3e6fcb2
commit 99dd84c210

@ -1,165 +0,0 @@
/*
* Copyright 2021 Rui Wang <wangrui@jingos.com>
*
* 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 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* 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 <https://www.gnu.org/licenses/>.
*/
import QtQuick 2.12
import FishUI 1.0 as FishUI
Rectangle {
id: background
property real moveX: 0
property real moveY: 0
property bool darkMode: false
anchors.fill: parent
radius: FishUI.Theme.smallRadius
color: "transparent"
signal clicked(var mouse)
property color hoveredColor: FishUI.Theme.darkMode ? Qt.lighter(FishUI.Theme.backgroundColor, 1.1)
: Qt.darker(FishUI.Theme.backgroundColor, 1.2)
property color pressedColor: FishUI.Theme.darkMode ? Qt.lighter(FishUI.Theme.backgroundColor, 1.2)
: Qt.darker(FishUI.Theme.backgroundColor, 1.3)
Rectangle {
id: press_item
anchors.fill: parent
color: background.pressedColor
visible: false
radius: parent.radius
// opacity: background.darkMode ? 0.3 : 0.16
}
Rectangle {
id: back_item
color: background.hoveredColor
radius: parent.radius
// opacity: darkMode ? 0.18 : 0.12
state: "hiden"
states: [
State {
name: "shown"
PropertyChanges {
target: back_item
x: 0
y: 0
width: background.width
height: background.height
visible:true
}
PropertyChanges {
target: background.parent
scale: 1.1
}
},
State {
name: "hiden"
PropertyChanges {
target: back_item
x: background.moveX
y: background.moveY
width: 0
height: 0
visible:false
scale: 1
}
PropertyChanges {
target: background.parent
scale: 1
}
}
]
transitions:[
Transition {
from:"hiden"; to:"shown"
SequentialAnimation{
PropertyAnimation { target: back_item; properties: "visible"; duration: 0; easing.type: Easing.OutQuart }
PropertyAnimation { target: back_item; properties: "x,y,width,height"; duration: 400; easing.type: Easing.OutQuart }
}
PropertyAnimation { target: background.parent; properties: "scale"; duration: 400; easing.type: Easing.OutQuart }
},
Transition {
from:"shown"; to:"hiden"
SequentialAnimation{
PropertyAnimation { target: back_item; properties: "x,y,width,height,"; duration: 200; easing.type: Easing.OutQuart }
PropertyAnimation { target: back_item; properties: "visible"; duration: 0; easing.type: Easing.OutQuart }
}
PropertyAnimation { target: background.parent; properties: "scale"; duration: 200; easing.type: Easing.OutQuart }
}
]
}
MouseArea {
id: area
anchors.fill: parent
hoverEnabled: true
onEntered: {
// cursorShape = Qt.BlankCursor
back_item.x = mouseX
back_item.y = mouseY
back_item.state = "shown"
}
onExited: {
// cursorShape = Qt.ArrowCursor
background.moveX = mouseX
background.moveY = mouseY
back_item.state = "hiden"
press_item.visible = false
}
onClicked: {
background.clicked(mouse)
}
onPressed: {
press_item.visible = true
back_item.visible = false
}
onReleased: {
press_item.visible = false
back_item.visible = true
}
}
}

@ -15,7 +15,7 @@ Window {
flags: Qt.WindowStaysOnTopHint | Qt.WindowDoesNotAcceptFocus | Qt.ToolTip
width: label.implicitWidth + FishUI.Units.largeSpacing * 1.5
height: FishUI.Units.fontMetrics.height + FishUI.Units.largeSpacing * 1.5
height: label.implicitHeight + FishUI.Units.largeSpacing * 1.5
FishUI.WindowShadow {
view: control

@ -11,46 +11,8 @@ Item {
property var color: FishUI.Theme.backgroundColor
property bool animationEnabled: true
property alias backgroundOpacity: _background.opacity
property QtObject sourceItem: null
property bool blurEnabled: false
property real blurRadius: 100
property int startX: 0
property int startY: 0
onStartXChanged: {
var jx = eff.mapToItem(sourceItem.parent, control.x, control.y)
control.startX = jx.x
control.startY = jx.y
eff.sourceRect = Qt.rect(control.startX, control.startY, control.width, control.height)
}
ShaderEffectSource {
id: eff
anchors.fill: parent
sourceItem: control.sourceItem
sourceRect: Qt.rect(control.startX, control.startY, control.width, control.height)
visible: false
}
FastBlur {
id: fastBlur
anchors.fill: parent
source: eff
radius: control.blurRadius
cached: true
visible: true
}
OpacityMask {
id: mask
anchors.fill: _background
source: fastBlur
maskSource: _background
}
Rectangle {
id: _background
anchors.fill: parent

@ -66,7 +66,6 @@ void FishUI::registerTypes(const char *uri)
qmlRegisterType(componentUrl(QStringLiteral("BusyIndicator.qml")), uri, 1, 0, "BusyIndicator");
qmlRegisterType(componentUrl(QStringLiteral("Icon.qml")), uri, 1, 0, "Icon");
qmlRegisterType(componentUrl(QStringLiteral("MouseHover.qml")), uri, 1, 0, "MouseHover");
qmlRegisterType(componentUrl(QStringLiteral("PopupTips.qml")), uri, 1, 0, "PopupTips");
qmlRegisterType(componentUrl(QStringLiteral("RoundedRect.qml")), uri, 1, 0, "RoundedRect");
qmlRegisterType(componentUrl(QStringLiteral("Toast.qml")), uri, 1, 0, "Toast");

@ -2,7 +2,6 @@
<qresource prefix="/fishui/kit">
<file alias="BusyIndicator.qml">controls/BusyIndicator.qml</file>
<file alias="Icon.qml">controls/Icon.qml</file>
<file alias="MouseHover.qml">controls/MouseHover.qml</file>
<file alias="PopupTips.qml">controls/PopupTips.qml</file>
<file alias="RoundedRect.qml">controls/RoundedRect.qml</file>
<file alias="Theme.qml">controls/Theme.qml</file>

Loading…
Cancel
Save