|
| 1 | +import QtQuick 2.15 |
| 2 | +import QtQuick.Layouts 1.15 |
| 3 | +import QtGraphicalEffects 1.15 |
| 4 | +import QtQuick.Templates 2.15 as T |
| 5 | + |
| 6 | +import "qrc:/../common" |
| 7 | +import "qrc:/../DelButton" |
| 8 | +import "qrc:/../DelDivider" |
| 9 | + |
| 10 | +T.Drawer { |
| 11 | + id: control |
| 12 | + |
| 13 | + titleFont { |
| 14 | + family: "微软雅黑" |
| 15 | + pixelSize: 18 |
| 16 | + } |
| 17 | + |
| 18 | + property bool animationEnabled: true |
| 19 | + property int drawerSize: 378 |
| 20 | + property string title: "" |
| 21 | + property font titleFont |
| 22 | + property color colorTitle: "#000" |
| 23 | + property color colorBg: "#fff" |
| 24 | + property color colorOverlay: Qt.rgba(0,0,0,0.45) |
| 25 | + property Component titleDelegate: Item { |
| 26 | + height: 56 |
| 27 | + |
| 28 | + Row { |
| 29 | + height: parent.height |
| 30 | + anchors.left: parent.left |
| 31 | + anchors.leftMargin: 15 |
| 32 | + spacing: 5 |
| 33 | + |
| 34 | + DelIconButton { |
| 35 | + id: __close |
| 36 | + type: DelButton.Type_Text |
| 37 | + effectEnabled: false |
| 38 | + topPadding: 2 |
| 39 | + bottomPadding: 2 |
| 40 | + leftPadding: 4 |
| 41 | + rightPadding: 4 |
| 42 | + radiusBg: 4 |
| 43 | + anchors.verticalCenter: parent.verticalCenter |
| 44 | + iconSource: DelIcon.CloseOutlined |
| 45 | + colorIcon: hovered ? Qt.rgba(0,0,0,1) : Qt.rgba(0,0,0,0.4) |
| 46 | + colorBg: __close.down ? Qt.rgba(0,0,0,0.15) : |
| 47 | + __close.hovered ? Qt.rgba(0,0,0,0.06) : Qt.rgba(0,0,0,0) |
| 48 | + onClicked: { |
| 49 | + control.close(); |
| 50 | + } |
| 51 | + |
| 52 | + HoverHandler { |
| 53 | + cursorShape: Qt.PointingHandCursor |
| 54 | + } |
| 55 | + } |
| 56 | + |
| 57 | + Text { |
| 58 | + anchors.verticalCenter: parent.verticalCenter |
| 59 | + text: control.title |
| 60 | + font: control.titleFont |
| 61 | + color: control.colorTitle |
| 62 | + } |
| 63 | + } |
| 64 | + |
| 65 | + DelDivider { |
| 66 | + width: parent.width |
| 67 | + height: 1 |
| 68 | + anchors.bottom: parent.bottom |
| 69 | + } |
| 70 | + } |
| 71 | + property Component contentDelegate: Item { } |
| 72 | + |
| 73 | + enter: Transition { NumberAnimation { duration: control.animationEnabled ? 200 : 0 } } |
| 74 | + exit: Transition { NumberAnimation { duration: control.animationEnabled ? 200 : 0 } } |
| 75 | + |
| 76 | + width: edge == Qt.LeftEdge || edge == Qt.RightEdge ? drawerSize : parent.width |
| 77 | + height: edge == Qt.LeftEdge || edge == Qt.RightEdge ? parent.height : drawerSize |
| 78 | + edge: Qt.RightEdge |
| 79 | + parent: T.Overlay.overlay |
| 80 | + modal: true |
| 81 | + background: Item { |
| 82 | + DropShadow { |
| 83 | + anchors.fill: __rect |
| 84 | + radius: 8.0 |
| 85 | + samples: 17 |
| 86 | + color: "#80000000" |
| 87 | + source: __rect |
| 88 | + } |
| 89 | + Rectangle { |
| 90 | + id: __rect |
| 91 | + anchors.fill: parent |
| 92 | + color: control.colorBg |
| 93 | + } |
| 94 | + } |
| 95 | + contentItem: ColumnLayout { |
| 96 | + Loader { |
| 97 | + Layout.fillWidth: true |
| 98 | + sourceComponent: titleDelegate |
| 99 | + } |
| 100 | + Loader { |
| 101 | + Layout.fillWidth: true |
| 102 | + Layout.fillHeight: true |
| 103 | + sourceComponent: contentDelegate |
| 104 | + } |
| 105 | + } |
| 106 | + |
| 107 | + T.Overlay.modal: Rectangle { |
| 108 | + color: control.colorOverlay |
| 109 | + } |
| 110 | +} |
0 commit comments