Skip to content

Commit

Permalink
Simplify qml
Browse files Browse the repository at this point in the history
  • Loading branch information
pvuorela committed Jun 27, 2016
1 parent b595712 commit 7b45173
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 124 deletions.
3 changes: 1 addition & 2 deletions qml/Keyboard.qml
Expand Up @@ -19,7 +19,7 @@

import QtQuick 2.0

Rectangle {
Item {
id: keyboard

property int keyModifiers
Expand All @@ -39,7 +39,6 @@ Rectangle {
property int keysPerRow: keyLoader.vkbColumns()
property real keywidth: (keyboard.width - keyspacing*keysPerRow - outmargins*2)/keysPerRow;

color: "transparent"
width: parent.width
height: childrenRect.height + outmargins

Expand Down
31 changes: 7 additions & 24 deletions qml/LayoutWindow.qml
Expand Up @@ -23,15 +23,18 @@ Rectangle {
id: layoutWindow

property variant layouts: [""]
property bool show

width: window.width-1
height: window.height-1
color: "#000000"
y: -(height+1)
y: show ? 0 : -(height+1)
border.color: "#c0c0c0"
border.width: 1
radius: window.radiusMedium

Behavior on y { NumberAnimation { duration: 200; easing.type: Easing.InOutCubic } }

MouseArea {
// event eater
anchors.fill: parent
Expand Down Expand Up @@ -66,8 +69,8 @@ Rectangle {
anchors.rightMargin: window.paddingSmall
onClicked: {
util.keyboardLayout = modelData
layoutWindow.state = "";
util.notifyText(modelData);
layoutWindow.show = false
util.notifyText(modelData)
}
}
}
Expand Down Expand Up @@ -97,26 +100,6 @@ Rectangle {
anchors.bottom: parent.bottom
anchors.bottomMargin: window.paddingMedium
text: "Back"
onClicked: {
layoutWindow.state = ""
}
onClicked: layoutWindow.show = false
}

states: [
State {
name: "visible"
PropertyChanges {
target: layoutWindow
y: 0
}
}
]

transitions: [
Transition {
from: "*"
to: "*"
PropertyAnimation { target: layoutWindow; properties: "y"; duration: 200; easing.type: Easing.InOutCubic }
}
]
}
25 changes: 5 additions & 20 deletions qml/Lineview.qml
Expand Up @@ -29,12 +29,15 @@ Rectangle {
property int cursorWidth: 10
property int cursorHeight: 10
property int extraLines: util.extraLinesFromCursor
property bool show

y: show ? 0 : -(height+window.paddingSmall)
color: "#404040"
border.width: 2
border.color: "#909090"
radius: window.radiusSmall
width: parent.width
height: lineTextCol.height + 8*window.pixelRatio

Text {
id: fontHeightHack
Expand All @@ -57,11 +60,13 @@ Rectangle {

Column {
id: lineTextCol

anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.right: parent.right
anchors.leftMargin: 2*window.pixelRatio
anchors.rightMargin: 2*window.pixelRatio

Repeater {
model: lines
delegate: Item {
Expand All @@ -79,25 +84,5 @@ Rectangle {
}
}
}
onHeightChanged: {
if(lineView.visible)
lineView.height = height+8*window.pixelRatio
setPosition(vkb.active)
}
}

function setPosition(vkbActive)
{
if (util.keyboardMode == Util.KeyboardOff) {
lineView.visible = false;
return;
}

lineView.visible = true;
if (vkbActive && util.keyboardMode != Util.KeyboardMove) {
y = 0;
} else {
y = -(height+window.paddingSmall)
}
}
}
43 changes: 11 additions & 32 deletions qml/Main.qml
Expand Up @@ -36,8 +36,7 @@ Item {
Binding {
target: util
property: "allowGestures"
value: !vkb.active && !menu.showing && urlWindow.state != "visible" && aboutDialog.state != "visible"
&& layoutWindow.state != "visible"
value: !vkb.active && !menu.showing && !urlWindow.show && !aboutDialog.show && !layoutWindow.show
}

Item {
Expand Down Expand Up @@ -98,13 +97,7 @@ Item {

Lineview {
id: lineView

property int duration

y: -(height+1)
onFontPointSizeChanged: {
lineView.setPosition(vkb.active)
}
show: (util.keyboardMode == Util.KeyboardFade) && vkb.active
}

Keyboard {
Expand Down Expand Up @@ -185,27 +178,21 @@ Item {
}
}

Rectangle {
MouseArea {
//top right corner menu button
x: window.width - width
width: menuImg.width + 60*window.pixelRatio
height: menuImg.height + 30*window.pixelRatio
color: "transparent"
opacity: 0.5
onClicked: menu.showing = true

Image {
anchors.centerIn: parent
id: menuImg

anchors.centerIn: parent
source: "qrc:/icons/menu.png"
height: sourceSize.height
width: sourceSize.width
scale: window.pixelRatio
}
MouseArea {
anchors.fill: parent
onClicked: {
menu.showing = true
}
}
}

Image {
Expand All @@ -226,6 +213,8 @@ Item {
height: parent.height
width: parent.width
fontPointSize: util.fontSize
opacity: (util.keyboardMode == Util.KeyboardFade && vkb.active) ? 0.3
: 1.0

Behavior on opacity {
NumberAnimation { duration: textrender.duration; easing.type: Easing.InOutQuad }
Expand Down Expand Up @@ -360,20 +349,16 @@ Item {
if(!vkb.visibleSetting)
return;

lineView.duration = window.fadeOutTime;
textrender.duration = window.fadeOutTime;
fadeTimer.restart();
vkb.active = true;
lineView.setPosition(vkb.active);
setTextRenderAttributes();
}

function sleepVKB()
{
textrender.duration = window.fadeInTime;
lineView.duration = window.fadeInTime;
vkb.active = false;
lineView.setPosition(vkb.active);
setTextRenderAttributes();
}

Expand All @@ -382,7 +367,6 @@ Item {
if (util.keyboardMode == Util.KeyboardMove)
{
vkb.visibleSetting = true;
textrender.opacity = 1.0;
if(vkb.active) {
var move = textrender.cursorPixelPos().y + textrender.fontHeight/2
+ textrender.fontHeight*util.extraLinesFromCursor
Expand All @@ -403,17 +387,12 @@ Item {
vkb.visibleSetting = true;
textrender.cutAfter = textrender.height;
textrender.y = 0;
if(vkb.active)
textrender.opacity = 0.3;
else
textrender.opacity = 1.0;
}
else // "off" (vkb disabled)
{
vkb.visibleSetting = false;
textrender.cutAfter = textrender.height;
textrender.y = 0;
textrender.opacity = 1.0;
}
}

Expand All @@ -428,7 +407,7 @@ Item {

Component.onCompleted: {
if (util.showWelcomeScreen)
aboutDialog.state = "visible"
aboutDialog.show = true
if (startupErrorMessage != "") {
showErrorMessage(startupErrorMessage)
}
Expand All @@ -437,7 +416,7 @@ Item {
function showErrorMessage(string)
{
errorDialog.text = "<font size=\"+2\">" + string + "</font>";
errorDialog.state = "visible"
errorDialog.show = true
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions qml/MenuFingerterm.qml
Expand Up @@ -151,7 +151,7 @@ Item {
onClicked: {
menuWin.showing = false;
urlWindow.urls = term.grabURLsFromBuffer();
urlWindow.state = "visible";
urlWindow.show = true
}
}
Rectangle {
Expand Down Expand Up @@ -354,7 +354,7 @@ Item {
onClicked: {
menuWin.showing = false;
layoutWindow.layouts = keyLoader.availableLayouts();
layoutWindow.state = "visible";
layoutWindow.show = true
}
}
Button {
Expand All @@ -363,7 +363,7 @@ Item {
menuWin.showing = false;
aboutDialog.termW = term.termSize().width
aboutDialog.termH = term.termSize().height
aboutDialog.state = "visible"
aboutDialog.show = true
}
}
Button {
Expand Down
26 changes: 5 additions & 21 deletions qml/NotifyWin.qml
Expand Up @@ -23,18 +23,20 @@ Rectangle {
id: notifyWin

property string text
property bool show

signal dismissed()

width: window.width-1
height: window.height-1
color: "#000000"
y: -(height+1)
state: ""
y: show ? 0 : -(height+1)
border.color: "#c0c0c0"
border.width: 1
radius: window.radiusMedium

Behavior on y { NumberAnimation { duration: 200; easing.type: Easing.InOutCubic } }

MouseArea {
// event eater
anchors.fill: parent
Expand Down Expand Up @@ -66,26 +68,8 @@ Rectangle {
anchors.bottomMargin: window.paddingMedium
text: "OK"
onClicked: {
notifyWin.state = ""
notifyWin.show = false
notifyWin.dismissed();
}
}

states: [
State {
name: "visible"
PropertyChanges {
target: notifyWin
y: 0
}
}
]

transitions: [
Transition {
from: "*"
to: "*"
PropertyAnimation { target: notifyWin; properties: "y"; duration: 200; easing.type: Easing.InOutCubic }
}
]
}
27 changes: 5 additions & 22 deletions qml/UrlWindow.qml
Expand Up @@ -23,15 +23,18 @@ Rectangle {
id: urlWindow

property variant urls: [""]
property bool show

width: window.width-1
height: window.height-1
color: "#000000"
y: -(height+1)
y: show ? 0 : -(height+1)
border.color: "#c0c0c0"
border.width: 1
radius: window.radiusMedium

Behavior on y { NumberAnimation { duration: 200; easing.type: Easing.InOutCubic } }

MouseArea {
// event eater
anchors.fill: parent
Expand Down Expand Up @@ -104,26 +107,6 @@ Rectangle {
anchors.bottom: parent.bottom
anchors.bottomMargin: window.paddingMedium
text: "Back"
onClicked: {
urlWindow.state = ""
}
onClicked: urlWindow.show = false
}

states: [
State {
name: "visible"
PropertyChanges {
target: urlWindow
y: 0
}
}
]

transitions: [
Transition {
from: "*"
to: "*"
PropertyAnimation { target: urlWindow; properties: "y"; duration: 200; easing.type: Easing.InOutCubic }
}
]
}

0 comments on commit 7b45173

Please sign in to comment.