初版,完善了基础设置

This commit is contained in:
2025-03-16 02:52:35 +08:00
commit fc5c01d9d2
46 changed files with 143568 additions and 0 deletions
Binary file not shown.
+21
View File
@@ -0,0 +1,21 @@
pragma Singleton
import QtQuick 2.15
QtObject {
readonly property string sColor_blue: "#333845"
readonly property string sColor_blueWithWhite: "#404451"
readonly property string sColor_blueWithBlack: "#2E3234"
readonly property string sColor_Red: "#E81123"
readonly property string sColor_RedWithWhite: "#F1707A"
readonly property string sColor_Green: "#11E823"
readonly property string sColor_GreenWithWhite: "#70F17A"
readonly property string sColor_GoldWithBlack: "#C8A564"
readonly property string sColor_Gold: "#DFB992"
readonly property string sColor_GoldWithWhite: "#FADEBD"
readonly property string sColor_Black: "#161616"
readonly property string sColor_BlackWithWhite: "#2D2D2D"
}
+42
View File
@@ -0,0 +1,42 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Controls.Basic 2.15
Button {
id: root
property alias iconSource: btnIcon.source // 允许外部设置图标
property color defaultColor: "transparent"
property color hoverColor: "gold"
property bool isHovered: false // 记录鼠标是否悬停
width: 60
height: 60
background: Rectangle {
color: root.isHovered ? root.hoverColor : root.defaultColor // ✅ 绑定状态
border.color: "transparent"
border.width: 0
radius: 0
}
contentItem: Image {
id: btnIcon
anchors.centerIn: parent
width: 40
height: 40
fillMode: Image.PreserveAspectFit
}
// 鼠标悬停时的颜色变化
MouseArea {
anchors.fill: parent
hoverEnabled: true
onEntered: root.isHovered = true // ✅ 修改 `isHovered` 触发背景更新
onExited: root.isHovered = false
}
// 设置默认样式
function toDefault() {
root.defaultColor = "transparent"
root.hoverColor = "gold"
}
}
+54
View File
@@ -0,0 +1,54 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Controls.Basic 2.15
import "qrc:/"
Button {
id: toolBarButton
property string iconSource: ""
property color hoverColor: Colors.sColor_GoldWithBlack
property int buttonWidth: 40 // 默认宽度
property int buttonHeight: 40 // 默认高度
width: buttonWidth
height: buttonHeight
implicitWidth: buttonWidth
implicitHeight: buttonHeight
background: Rectangle {
width: parent.width
height: parent.height
color: "transparent"
border.color: "red"
border.width: 0
radius: 0
MouseArea {
id: mouseArea
anchors.fill: parent
hoverEnabled: true
onEntered: {
parent.color = toolBarButton.hoverColor
}
onExited: {
parent.color = "transparent"
}
onClicked: {
// 确保第一次点击有效果
console.log("Button clicked");
}
}
}
contentItem: Image {
id: image
source: toolBarButton.iconSource
width: toolBarButton.buttonWidth
height: toolBarButton.buttonHeight
fillMode: Image.PreserveAspectFit
anchors.centerIn: parent
}
}
+58
View File
@@ -0,0 +1,58 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
Button {
id: root
property alias text: btnText.text
property string defaultColor: "transparent"
property string hoverColor: "gold"
property string redColor: "red"
property string greenColor: "green"
// 默认样式
background: Rectangle {
color: root.defaultColor
border.color: "transparent"
border.width: 0
radius: 0
}
contentItem: Text {
id: btnText
text: root.text
font.family: "微软雅黑"
font.pixelSize: 14
font.bold: true
color: "white"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
anchors.fill: parent
}
// 鼠标悬停时的颜色变化
MouseArea {
anchors.fill: parent
hoverEnabled: true
onEntered: root.background.color = root.hoverColor
onExited: root.background.color = root.defaultColor
}
// 切换颜色方法
function toDefault() {
root.defaultColor = "transparent"
root.hoverColor = "gold"
root.background.color = root.defaultColor
}
function toRed() {
root.defaultColor = root.redColor
root.hoverColor = "white"
root.background.color = root.defaultColor
}
function toGreen() {
root.defaultColor = root.greenColor
root.hoverColor = "white"
root.background.color = root.defaultColor
}
}
+1
View File
@@ -0,0 +1 @@
singleton Colors 1.0 Colors.qml
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 743 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 954 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 977 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

+17
View File
@@ -0,0 +1,17 @@
from PySide6.QtCore import QUrl, QObject, QCoreApplication, QFileInfo
from PySide6.QtWidgets import QApplication
from PySide6.QtQml import QQmlApplicationEngine, qmlRegisterType
import os
import resources_rc
# from backend import Backend
os.system("pyside6-rcc resources.qrc -o resources_rc.py")
app = QApplication([])
engine = QQmlApplicationEngine()
# backend = Backend()
# engine.rootContext().setContextProperty("backend", backend)
engine.load("ui.qml")
app.exec()
+2
View File
@@ -0,0 +1,2 @@
pyside6-rcc resources.qrc -o resources_rc.py
pause
+39
View File
@@ -0,0 +1,39 @@
<RCC>
<qresource prefix="/">
<file>icon/121.png</file>
<file>icon/close_n.png</file>
<file>icon/cycleButton.png</file>
<file>icon/cycleRunning.png</file>
<file>icon/logo_Dongsheng.png</file>
<file>icon/logo_Dongsheng1.png</file>
<file>icon/Max_n.png</file>
<file>icon/min_n.png</file>
<file>icon/oncerun.png</file>
<file>icon/search.png</file>
<file>icon/stop_n.png</file>
<file>icon/user_n.png</file>
<file>icon/clear.png</file>
<file>icon/reset.png</file>
<file>icon/search_1.png</file>
<file>icon/start_n.png</file>
<file>icon/stop.png</file>
<file>icon/close.png</file>
<file>icon/fullscreen.png</file>
<file>icon/fullscreen-exit.png</file>
<file>icon/minus.png</file>
<file>icon/home.png</file>
<file>icon/home2.png</file>
<file>icon/config.png</file>
<file>icon/menu.png</file>
<file>icon/save.png</file>
<file>icon/warning.png</file>
<file>icon/setting.png</file>
<file>icon/switch.png</file>
<file>icon/waitting.png</file>
<file>icon/loading.gif</file>
<file>icon/sql.png</file>
<file>icon/error.png</file>
<file>icon/history.png</file>
<file>icon/rollback.png</file>
</qresource>
</RCC>
+143082
View File
File diff suppressed because it is too large Load Diff
+252
View File
@@ -0,0 +1,252 @@
import QtQuick 6.2
import QtQuick.Controls 6.2
import QtQuick.Layouts 6.2
import "components"
ApplicationWindow {
id: window
width: 1920
height: 1080
visible: true
title: "Custom Window"
flags: Qt.FramelessWindowHint | Qt.Window // 无边框但可调整大小
readonly property int titleBarHeight: 35
readonly property int titleBarButtonWidth: 50
Rectangle {//主窗口
id: mainContainer
anchors.fill: parent
color: Colors.sColor_blue // 主窗口背景色
// 顶部任务栏
Rectangle {
id: titleBar
width: parent.width
height: titleBarHeight
color: Colors.sColor_Black
anchors.left: parent.left
anchors.top: parent.top // 确保对齐顶部
// anchors.margins: 0 // 设置内容边距为 0
// border.color: "#222"
// 允许拖动窗口
MouseArea {
id: dragArea
anchors.fill: parent
onPressed: function(event) {
window.startSystemMove(); // ✅ 直接调用系统级移动(防止拖影)
}
onDoubleClicked: {
// 切换窗口为全屏 / 还原
if (window.visibility === Window.Maximized) {
window.visibility = Window.Windowed; // 如果已经是全屏则还原
} else {
window.visibility = Window.Maximized; // 否则切换为全屏
}
}
}
RowLayout {
anchors.fill: parent
anchors.margins: 0 // 设置内容边距为 0
anchors.top: parent.top // 确保对齐顶部
spacing: 0
Layout.fillWidth: true
Layout.fillHeight: true
Layout.minimumHeight: titleBarHeight
// 左侧标题
Text {
text: "WIDGET"
color: "white"
font.pixelSize: 16
Layout.leftMargin: 10
}
// 占位符,让按钮靠右
Item {
Layout.fillWidth: true
}
// 最小化按钮
ToolBarButton {
id: toolBarMinimizeButton
iconSource: "qrc:/icon/minus.png" // 设置按钮图标
buttonWidth: titleBarButtonWidth
buttonHeight: titleBarHeight
Layout.alignment: Qt.AlignTop
Layout.margins: 0 // 确保没有额外的边距
onClicked: window.showMinimized()
}
// 最大化 / 还原窗口按钮
ToolBarButton {
id: windowMaximizeButton
iconSource: window.visibility === Window.Maximized ? "qrc:/icon/fullscreen-exit.png" : "qrc:/icon/fullscreen.png"
buttonWidth: titleBarButtonWidth
buttonHeight: titleBarHeight
Layout.alignment: Qt.AlignTop
Layout.margins: 0 // 确保没有额外的边距
onClicked: {
if (window.visibility === Window.Maximized) {
window.visibility = Window.Windowed;
} else {
window.visibility = Window.Maximized;
}
}
}
// 关闭按钮
ToolBarButton {
id: toolBarCloseButton
iconSource: "qrc:/icon/close.png" // 设置按钮图标
buttonWidth: titleBarButtonWidth
buttonHeight: titleBarHeight
Layout.alignment: Qt.AlignTop
Layout.margins: 0 // 确保没有额外的边距
onClicked: Qt.quit()
}
}
}
Rectangle {//主窗口2
id: mainContainer2
width: parent.width
height: parent.height - titleBarHeight
color: Colors.sColor_blue
anchors.left: parent.left
anchors.bottom: parent.bottom // 确保对齐顶部
Rectangle {
id: leftWidgetSwitchBar
width: titleBarButtonWidth
height: parent.height
color: Colors.sColor_Black
anchors.margins: 0 // 设置内容边距为 0
anchors.left: parent.left
anchors.top: parent.top // 确保对齐顶部
ColumnLayout {
anchors.fill: parent
anchors.margins: 0 // 设置内容边距为 0
anchors.top: parent.top // 确保对齐顶部
spacing: 0
Layout.fillWidth: true
Layout.fillHeight: true
Layout.minimumWidth: titleBarButtonWidth
// 左侧标题
// 最小化按钮
ToolBarButton {
id: toolBarMinimizeButton2
iconSource: "qrc:/icon/minus.png" // 设置按钮图标
buttonWidth: titleBarButtonWidth
buttonHeight: titleBarButtonWidth
Layout.alignment: Qt.AlignTop
Layout.margins: 0 // 确保没有额外的边距
onClicked: window.showMinimized()
}
// 最大化 / 还原窗口按钮
ToolBarButton {
id: windowMaximizeButton2
iconSource: window.visibility === Window.Maximized ? "qrc:/icon/fullscreen-exit.png" : "qrc:/icon/fullscreen.png"
buttonWidth: titleBarButtonWidth
buttonHeight: titleBarButtonWidth
Layout.alignment: Qt.AlignTop
Layout.margins: 0 // 确保没有额外的边距
onClicked: {
if (window.visibility === Window.Maximized) {
window.visibility = Window.Windowed;
} else {
window.visibility = Window.Maximized;
}
}
}
Item {
Layout.fillHeight: true
}
}
}
StackLayout {//主显示界面
id: stackLayout
width: parent.width - titleBarButtonWidth
height: parent.height
anchors.right: parent.right
anchors.top: parent.top // 确保对齐顶部
// 页面1
Rectangle {
color: "lightblue"
Text {
anchors.centerIn: parent
text: "Page 1"
font.pixelSize: 24
}
}
// 页面2
Rectangle {
color: "lightgreen"
Text {
anchors.centerIn: parent
text: "Page 2"
font.pixelSize: 24
}
}
// 页面3
Rectangle {
color: "lightcoral"
Text {
anchors.centerIn: parent
text: "Page 3"
font.pixelSize: 24
}
}
}
}
}
// 允许调整窗口大小
MouseArea {
id: resizeArea
anchors.right: parent.right
anchors.bottom: parent.bottom
width: 20
height: 20
cursorShape: Qt.SizeFDiagCursor
property real startX: 0
property real startY: 0
property real startWidth: 0
property real startHeight: 0
property bool resizing: false
onPressed: function(event) {
cursorShape = Qt.SizeFDiagCursor
var globalPos = resizeArea.mapToItem(null, event.x, event.y);
startX = globalPos.x;
startY = globalPos.y;
startWidth = window.width;
startHeight = window.height;
resizing = true;
}
onReleased: {
resizing = false;
}
onPositionChanged: function(event) {
if (resizing && event.buttons & Qt.LeftButton) {
var globalPos = resizeArea.mapToItem(null, event.x, event.y);
var newWidth = startWidth + (globalPos.x - startX);
var newHeight = startHeight + (globalPos.y - startY);
window.width = Math.max(400, newWidth); // 限制最小宽度
window.height = Math.max(300, newHeight); // 限制最小高度
}
}
}
Component.onCompleted: {
console.log("窗口初始化结束")
window.visibility = Window.Maximized // 默认全屏显示
window.raise() // 确保窗口在最前
}
}