This commit is contained in:
zhuzihcu
2023-03-02 18:21:43 +08:00
parent 91be0e4da2
commit 1b5223a7d5
23 changed files with 746 additions and 361 deletions

View File

@ -1,6 +1,85 @@
import QtQuick 2.15
import QtQuick.Layouts 1.15
import FluentUI 1.0
Item {
id:root
property bool checked: false
property string text: "Check Box"
width: childrenRect.width
height: childrenRect.height
RowLayout{
spacing: 4
Rectangle{
width: 22
height: 22
radius: 4
border.color: {
if(FluApp.isDark){
if(checked){
return Qt.rgba(76/255,160/255,224/255,1)
}
return Qt.rgba(160/255,160/255,160/255,1)
}else{
if(checked){
if(mouse_area.containsMouse){
return Qt.rgba(25/255,117/255,187/255,1)
}
return Qt.rgba(0/255,102/255,180/255,1)
}
return Qt.rgba(136/255,136/255,136/255,1)
}
}
border.width: 1
color: {
if(FluApp.isDark){
if(checked){
if(mouse_area.containsMouse){
return Qt.rgba(74/255,149/255,207/255,1)
}
return Qt.rgba(76/255,160/255,224/255,1)
}
if(mouse_area.containsMouse){
return Qt.rgba(62/255,62/255,62/255,1)
}
return Qt.rgba(45/255,45/255,45/255,1)
}else{
if(checked){
if(mouse_area.containsMouse){
return Qt.rgba(25/255,117/255,187/255,1)
}
return Qt.rgba(0/255,102/255,180/255,1)
}
if(mouse_area.containsMouse){
return Qt.rgba(244/255,244/255,244/255,1)
}
return Qt.rgba(247/255,247/255,247/255,1)
}
}
FluIcon {
anchors.centerIn: parent
icon: FluentIcons.FA_check
iconSize: 15
visible: checked
color: FluApp.isDark ? Qt.rgba(0,0,0,1) : Qt.rgba(1,1,1,1)
}
}
FluText{
text:root.text
}
}
MouseArea{
id:mouse_area
anchors.fill: parent
hoverEnabled: true
onClicked: {
checked = !checked
}
}
}

41
src/controls/FluMenu.qml Normal file
View File

@ -0,0 +1,41 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Controls.impl 2.15
import QtQuick.Templates 2.15 as T
import QtQuick.Window 2.15
import QtGraphicalEffects 1.15
T.Menu {
id: control
implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
contentWidth + leftPadding + rightPadding)
implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
contentHeight + topPadding + bottomPadding)
margins: 0
delegate: FluMenuItem { }
contentItem: ListView {
implicitHeight: contentHeight
model: control.contentModel
interactive: Window.window ? contentHeight > Window.window.height : false
clip: true
currentIndex: control.currentIndex
ScrollIndicator.vertical: ScrollIndicator {}
}
background: Item {
implicitWidth: 122
implicitHeight: 30
Rectangle{
anchors.fill: parent
color: "#FFFFFF"
layer.effect: FluDropShadow{}
layer.enabled: true
}
}
}

View File

@ -0,0 +1,29 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Controls.impl 2.15
import QtQuick.Templates 2.15 as T
import QtQuick.Shapes 1.15
T.MenuItem {
id: control
implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
implicitContentWidth + leftPadding + rightPadding)
implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
implicitContentHeight + topPadding + bottomPadding,
implicitIndicatorHeight + topPadding + bottomPadding)
padding: 0
spacing: 6
contentItem: FluText {
text: control.text
}
background: Rectangle {
implicitWidth: 120
implicitHeight: 30
width: control.width
height: control.height
}
}

View File

@ -0,0 +1,7 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import FluentUI 1.0
ScrollBar {
}

View File

@ -2,27 +2,11 @@
import QtQuick.Window 2.15
import QtQuick.Layouts 1.15
import FluentUI 1.0
import QtGraphicalEffects 1.15
Rectangle {
Item {
id:root
property bool isMax: {
if(Window.window == null)
return false
return Window.Maximized === Window.window.visibility
}
property string title: "FluentUI"
property string winId
property var minimumSize
property var maximumSize
Behavior on opacity{
NumberAnimation{
duration: 100
}
}
property var window : {
if(Window.window == null)
@ -30,17 +14,42 @@ Rectangle {
return Window.window
}
onIsMaxChanged: {
if(isMax){
root.anchors.margins = 8*(1/Screen.devicePixelRatio)
root.anchors.fill = parent
}else{
root.anchors.margins = 0
root.anchors.fill = null
property color color: FluApp.isDark ? "#202020" : "#F3F3F3"
property string title: "FluentUI"
property int minimumWidth
property int maximumWidth
property int minimumHeight
property int maximumHeight
property int borderless:{
if(Window.window == null)
return 4
if(Window.window.visibility === Window.Maximized){
return 0
}
return 4
}
default property alias content: container.children
FluWindowResize{}
Behavior on opacity{
NumberAnimation{
duration: 100
}
}
color : FluApp.isDark ? "#202020" : "#F3F3F3"
Rectangle{
id:container
color:root.color
anchors.fill: parent
anchors.margins: borderless
layer.enabled: true
layer.effect: DropShadow {
radius: 5
samples: 4
color: "#40000000"
}
}
Component.onCompleted: {
@ -52,13 +61,18 @@ Rectangle {
if(FluApp.equalsWindow(view,window)){
helper.initWindow(view);
helper.setTitle(title);
if(minimumSize){
helper.setMinimumSize(minimumSize)
if(minimumWidth){
helper.setMinimumWidth(minimumWidth)
}
if(maximumSize){
helper.setMaximumSize(maximumSize)
if(maximumWidth){
helper.setMaximumWidth(maximumWidth)
}
if(minimumHeight){
helper.setMinimumHeight(minimumHeight)
}
if(maximumHeight){
helper.setMaximumHeight(maximumHeight)
}
helper.refreshWindow()
}
}
}

View File

@ -0,0 +1,185 @@
import QtQuick 2.15
import QtQuick.Window 2.15
MouseArea {
property int border: 4
property bool fixedSize: {
if(Window.window == null)
return true
if(Window.window.visibility === Window.Maximized || Window.window.visibility === Window.FullScreen){
return true
}
return (Window.window.minimumWidth === Window.window.maximumWidth && Window.window.minimumHeight === Window.window.maximumHeight)
}
anchors.fill: parent
acceptedButtons: Qt.LeftButton
hoverEnabled: true
preventStealing: true
propagateComposedEvents: true
z: -65535
onReleased: {
Window.window.width = Window.window.width+1
Window.window.width = Window.window.width-1
}
onPressed :
(mouse)=> {
if (fixedSize) {
return;
}
var rc = Qt.rect(0, 0, 0, 0);
let e = 0;
//top-left
rc = Qt.rect(0, 0, border, border);
if (ptInRect(rc, mouse.x, mouse.y)) {
e = Qt.TopEdge | Qt.LeftEdge;
window.startSystemResize(e);
return;
}
//top
rc = Qt.rect(border, 0, window.width-border*2, border);
if (ptInRect(rc, mouse.x, mouse.y)) {
e = Qt.TopEdge;
window.startSystemResize(e);
return;
}
//top-right
rc = Qt.rect(window.width-border, 0, border, border);
if (ptInRect(rc, mouse.x, mouse.y)) {
e = Qt.TopEdge | Qt.RightEdge;
window.startSystemResize(e);
return;
}
//right
rc = Qt.rect(window.width-border, border, border, window.height-border*2);
if (ptInRect(rc, mouse.x, mouse.y)) {
e = Qt.RightEdge;
window.startSystemResize(e);
return;
}
//bottom-right
rc = Qt.rect(window.width-border, window.height-border, border, border);
if (ptInRect(rc, mouse.x, mouse.y)) {
e = Qt.BottomEdge | Qt.RightEdge;
window.startSystemResize(e);
return;
}
//bottom
rc = Qt.rect(border, window.height-border, window.width-border*2, border);
if (ptInRect(rc, mouse.x, mouse.y)) {
e = Qt.BottomEdge;
window.startSystemResize(e);
return;
}
//bottom_left
rc = Qt.rect(0, window.height-border,border, border);
if (ptInRect(rc, mouse.x, mouse.y)) {
e = Qt.BottomEdge | Qt.LeftEdge;
window.startSystemResize(e);
return;
}
//left
rc = Qt.rect(0, border,border, window.height-border*2);
if (ptInRect(rc, mouse.x, mouse.y)) {
e = Qt.LeftEdge;
window.startSystemResize(e);
return;
}
}
onPositionChanged:
(mouse)=> {
if (fixedSize) {
cursorShape = Qt.ArrowCursor;
return;
}
var rc = Qt.rect(0, 0, 0, 0);
//top-left
rc = Qt.rect(0, 0, border, border);
if (ptInRect(rc, mouse.x, mouse.y)) {
cursorShape = Qt.SizeFDiagCursor;
return;
}
//top
rc = Qt.rect(border, 0, window.width-border*2, border);
if (ptInRect(rc, mouse.x, mouse.y)) {
cursorShape = Qt.SizeVerCursor;
return;
}
//top-right
rc = Qt.rect(window.width-border, 0, border, border);
if (ptInRect(rc, mouse.x, mouse.y)) {
cursorShape = Qt.SizeBDiagCursor;
return;
}
//right
rc = Qt.rect(window.width-border, border, border, window.height-border*2);
if (ptInRect(rc, mouse.x, mouse.y)) {
cursorShape = Qt.SizeHorCursor;
return;
}
//bottom-right
rc = Qt.rect(window.width-border, window.height-border, border, border);
if (ptInRect(rc, mouse.x, mouse.y)) {
cursorShape = Qt.SizeFDiagCursor;
return;
}
//bottom
rc = Qt.rect(border, window.height-border, window.width-border*2, border);
if (ptInRect(rc, mouse.x, mouse.y)) {
cursorShape = Qt.SizeVerCursor;
return;
}
//bottom_left
rc = Qt.rect(0, window.height-border,border, border);
if (ptInRect(rc, mouse.x, mouse.y)) {
cursorShape = Qt.SizeBDiagCursor;
return;
}
//left
rc = Qt.rect(0, border,border, window.height-border*2);
if (ptInRect(rc, mouse.x, mouse.y)) {
cursorShape = Qt.SizeHorCursor;
return;
}
//default
cursorShape = Qt.ArrowCursor;
}
onExited: {
cursorShape = Qt.ArrowCursor;
}
function ptInRect(rc, x, y)
{
if ((rc.x <= x && x <= (rc.x + rc.width)) &&
(rc.y <= y && y <= (rc.y + rc.height))) {
return true;
}
return false;
}
}