Commit 08d4d7ab authored by Han Young's avatar Han Young
Browse files

calculate GridLayout

parent 1b04b29f
......@@ -7,10 +7,22 @@ import QtQuick 2.0
import org.kde.kirigami 2.13 as Kirigami
import QtQuick.Layouts 1.1
GridLayout {
id: functionPad
signal pressed(string text)
columns: 2
rowSpacing: Kirigami.Units.smallSpacing
columnSpacing: Kirigami.Units.smallSpacing
function calculateLayout() {
let childrens = 12;
let calculated = Math.sqrt(functionPad.width * childrens / functionPad.height);
functionPad.columns = calculated;
}
Component.onCompleted: calculateLayout()
onWidthChanged: calculateLayout()
onHeightChanged: calculateLayout()
NumberButton {text: "sin(" ; display: "sin"; onClicked: pressed(text);}
NumberButton {text: "cos(" ; display: "cos"; onClicked: pressed(text);}
NumberButton {text: "tan(" ; display: "tan"; onClicked: pressed(text);}
......
......@@ -7,11 +7,26 @@ import QtQuick 2.0
import org.kde.kirigami 2.13 as Kirigami
import QtQuick.Layouts 1.1
GridLayout {
id: numberPad
signal pressed(string text)
signal clear()
property bool pureNumber: false
columns: pureNumber ? 3 : 4
function calculateLayout() {
let childrens = 0;
if (pureNumber)
childrens = 17;
else
childrens = 24;
let calculated = Math.sqrt(numberPad.width * childrens / numberPad.height);
numberPad.columns = calculated;
}
Component.onCompleted: calculateLayout()
onWidthChanged: calculateLayout()
onHeightChanged: calculateLayout()
NumberButton {text: "√(" ; display: ""; onClicked: pressed(text);}
NumberButton {text: "^2" ; display: ""; onClicked: pressed(text);}
NumberButton {text: "(" ; onClicked: pressed(text); special: true; visible: !pureNumber}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment