Commit 5fc1d995 authored by Pekka Vuorela's avatar Pekka Vuorela

Some quick code cleanup

Avoiding setting default values to properties, grouped code a bit better.
parent 0a1bb5db
......@@ -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)
......@@ -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");
......
......@@ -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
......@@ -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
......
......@@ -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
......@@ -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
......
......@@ -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
......@@ -32,7 +33,6 @@ Rectangle {
border.width: 2
border.color: "#909090"
radius: window.radiusSmall
height: 0
width: parent.width
Text {
......
......@@ -64,6 +64,8 @@ Item {
}
Rectangle {
id: window
property string fgcolor: "black"
property string bgcolor: "#000000"
property int fontSize: 14*pixelRatio
......@@ -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\">" +
......@@ -131,7 +133,7 @@ Item {
NotifyWin {
id: errorDialog
text: ""
z: 1002
}
......@@ -148,10 +150,11 @@ Item {
Lineview {
id: lineView
x: 0
property int duration
y: -(height+1)
z: 20
property int duration: 0;
onFontPointSizeChanged: {
lineView.setPosition(vkb.active)
}
......@@ -159,8 +162,9 @@ Item {
Keyboard {
id: vkb
property bool visibleSetting: true
x: 0
y: parent.height-vkb.height
visible: page.activeFocus && visibleSetting
}
......@@ -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
......@@ -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 }
......@@ -304,8 +306,6 @@ Item {
// painted with the updated value (might not otherwise happen because of caching)
textrender.redraw();
}
z: 10
}
Timer {
......@@ -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; }
......@@ -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
......
......@@ -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: {
......@@ -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
......@@ -174,6 +176,7 @@ Rectangle {
color: "#606060"
border.color: "#000000"
border.width: 1
Column {
Text {
width: window.buttonWidthLarge
......@@ -214,6 +217,7 @@ Rectangle {
color: "#606060"
border.color: "#000000"
border.width: 1
Column {
Text {
width: window.buttonWidthLarge
......@@ -264,6 +268,7 @@ Rectangle {
color: "#606060"
border.color: "#000000"
border.width: 1
Column {
Text {
width: window.buttonWidthLarge
......@@ -319,6 +324,7 @@ Rectangle {
color: "#606060"
border.color: "#000000"
border.width: 1
Column {
Text {
width: window.buttonWidthLarge
......@@ -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
......@@ -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
......
......@@ -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
......@@ -34,8 +36,6 @@ Rectangle {
border.width: 1
radius: window.radiusMedium
signal dismissed();
MouseArea {
// event eater
anchors.fill: parent
......
......@@ -22,11 +22,12 @@ import QtQuick 2.0
Rectangle {
id: urlWindow
property variant urls: [""]
width: window.width-1
height: window.height-1
color: "#000000"
z: 100
property variant urls: [""]
state: ""
y: -(height+1)
border.color: "#c0c0c0"
......
......@@ -29,9 +29,12 @@ class QQuickView;
class Util : public QObject
{
Q_OBJECT
Q_PROPERTY(bool allowGestures READ allowGestures WRITE setAllowGestures NOTIFY allowGesturesChanged)
public:
explicit Util(QSettings* settings, QObject *parent = 0);
virtual ~Util();
void setWindow(QQuickView* win);
void setWindowTitle(QString title);
Q_INVOKABLE QString currentWindowTitle();
......@@ -61,8 +64,6 @@ public:
bool allowGestures() { return iAllowGestures; }
void setAllowGestures(bool a) { if(iAllowGestures!=a) { iAllowGestures=a; emit allowGesturesChanged(); } }
Q_PROPERTY(bool allowGestures READ allowGestures WRITE setAllowGestures NOTIFY allowGesturesChanged)
static bool charIsHexDigit(QChar ch);
public slots:
......
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