mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2025-02-02 19:27:38 +08:00
update
This commit is contained in:
parent
e1096b8e22
commit
059a1b17cc
@ -48,9 +48,9 @@ FluContentPage{
|
|||||||
|
|
||||||
Component{
|
Component{
|
||||||
id:com_combobox
|
id:com_combobox
|
||||||
|
|
||||||
FluComboBox {
|
FluComboBox {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
focus: true
|
||||||
currentIndex: display
|
currentIndex: display
|
||||||
editable: true
|
editable: true
|
||||||
model: ListModel {
|
model: ListModel {
|
||||||
@ -63,8 +63,9 @@ FluContentPage{
|
|||||||
currentIndex=[100,300,500,1000].findIndex((element) => element === Number(display))
|
currentIndex=[100,300,500,1000].findIndex((element) => element === Number(display))
|
||||||
selectAll()
|
selectAll()
|
||||||
}
|
}
|
||||||
TableView.onCommit: {
|
onCommit: {
|
||||||
display = editText
|
display = editText
|
||||||
|
tableView.closeEditor()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -97,8 +98,7 @@ FluContentPage{
|
|||||||
{
|
{
|
||||||
title: '别名',
|
title: '别名',
|
||||||
dataIndex: 'nickname',
|
dataIndex: 'nickname',
|
||||||
width:100,
|
width:100
|
||||||
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -38,13 +38,13 @@ void FluApp::run(){
|
|||||||
|
|
||||||
void FluApp::navigate(const QString& route,const QJsonObject& argument,FluRegister* fluRegister){
|
void FluApp::navigate(const QString& route,const QJsonObject& argument,FluRegister* fluRegister){
|
||||||
if(!routes().contains(route)){
|
if(!routes().contains(route)){
|
||||||
qFatal()<<"No route found "<<route;
|
qCritical()<<"No route found "<<route;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QQmlEngine *engine = qmlEngine(appWindow);
|
QQmlEngine *engine = qmlEngine(appWindow);
|
||||||
QQmlComponent component(engine, routes().value(route).toString());
|
QQmlComponent component(engine, routes().value(route).toString());
|
||||||
if (component.isError()) {
|
if (component.isError()) {
|
||||||
qFatal() << component.errors();
|
qCritical() << component.errors();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QVariantMap properties;
|
QVariantMap properties;
|
||||||
|
@ -63,6 +63,18 @@ bool FluTools::isWin(){
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int FluTools::qtMajor(){
|
||||||
|
const QString qtVersion = QString::fromLatin1(qVersion());
|
||||||
|
const QStringList versionParts = qtVersion.split('.');
|
||||||
|
return versionParts[0].toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
int FluTools::qtMinor(){
|
||||||
|
const QString qtVersion = QString::fromLatin1(qVersion());
|
||||||
|
const QStringList versionParts = qtVersion.split('.');
|
||||||
|
return versionParts[1].toInt();
|
||||||
|
}
|
||||||
|
|
||||||
void FluTools::setQuitOnLastWindowClosed(bool val){
|
void FluTools::setQuitOnLastWindowClosed(bool val){
|
||||||
qApp->setQuitOnLastWindowClosed(val);
|
qApp->setQuitOnLastWindowClosed(val);
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,10 @@ public:
|
|||||||
|
|
||||||
Q_INVOKABLE void setQuitOnLastWindowClosed(bool val);
|
Q_INVOKABLE void setQuitOnLastWindowClosed(bool val);
|
||||||
|
|
||||||
|
Q_INVOKABLE int qtMajor();
|
||||||
|
|
||||||
|
Q_INVOKABLE int qtMinor();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FLUTOOLS_H
|
#endif // FLUTOOLS_H
|
||||||
|
@ -6,6 +6,7 @@ import QtQuick.Templates as T
|
|||||||
|
|
||||||
ComboBox {
|
ComboBox {
|
||||||
id: control
|
id: control
|
||||||
|
signal commit
|
||||||
property bool disabled: false
|
property bool disabled: false
|
||||||
property color normalColor: FluTheme.dark ? Qt.rgba(62/255,62/255,62/255,1) : Qt.rgba(254/255,254/255,254/255,1)
|
property color normalColor: FluTheme.dark ? Qt.rgba(62/255,62/255,62/255,1) : Qt.rgba(254/255,254/255,254/255,1)
|
||||||
property color hoverColor: FluTheme.dark ? Qt.rgba(68/255,68/255,68/255,1) : Qt.rgba(251/255,251/255,251/255,1)
|
property color hoverColor: FluTheme.dark ? Qt.rgba(68/255,68/255,68/255,1) : Qt.rgba(251/255,251/255,251/255,1)
|
||||||
@ -64,7 +65,13 @@ ComboBox {
|
|||||||
inputItem: contentItem
|
inputItem: contentItem
|
||||||
}
|
}
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
focus = true
|
forceActiveFocus()
|
||||||
|
}
|
||||||
|
Keys.onEnterPressed: {
|
||||||
|
control.commit()
|
||||||
|
}
|
||||||
|
Keys.onReturnPressed: {
|
||||||
|
control.commit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import QtQuick.Controls.Basic
|
|||||||
import FluentUI
|
import FluentUI
|
||||||
|
|
||||||
TextArea{
|
TextArea{
|
||||||
|
signal commit
|
||||||
property bool disabled: false
|
property bool disabled: false
|
||||||
property color normalColor: FluTheme.dark ? Qt.rgba(255/255,255/255,255/255,1) : Qt.rgba(27/255,27/255,27/255,1)
|
property color normalColor: FluTheme.dark ? Qt.rgba(255/255,255/255,255/255,1) : Qt.rgba(27/255,27/255,27/255,1)
|
||||||
property color disableColor: FluTheme.dark ? Qt.rgba(131/255,131/255,131/255,1) : Qt.rgba(160/255,160/255,160/255,1)
|
property color disableColor: FluTheme.dark ? Qt.rgba(131/255,131/255,131/255,1) : Qt.rgba(160/255,160/255,160/255,1)
|
||||||
@ -34,6 +35,12 @@ TextArea{
|
|||||||
}
|
}
|
||||||
selectByMouse: true
|
selectByMouse: true
|
||||||
background: FluTextBoxBackground{ inputItem: control }
|
background: FluTextBoxBackground{ inputItem: control }
|
||||||
|
Keys.onEnterPressed: {
|
||||||
|
control.commit()
|
||||||
|
}
|
||||||
|
Keys.onBackPressed: {
|
||||||
|
control.commit()
|
||||||
|
}
|
||||||
TapHandler {
|
TapHandler {
|
||||||
acceptedButtons: Qt.RightButton
|
acceptedButtons: Qt.RightButton
|
||||||
onTapped: control.echoMode !== TextInput.Password && menu.popup()
|
onTapped: control.echoMode !== TextInput.Password && menu.popup()
|
||||||
|
@ -4,6 +4,7 @@ import QtQuick.Controls.Basic
|
|||||||
import FluentUI
|
import FluentUI
|
||||||
|
|
||||||
TextField{
|
TextField{
|
||||||
|
signal commit
|
||||||
property bool disabled: false
|
property bool disabled: false
|
||||||
property int iconSource: 0
|
property int iconSource: 0
|
||||||
property color normalColor: FluTheme.dark ? Qt.rgba(255/255,255/255,255/255,1) : Qt.rgba(27/255,27/255,27/255,1)
|
property color normalColor: FluTheme.dark ? Qt.rgba(255/255,255/255,255/255,1) : Qt.rgba(27/255,27/255,27/255,1)
|
||||||
@ -50,6 +51,12 @@ TextField{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Keys.onEnterPressed: {
|
||||||
|
control.commit()
|
||||||
|
}
|
||||||
|
Keys.onBackPressed: {
|
||||||
|
control.commit()
|
||||||
|
}
|
||||||
FluIconButton{
|
FluIconButton{
|
||||||
id:btn_reveal
|
id:btn_reveal
|
||||||
iconSource:FluentIcons.RevealPasswordMedium
|
iconSource:FluentIcons.RevealPasswordMedium
|
||||||
|
@ -38,9 +38,13 @@ Rectangle {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
text: display
|
text: display
|
||||||
verticalAlignment: TextInput.AlignVCenter
|
verticalAlignment: TextInput.AlignVCenter
|
||||||
Component.onCompleted: selectAll()
|
Component.onCompleted: {
|
||||||
TableView.onCommit: {
|
forceActiveFocus()
|
||||||
|
selectAll()
|
||||||
|
}
|
||||||
|
onCommit: {
|
||||||
display = text
|
display = text
|
||||||
|
tableView.closeEditor()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -52,6 +56,7 @@ Rectangle {
|
|||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
||||||
ScrollBar.vertical.policy: ScrollBar.AlwaysOff
|
ScrollBar.vertical.policy: ScrollBar.AlwaysOff
|
||||||
|
|
||||||
TableView {
|
TableView {
|
||||||
id:table_view
|
id:table_view
|
||||||
ListModel{
|
ListModel{
|
||||||
@ -62,27 +67,44 @@ Rectangle {
|
|||||||
ScrollBar.vertical: FluScrollBar{}
|
ScrollBar.vertical: FluScrollBar{}
|
||||||
selectionModel: ItemSelectionModel {}
|
selectionModel: ItemSelectionModel {}
|
||||||
columnWidthProvider: function(column) {
|
columnWidthProvider: function(column) {
|
||||||
let w = explicitColumnWidth(column)
|
var w
|
||||||
if (w >= 0){
|
var minimumWidth = columnSource[column].minimumWidth
|
||||||
var minimumWidth = columnSource[column].minimumWidth
|
var maximumWidth = columnSource[column].maximumWidth
|
||||||
var maximumWidth = columnSource[column].maximumWidth
|
if(FluTools.qtMajor()>=6 && FluTools.qtMinor()>=5){
|
||||||
|
w = explicitColumnWidth(column)
|
||||||
|
if (w >= 0){
|
||||||
|
if(!minimumWidth){
|
||||||
|
minimumWidth = 100
|
||||||
|
}
|
||||||
|
if(!maximumWidth){
|
||||||
|
maximumWidth = 65535
|
||||||
|
}
|
||||||
|
return Math.min(Math.max(minimumWidth, w),maximumWidth)
|
||||||
|
}
|
||||||
|
return implicitColumnWidth(column)
|
||||||
|
}else{
|
||||||
|
w = implicitColumnWidth(column)
|
||||||
if(!minimumWidth){
|
if(!minimumWidth){
|
||||||
minimumWidth = 100
|
minimumWidth = 100
|
||||||
}
|
}
|
||||||
if(!maximumWidth){
|
if(!maximumWidth){
|
||||||
maximumWidth = 65535
|
maximumWidth = 65535
|
||||||
}
|
}
|
||||||
|
|
||||||
return Math.min(Math.max(minimumWidth, w),maximumWidth)
|
return Math.min(Math.max(minimumWidth, w),maximumWidth)
|
||||||
}
|
}
|
||||||
return implicitColumnWidth(column)
|
|
||||||
}
|
}
|
||||||
rowHeightProvider: function(row) {
|
rowHeightProvider: function(row) {
|
||||||
let h = explicitRowHeight(row)
|
var h
|
||||||
if (h >= 0){
|
if(FluTools.qtMajor()>=6 && FluTools.qtMinor()>=5){
|
||||||
|
h = explicitRowHeight(row)
|
||||||
|
if (h >= 0){
|
||||||
|
return Math.max(40, h)
|
||||||
|
}
|
||||||
|
return implicitRowHeight(row)
|
||||||
|
}else{
|
||||||
|
h = implicitRowHeight(row)
|
||||||
return Math.max(40, h)
|
return Math.max(40, h)
|
||||||
}
|
}
|
||||||
return implicitRowHeight(row)
|
|
||||||
}
|
}
|
||||||
model: table_model
|
model: table_model
|
||||||
clip: true
|
clip: true
|
||||||
@ -92,6 +114,17 @@ Rectangle {
|
|||||||
color: selected ? FluTheme.primaryColor.lightest: (row%2!==0) ? control.color : (FluTheme.dark ? Qt.rgba(1,1,1,0.06) : Qt.rgba(0,0,0,0.06))
|
color: selected ? FluTheme.primaryColor.lightest: (row%2!==0) ? control.color : (FluTheme.dark ? Qt.rgba(1,1,1,0.06) : Qt.rgba(0,0,0,0.06))
|
||||||
implicitHeight: 40
|
implicitHeight: 40
|
||||||
implicitWidth: columnSource[column].width
|
implicitWidth: columnSource[column].width
|
||||||
|
TapHandler{
|
||||||
|
onDoubleTapped: {
|
||||||
|
item_loader.sourceComponent = obtEditDelegate(column,row)
|
||||||
|
var index = table_view.index(row,column)
|
||||||
|
}
|
||||||
|
onTapped: {
|
||||||
|
if(!current){
|
||||||
|
item_loader.sourceComponent = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
FluText {
|
FluText {
|
||||||
text: display
|
text: display
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
@ -99,16 +132,39 @@ Rectangle {
|
|||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
}
|
}
|
||||||
TableView.editDelegate: {
|
}
|
||||||
var obj =columnSource[column].editDelegate
|
}
|
||||||
if(obj){
|
Loader{
|
||||||
return obj
|
id:item_loader
|
||||||
}
|
z:2
|
||||||
return com_edit
|
property var display
|
||||||
}
|
property int column
|
||||||
|
property int row
|
||||||
|
property var tableView: control
|
||||||
|
onDisplayChanged: {
|
||||||
|
table_model.setData(table_view.index(row,column),"display",display)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function obtEditDelegate(column,row){
|
||||||
|
var display = table_model.data(table_view.index(row,column),"display")
|
||||||
|
var cellItem = table_view.itemAtCell(column, row)
|
||||||
|
var cellPosition = cellItem.mapToItem(scroll_table, 0, 0)
|
||||||
|
item_loader.column = column
|
||||||
|
item_loader.row = row
|
||||||
|
item_loader.x =table_view.contentX + cellPosition.x
|
||||||
|
item_loader.y =table_view.contentY + cellPosition.y
|
||||||
|
item_loader.width = table_view.columnWidthProvider(column)
|
||||||
|
item_loader.height = table_view.rowHeightProvider(row)
|
||||||
|
item_loader.display = display
|
||||||
|
var obj =columnSource[column].editDelegate
|
||||||
|
if(obj){
|
||||||
|
return obj
|
||||||
|
}
|
||||||
|
return com_edit
|
||||||
|
}
|
||||||
|
|
||||||
Component{
|
Component{
|
||||||
id:com_handle
|
id:com_handle
|
||||||
FluControl {
|
FluControl {
|
||||||
@ -160,5 +216,10 @@ Rectangle {
|
|||||||
syncView: table_view
|
syncView: table_view
|
||||||
clip: true
|
clip: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function closeEditor(){
|
||||||
|
item_loader.sourceComponent = null
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import QtQuick.Controls.Basic
|
|||||||
import FluentUI
|
import FluentUI
|
||||||
|
|
||||||
TextField{
|
TextField{
|
||||||
|
signal commit
|
||||||
property bool disabled: false
|
property bool disabled: false
|
||||||
property int iconSource: 0
|
property int iconSource: 0
|
||||||
property color normalColor: FluTheme.dark ? Qt.rgba(255/255,255/255,255/255,1) : Qt.rgba(27/255,27/255,27/255,1)
|
property color normalColor: FluTheme.dark ? Qt.rgba(255/255,255/255,255/255,1) : Qt.rgba(27/255,27/255,27/255,1)
|
||||||
@ -32,6 +33,12 @@ TextField{
|
|||||||
}
|
}
|
||||||
return placeholderNormalColor
|
return placeholderNormalColor
|
||||||
}
|
}
|
||||||
|
Keys.onEnterPressed: {
|
||||||
|
control.commit()
|
||||||
|
}
|
||||||
|
Keys.onReturnPressed: {
|
||||||
|
control.commit()
|
||||||
|
}
|
||||||
selectByMouse: true
|
selectByMouse: true
|
||||||
rightPadding: icon_end.visible ? 50 : 30
|
rightPadding: icon_end.visible ? 50 : 30
|
||||||
background: FluTextBoxBackground{
|
background: FluTextBoxBackground{
|
||||||
|
Loading…
Reference in New Issue
Block a user