QML UI: dynamic button sizes

Butons are sized based in the text printed on them,
we want our buttons to have a meaningful minimum size and a
preferred size that is similar regardless of screen resolution.

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Joakim Bygdell 2015-07-30 08:17:09 +02:00 committed by Dirk Hohndel
parent d337def212
commit 10e531d907
2 changed files with 6 additions and 1 deletions

View file

@ -4,6 +4,7 @@ import QtQuick.Controls.Styles 1.2
import QtQuick.Window 2.2 import QtQuick.Window 2.2
import QtQuick.Dialogs 1.2 import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
import QtQuick.Window 2.2
import org.subsurfacedivelog.mobile 1.0 import org.subsurfacedivelog.mobile 1.0
Item { Item {
@ -44,10 +45,12 @@ Item {
Button { Button {
id: backButton id: backButton
Layout.margins: 0.1 * height Layout.margins: 0.1 * height
Layout.preferredWidth: Screen.width * 0.1
text: "\u2190" text: "\u2190"
style: ButtonStyle { style: ButtonStyle {
background: Rectangle { background: Rectangle {
color: "#4C68A2" color: "#4C68A2"
implicitWidth: 50
} }
label: Text { label: Text {
id: txt id: txt

View file

@ -4,6 +4,7 @@ import QtQuick.Controls.Styles 1.2
import QtQuick.Window 2.2 import QtQuick.Window 2.2
import QtQuick.Dialogs 1.2 import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
import QtQuick.Window 2.2
import org.subsurfacedivelog.mobile 1.0 import org.subsurfacedivelog.mobile 1.0
ApplicationWindow { ApplicationWindow {
@ -85,9 +86,10 @@ ApplicationWindow {
id: prefsButton id: prefsButton
text: "\u22ee" text: "\u22ee"
anchors.right: parent.right anchors.right: parent.right
Layout.preferredWidth: Screen.width * 0.1
style: ButtonStyle { style: ButtonStyle {
background: Rectangle { background: Rectangle {
implicitWidth: 72 implicitWidth: 50
color: "#2C4882" color: "#2C4882"
} }
label: Text { label: Text {