This commit is contained in:
zhuzichu 2023-10-17 15:17:05 +08:00
parent 0eacc177d0
commit b836b25028
6 changed files with 254 additions and 148 deletions

View File

@ -4,9 +4,8 @@ import QtQuick.Controls
import QtQuick.Layouts import QtQuick.Layouts
import FluentUI import FluentUI
Window { Item {
id: app id: app
flags: Qt.SplashScreen
Connections{ Connections{
target: FluTheme target: FluTheme

View File

@ -4,9 +4,8 @@ import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15 import QtQuick.Layouts 1.15
import FluentUI 1.0 import FluentUI 1.0
Window { Item {
id: app id: app
flags: Qt.SplashScreen
Connections{ Connections{
target: FluTheme target: FluTheme

View File

@ -21,8 +21,8 @@ FluApp::FluApp(QObject *parent):QObject{parent}{
FluApp::~FluApp(){ FluApp::~FluApp(){
} }
void FluApp::init(QQuickWindow *window){ void FluApp::init(QObject *application){
this->_application = window; this->_application = application;
FramelessHelper::Quick::initialize(); FramelessHelper::Quick::initialize();
FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial); FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial);
FramelessConfig::instance()->set(Global::Option::CenterWindowBeforeShow); FramelessConfig::instance()->set(Global::Option::CenterWindowBeforeShow);

View File

@ -33,13 +33,13 @@ public:
static FluApp *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();} static FluApp *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
Q_INVOKABLE void run(); Q_INVOKABLE void run();
Q_INVOKABLE void navigate(const QString& route,const QJsonObject& argument = {},FluRegister* fluRegister = nullptr); Q_INVOKABLE void navigate(const QString& route,const QJsonObject& argument = {},FluRegister* fluRegister = nullptr);
Q_INVOKABLE void init(QQuickWindow *window); Q_INVOKABLE void init(QObject *window);
Q_INVOKABLE void exit(int retCode = 0); Q_INVOKABLE void exit(int retCode = 0);
void addWindow(QQuickWindow* window); void addWindow(QQuickWindow* window);
void removeWindow(QQuickWindow* window); void removeWindow(QQuickWindow* window);
private: private:
QMap<quint64, QQuickWindow*> _windows; QMap<quint64, QQuickWindow*> _windows;
QWindow* _application; QObject* _application;
}; };
#endif // FLUAPP_H #endif // FLUAPP_H

View File

@ -10,6 +10,7 @@ Rectangle {
property color selectionColor: FluTools.colorAlpha(FluTheme.primaryColor.lightest,0.6) property color selectionColor: FluTools.colorAlpha(FluTheme.primaryColor.lightest,0.6)
property color hoverButtonColor: FluTools.colorAlpha(selectionColor,0.2) property color hoverButtonColor: FluTools.colorAlpha(selectionColor,0.2)
property color pressedButtonColor: FluTools.colorAlpha(selectionColor,0.4) property color pressedButtonColor: FluTools.colorAlpha(selectionColor,0.4)
property color borderColor: FluTheme.dark ? "#252525" : "#e4e4e4"
property alias tableModel: table_model property alias tableModel: table_model
id:control id:control
color: FluTheme.dark ? Qt.rgba(39/255,39/255,39/255,1) : Qt.rgba(251/255,251/255,253/255,1) color: FluTheme.dark ? Qt.rgba(39/255,39/255,39/255,1) : Qt.rgba(251/255,251/255,253/255,1)
@ -240,15 +241,8 @@ Rectangle {
} }
model: table_model model: table_model
clip: true clip: true
delegate: Rectangle { delegate: MouseArea{
id:item_table hoverEnabled: true
property point position: Qt.point(column,row)
color:{
if(d.rowHoverIndex === row || d.currentRow === table_model.getRow(row).__index){
return FluTheme.dark ? Qt.rgba(1,1,1,0.06) : Qt.rgba(0,0,0,0.06)
}
return (row%2!==0) ? control.color : (FluTheme.dark ? Qt.rgba(1,1,1,0.015) : Qt.rgba(0,0,0,0.015))
}
implicitHeight: 40 implicitHeight: 40
implicitWidth: { implicitWidth: {
var w = columnSource[column].width var w = columnSource[column].width
@ -260,76 +254,80 @@ Rectangle {
} }
return w return w
} }
onEntered: {
d.rowHoverIndex = row
}
Rectangle{ Rectangle{
height: 18 id:item_table
radius: 1.5
color: FluTheme.primaryColor.dark
width: 3
visible: d.currentRow === table_model.getRow(row).__index && column === 0
anchors{
verticalCenter: parent.verticalCenter
left: parent.left
leftMargin: 3
}
}
MouseArea{
anchors.fill: parent anchors.fill: parent
acceptedButtons: Qt.LeftButton property point position: Qt.point(column,row)
onPressed:{ color:{
closeEditor() if(d.rowHoverIndex === row || d.currentRow === table_model.getRow(row).__index){
} return FluTheme.dark ? Qt.rgba(1,1,1,0.06) : Qt.rgba(0,0,0,0.06)
onCanceled: {
}
onReleased: {
}
onDoubleClicked:{
if(typeof(display) == "object"){
return
} }
item_loader.sourceComponent = d.obtEditDelegate(column,row,item_table) return (row%2!==0) ? control.color : (FluTheme.dark ? Qt.rgba(1,1,1,0.015) : Qt.rgba(0,0,0,0.015))
} }
onClicked: Rectangle{
(event)=>{ height: 18
d.currentRow = table_model.getRow(row).__index radius: 1.5
item_loader.sourceComponent = undefined color: FluTheme.primaryColor.dark
event.accepted = true width: 3
visible: d.currentRow === table_model.getRow(row).__index && column === 0
anchors{
verticalCenter: parent.verticalCenter
left: parent.left
leftMargin: 3
} }
} }
Loader{ MouseArea{
property var itemModel: model anchors.fill: parent
property var modelData: display acceptedButtons: Qt.LeftButton
property var tableView: table_view onPressed:{
property var tableModel: table_model closeEditor()
property var position: item_table.position
property int row: position.y
property int column: position.x
property var options: {
if(typeof(modelData) == "object"){
return modelData.options
} }
return {} onCanceled: {
}
anchors.fill: parent
sourceComponent: {
if(typeof(modelData) == "object"){
return modelData.comId
} }
return com_text onReleased: {
}
onDoubleClicked:{
if(typeof(display) == "object"){
return
}
item_loader.sourceComponent = d.obtEditDelegate(column,row,item_table)
}
onClicked:
(event)=>{
d.currentRow = table_model.getRow(row).__index
item_loader.sourceComponent = undefined
event.accepted = true
}
} }
} Loader{
MouseArea{ property var itemModel: model
acceptedButtons: Qt.NoButton property var modelData: display
anchors.fill: parent property var tableView: table_view
hoverEnabled: true property var tableModel: table_model
z:99 property var position: item_table.position
onPositionChanged: { property int row: position.y
d.rowHoverIndex = row property int column: position.x
} property var options: {
onEntered: { if(typeof(modelData) == "object"){
d.rowHoverIndex = row return modelData.options
}
return {}
}
anchors.fill: parent
sourceComponent: {
if(typeof(modelData) == "object"){
return modelData.comId
}
return com_text
}
} }
} }
} }
} }
MouseArea{ MouseArea{
id:item_loader_layout id:item_loader_layout
@ -400,7 +398,35 @@ Rectangle {
} }
return column_item_control_mouse.containsMouse&&!canceled ? control.hoverButtonColor : FluTheme.dark ? Qt.rgba(50/255,50/255,50/255,1) : Qt.rgba(247/255,247/255,247/255,1) return column_item_control_mouse.containsMouse&&!canceled ? control.hoverButtonColor : FluTheme.dark ? Qt.rgba(50/255,50/255,50/255,1) : Qt.rgba(247/255,247/255,247/255,1)
} }
border.color: FluTheme.dark ? "#252525" : "#e4e4e4" Rectangle{
border.color: control.borderColor
width: parent.width
height: 1
anchors.top: parent.top
color:"#00000000"
}
Rectangle{
border.color: control.borderColor
width: parent.width
height: 1
anchors.bottom: parent.bottom
color:"#00000000"
}
Rectangle{
border.color: control.borderColor
width: 1
height: parent.height
anchors.left: parent.left
color:"#00000000"
}
Rectangle{
border.color: control.borderColor
width: 1
height: parent.height
anchors.right: parent.right
color:"#00000000"
visible: column === tableModel.columnCount - 1
}
MouseArea{ MouseArea{
id:column_item_control_mouse id:column_item_control_mouse
anchors.fill: parent anchors.fill: parent
@ -521,7 +547,35 @@ Rectangle {
} }
return item_control_mouse.containsMouse&&!canceled ? control.hoverButtonColor : FluTheme.dark ? Qt.rgba(50/255,50/255,50/255,1) : Qt.rgba(247/255,247/255,247/255,1) return item_control_mouse.containsMouse&&!canceled ? control.hoverButtonColor : FluTheme.dark ? Qt.rgba(50/255,50/255,50/255,1) : Qt.rgba(247/255,247/255,247/255,1)
} }
border.color: FluTheme.dark ? "#252525" : "#e4e4e4" Rectangle{
border.color: control.borderColor
width: parent.width
height: 1
anchors.top: parent.top
color:"#00000000"
}
Rectangle{
border.color: control.borderColor
width: parent.width
height: 1
anchors.bottom: parent.bottom
visible: row === tableModel.rowCount - 1
color:"#00000000"
}
Rectangle{
border.color: control.borderColor
width: 1
height: parent.height
anchors.left: parent.left
color:"#00000000"
}
Rectangle{
border.color: control.borderColor
width: 1
height: parent.height
anchors.right: parent.right
color:"#00000000"
}
FluText{ FluText{
id:row_text id:row_text
anchors.centerIn: parent anchors.centerIn: parent

View File

@ -11,6 +11,7 @@ Rectangle {
property color selectionColor: FluTools.colorAlpha(FluTheme.primaryColor.lightest,0.6) property color selectionColor: FluTools.colorAlpha(FluTheme.primaryColor.lightest,0.6)
property color hoverButtonColor: FluTools.colorAlpha(selectionColor,0.2) property color hoverButtonColor: FluTools.colorAlpha(selectionColor,0.2)
property color pressedButtonColor: FluTools.colorAlpha(selectionColor,0.4) property color pressedButtonColor: FluTools.colorAlpha(selectionColor,0.4)
property color borderColor: FluTheme.dark ? "#252525" : "#e4e4e4"
property alias tableModel: table_model property alias tableModel: table_model
id:control id:control
color: FluTheme.dark ? Qt.rgba(39/255,39/255,39/255,1) : Qt.rgba(251/255,251/255,253/255,1) color: FluTheme.dark ? Qt.rgba(39/255,39/255,39/255,1) : Qt.rgba(251/255,251/255,253/255,1)
@ -241,15 +242,8 @@ Rectangle {
} }
model: table_model model: table_model
clip: true clip: true
delegate: Rectangle { delegate: MouseArea{
id:item_table hoverEnabled: true
property point position: Qt.point(column,row)
color:{
if(d.rowHoverIndex === row || d.currentRow === table_model.getRow(row).__index){
return FluTheme.dark ? Qt.rgba(1,1,1,0.06) : Qt.rgba(0,0,0,0.06)
}
return (row%2!==0) ? control.color : (FluTheme.dark ? Qt.rgba(1,1,1,0.015) : Qt.rgba(0,0,0,0.015))
}
implicitHeight: 40 implicitHeight: 40
implicitWidth: { implicitWidth: {
var w = columnSource[column].width var w = columnSource[column].width
@ -261,76 +255,80 @@ Rectangle {
} }
return w return w
} }
onEntered: {
d.rowHoverIndex = row
}
Rectangle{ Rectangle{
height: 18 id:item_table
radius: 1.5
color: FluTheme.primaryColor.dark
width: 3
visible: d.currentRow === table_model.getRow(row).__index && column === 0
anchors{
verticalCenter: parent.verticalCenter
left: parent.left
leftMargin: 3
}
}
MouseArea{
anchors.fill: parent anchors.fill: parent
acceptedButtons: Qt.LeftButton property point position: Qt.point(column,row)
onPressed:{ color:{
closeEditor() if(d.rowHoverIndex === row || d.currentRow === table_model.getRow(row).__index){
} return FluTheme.dark ? Qt.rgba(1,1,1,0.06) : Qt.rgba(0,0,0,0.06)
onCanceled: {
}
onReleased: {
}
onDoubleClicked:{
if(typeof(display) == "object"){
return
} }
item_loader.sourceComponent = d.obtEditDelegate(column,row,item_table) return (row%2!==0) ? control.color : (FluTheme.dark ? Qt.rgba(1,1,1,0.015) : Qt.rgba(0,0,0,0.015))
} }
onClicked: Rectangle{
(event)=>{ height: 18
d.currentRow = table_model.getRow(row).__index radius: 1.5
item_loader.sourceComponent = undefined color: FluTheme.primaryColor.dark
event.accepted = true width: 3
visible: d.currentRow === table_model.getRow(row).__index && column === 0
anchors{
verticalCenter: parent.verticalCenter
left: parent.left
leftMargin: 3
} }
} }
Loader{ MouseArea{
property var itemModel: model anchors.fill: parent
property var modelData: display acceptedButtons: Qt.LeftButton
property var tableView: table_view onPressed:{
property var tableModel: table_model closeEditor()
property var position: item_table.position
property int row: position.y
property int column: position.x
property var options: {
if(typeof(modelData) == "object"){
return modelData.options
} }
return {} onCanceled: {
}
anchors.fill: parent
sourceComponent: {
if(typeof(modelData) == "object"){
return modelData.comId
} }
return com_text onReleased: {
}
onDoubleClicked:{
if(typeof(display) == "object"){
return
}
item_loader.sourceComponent = d.obtEditDelegate(column,row,item_table)
}
onClicked:
(event)=>{
d.currentRow = table_model.getRow(row).__index
item_loader.sourceComponent = undefined
event.accepted = true
}
} }
} Loader{
MouseArea{ property var itemModel: model
acceptedButtons: Qt.NoButton property var modelData: display
anchors.fill: parent property var tableView: table_view
hoverEnabled: true property var tableModel: table_model
z:99 property var position: item_table.position
onPositionChanged: { property int row: position.y
d.rowHoverIndex = row property int column: position.x
} property var options: {
onEntered: { if(typeof(modelData) == "object"){
d.rowHoverIndex = row return modelData.options
}
return {}
}
anchors.fill: parent
sourceComponent: {
if(typeof(modelData) == "object"){
return modelData.comId
}
return com_text
}
} }
} }
} }
} }
MouseArea{ MouseArea{
id:item_loader_layout id:item_loader_layout
@ -401,7 +399,35 @@ Rectangle {
} }
return column_item_control_mouse.containsMouse&&!canceled ? control.hoverButtonColor : FluTheme.dark ? Qt.rgba(50/255,50/255,50/255,1) : Qt.rgba(247/255,247/255,247/255,1) return column_item_control_mouse.containsMouse&&!canceled ? control.hoverButtonColor : FluTheme.dark ? Qt.rgba(50/255,50/255,50/255,1) : Qt.rgba(247/255,247/255,247/255,1)
} }
border.color: FluTheme.dark ? "#252525" : "#e4e4e4" Rectangle{
border.color: control.borderColor
width: parent.width
height: 1
anchors.top: parent.top
color:"#00000000"
}
Rectangle{
border.color: control.borderColor
width: parent.width
height: 1
anchors.bottom: parent.bottom
color:"#00000000"
}
Rectangle{
border.color: control.borderColor
width: 1
height: parent.height
anchors.left: parent.left
color:"#00000000"
}
Rectangle{
border.color: control.borderColor
width: 1
height: parent.height
anchors.right: parent.right
color:"#00000000"
visible: column === tableModel.columnCount - 1
}
MouseArea{ MouseArea{
id:column_item_control_mouse id:column_item_control_mouse
anchors.fill: parent anchors.fill: parent
@ -522,7 +548,35 @@ Rectangle {
} }
return item_control_mouse.containsMouse&&!canceled ? control.hoverButtonColor : FluTheme.dark ? Qt.rgba(50/255,50/255,50/255,1) : Qt.rgba(247/255,247/255,247/255,1) return item_control_mouse.containsMouse&&!canceled ? control.hoverButtonColor : FluTheme.dark ? Qt.rgba(50/255,50/255,50/255,1) : Qt.rgba(247/255,247/255,247/255,1)
} }
border.color: FluTheme.dark ? "#252525" : "#e4e4e4" Rectangle{
border.color: control.borderColor
width: parent.width
height: 1
anchors.top: parent.top
color:"#00000000"
}
Rectangle{
border.color: control.borderColor
width: parent.width
height: 1
anchors.bottom: parent.bottom
visible: row === tableModel.rowCount - 1
color:"#00000000"
}
Rectangle{
border.color: control.borderColor
width: 1
height: parent.height
anchors.left: parent.left
color:"#00000000"
}
Rectangle{
border.color: control.borderColor
width: 1
height: parent.height
anchors.right: parent.right
color:"#00000000"
}
FluText{ FluText{
id:row_text id:row_text
anchors.centerIn: parent anchors.centerIn: parent