Skip to content

Commit

Permalink
Some quick code cleanup
Browse files Browse the repository at this point in the history
Avoiding setting default values to properties, grouped code a bit better.
  • Loading branch information
pvuorela committed May 4, 2016
1 parent 0a1bb5d commit 5fc1d99
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 64 deletions.
13 changes: 6 additions & 7 deletions main.cpp
Expand Up @@ -72,8 +72,7 @@ int main(int argc, char *argv[])
execCmd.append(" --login");
}

if(settings)
delete settings; // don't need 'em here
delete settings; // don't need 'em here

QStringList execParts = execCmd.split(' ', QString::SkipEmptyParts);
if(execParts.length()==0)
Expand All @@ -94,11 +93,11 @@ int main(int argc, char *argv[])

QScreen* sc = app.primaryScreen();
if(sc){
sc->setOrientationUpdateMask(Qt::PrimaryOrientation
| Qt::LandscapeOrientation
| Qt::PortraitOrientation
| Qt::InvertedLandscapeOrientation
| Qt::InvertedPortraitOrientation);
sc->setOrientationUpdateMask(Qt::PrimaryOrientation
| Qt::LandscapeOrientation
| Qt::PortraitOrientation
| Qt::InvertedLandscapeOrientation
| Qt::InvertedPortraitOrientation);
}

qmlRegisterType<TextRender>("TextRender",1,0,"TextRender");
Expand Down
24 changes: 12 additions & 12 deletions qml/Key.qml
Expand Up @@ -21,22 +21,24 @@ import QtQuick 2.0

Rectangle {
id: key
property string label: ""
property string label_alt: ""
property int code: 0
property int code_alt: 0

property string label
property string label_alt
property int code
property int code_alt
property int currentCode: (shiftActive && label_alt != '') ? code_alt : code
property string currentLabel: (shiftActive && label_alt != '') ? label_alt : label
property bool sticky: false // can key be stickied?
property bool becomesSticky: false // will this become sticky after release?
property int stickiness: 0 // current stickiness status
property bool sticky // can key be stickied?
property bool becomesSticky // will this become sticky after release?
property int stickiness // current stickiness status
property real labelOpacity: keyboard.active ? 1.0 : 0.3

// mouse input handling
property int clickThreshold: 20
property bool isClick: false
property int pressMouseY: 0
property int pressMouseX: 0
property bool isClick
property int pressMouseY
property int pressMouseX
property bool shiftActive: (keyboard.keyModifiers & Qt.ShiftModifier) && !sticky

width: window.width/12 // some default
height: window.height/8 < 55*window.pixelRatio ? window.height/8 : 55*window.pixelRatio
Expand All @@ -45,8 +47,6 @@ Rectangle {
border.width: 1
radius: window.radiusSmall

property bool shiftActive: (keyboard.keyModifiers & Qt.ShiftModifier) && !sticky

Image {
id: keyImage
anchors.centerIn: parent
Expand Down
16 changes: 10 additions & 6 deletions qml/Keyboard.qml
Expand Up @@ -21,12 +21,8 @@ import QtQuick 2.0

Rectangle {
id: keyboard
color: "transparent"

width: parent.width
height: childrenRect.height + outmargins

property int keyModifiers: 0
property int keyModifiers
property variant resetSticky: 0
property variant currentStickyPressed: null
property variant currentKeyPressed: 0
Expand All @@ -36,21 +32,29 @@ Rectangle {
property string keyHilightBgColor: "#ffffff"
property string keyBorderColor: "#303030"

property bool active: false
property bool active

property int outmargins: util.settingsValue("ui/keyboardMargins")
property int keyspacing: 6
property int keysPerRow: keyLoader.vkbColumns()
property real keywidth: (keyboard.width - keyspacing*keysPerRow - outmargins*2)/keysPerRow;

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

Component {
id: keyboardContents

Column {
id: col

x: (keyboard.width-width)/2
spacing: keyboard.keyspacing

Repeater {
id: rowRepeater

model: keyLoader.vkbRows()
delegate: Row {
spacing: keyboard.keyspacing
Expand Down
2 changes: 1 addition & 1 deletion qml/Lineview.qml
Expand Up @@ -21,6 +21,7 @@ import QtQuick 2.0

Rectangle {
id: lineView

property variant lines: [""]
property int fontPointSize: util.settingsValue("ui/fontSize")*window.pixelRatio;
property int cursorX: 1
Expand All @@ -32,7 +33,6 @@ Rectangle {
border.width: 2
border.color: "#909090"
radius: window.radiusSmall
height: 0
width: parent.width

Text {
Expand Down
45 changes: 23 additions & 22 deletions qml/Main.qml
Expand Up @@ -64,6 +64,8 @@ Item {
}

Rectangle {
id: window

property string fgcolor: "black"
property string bgcolor: "#000000"
property int fontSize: 14*pixelRatio
Expand Down Expand Up @@ -97,15 +99,15 @@ Item {
property int scrollBarWidth: 6*window.pixelRatio

anchors.fill: parent

id: window
objectName: "window"
color: bgcolor

NotifyWin {
id: aboutDialog
property int termW: 0
property int termH: 0

property int termW
property int termH

text: {
var str = "<font size=\"+3\">FingerTerm " + util.versionString() + "</font><br>\n" +
"<font size=\"+1\">" +
Expand All @@ -131,7 +133,7 @@ Item {

NotifyWin {
id: errorDialog
text: ""

z: 1002
}

Expand All @@ -148,19 +150,21 @@ Item {

Lineview {
id: lineView
x: 0

property int duration

y: -(height+1)
z: 20
property int duration: 0;
onFontPointSizeChanged: {
lineView.setPosition(vkb.active)
}
}

Keyboard {
id: vkb

property bool visibleSetting: true
x: 0

y: parent.height-vkb.height
visible: page.activeFocus && visibleSetting
}
Expand Down Expand Up @@ -237,7 +241,6 @@ Item {
Rectangle {
//top right corner menu button
x: window.width - width
y: 0
z: 1
width: menuImg.width + 60*window.pixelRatio
height: menuImg.height + 30*window.pixelRatio
Expand Down Expand Up @@ -272,21 +275,20 @@ Item {
MenuFingerterm {
id: menu
x: window.width-width
y: 0
}

TextRender {
id: textrender

property int duration
property int cutAfter: height

objectName: "textrender"
x: 0
y: 0
height: parent.height
width: parent.width
myWidth: width
myHeight: height
opacity: 1.0
property int duration: 0;
property int cutAfter: height
z: 10

Behavior on opacity {
NumberAnimation { duration: textrender.duration; easing.type: Easing.InOutQuad }
Expand All @@ -304,8 +306,6 @@ Item {
// painted with the updated value (might not otherwise happen because of caching)
textrender.redraw();
}

z: 10
}

Timer {
Expand Down Expand Up @@ -348,12 +348,14 @@ Item {
Text {
// shows large text notification in the middle of the screen (for gestures)
id: textNotify

anchors.centerIn: parent
color: "#ffffff"
z: 100
opacity: 0
text: ""
font.pointSize: 40*window.pixelRatio

Behavior on opacity {
id: textNotifyAnim
NumberAnimation { duration: 500; }
Expand All @@ -364,15 +366,14 @@ Item {
// visual key press feedback...
// easier to work with the coordinates if it's here and not under keyboard element
id: visualKeyFeedbackRect

property string label

visible: false
x: 0
y: 0
z: 200
width: 0
height: 0
radius: window.radiusSmall
color: "#ffffff"
property string label: ""

Text {
color: "#000000"
font.pointSize: 34*window.pixelRatio
Expand Down
30 changes: 20 additions & 10 deletions qml/MenuFingerterm.qml
Expand Up @@ -22,27 +22,29 @@ import QtQuick.XmlListModel 2.0

Rectangle {
id: menuWin

property bool showing
property bool enableCopy
property bool enablePaste
property string currentShowMethod: util.settingsValue("ui/vkbShowMethod")
property string currentDragMode: util.settingsValue("ui/dragMode")
property string currentOrientationLockMode: util.settingsValue("ui/orientationLockMode")
property int keyboardFadeOutDelay: util.settingsValue("ui/keyboardFadeOutDelay")

color: "transparent"
z: 30
width: window.width
height: window.height
visible: false
property bool showing: false
property bool enableCopy: false
property bool enablePaste: false
property string currentShowMethod: util.settingsValue("ui/vkbShowMethod")
property string currentDragMode: util.settingsValue("ui/dragMode")
property string currentOrientationLockMode: util.settingsValue("ui/orientationLockMode")
property int keyboardFadeOutDelay: util.settingsValue("ui/keyboardFadeOutDelay")

Rectangle {
id: fader

color: "#000000"
opacity: 0
y: 0
x: 0
width: menuWin.width
height: menuWin.height

MouseArea {
anchors.fill: parent
onClicked: {
Expand All @@ -58,8 +60,8 @@ Rectangle {
}
Rectangle {
id: rect

color: "#e0e0e0"
y: 0
x: menuWin.width+1;
width: flickableContent.width + 22*window.pixelRatio;
height: menuWin.height
Expand Down Expand Up @@ -174,6 +176,7 @@ Rectangle {
color: "#606060"
border.color: "#000000"
border.width: 1

Column {
Text {
width: window.buttonWidthLarge
Expand Down Expand Up @@ -214,6 +217,7 @@ Rectangle {
color: "#606060"
border.color: "#000000"
border.width: 1

Column {
Text {
width: window.buttonWidthLarge
Expand Down Expand Up @@ -264,6 +268,7 @@ Rectangle {
color: "#606060"
border.color: "#000000"
border.width: 1

Column {
Text {
width: window.buttonWidthLarge
Expand Down Expand Up @@ -319,6 +324,7 @@ Rectangle {
color: "#606060"
border.color: "#000000"
border.width: 1

Column {
Text {
width: window.buttonWidthLarge
Expand Down Expand Up @@ -404,12 +410,14 @@ Rectangle {
// VKB delay slider
Rectangle {
id: vkbDelaySliderArea

width: menuBlocksRow.width
height: window.buttonHeightLarge
radius: window.radiusSmall
color: "#606060"
border.color: "#000000"
border.width: 1

Text {
width: parent.width
height: window.headerHeight
Expand All @@ -429,7 +437,9 @@ Rectangle {
}
Rectangle {
id: vkbDelaySlider

property int keyboardFadeOutDelayLabel: keyboardFadeOutDelay

x: (keyboardFadeOutDelay-1000)/9000 * (vkbDelaySliderArea.width - vkbDelaySlider.width)
y: window.headerHeight
width: window.buttonWidthSmall
Expand Down
6 changes: 3 additions & 3 deletions qml/NotifyWin.qml
Expand Up @@ -22,7 +22,9 @@ import QtQuick 2.0
Rectangle {
id: notifyWin

property string text: ""
property string text

signal dismissed();

width: window.width-1
height: window.height-1
Expand All @@ -34,8 +36,6 @@ Rectangle {
border.width: 1
radius: window.radiusMedium

signal dismissed();

MouseArea {
// event eater
anchors.fill: parent
Expand Down

0 comments on commit 5fc1d99

Please sign in to comment.