Fixes as a Result of Android Testing: (#25)

Use Primary Text Size

Opaque Button Images Color Themselves Correctly

Fixes as a Result of Android Testing:

Fixes Crashes related to ButtonTextField Resize
Fixes Crashes related to EllipsisLabel

Reviewed-on: #25
This commit is contained in:
Sarah Jamie Lewis 2020-11-19 16:15:50 -08:00 committed by erinn
parent b8d0133878
commit 3b9675e259
7 changed files with 31 additions and 92 deletions

View File

@ -40,12 +40,23 @@ Rectangle {
Image {
id: ico
source: icon!="" ? gcd.assetPath + "fontawesome/"+icon+".webp" : "";
source: icon!="" ? gcd.assetPath + "core/"+icon+".webp" : "";
visible: icon != ""
height: button.height / 2
sourceSize.height: button.height / 2
ColorOverlay{
id: iconColorOverlay
color: textColor
anchors.fill: ico
source: ico
antialiasing: true
smooth: true
}
}
Label {
id: buttonText
font.family: Fonts.applicationFontRegular.name

View File

@ -14,6 +14,9 @@ TextField {
font.pixelSize: Theme.secondaryTextSize * gcd.themeScale
width: parent.width - 20
// IMPORTANT: Setting a dynamic height on the internal button widget caused it to crash on Android when
// resized (smaller), so we set an explicit height on TextField which seems to resolve the issue.
height: font.pixelSize + 20
property string icon
property string button_text
signal clicked

View File

@ -1,58 +0,0 @@
import QtQuick 2.7
import QtQuick.Controls 2.4
import QtQuick.Controls.Material 2.0
import QtQuick.Layouts 1.3
import CustomQmlTypes 1.0
import "." as Widgets
import "theme"
// Needs the parent to have an onWidthChanged that calls .textResize()
Item {
property string text
property alias color: label.color
property alias size: label.font.pixelSize
property alias weight: label.font.weight
property alias strikeout: label.font.strikeout
property alias font: label.font
property alias topPadding: label.topPadding
property alias leftPadding: label.leftPadding
property int extraPadding: 0
property Item container: parent
height: textMetric.height
width: textMetric.width + 10
anchors.leftMargin: 10
Label {
id: label
textFormat: Text.PlainText
elide: Text.ElideRight
text: textMetric.text
}
TextMetrics {
id: textMetric
text: text
font: label.font
}
onTextChanged: {
textResize()
}
function textResize() {
textMetric.text = text
var i = 2
var containerWidth = container != null ? container.width : 50
// - 30 for padding
while (textMetric.width > containerWidth - ((30 + extraPadding) * gcd.themeScale) && textMetric.width > 50) {
textMetric.text = text.slice(0, text.length - (i * 3)) + "..."
i++
}
}
}

View File

@ -28,14 +28,8 @@ Rectangle {
signal hover(bool hover)
//property int horizontalPadding: 0
//property int verticalPadding: 0
property int size: Math.min(height, width)
//property int innerHeight: height - (verticalPadding*2)
//property int innerWidth: width - (horizontalPadding*2)
Image {
id: srcImg
anchors.verticalCenter: parent.verticalCenter
@ -48,7 +42,6 @@ Rectangle {
// Apparently qml can now only DOWN-SCALE/SHRINK the SVG, so with this hack it which won't cause blurriness/pixelation
sourceSize.width: size*2
sourceSize.height: size*2
}
ColorOverlay{

View File

@ -71,32 +71,24 @@ Item {
anchors.leftMargin: 4 * logscale
anchors.verticalCenter: parent.verticalCenter
spacing: 2 * gcd.themeScale
EllipsisLabel { // CONTACT NAME
Label { // CONTACT NAME
id: cn
anchors.right: parent.right
anchors.left: parent.left
size: Theme.usernameSize * gcd.themeScale
Layout.fillWidth: true
elide: Text.ElideRight
font.pixelSize: Theme.usernameSize * gcd.themeScale
font.family: Fonts.applicationFontExtraBold.name
font.styleName: "ExtraBold"
text: displayName
}
EllipsisLabel { // Onion
Label { // Onion
id: onion
text: handle
anchors.right: parent.right
anchors.left: parent.left
size: Theme.secondaryTextSize * gcd.themeScale
}
Layout.fillWidth: true
elide: Text.ElideRight
font.pixelSize: Theme.secondaryTextSize * gcd.themeScale
onWidthChanged: {
cn.textResize()
onion.textResize()
}
}
Column {

View File

@ -67,24 +67,20 @@ Rectangle { // Global Toolbar
id: paneArea
anchors.right: parent.right
EllipsisLabel {
Label {
id: paneTitle
visible: true
anchors.horizontalCenter: parent.horizontalCenter
color: Theme.mainTextColor
size: Theme.tabSize * gcd.themeScale
weight: Font.Bold
font.pixelSize: Theme.primaryTextSize * gcd.themeScale
elide: Text.ElideRight
font.weight: Font.Bold
font.family: Fonts.applicationFontRegular.name
font.styleName: "Bold"
text: "global toolbar"
//extraPadding: btnRightMenu.width + 10
}
onWidthChanged: { paneTitle.textResize() }
}
Icon {
@ -104,7 +100,6 @@ Rectangle { // Global Toolbar
function setTitle(text, width) {
paneTitle.text = text
paneArea.width = theStack.width
paneTitle.textResize()
paneTitle.visible = true
}

View File

@ -13,11 +13,14 @@ TextField {
property bool error: false
color: error ? errorColor : Theme.mainTextColor
font.pixelSize: Theme.secondaryTextSize * gcd.themeScale * gcd.themeScale
font.pixelSize: Theme.secondaryTextSize * gcd.themeScale
signal clicked
smooth: true
placeholderTextColor: Theme.altTextColor
// NOTE: Android Password Fields don't work unless we set an explicit character.
passwordCharacter: "*"
background: Rectangle {
id: bg
anchors.fill: parent