fixed scaling bug of fancy button on window

This commit is contained in:
Dorian Zedler 2019-03-20 17:25:30 +01:00
parent 2ec52ac6e3
commit 552bee0213
3 changed files with 45 additions and 40 deletions

View file

@ -28,6 +28,10 @@ Button {
property real imageScale: 1 property real imageScale: 1
property color color: app.style.style.buttonColor property color color: app.style.style.buttonColor
property int size: 100
height: control.size
width: control.size
scale: control.pressed ? 0.8:1 scale: control.pressed ? 0.8:1
@ -37,7 +41,14 @@ Button {
} }
} }
background: Item { onSizeChanged: {
control.width = control.size
control.height = control.size
console.log("Button: size: " + control.size + " height: " + control.height + " width: " + control.width)
}
background: Item {
id: controlBackgroundContainer id: controlBackgroundContainer
RectangularGlow { RectangularGlow {
@ -54,27 +65,30 @@ Button {
Rectangle { Rectangle {
id: controlBackground id: controlBackground
anchors.fill: parent anchors.centerIn: parent
radius: height * 0.5 height: control.height
width: control.width
radius: control.size * 0.5
color: control.color color: control.color
Image {
id: buttonIcon
source: control.image
anchors.centerIn: parent
height: parent.height * 0.5
width: height
mipmap: true
fillMode: Image.PreserveAspectFit
scale: control.imageScale
}
} }
} }
Image {
id: buttonIcon
source: control.image
anchors.centerIn: parent
height: parent.height * 0.5
width: height
mipmap: true
fillMode: Image.PreserveAspectFit
scale: control.imageScale
}
} }

View file

@ -161,7 +161,7 @@ Page {
background: Rectangle { background: Rectangle {
radius: 2 radius: 2
color: app.style.style.backgroundColor color: classLetterCb.Material.dialogColor
layer.enabled: classLetterCb.enabled layer.enabled: classLetterCb.enabled
// layer.effect: ElevationEffect { // layer.effect: ElevationEffect {
@ -307,8 +307,7 @@ Page {
imageScale: 0 imageScale: 0
height: 50 size: 50
width: height
onClicked: { onClicked: {
filterDialog.createContact() filterDialog.createContact()

View file

@ -33,19 +33,18 @@ Page {
Column { Column {
id: mainMenu id: mainMenu
spacing: buttonWidth * 0.1 spacing: buttonSize * 0.1
anchors { anchors {
horizontalCenter: parent.horizontalCenter horizontalCenter: parent.horizontalCenter
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
} }
property int buttonHeight: app.landscape() ? root.height * (0.5*0.8):buttonWidth property int buttonSize: app.landscape() ? root.height * (0.5*0.8):root.width * (0.5*0.8)
property int buttonWidth: app.landscape() ? buttonHeight:root.width * (0.5*0.8)
Row { Row {
id: bigMenu id: bigMenu
spacing: mainMenu.buttonWidth * 0.1 spacing: mainMenu.buttonSize * 0.1
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
FancyButton { FancyButton {
@ -53,8 +52,7 @@ Page {
image: "qrc:/graphics/icons/sheute.png" image: "qrc:/graphics/icons/sheute.png"
width: mainMenu.buttonWidth size: mainMenu.buttonSize
height: mainMenu.buttonHeight
onClicked: { onClicked: {
formStack.eventDay = 0 formStack.eventDay = 0
@ -67,8 +65,7 @@ Page {
image: "qrc:/graphics/icons/smorgen.png" image: "qrc:/graphics/icons/smorgen.png"
width: mainMenu.buttonWidth size: mainMenu.buttonSize
height: mainMenu.buttonHeight
onClicked: { onClicked: {
formStack.eventDay = 1 formStack.eventDay = 1
@ -81,20 +78,18 @@ Page {
Grid { Grid {
id: smallMenu id: smallMenu
columns: app.landscape() ? 4:2 columns: app.landscape() ? 4:2
spacing: mainMenu.buttonWidth * 0.1 spacing: mainMenu.buttonSize * 0.1
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
property int buttonHeight: mainMenu.buttonHeight * 0.7 property int buttonSize: mainMenu.buttonSize * 0.7
property int buttonWidth: mainMenu.buttonWidth * 0.7
FancyButton { FancyButton {
id: foodplanButton id: foodplanButton
image: app.style.style.treffpunktFannyIcon image: app.style.style.treffpunktFannyIcon
width: smallMenu.buttonWidth size: smallMenu.buttonSize
height: smallMenu.buttonHeight
onClicked: { onClicked: {
formStack.push(foodPlanForm) formStack.push(foodPlanForm)
@ -107,8 +102,7 @@ Page {
image: app.style.style.fannyLogo image: app.style.style.fannyLogo
imageScale: 1.2 imageScale: 1.2
width: smallMenu.buttonWidth size: smallMenu.buttonSize
height: smallMenu.buttonHeight
onClicked: { onClicked: {
Qt.openUrlExternally("http://www.fanny-leicht.de") Qt.openUrlExternally("http://www.fanny-leicht.de")
@ -121,8 +115,7 @@ Page {
image: app.style.style.settingsIcon image: app.style.style.settingsIcon
imageScale: 0.8 imageScale: 0.8
width: smallMenu.buttonWidth size: smallMenu.buttonSize
height: smallMenu.buttonHeight
onClicked: { onClicked: {
formStack.push(settingsForm) formStack.push(settingsForm)
@ -135,8 +128,7 @@ Page {
image: "qrc:/graphics/icons/logoutRed.png" image: "qrc:/graphics/icons/logoutRed.png"
imageScale: 0.8 imageScale: 0.8
width: smallMenu.buttonWidth size: smallMenu.buttonSize
height: smallMenu.buttonHeight
onClicked: { onClicked: {
logoutConfirmationDialog.open() logoutConfirmationDialog.open()