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{
|
||||
id:com_combobox
|
||||
|
||||
FluComboBox {
|
||||
anchors.fill: parent
|
||||
focus: true
|
||||
currentIndex: display
|
||||
editable: true
|
||||
model: ListModel {
|
||||
@ -63,8 +63,9 @@ FluContentPage{
|
||||
currentIndex=[100,300,500,1000].findIndex((element) => element === Number(display))
|
||||
selectAll()
|
||||
}
|
||||
TableView.onCommit: {
|
||||
onCommit: {
|
||||
display = editText
|
||||
tableView.closeEditor()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -97,8 +98,7 @@ FluContentPage{
|
||||
{
|
||||
title: '别名',
|
||||
dataIndex: 'nickname',
|
||||
width:100,
|
||||
|
||||
width:100
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -38,13 +38,13 @@ void FluApp::run(){
|
||||
|
||||
void FluApp::navigate(const QString& route,const QJsonObject& argument,FluRegister* fluRegister){
|
||||
if(!routes().contains(route)){
|
||||
qFatal()<<"No route found "<<route;
|
||||
qCritical()<<"No route found "<<route;
|
||||
return;
|
||||
}
|
||||
QQmlEngine *engine = qmlEngine(appWindow);
|
||||
QQmlComponent component(engine, routes().value(route).toString());
|
||||
if (component.isError()) {
|
||||
qFatal() << component.errors();
|
||||
qCritical() << component.errors();
|
||||
return;
|
||||
}
|
||||
QVariantMap properties;
|
||||
|
@ -63,6 +63,18 @@ bool FluTools::isWin(){
|
||||
#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){
|
||||
qApp->setQuitOnLastWindowClosed(val);
|
||||
}
|
||||
|
@ -50,6 +50,10 @@ public:
|
||||
|
||||
Q_INVOKABLE void setQuitOnLastWindowClosed(bool val);
|
||||
|
||||
Q_INVOKABLE int qtMajor();
|
||||
|
||||
Q_INVOKABLE int qtMinor();
|
||||
|
||||
};
|
||||
|
||||
#endif // FLUTOOLS_H
|
||||
|
@ -6,6 +6,7 @@ import QtQuick.Templates as T
|
||||
|
||||
ComboBox {
|
||||
id: control
|
||||
signal commit
|
||||
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 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
|
||||
}
|
||||
Component.onCompleted: {
|
||||
focus = true
|
||||
forceActiveFocus()
|
||||
}
|
||||
Keys.onEnterPressed: {
|
||||
control.commit()
|
||||
}
|
||||
Keys.onReturnPressed: {
|
||||
control.commit()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import QtQuick.Controls.Basic
|
||||
import FluentUI
|
||||
|
||||
TextArea{
|
||||
signal commit
|
||||
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 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
|
||||
background: FluTextBoxBackground{ inputItem: control }
|
||||
Keys.onEnterPressed: {
|
||||
control.commit()
|
||||
}
|
||||
Keys.onBackPressed: {
|
||||
control.commit()
|
||||
}
|
||||
TapHandler {
|
||||
acceptedButtons: Qt.RightButton
|
||||
onTapped: control.echoMode !== TextInput.Password && menu.popup()
|
||||
|
@ -4,6 +4,7 @@ import QtQuick.Controls.Basic
|
||||
import FluentUI
|
||||
|
||||
TextField{
|
||||
signal commit
|
||||
property bool disabled: false
|
||||
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)
|
||||
@ -50,6 +51,12 @@ TextField{
|
||||
}
|
||||
}
|
||||
}
|
||||
Keys.onEnterPressed: {
|
||||
control.commit()
|
||||
}
|
||||
Keys.onBackPressed: {
|
||||
control.commit()
|
||||
}
|
||||
FluIconButton{
|
||||
id:btn_reveal
|
||||
iconSource:FluentIcons.RevealPasswordMedium
|
||||
|
@ -38,9 +38,13 @@ Rectangle {
|
||||
anchors.fill: parent
|
||||
text: display
|
||||
verticalAlignment: TextInput.AlignVCenter
|
||||
Component.onCompleted: selectAll()
|
||||
TableView.onCommit: {
|
||||
Component.onCompleted: {
|
||||
forceActiveFocus()
|
||||
selectAll()
|
||||
}
|
||||
onCommit: {
|
||||
display = text
|
||||
tableView.closeEditor()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -52,6 +56,7 @@ Rectangle {
|
||||
anchors.bottom: parent.bottom
|
||||
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
||||
ScrollBar.vertical.policy: ScrollBar.AlwaysOff
|
||||
|
||||
TableView {
|
||||
id:table_view
|
||||
ListModel{
|
||||
@ -62,27 +67,44 @@ Rectangle {
|
||||
ScrollBar.vertical: FluScrollBar{}
|
||||
selectionModel: ItemSelectionModel {}
|
||||
columnWidthProvider: function(column) {
|
||||
let w = explicitColumnWidth(column)
|
||||
if (w >= 0){
|
||||
var w
|
||||
var minimumWidth = columnSource[column].minimumWidth
|
||||
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){
|
||||
minimumWidth = 100
|
||||
}
|
||||
if(!maximumWidth){
|
||||
maximumWidth = 65535
|
||||
}
|
||||
return Math.min(Math.max(minimumWidth, w),maximumWidth)
|
||||
}
|
||||
}
|
||||
rowHeightProvider: function(row) {
|
||||
let h = explicitRowHeight(row)
|
||||
var h
|
||||
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)
|
||||
}
|
||||
}
|
||||
model: table_model
|
||||
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))
|
||||
implicitHeight: 40
|
||||
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 {
|
||||
text: display
|
||||
anchors.fill: parent
|
||||
@ -99,16 +132,39 @@ Rectangle {
|
||||
elide: Text.ElideRight
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
TableView.editDelegate: {
|
||||
}
|
||||
}
|
||||
Loader{
|
||||
id:item_loader
|
||||
z:2
|
||||
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{
|
||||
id:com_handle
|
||||
FluControl {
|
||||
@ -160,5 +216,10 @@ Rectangle {
|
||||
syncView: table_view
|
||||
clip: true
|
||||
}
|
||||
|
||||
function closeEditor(){
|
||||
item_loader.sourceComponent = null
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import QtQuick.Controls.Basic
|
||||
import FluentUI
|
||||
|
||||
TextField{
|
||||
signal commit
|
||||
property bool disabled: false
|
||||
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)
|
||||
@ -32,6 +33,12 @@ TextField{
|
||||
}
|
||||
return placeholderNormalColor
|
||||
}
|
||||
Keys.onEnterPressed: {
|
||||
control.commit()
|
||||
}
|
||||
Keys.onReturnPressed: {
|
||||
control.commit()
|
||||
}
|
||||
selectByMouse: true
|
||||
rightPadding: icon_end.visible ? 50 : 30
|
||||
background: FluTextBoxBackground{
|
||||
|
Loading…
Reference in New Issue
Block a user