main
zhuzihcu 2023-05-09 18:31:59 +08:00
parent b20046c0a9
commit a14e502abd
3 changed files with 93 additions and 7 deletions

View File

@ -0,0 +1,79 @@
import QtQuick
import QtQuick.Controls
import FluentUI
TextField {
property int fontStyle: FluText.Body
property color textColor: FluTheme.dark ? FluColors.White : FluColors.Grey220
property int pixelSize : FluTheme.textSize
id:control
color: textColor
readOnly: true
renderType: FluTheme.nativeText ? Text.NativeRendering : Text.QtRendering
padding: 0
leftPadding: 0
rightPadding: 0
topPadding: 0
bottomPadding: 0
selectionColor: FluTheme.primaryColor.lightest
TextMetrics {
id: text_metrics
font:control.font
text: control.text
}
background: Item{
implicitWidth: text_metrics.width+10
implicitHeight: text_metrics.height
}
font.bold: {
switch (fontStyle) {
case FluText.Display:
return true
case FluText.TitleLarge:
return true
case FluText.Title:
return true
case FluText.SubTitle:
return true
case FluText.BodyStrong:
return true
case FluText.Body:
return false
case FluText.Caption:
return false
default:
return false
}
}
font.pixelSize: {
switch (fontStyle) {
case FluText.Display:
return text.pixelSize * 4.857
case FluText.TitleLarge:
return text.pixelSize * 2.857
case FluText.Title:
return text.pixelSize * 2
case FluText.SubTitle:
return text.pixelSize * 1.428
case FluText.Body:
return text.pixelSize * 1.0
case FluText.BodyStrong:
return text.pixelSize * 1.0
case FluText.Caption:
return text.pixelSize * 0.857
default:
return text.pixelSize * 1.0
}
}
TapHandler {
acceptedButtons: Qt.RightButton
onTapped: control.echoMode !== TextInput.Password && menu.popup()
}
FluTextBoxMenu{
id:menu
inputItem: control
}
}

View File

@ -195,15 +195,10 @@ Item {
Component{ Component{
id:com_text id:com_text
Item{ Item{
MouseArea{ FluCopyableText{
id:item_mouse
hoverEnabled: true
anchors.fill: parent
}
FluText{
id:table_value id:table_value
text:String(model.itemData) text:String(model.itemData)
width: parent.width - 14 width: Math.min(parent.width - 14,implicitWidth)
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
onImplicitHeightChanged: parent.parent.parent.height = Math.max(implicitHeight + 20,itemHeight) onImplicitHeightChanged: parent.parent.parent.height = Math.max(implicitHeight + 20,itemHeight)
anchors{ anchors{
@ -211,6 +206,12 @@ Item {
left: parent.left left: parent.left
leftMargin: 14 leftMargin: 14
} }
MouseArea{
id:item_mouse
hoverEnabled: true
anchors.fill: parent
acceptedButtons: Qt.NoButton
}
FluTooltip{ FluTooltip{
visible: item_mouse.containsMouse visible: item_mouse.containsMouse
text:parent.text text:parent.text

View File

@ -14,6 +14,12 @@ FluMenu{
focus:false focus:false
enableAnimation:false enableAnimation:false
onVisibleChanged: {
if(visible){
inputItem.forceActiveFocus()
}
}
Connections{ Connections{
target: inputItem target: inputItem
function onTextChanged() { function onTextChanged() {