Skip to content

Commit

Permalink
[port] Now uses qtcomponents, added preliminary orientationLock suppo…
Browse files Browse the repository at this point in the history
…rt, qml code more robust

- Added PageStackWindow and Page elements to exploit qtcomponents' screen orientation support.
To do that part of QML code had to be modified a bit because many function calls assumed that the "window" element was in their scope, which has always been the case so far because it was the root QML item, but not anymore, now that the root item is a PageStackWindow, and "window" has been moved as a child of the initialPage.

- A new Orientation Lock setting has been added in Fingerterm's menu. It lets you choose between Auto, Portrait Lock and Landscape Lock (defaults to Auto).
  • Loading branch information
faenil committed Aug 14, 2013
1 parent f8573e5 commit e2f5a26
Show file tree
Hide file tree
Showing 11 changed files with 118 additions and 27 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
10 changes: 7 additions & 3 deletions main.cpp
Expand Up @@ -135,14 +135,16 @@ 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);
Expand Down Expand Up @@ -178,6 +180,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
2 changes: 1 addition & 1 deletion qml/Key.qml
Expand Up @@ -125,7 +125,7 @@ Rectangle {
key.color = keyboard.keyBgColor

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

if( !sticky && keyboard.resetSticky != 0 && keyboard.resetSticky !== key ) {
resetSticky.setStickiness(0);
Expand Down
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
60 changes: 48 additions & 12 deletions qml/Main.qml
Expand Up @@ -20,6 +20,22 @@
import QtQuick 2.0
import TextRender 1.0
import QtQuick.Window 2.0
import com.nokia.meego 2.0

PageStackWindow {
id: pageStackWindow

focus: true

Keys.onPressed: {
window.vkbKeypress(event.key,event.modifiers);
}

initialPage:Page {
id: page
anchors.fill: parent

orientationLock: window.getOrientationLockMode()

Rectangle {
property string fgcolor: "black"
Expand All @@ -31,8 +47,7 @@ Rectangle {

property string windowTitle: util.currentWindowTitle();

width: Screen.width
height: Screen.height
anchors.fill: parent

id: window
objectName: "window"
Expand Down Expand Up @@ -102,9 +117,9 @@ Rectangle {
onClicked: {
if (util.settingsValue("ui/dragMode") !== "select") {
if (vkb.active)
sleepVKB();
window.sleepVKB();
else
wakeVKB();
window.wakeVKB();
}
}
}
Expand Down Expand Up @@ -142,7 +157,7 @@ Rectangle {
z: 5
}

Menu {
MenuFingerterm {
id: menu
x: window.width-width
y: 0
Expand All @@ -155,11 +170,6 @@ Rectangle {
z: 0
}

focus: true
Keys.onPressed: {
vkbKeypress(event.key,event.modifiers);
}

TextRender {
id: textrender
objectName: "textrender"
Expand Down Expand Up @@ -199,7 +209,7 @@ Rectangle {
repeat: false
interval: menu.keyboardFadeOutDelay
onTriggered: {
sleepVKB();
window.sleepVKB();
}
}

Expand All @@ -216,7 +226,7 @@ Rectangle {
Connections {
target: util
onVisualBell: {
visualBell();
window.visualBell();
}
onGestureNotify: {
textNotify.text = msg;
Expand Down Expand Up @@ -373,4 +383,30 @@ Rectangle {
else
util.allowGestures = true;
}

function lockModeStringToQtEnum(stringMode) {
switch (stringMode) {
case "auto":
return PageOrientation.Automatic
case "landscape":
return PageOrientation.LockLandscape
case "portrait":
return PageOrientation.LockPortrait
}
}

function getOrientationLockMode()
{
var stringMode = util.settingsValue("ui/orientationLockMode");
page.orientationLock = lockModeStringToQtEnum(stringMode)
}

function setOrientationLockMode(stringMode)
{
util.setSettingsValue("ui/orientationLockMode", stringMode);
page.orientationLock = lockModeStringToQtEnum(stringMode)
}
}
}

}
61 changes: 56 additions & 5 deletions qml/Menu.qml → qml/MenuFingerterm.qml
Expand Up @@ -33,6 +33,7 @@ Rectangle {
property string currentSwipeLocking: util.settingsValue("ui/allowSwipe")
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 {
Expand Down Expand Up @@ -203,6 +204,56 @@ Rectangle {
}
}
}
Rectangle {
width: 180
height: 68
radius: 5
color: "#606060"
border.color: "#000000"
border.width: 1
Column {
Text {
width: 180
height: 20
color: "#ffffff"
font.pointSize: util.uiFontSize()-1;
text: "UI Orientation"
horizontalAlignment: Text.AlignHCenter
}
Row {
Button {
text: "<font size=\"-1\">Auto</font>"
highlighted: currentOrientationLockMode=="auto"
onClicked: {
currentOrientationLockMode = "auto";
window.setOrientationLockMode("auto");
}
width: 60
height: 48
}
Button {
text: "<font size=\"-1\">L<font>"
highlighted: currentOrientationLockMode=="landscape"
onClicked: {
currentOrientationLockMode = "landscape";
window.setOrientationLockMode("landscape");
}
width: 60
height: 48
}
Button {
text: "<font size=\"-1\">P</font>"
highlighted: currentOrientationLockMode=="portrait"
onClicked: {
currentOrientationLockMode = "portrait";
window.setOrientationLockMode("portrait");
}
width: 60
height: 48
}
}
}
}
Rectangle {
width: 180
height: 68
Expand Down Expand Up @@ -281,7 +332,7 @@ Rectangle {
onClicked: {
util.setSettingsValue("ui/vkbShowMethod", "off");
currentShowMethod = "off";
setTextRenderAttributes();
window.setTextRenderAttributes();
hideMenu();
}
width: 60
Expand All @@ -293,7 +344,7 @@ Rectangle {
onClicked: {
util.setSettingsValue("ui/vkbShowMethod", "fade");
currentShowMethod = "fade";
setTextRenderAttributes();
window.setTextRenderAttributes();
hideMenu();
}
width: 60
Expand All @@ -305,7 +356,7 @@ Rectangle {
onClicked: {
util.setSettingsValue("ui/vkbShowMethod", "move");
currentShowMethod = "move";
setTextRenderAttributes();
window.setTextRenderAttributes();
hideMenu();
}
width: 60
Expand Down Expand Up @@ -486,7 +537,7 @@ Rectangle {
visible = true;
fader.opacity = 0.5;
rect.x = menuWin.width-rect.width;
updateGesturesAllowed();
window.updateGesturesAllowed();
enableCopy = util.terminalHasSelection();
enablePaste = util.canPaste();
}
Expand All @@ -496,7 +547,7 @@ Rectangle {
showing = false;
fader.opacity = 0;
rect.x = menuWin.width+1;
updateGesturesAllowed();
window.updateGesturesAllowed();
}

function changeSwipeLocking(state)
Expand Down
2 changes: 1 addition & 1 deletion qml/NotifyWin.qml
Expand Up @@ -88,7 +88,7 @@ Rectangle {
to: "*"
SequentialAnimation {
PropertyAnimation { target: notifyWin; properties: "y"; duration: 200; easing.type: Easing.InOutCubic }
ScriptAction { script: updateGesturesAllowed(); }
ScriptAction { script: window.updateGesturesAllowed(); }
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion qml/UrlWindow.qml
Expand Up @@ -126,7 +126,7 @@ Rectangle {
to: "*"
SequentialAnimation {
PropertyAnimation { target: urlWindow; properties: "y"; duration: 200; easing.type: Easing.InOutCubic }
ScriptAction { script: updateGesturesAllowed(); }
ScriptAction { script: window.updateGesturesAllowed(); }
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion resources.qrc
Expand Up @@ -5,7 +5,7 @@
<file>qml/Keyboard.qml</file>
<file>qml/Lineview.qml</file>
<file>qml/Button.qml</file>
<file>qml/Menu.qml</file>
<file>qml/MenuFingerterm.qml</file>
<file>qml/NotifyWin.qml</file>
<file>icons/backspace.png</file>
<file>icons/down.png</file>
Expand Down
1 change: 1 addition & 0 deletions rpm/fingerterm.spec
Expand Up @@ -13,6 +13,7 @@ BuildRequires: pkgconfig(Qt5Qml)
BuildRequires: pkgconfig(Qt5Quick)
Requires: qt5-qtdeclarative-import-xmllistmodel
Requires: qt5-qtdeclarative-import-window2
Requires: qt-components-qt5
Obsoletes: meego-terminal <= 0.2.2
Provides: meego-terminal > 0.2.2

Expand Down
1 change: 0 additions & 1 deletion terminal.cpp
Expand Up @@ -177,7 +177,6 @@ void Terminal::putString(QString str, bool unEscape)
void Terminal::keyPress(int key, int modifiers)
{
QChar c(key);
//qDebug() << key;

resetBackBufferScrollPos();

Expand Down

0 comments on commit e2f5a26

Please sign in to comment.