make most things obey ui scale

This commit is contained in:
erinn 2019-04-16 12:40:19 -07:00
parent 5cb93c8fe9
commit 61571989e7
11 changed files with 154 additions and 84 deletions

View File

@ -179,7 +179,6 @@ func (this *GrandCentralDispatcher) loadMessagesPaneHelper(handle string) {
if len(handle) == 32 { // LOAD GROUP if len(handle) == 32 { // LOAD GROUP
log.Debugf("LOADING GROUP %s", handle)
group := the.Peer.GetGroup(handle) group := the.Peer.GetGroup(handle)
tl := group.GetTimeline() tl := group.GetTimeline()
nick, _ := group.GetAttribute("nick") nick, _ := group.GetAttribute("nick")
@ -188,7 +187,7 @@ func (this *GrandCentralDispatcher) loadMessagesPaneHelper(handle string) {
} else { } else {
this.SetToolbarTitle(nick) this.SetToolbarTitle(nick)
} }
log.Debugf("messages: %d", len(tl))
for i := len(tl) - 1; i >= 0; i-- { for i := len(tl) - 1; i >= 0; i-- {
if tl[i].PeerID == the.Peer.GetProfile().Onion { if tl[i].PeerID == the.Peer.GetProfile().Onion {
handle = "me" handle = "me"

View File

@ -55,9 +55,13 @@ ApplicationWindow {
return newtext return newtext
} }
function scale() { function ptToPx(pt) {
return 0.1 + 2 * zoomSlider.value return Screen.pixelDensity * 25.4 * pt / 72
} }
function pxToPt(px) {
return px * 72 / (Screen.pixelDensity * 25.4)
}
/* Rectangle { // THE TOOLBAR /* Rectangle { // THE TOOLBAR

View File

@ -10,17 +10,32 @@ import "../widgets"
import "../styles" import "../styles"
ColumnLayout { // settingsPane ColumnLayout { // settingsPane
id: root
anchors.fill: parent anchors.fill: parent
StackToolbar { StackToolbar {
id: stb
text: qsTr("create-group-title") text: qsTr("create-group-title")
aux.visible: false aux.visible: false
membership.visible: false
} }
Flickable {
anchors.top: stb.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
boundsBehavior: Flickable.StopAtBounds
clip:true
contentWidth: tehcol.width
contentHeight: tehcol.height
Column { Column {
id: tehcol
leftPadding: 10 leftPadding: 10
spacing: 5 spacing: 5
width: root.width
ScalingLabel { ScalingLabel {
//: Server label //: Server label
@ -29,7 +44,7 @@ ColumnLayout { // settingsPane
TextField { TextField {
id: txtServer id: txtServer
style: CwtchTextFieldStyle{ width: 400 } style: CwtchTextFieldStyle{ width: tehcol.width * 0.8 }
text: "2c3kmoobnyghj2zw6pwv7d57yzld753auo3ugauezzpvfak3ahc4bdyd" text: "2c3kmoobnyghj2zw6pwv7d57yzld753auo3ugauezzpvfak3ahc4bdyd"
} }
@ -40,7 +55,7 @@ ColumnLayout { // settingsPane
TextField { TextField {
id: txtGroupName id: txtGroupName
style: CwtchTextFieldStyle{ width: 400 } style: CwtchTextFieldStyle{ width: tehcol.width * 0.8 }
//: default suggested group name //: default suggested group name
text: qsTr("default-group-name") text: qsTr("default-group-name")
} }
@ -55,4 +70,5 @@ ColumnLayout { // settingsPane
} }
}//end of column with padding }//end of column with padding
}//end of flickable
} }

View File

@ -22,7 +22,19 @@ ColumnLayout { // groupSettingsPane
back.onClicked: theStack.pane = theStack.messagePane back.onClicked: theStack.pane = theStack.messagePane
} }
Flickable {
anchors.top: toolbar.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
boundsBehavior: Flickable.StopAtBounds
clip:true
contentWidth: tehcol.width
contentHeight: tehcol.height
Column { Column {
id: tehcol
width: gsp.width
leftPadding: 10 leftPadding: 10
spacing: 5 spacing: 5
@ -32,7 +44,7 @@ ColumnLayout { // groupSettingsPane
TextField { TextField {
id: txtServer id: txtServer
style: CwtchTextFieldStyle{ width: 400 } style: CwtchTextFieldStyle{ width: tehcol.width * 0.8 }
readOnly: true readOnly: true
} }
@ -53,7 +65,7 @@ ColumnLayout { // groupSettingsPane
TextField { TextField {
id: txtInvitation id: txtInvitation
style: CwtchTextFieldStyle{ width: 400 } style: CwtchTextFieldStyle{ width: tehcol.width * 0.8 }
readOnly: true readOnly: true
} }
@ -74,7 +86,7 @@ ColumnLayout { // groupSettingsPane
TextField { TextField {
id: txtGroupName id: txtGroupName
style: CwtchTextFieldStyle{ width: 400 } style: CwtchTextFieldStyle{ width: tehcol.width * 0.8 }
} }
SimpleButton { SimpleButton {
@ -117,6 +129,7 @@ ColumnLayout { // groupSettingsPane
} }
}//end of column with padding }//end of column with padding
}//end of flickable
Connections { Connections {
target: gcd target: gcd

View File

@ -10,6 +10,7 @@ import "../widgets"
import "../styles" import "../styles"
ColumnLayout { // peerSettingsPane ColumnLayout { // peerSettingsPane
id: root
anchors.fill: parent anchors.fill: parent
@ -21,7 +22,19 @@ ColumnLayout { // peerSettingsPane
back.onClicked: theStack.pane = theStack.messagePane back.onClicked: theStack.pane = theStack.messagePane
} }
Flickable {
anchors.top: toolbar.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
boundsBehavior: Flickable.StopAtBounds
clip:true
contentWidth: tehcol.width
contentHeight: tehcol.height
Column { Column {
id: tehcol
width: root.width
leftPadding: 10 leftPadding: 10
spacing: 5 spacing: 5
@ -31,7 +44,7 @@ ColumnLayout { // peerSettingsPane
TextField { TextField {
id: txtOnion id: txtOnion
style: CwtchTextFieldStyle{ width: 400 } style: CwtchTextFieldStyle{ width: tehcol.width * 0.8 }
readOnly: true readOnly: true
} }
@ -53,7 +66,7 @@ ColumnLayout { // peerSettingsPane
TextField { TextField {
id: txtDisplayName id: txtDisplayName
style: CwtchTextFieldStyle{ width: 400 } style: CwtchTextFieldStyle{ width: tehcol.width * 0.8 }
} }
SimpleButton { SimpleButton {
@ -77,6 +90,7 @@ ColumnLayout { // peerSettingsPane
} }
}//end of column with padding }//end of column with padding
}//end of flickable
Connections { Connections {

View File

@ -10,26 +10,45 @@ import "../widgets"
import "../widgets/controls" import "../widgets/controls"
ColumnLayout { // settingsPane ColumnLayout { // settingsPane
id: root
anchors.fill: parent anchors.fill: parent
StackToolbar { StackToolbar {
id: stb
//: Cwtch Settings title //: Cwtch Settings title
text: qsTr("cwtch-settings-title") text: qsTr("cwtch-settings-title")
aux.visible: false aux.visible: false
membership.visible: false
} }
Flickable {
anchors.top: stb.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
boundsBehavior: Flickable.StopAtBounds
clip:true
contentWidth: tehcol.width
contentHeight: tehcol.height
Column { Column {
id: tehcol
leftPadding: 10 leftPadding: 10
spacing: 5 spacing: 5
width: root.width
ScalingLabel { ScalingLabel {
width: parent.width
wrapMode: TextEdit.Wrap
//: Version: %1 Built on: %2 //: Version: %1 Built on: %2
text: qsTr("version %1 builddate %2").arg(gcd.version).arg(gcd.buildDate) text: qsTr("version %1 builddate %2").arg(gcd.version).arg(gcd.buildDate)
} }
ScalingLabel { ScalingLabel {
Layout.maximumWidth: parent.width width: parent.width
wrapMode: TextEdit.Wrap
//: Interface zoom (mostly affects text and button sizes) //: Interface zoom (mostly affects text and button sizes)
text: qsTr("zoom-label") + ":" text: qsTr("zoom-label") + ":"
} }
@ -48,13 +67,16 @@ ColumnLayout { // settingsPane
} }
ScalingLabel { ScalingLabel {
wrapMode: TextEdit.Wrap
text: qsTr("large-text-label") text: qsTr("large-text-label")
size: 20 size: 20
} }
ScalingLabel{ ScalingLabel{
width: parent.width
wrapMode: TextEdit.Wrap
//: "Default size text (scale factor: " //: "Default size text (scale factor: "
text: qsTr("default-scaling-text") + zoomSlider.value + ")" text: qsTr("default-scaling-text") + " " + Math.round(zoomSlider.value * 100) / 100 + ")"
} }
ScalingLabel { ScalingLabel {
@ -90,6 +112,7 @@ ColumnLayout { // settingsPane
} }
}//end of column with padding }//end of column with padding
}//end of flickable
function saveSettings() { function saveSettings() {
// language switcher saves itself because erinn is a bad (read: amazing) programmer // language switcher saves itself because erinn is a bad (read: amazing) programmer

View File

@ -1,17 +1,16 @@
import QtQuick.Controls.Styles 1.4 import QtQuick.Controls.Styles 1.4
import QtQuick 2.7 import QtQuick 2.7
TextFieldStyle { TextFieldStyle {
id: root id: root
textColor: "black" textColor: "black"
font.pointSize: 10 font.pointSize: 10 * gcd.themeScale
property int width: 100 property int width: 100
background: Rectangle { background: Rectangle {
radius: 2 radius: 2
implicitWidth: root.width implicitWidth: root.width
implicitHeight: 24 implicitHeight: ptToPx(10 * gcd.themeScale)
color: windowItem.cwtch_background_color color: windowItem.cwtch_background_color
border.color: windowItem.cwtch_color border.color: windowItem.cwtch_color
} }

View File

@ -7,8 +7,8 @@ import CustomQmlTypes 1.0
Item { Item {
id: imgProfile id: imgProfile
implicitWidth: 48 implicitWidth: baseWidth
implicitHeight: 48 implicitHeight: baseWidth
anchors.margins: 5 anchors.margins: 5
property string handle property string handle
@ -17,17 +17,18 @@ Item {
property bool isGroup property bool isGroup
property bool showStatus property bool showStatus
property bool highlight property bool highlight
property int baseWidth: 48 * gcd.themeScale
Rectangle { Rectangle {
id: mainImage id: mainImage
width: 48 width: baseWidth
height: 48 height: baseWidth
color: highlight ? windowItem.cwtch_dark_color: "#FFFFFF" color: highlight ? windowItem.cwtch_dark_color: "#FFFFFF"
radius: width / 2 radius: width / 2
Rectangle { Rectangle {
width: highlight ? 44 : 48 width: highlight ? baseWidth - 4 : baseWidth
height: highlight ? 44 : 48 height: highlight ? baseWidth - 4 : baseWidth
color: "#FFFFFF" color: "#FFFFFF"
radius: width / 2 radius: width / 2
anchors.centerIn:parent anchors.centerIn:parent
@ -58,22 +59,22 @@ Item {
Rectangle { // PRESENCE INDICATOR Rectangle { // PRESENCE INDICATOR
visible: showStatus visible: showStatus
color: "#FFFFFF" color: "#FFFFFF"
width: 8 width: 8 * gcd.themeScale
height: 8 height: 8 * gcd.themeScale
radius: 2 radius: 2 * gcd.themeScale
anchors.right: parent.right anchors.right: parent.right
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.margins: 4 anchors.margins: 4 * gcd.themeScale
Rectangle { //-2:WtfCodeError,-1:Untrusted,0:Disconnected,1:Connecting,2:Connected,3:Authenticated,4:Failed,5:Killed Rectangle { //-2:WtfCodeError,-1:Untrusted,0:Disconnected,1:Connecting,2:Connected,3:Authenticated,4:Failed,5:Killed
color: status == 3 ? "green" : status == -1 ? "blue" : status == 1 ? "orange" : status == 2 ? "orange" : "red" color: status == 3 ? "green" : status == -1 ? "blue" : status == 1 ? "orange" : status == 2 ? "orange" : "red"
width: 5 width: 5 * gcd.themeScale
height: 5 height: 5 * gcd.themeScale
radius: 2 radius: 2 * gcd.themeScale
anchors.right: parent.right anchors.right: parent.right
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.margins: 1.5 anchors.margins: 1.5 * gcd.themeScale
} }
} }

View File

@ -5,10 +5,12 @@ import QtQuick.Controls.Material 2.0
import QtQuick.Layouts 1.3 import QtQuick.Layouts 1.3
import CustomQmlTypes 1.0 import CustomQmlTypes 1.0
RowLayout { // LOTS OF NESTING TO DEAL WITH QT WEIRDNESS, SORRY Item { // LOTS OF NESTING TO DEAL WITH QT WEIRDNESS, SORRY
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
visible: !deleted visible: !deleted
height: 48 * gcd.themeScale + 3
implicitHeight: height
property alias displayName: cn.text property alias displayName: cn.text
property alias image: imgProfile.source property alias image: imgProfile.source
@ -24,61 +26,60 @@ RowLayout { // LOTS OF NESTING TO DEAL WITH QT WEIRDNESS, SORRY
Rectangle { // CONTACT ENTRY BACKGROUND COLOR Rectangle { // CONTACT ENTRY BACKGROUND COLOR
id: root id: crRect
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
height: childrenRect.height + 3 height: 48 * gcd.themeScale + 3
width: parent.width width: parent.width
color: background ? (isHover ? "#D2D2F3" : (isActive ? "#D2D2F3" : "#D2C0DD")) : windowItem.cwtch_background_color color: background ? (isHover ? "#D2D2F3" : (isActive ? "#D2D2F3" : "#D2C0DD")) : windowItem.cwtch_background_color
ContactPicture {
id: imgProfile
showStatus: true
}
RowLayout { Label { // CONTACT NAME
width: parent.width id: cn
anchors.left: parent.left leftPadding: 10
anchors.right: parent.right rightPadding: 10
//wrapMode: Text.WordWrap
anchors.left: imgProfile.right
anchors.right: rectUnread.left
anchors.verticalCenter: parent.verticalCenter
font.pixelSize: 16 * gcd.themeScale
font.italic: !trusted
textFormat: Text.PlainText
//fontSizeMode: Text.HorizontalFit
elide: Text.ElideRight
color: "#000000"
}
Rectangle { // UNREAD MESSAGES?
id: rectUnread
height: txtmetric.tightBoundingRect.height + 8 * gcd.themeScale
width: txtmetric.tightBoundingRect.width + 8 * gcd.themeScale
radius: 8 * gcd.themeScale
color: "#4B3557"
visible: badge != 0
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
anchors.rightMargin: 9 * gcd.themeScale
ContactPicture { Label {
id: imgProfile id: lblUnread
showStatus: true anchors.verticalCenter: parent.verticalCenter
} anchors.horizontalCenter: parent.horizontalCenter
color: "#FFFFFF"
font.pixelSize: 12 * gcd.themeScale
text: txtmetric.text
}
Label { // CONTACT NAME TextMetrics {
id: cn id: txtmetric
leftPadding: 10 text: badge
rightPadding: 10 font: lblUnread.font
//wrapMode: Text.WordWrap }
anchors.left: imgProfile.right }
anchors.right: rectUnread.left
font.pixelSize: 16
font.italic: !trusted
textFormat: Text.PlainText
//fontSizeMode: Text.HorizontalFit
elide: Text.ElideRight
color: "#000000"
}
Rectangle { // UNREAD MESSAGES?
id: rectUnread
anchors.right: parent.right
height: 16
width: lblUnread.width + 10
radius: 8
color: "#4B3557"
visible: badge != 0
anchors.rightMargin: 9
Label {
id: lblUnread
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
color: "#FFFFFF"
font.pixelSize: 12
text: badge
}
}
}
} }
MouseArea { // ONCLICK: LOAD CONVERSATION WITH THIS CONTACT MouseArea { // ONCLICK: LOAD CONVERSATION WITH THIS CONTACT

View File

@ -113,7 +113,7 @@ RowLayout {
padding: 6 padding: 6
leftPadding: 10 leftPadding: 10
font.pixelSize: gcd.themeScale * 12 font.pixelSize: gcd.themeScale * 12
selectByMouse: false selectByMouse: gcd.os != "android"
readOnly: true readOnly: true
width: Math.min(dummy.width, root.parent.width - (imgProfile.visible ? imgProfile.width : 0) - 40) width: Math.min(dummy.width, root.parent.width - (imgProfile.visible ? imgProfile.width : 0) - 40)
wrapMode: TextEdit.Wrap wrapMode: TextEdit.Wrap
@ -169,7 +169,7 @@ RowLayout {
} }
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: gcd.os == "android" ? parent : null
onPressAndHold: { onPressAndHold: {

View File

@ -144,13 +144,13 @@ ColumnLayout {
} }
*/ */
ScalingLabel { // ONION ADDRESS Text { // ONION ADDRESS
id: lblOnion id: lblOnion
//font.pixelSize: 6 fontSizeMode: Text.HorizontalFit
minimumPointSize: 2
Layout.fillWidth: true Layout.fillWidth: true
padding: 3
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
text:onion text: onion
} }
Row { // TOOLS FOR EDITING PROFILE Row { // TOOLS FOR EDITING PROFILE