Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add timedatewidget and powerlist #42

Merged
merged 4 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/greeter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ qt_add_qml_module(greeterplugin
QML_FILES Center.qml
QML_FILES LoginAnimation.qml
QML_FILES RoundBlur.qml
QML_FILES PowerList.qml
QML_FILES TimeDateWidget.qml
)

target_include_directories(greeterplugin
Expand Down
50 changes: 30 additions & 20 deletions src/greeter/Center.qml
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,17 @@ Item {
anchors.top: parent.top
anchors.bottom: parent.bottom
width: root.width * 0.4
Rectangle {

TimeDateWidget {
anchors.right: parent.right
anchors.rightMargin: parent.width / 10
anchors.verticalCenter: parent.verticalCenter
width: 400
height: 500
color: Qt.rgba(1, 1, 1, 0.5)
radius: 15
Text {
text: "There will display some widgets."
height: 156
background: Rectangle {
radius: 8
color: "white"
opacity: 0.1
}
}
}
Expand Down Expand Up @@ -100,6 +101,7 @@ Item {
anchors.leftMargin: 80
}

//TODO: abstract ot a Button type
RowLayout {
id: bottomGroup
property var buttonSize: 30
Expand Down Expand Up @@ -138,7 +140,7 @@ Item {
height: bottomGroup.buttonSize
anchors.centerIn: parent
onClicked: {
console.log(userList.count > 1)
console.log("need impl btn 2")
}

background: RoundBlur {}
Expand All @@ -155,25 +157,23 @@ Item {
RoundButton {
id: usersBtn
text: '3'
width: bottomGroup.buttonSize
height: bottomGroup.buttonSize
property bool expand: false
width: expand ? bottomGroup.buttonSize + 6 : bottomGroup.buttonSize
height: expand ? bottomGroup.buttonSize + 6 : bottomGroup.buttonSize
anchors.centerIn: parent
hoverEnabled: parent.visible
D.ToolTip.visible: hovered
D.ToolTip.text: qsTr("Other Users")

UserList {
id: userList
onClosed: {
usersBtn.width -= 6
usersBtn.height -= 6
}
x: (usersBtn.width - userList.width) / 2 - 10
y: -userList.height - 10
onClosed: usersBtn.expand = false
}

onClicked: {
usersBtn.width += 6
usersBtn.height += 6
userList.x = (width - userList.width) / 2 - 10
userList.y = -userList.height - 10
usersBtn.expand = true
userList.open()
}

Expand All @@ -189,11 +189,21 @@ Item {
RoundButton {
id: powerBtn
text: '4'
width: bottomGroup.buttonSize
height: bottomGroup.buttonSize
property bool expand: false
width: expand ? bottomGroup.buttonSize + 6 : bottomGroup.buttonSize
height: expand ? bottomGroup.buttonSize + 6 : bottomGroup.buttonSize
anchors.centerIn: parent
D.ToolTip.visible: hovered
D.ToolTip.text: qsTr("Power")
PowerList {
id: powerList
y: -powerList.height - 10
x: (powerBtn.width - powerList.width) / 2 - 10
onClosed: powerBtn.expand = false
}
onClicked: {
console.log("need impl btn 4")
powerBtn.expand = true
powerList.open()
}

background: RoundBlur {}
Expand Down
130 changes: 130 additions & 0 deletions src/greeter/PowerList.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
import QtQuick
import TreeLand.Greeter
import org.deepin.dtk 1.0 as D
import QtQuick.Controls

D.Menu {
id: powers
modal: true
padding: 6
width: 122

background: D.FloatingPanel {
anchors.fill: parent
radius: 12
blurRadius: 30
backgroundColor: D.Palette {
normal: Qt.rgba(238 / 255, 238 / 255, 238 / 255, 0.8)
}
insideBorderColor: D.Palette {
normal: Qt.rgba(1, 1, 1, 0.1)
}
outsideBorderColor: D.Palette {
normal: Qt.rgba(0, 0, 0, 0.06)
}
dropShadowColor: D.Palette {
normal: Qt.rgba(0, 0, 0, 0.2)
}
}

Action {
enabled: GreeterModel.proxy.canHibernate
text: qsTr("Hibernate")
icon.source: "file:///usr/share/icons/Papirus-Dark/symbolic/actions/system-hibernate-symbolic"

onTriggered: GreeterModel.proxy.hibernate()
}

Action {
enabled: GreeterModel.proxy.canSuspend
text: qsTr("Suspend")
icon.source: "file:///usr/share/icons/Papirus-Dark/symbolic/actions/system-suspend-symbolic"

onTriggered: GreeterModel.proxy.suspend()
}

Action {
enabled: GreeterModel.proxy.canReboot
text: qsTr("Reboot")
icon.source: "file:///usr/share/icons/Papirus-Dark/symbolic/actions/system-restart-symbolic"

onTriggered: GreeterModel.proxy.reboot()
}

Action {
id: powerOff
enabled: GreeterModel.proxy.canPowerOff
text: qsTr("Shut Down")
icon.source: "file:///usr/share/icons/Papirus-Dark/symbolic/actions/system-shutdown-symbolic"

onTriggered: GreeterModel.proxy.powerOff()
}

onAboutToShow: {
currentIndex = count - 1
}

delegate: D.MenuItem {
id: item
height: enabled ? 26 : 0
display: D.IconLabel.IconBesideText
font.weight: Font.Medium
font.pixelSize: 13
font.family: "Source Han Sans CN"
visible: enabled

property D.Palette highlightColor: D.Palette {
normal: D.DTK.makeColor(D.Color.Highlight)
}

Keys.onUpPressed: {
let nextIndex = powers.currentIndex - 1
for (var index = 0; index < count; index++) {
if (nextIndex < 0) {
nextIndex += powers.count
}

let tmp = powers.itemAt(nextIndex)
if (tmp.visible) {
break
}
nextIndex--
}

powers.currentIndex = nextIndex
}

Keys.onDownPressed: {
let nextIndex = powers.currentIndex + 1
for (var index = 0; index < count; index++) {
if (nextIndex >= powers.count) {
nextIndex -= powers.count
}

let tmp = powers.itemAt(nextIndex)
if (tmp.enabled) {
break
}
nextIndex++
}

powers.currentIndex = nextIndex
}

background: Rectangle {
id: backgroundColor
radius: 6
anchors.fill: parent
D.BoxShadow {
anchors.fill: parent
shadowBlur: 0
shadowOffsetX: 0
shadowOffsetY: -1
cornerRadius: parent.radius
hollow: true
}
color: powers.itemAt(powers.currentIndex)
== item ? item.D.ColorSelector.highlightColor : "transparent"
}
}
}
48 changes: 48 additions & 0 deletions src/greeter/TimeDateWidget.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import QtQuick
import QtQuick.Controls
import TreeLand.Greeter

Control {
id: timedataWidget

property date currentDate: new Date()
property var currentLocale: Qt.locale("zh_CN")

Timer {
interval: 1000
running: true
repeat: true
triggeredOnStart: true

onTriggered: {
currentDate = new Date()
}
}

Text {
id: timeText
text: currentDate.toLocaleTimeString(currentLocale, "HH:mm")
font.weight: Font.Light
font.pixelSize: 80
font.family: "Source Han Sans CN"
color: "white"

anchors.left: parent.left
anchors.leftMargin: 20
anchors.top: parent.top
// anchors.topMargin: 10
}

Text {
id: dateText
text: currentDate.toLocaleDateString(currentLocale)
font.family: "Source Han Sans CN"
font.weight: Font.Normal
font.pixelSize: 20
color: "white"

anchors.left: parent.left
anchors.leftMargin: 20
anchors.top: timeText.bottom
}
}
7 changes: 7 additions & 0 deletions src/treeland/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
pkg_search_module(WLROOTS REQUIRED IMPORTED_TARGET wlroots)

add_subdirectory(data)
add_subdirectory(protocols)
add_subdirectory(quick)
Expand Down Expand Up @@ -41,6 +43,11 @@ target_link_libraries(treeland
Qt${QT_MAJOR_VERSION}::DBus
)

target_compile_definitions(treeland
PRIVATE
WLR_USE_UNSTABLE
)

if(JOURNALD_FOUND)
target_link_libraries(treeland PRIVATE ${JOURNALD_LIBRARIES})
endif()
Expand Down
Loading