fix🐛: 修复显示的问题,更新button的功能

This commit is contained in:
Alvin Young 2024-12-02 17:51:21 +08:00
parent e4b0551e59
commit a6fa2fa5d3
7 changed files with 82 additions and 28 deletions

View File

@ -10,9 +10,6 @@ Window {
minimumHeight: 600
minimumWidth: 800
// color: "green"
GlobalProperties {
id: id_gp
}
MainPage {
id: id_home_page

View File

@ -33,15 +33,30 @@ Item {
}
Button {
Layout.preferredWidth: 100
id: button
text: "重新连接"
hoverEnabled: false
Layout.preferredWidth: 100
Layout.preferredHeight: 50
font.pixelSize: id_gp.font_info_pixel_size
background: Rectangle { //
color: control.pressed ? "lightblue" : "blue"
border.color: "black"
background: Rectangle {
color: button.down ? id_gp.btn_pressedBackground :
button.hovered ? id_gp.btn_hoverBackground : id_gp.btn_normalBackground
border.color: id_gp.btn_borderColor
radius: 10
}
// 使 Button hover
hoverEnabled: true
// MouseArea
MouseArea {
anchors.fill: parent
onPressed: button.background.color = id_gp.btn_pressedBackground
onReleased: button.background.color = button.hovered ? id_gp.btn_hoverBackground : id_gp.btn_normalBackground
onExited: button.background.color = id_gp.btn_normalBackground
}
onClicked: {
console.log("press butn")
}

View File

@ -20,14 +20,15 @@ Item {
source: "qrc:/assets/img/terminal-box-fill.svg"
smooth: true // 使
asynchronous: true //
// 使 ColorOverlay SVG
ColorOverlay {
anchors.fill: parent
source: parent
color: id_gp.left_menu_non_lighlight_color // SVG
}
}
// 使 ColorOverlay SVG
ColorOverlay {
anchors.fill: id_svg_icon_info_lb
source: id_svg_icon_info_lb
color: id_gp.left_menu_non_lighlight_color // SVG
}
Text {
text: "芯片类型:"

View File

@ -8,11 +8,8 @@ Item {
Component {
id: contactDelegate
// property int my_index: index
Rectangle {
width: 60; height: 60
anchors.left: parent.left //
anchors.leftMargin: 10 // 20
radius: 5
color: id_gp.left_menu_non_lighlight_color
MouseArea {
@ -100,6 +97,7 @@ Item {
id: id_view
spacing: 10
topMargin: 10
leftMargin: 10
anchors.fill: parent
model: TestModels {}
delegate: contactDelegate
@ -108,18 +106,42 @@ Item {
snapMode: ListView.SnapToItem
onCurrentIndexChanged: {
// console.log("2 left_menu_index", id_gp.left_menu_index_now)
itemAtIndex(id_gp.left_menu_index_now).color = id_gp.left_menu_lighlight_color
itemAtIndex(id_gp.left_menu_index_last).color = id_gp.left_menu_non_lighlight_color
itemAtIndex(id_gp.left_menu_index_now).color = id_gp.left_menu_lighlight_color
}
Component.onCompleted: {
id_view.currentIndex = id_view.count
id_gp.left_menu_index_last = id_view.count
id_gp.left_menu_index_now = 0
id_view.currentIndex = 0
console.log("complete at ", id_gp.left_menu_index_now)
id_timer_leftmenu.start()
}
}
}
Timer {
id: id_timer_leftmenu
interval: 500 // 1
repeat: true
running: true
triggeredOnStart: false
onTriggered: {
//
if (id_gp.gp_inited == 1) {
running = false;
id_gp.left_menu_index_last = id_view.count
id_gp.left_menu_index_now = 0
id_view.itemAtIndex(id_gp.left_menu_index_now).color = id_gp.left_menu_lighlight_color
} else {
pollForData();
console.log("id gp ini : " , id_gp.gp_inited )
}
}
}
function pollForData() {
//
console.log("Polling for new data...");
}
}

View File

@ -1,13 +1,28 @@
import QtQuick 2.15
import ESP32_upper
Item {
property int gp_inited: 0
property string global_banner: "Hello World"
property int left_menu_index_now: 0
property int left_menu_index_last: 0
property string left_menu_lighlight_color: "#FF00FF"
property string left_menu_non_lighlight_color: "#00FF00"
property string left_menu_focus_color: "#FAFA00"
property string left_menu_icon_color: "#0d4e8b"
property int left_menu_index_last: 255
property color left_menu_lighlight_color: "#FF00FF"
property color left_menu_non_lighlight_color: "#00FF00"
property color left_menu_focus_color: "#FAFA00"
property color left_menu_icon_color: "#0d4e8b"
property int font_info_pixel_size: 20
//
property color btn_normalBackground: "#FFFFFF" //
// hover
property color btn_hoverBackground: "#F0F0F0" //
// pressed
property color btn_pressedBackground: "#D0D0D0" //
// pressed
property color btn_borderColor: "#000000" //
Component.onCompleted: {
console.log("global property has been initialized");
gp_inited = 1;
}
}

View File

@ -3,7 +3,7 @@ import QtQuick.Layouts
import ESP32_upper 1.0
Item {
anchors.fill: parent
// anchors.fill: parent
ColumnLayout {
width: parent.width
height: parent.height

View File

@ -6,6 +6,10 @@ import ESP32_upper 1.0
Item {
id: root
GlobalProperties {
id: id_gp
}
RowLayout {
spacing: 0