forked from linuxdeepin/dtkdeclarative
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add ControlGroup Log:
- Loading branch information
wangfei
committed
Jul 19, 2024
1 parent
a6ccd0f
commit c1b1da0
Showing
6 changed files
with
155 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: LGPL-3.0-or-later | ||
|
||
import QtQuick 2.0 | ||
import QtQuick.Window 2.11 | ||
import QtQuick.Layouts 1.11 | ||
import org.deepin.dtk 1.0 | ||
import ".." | ||
|
||
ControlGroup { | ||
ControlGroupItem { | ||
Label { | ||
visible: true | ||
text: "test0111111111111" | ||
} | ||
Label { | ||
visible: true | ||
text: "test13333333333" | ||
} | ||
} | ||
ControlGroupItem { | ||
Rectangle { | ||
width: 100 | ||
height: 100 | ||
color: "red" | ||
border.color: "black" | ||
border.width: 5 | ||
radius: 10 | ||
} | ||
Switch { | ||
checked: true | ||
Layout.alignment: Qt.AlignHCenter | ||
} | ||
} | ||
ControlGroupItem { | ||
Rectangle { | ||
width: 100 | ||
height: 100 | ||
color: "green" | ||
border.color: "black" | ||
border.width: 5 | ||
radius: 10 | ||
} | ||
Button { | ||
width: 100 | ||
height: 100 | ||
Layout.alignment: Qt.AlignHCenter | ||
} | ||
} | ||
} |
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
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,61 @@ | ||
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: LGPL-3.0-or-later | ||
|
||
import QtQuick 2.0 | ||
import QtQuick.Layouts 1.11 | ||
import QtQml.Models 2.11 | ||
import org.deepin.dtk 1.0 | ||
|
||
ColumnLayout { | ||
id: root | ||
spacing: 10 | ||
clip: true | ||
Layout.fillHeight: true | ||
|
||
property string title | ||
property bool isExpanded: true | ||
property int interval: 500 / (children.length - 1) | ||
property int duration: 0 | ||
property int index: 1 | ||
|
||
ItemDelegate { | ||
id: titleBar | ||
Layout.fillWidth: true; Layout.preferredHeight: 36 | ||
text: title | ||
icon.name: isExpanded ? "go-down": "go-next" | ||
display: IconLabel.IconBesideText | ||
checkable: false | ||
font: DTK.fontManager.t5 | ||
backgroundVisible: hovered | ||
MouseArea { | ||
anchors.fill: parent | ||
onClicked: { | ||
root.isExpanded = !root.isExpanded | ||
} | ||
} | ||
} | ||
|
||
Timer { | ||
id: timer | ||
} | ||
|
||
onIsExpandedChanged: delay(interval, timeout) | ||
|
||
function timeout() { | ||
children[index].isExpanded = !children[index].isExpanded | ||
++index | ||
if (index === children.length) { | ||
timer.stop() | ||
timer.triggered.disconnect(timeout) | ||
index = 1 | ||
} | ||
} | ||
|
||
function delay(delayTime, cb) { | ||
timer.interval = delayTime | ||
timer.repeat = true | ||
timer.triggered.connect(cb) | ||
timer.restart() | ||
} | ||
} |
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,38 @@ | ||
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: LGPL-3.0-or-later | ||
|
||
import QtQuick 2.0 | ||
import QtQuick.Layouts 1.11 | ||
import QtQml.Models 2.11 | ||
import org.deepin.dtk 1.0 | ||
|
||
RowLayout { | ||
id: root | ||
|
||
property int initY | ||
property bool isExpanded: true | ||
|
||
y: isExpanded ? initY : 0 | ||
opacity: isExpanded ? 1.0 : 0.0 | ||
|
||
Layout.fillWidth: true | ||
Layout.fillHeight: true | ||
|
||
Behavior on y { | ||
NumberAnimation { | ||
duration: parent.interval | ||
easing.type: Easing.OutQuad | ||
} | ||
} | ||
Behavior on opacity { | ||
NumberAnimation { | ||
duration: parent.interval | ||
easing.type: Easing.OutQuad | ||
} | ||
} | ||
|
||
Component.onCompleted: { | ||
root.initY = root.y | ||
} | ||
} |