Skip to content

Commit

Permalink
Merge pull request #5 from faenil/qtquick2
Browse files Browse the repository at this point in the history
Finalizing QtQuick2 port
  • Loading branch information
bwachter committed Aug 16, 2013
2 parents 8f3a68b + 2517ade commit 8b6faf6
Show file tree
Hide file tree
Showing 14 changed files with 539 additions and 385 deletions.
2 changes: 1 addition & 1 deletion fingerterm.pro
Expand Up @@ -40,7 +40,7 @@ OTHER_FILES += \
qtc_packaging/debian_harmattan/compat \
qtc_packaging/debian_harmattan/changelog \
qml/Button.qml \
qml/Menu.qml \
qml/MenuFingerterm.qml \
qml/NotifyWin.qml \
qml/UrlWindow.qml \
qml/LayoutWindow.qml
Expand Down
11 changes: 7 additions & 4 deletions main.cpp
Expand Up @@ -135,22 +135,23 @@ int main(int argc, char *argv[])

view.setSource(QUrl("qrc:/qml/Main.qml"));

QObject *win = view.rootObject();
if(!win)
QObject *root = view.rootObject();
if(!root)
qFatal("no root object - qml error");

QObject* win = root->findChild<QObject*>("window");

if(!startupErrorMsg.isEmpty())
QMetaObject::invokeMethod(win, "showErrorMessage", Qt::QueuedConnection, Q_ARG(QVariant, startupErrorMsg));

TextRender *tr = win->findChild<TextRender*>("textrender");
TextRender *tr = root->findChild<TextRender*>("textrender");
tr->setUtil(&util);
tr->setTerminal(&term);
term.setRenderer(tr);
term.setWindow(&view);
util.setWindow(&view);
util.setTerm(&term);
util.setRenderer(tr);
view.installEventFilter(&util); //for grabbing mouse drags

QObject::connect(&term,SIGNAL(displayBufferChanged()),win,SLOT(displayBufferChanged()));
QObject::connect(view.engine(),SIGNAL(quit()),&app,SLOT(quit()));
Expand Down Expand Up @@ -178,6 +179,8 @@ int main(int argc, char *argv[])

void defaultSettings(QSettings* settings)
{
if(!settings->contains("ui/orientationLockMode"))
settings->setValue("ui/orientationLockMode", "auto");
if(!settings->contains("general/execCmd"))
settings->setValue("general/execCmd", "");
if(!settings->contains("general/visualBell"))
Expand Down
57 changes: 24 additions & 33 deletions qml/Key.qml
Expand Up @@ -94,47 +94,38 @@ Rectangle {
anchors.topMargin: key.height/2
}

MouseArea {
enabled: label!=""
id: keyMouseArea
anchors.fill: parent
anchors.margins: -3 // -(half of keyspacing)
onExited: {
keyRepeatStarter.stop();
keyRepeatTimer.stop();

key.color = keyboard.keyBgColor
keyboard.currentKeyPressed = 0;
}
onPressedChanged: {
if(pressed) {
key.color = keyboard.keyHilightBgColor
keyboard.currentKeyPressed = key;
util.keyPressFeedback();
function handlePress() {
key.color = keyboard.keyHilightBgColor
keyboard.currentKeyPressed = key;
util.keyPressFeedback();

keyRepeatStarter.start();
} else {
keyboard.currentKeyPressed = 0;
if(containsMouse) {
keyRepeatStarter.start();
}

util.keyReleaseFeedback();
function handleRelease() {
util.keyReleaseFeedback();

keyRepeatStarter.stop();
keyRepeatTimer.stop();
keyRepeatStarter.stop();
keyRepeatTimer.stop();

key.color = keyboard.keyBgColor
key.color = keyboard.keyBgColor

setStickiness(-1)
vkbKeypress(currentCode, keyboard.keyModifiers);
setStickiness(-1)
window.vkbKeypress(currentCode, keyboard.keyModifiers);

if( !sticky && keyboard.resetSticky != 0 && keyboard.resetSticky !== key ) {
resetSticky.setStickiness(0);
}
}
}
if( !sticky && keyboard.resetSticky != 0 && keyboard.resetSticky !== key ) {
resetSticky.setStickiness(0);
}
}

function handleExit() {
keyRepeatStarter.stop();
keyRepeatTimer.stop();

key.color = keyboard.keyBgColor
keyboard.currentKeyPressed = 0;
}

Timer {
id: keyRepeatStarter
running: false
Expand All @@ -153,7 +144,7 @@ Rectangle {
triggeredOnStart: true
interval: 80
onTriggered: {
vkbKeypress(currentCode, keyboard.keyModifiers);
window.vkbKeypress(currentCode, keyboard.keyModifiers);
}
}

Expand Down
21 changes: 21 additions & 0 deletions qml/Keyboard.qml
Expand Up @@ -110,4 +110,25 @@ Rectangle {
keyboardLoader.sourceComponent = undefined
keyboardLoader.sourceComponent = keyboardContents
}

//borrowed from nemo-keyboard
//Parameters: (x, y) in view coordinates
function keyAt(x, y) {
var item = keyboard
x -= keyboard.x
y -= keyboard.y

while ((item = item.childAt(x, y)) != null) {
//return the first "Key" element we find
if (typeof item.currentCode !== 'undefined') {
return item
}

// Cheaper mapToItem, assuming we're not using anything fancy.
x -= item.x
y -= item.y
}

return null
}
}
2 changes: 1 addition & 1 deletion qml/LayoutWindow.qml
Expand Up @@ -125,7 +125,7 @@ Rectangle {
to: "*"
SequentialAnimation {
PropertyAnimation { target: layoutWindow; properties: "y"; duration: 200; easing.type: Easing.InOutCubic }
ScriptAction { script: updateGesturesAllowed(); }
ScriptAction { script: window.updateGesturesAllowed(); }
}
}
]
Expand Down

0 comments on commit 8b6faf6

Please sign in to comment.