long text truncation

This commit is contained in:
Alexander Ivash 2018-06-01 01:06:38 +03:00
parent 8d921b123d
commit 41a9b22bf6
2 changed files with 20 additions and 22 deletions

View file

@ -1,5 +1,6 @@
import QtQuick 2.6 import QtQuick 2.6
import QtQuick.Controls 2.2 import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import QtQml.Models 2.1 import QtQml.Models 2.1
import QtGraphicalEffects 1.0 import QtGraphicalEffects 1.0
import "../controls-uit" as HifiControls import "../controls-uit" as HifiControls
@ -315,13 +316,14 @@ Rectangle {
Rectangle { Rectangle {
id: mainBlock id: mainBlock
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: 30
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: 30
anchors.top: header.bottom anchors.top: header.bottom
anchors.bottom: favoritesBlock.top anchors.bottom: favoritesBlock.top
TextStyle1 { TextStyle1 {
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: 30
anchors.top: parent.top anchors.top: parent.top
anchors.topMargin: 34 anchors.topMargin: 34
} }
@ -329,7 +331,6 @@ Rectangle {
TextStyle1 { TextStyle1 {
id: displayNameLabel id: displayNameLabel
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: 30
anchors.top: parent.top anchors.top: parent.top
anchors.topMargin: 25 anchors.topMargin: 25
text: 'Display Name' text: 'Display Name'
@ -344,7 +345,6 @@ Rectangle {
anchors.leftMargin: 30 anchors.leftMargin: 30
anchors.verticalCenter: displayNameLabel.verticalCenter anchors.verticalCenter: displayNameLabel.verticalCenter
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: 30
width: 232 width: 232
text: 'ThisIsDisplayName' text: 'ThisIsDisplayName'
@ -359,16 +359,12 @@ Rectangle {
id: avatarImage id: avatarImage
width: 134 width: 134
height: 134 height: 134
anchors.left: displayNameLabel.left
anchors.top: displayNameLabel.bottom anchors.top: displayNameLabel.bottom
anchors.topMargin: 31 anchors.topMargin: 31
Binding on source { Binding on source {
when: avatarUrl !== '' when: avatarUrl !== ''
value: avatarUrl value: avatarUrl
} }
onSourceChanged: {
console.debug('avatarImage: source = ', source);
}
visible: avatarImage.status !== Image.Loading && avatarImage.status !== Image.Error visible: avatarImage.status !== Image.Loading && avatarImage.status !== Image.Error
fillMode: Image.PreserveAspectCrop fillMode: Image.PreserveAspectCrop
@ -407,12 +403,13 @@ Rectangle {
visible: avatarWearablesCount !== 0 visible: avatarWearablesCount !== 0
} }
Row { RowLayout {
id: star id: star
anchors.top: avatarImage.top anchors.top: avatarImage.top
anchors.topMargin: 11 anchors.topMargin: 11
anchors.left: avatarImage.right anchors.left: avatarImage.right
anchors.leftMargin: 30.5 anchors.leftMargin: 30.5
anchors.right: parent.right
spacing: 12.3 spacing: 12.3
@ -424,7 +421,9 @@ Rectangle {
} }
TextStyle5 { TextStyle5 {
Layout.fillWidth: true
text: isAvatarInFavorites ? avatarName : "Add to Favorites" text: isAvatarInFavorites ? avatarName : "Add to Favorites"
elide: Qt.ElideRight
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
} }
} }
@ -459,19 +458,15 @@ Rectangle {
TextStyle3 { TextStyle3 {
id: avatarNameLabel id: avatarNameLabel
text: { text: getAvatarModelName();
var avatarName = getAvatarModelName(); elide: Qt.ElideRight
console.debug('getAvatarModelName() returned: ', avatarName)
return avatarName.length <= 14 ? avatarName : avatarName.substring(0, 14) + '...' anchors.right: linkLabel.left
}
anchors.left: avatarImage.right anchors.left: avatarImage.right
anchors.leftMargin: 30 anchors.leftMargin: 30
anchors.top: star.bottom anchors.top: star.bottom
anchors.topMargin: 11 anchors.topMargin: 11
property bool hasMarketId: currentAvatar && allAvatars.extractMarketId(currentAvatar.avatarUrl) !== ''; property bool hasMarketId: currentAvatar && allAvatars.extractMarketId(currentAvatar.avatarUrl) !== '';
onHasMarketIdChanged: {
console.debug('hasMarketId: ', hasMarketId, currentAvatar.avatarUrl);
}
MouseArea { MouseArea {
enabled: avatarNameLabel.hasMarketId enabled: avatarNameLabel.hasMarketId
@ -492,8 +487,8 @@ Rectangle {
} }
SquareLabel { SquareLabel {
id: linkLabel
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: 30
anchors.verticalCenter: avatarNameLabel.verticalCenter anchors.verticalCenter: avatarNameLabel.verticalCenter
glyphText: "." glyphText: "."
glyphSize: 22 glyphSize: 22
@ -514,7 +509,6 @@ Rectangle {
SquareLabel { SquareLabel {
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: 30
anchors.verticalCenter: wearablesLabel.verticalCenter anchors.verticalCenter: wearablesLabel.verticalCenter
glyphText: "\ue02e" glyphText: "\ue02e"
@ -531,7 +525,6 @@ Rectangle {
TextStyle3 { TextStyle3 {
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: 30
anchors.verticalCenter: wearablesLabel.verticalCenter anchors.verticalCenter: wearablesLabel.verticalCenter
font.underline: true font.underline: true
text: "Add" text: "Add"
@ -608,6 +601,8 @@ Rectangle {
property int horizontalSpacing: 18 property int horizontalSpacing: 18
property int verticalSpacing: 44 property int verticalSpacing: 44
property int thumbnailWidth: 92
property int thumbnailHeight: 92
function selectAvatar(avatar) { function selectAvatar(avatar) {
emitSendToScript({'method' : 'selectAvatar', 'name' : avatar.name}) emitSendToScript({'method' : 'selectAvatar', 'name' : avatar.name})
@ -687,8 +682,8 @@ Rectangle {
flow: GridView.FlowLeftToRight flow: GridView.FlowLeftToRight
cellHeight: 92 + verticalSpacing cellHeight: thumbnailHeight + verticalSpacing
cellWidth: 92 + horizontalSpacing cellWidth: thumbnailWidth + horizontalSpacing
delegate: Item { delegate: Item {
id: delegateRoot id: delegateRoot
@ -808,7 +803,9 @@ Rectangle {
TextStyle7 { TextStyle7 {
id: text id: text
width: 92 width: view.thumbnailWidth
height: view.verticalSpacing
elide: Qt.ElideRight
anchors.top: container.bottom anchors.top: container.bottom
anchors.topMargin: 8 anchors.topMargin: 8
anchors.horizontalCenter: container.horizontalCenter anchors.horizontalCenter: container.horizontalCenter

View file

@ -83,6 +83,7 @@ Rectangle {
anchors.rightMargin: 30 anchors.rightMargin: 30
text: root.titleText text: root.titleText
elide: Qt.ElideRight
} }
Column { Column {