diff --git a/fingerterm.pro b/fingerterm.pro index c43f243..76938dc 100644 --- a/fingerterm.pro +++ b/fingerterm.pro @@ -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 diff --git a/main.cpp b/main.cpp index 4ff75be..78c7331 100644 --- a/main.cpp +++ b/main.cpp @@ -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("window"); + if(!startupErrorMsg.isEmpty()) QMetaObject::invokeMethod(win, "showErrorMessage", Qt::QueuedConnection, Q_ARG(QVariant, startupErrorMsg)); - TextRender *tr = win->findChild("textrender"); + TextRender *tr = root->findChild("textrender"); tr->setUtil(&util); tr->setTerminal(&term); term.setRenderer(tr); @@ -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")) diff --git a/qml/Key.qml b/qml/Key.qml index e9576cb..a8e3d43 100644 --- a/qml/Key.qml +++ b/qml/Key.qml @@ -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); diff --git a/qml/LayoutWindow.qml b/qml/LayoutWindow.qml index 7453ff8..368ae3d 100644 --- a/qml/LayoutWindow.qml +++ b/qml/LayoutWindow.qml @@ -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(); } } } ] diff --git a/qml/Main.qml b/qml/Main.qml index 838a1eb..309a2aa 100644 --- a/qml/Main.qml +++ b/qml/Main.qml @@ -20,357 +20,393 @@ import QtQuick 2.0 import TextRender 1.0 import QtQuick.Window 2.0 +import com.nokia.meego 2.0 -Rectangle { - property string fgcolor: "black" - property string bgcolor: "#000000" - property int fontSize: 14 - - property int fadeOutTime: 80 - property int fadeInTime: 350 - - property string windowTitle: util.currentWindowTitle(); - - width: Screen.width - height: Screen.height - - id: window - objectName: "window" - color: bgcolor - - NotifyWin { - id: aboutDialog - property int termW: 0 - property int termH: 0 - text: { - var str = "FingerTerm " + util.versionString() + "
\n" + - "" + - "by Heikki Holstila <heikki.holstila@gmail.com>

\n\n" + - "Config files for adjusting settings are at:
\n" + - util.configPath() + "/

\n" + - "Documentation:
\nhttp://hqh.unlink.org/harmattan" - if (termH != 0 && termW != 0) { - str += "

Current window title: " + windowTitle.substring(0,40) + ""; //cut long window title - if(windowTitle.length>40) - str += "..."; - str += "
Current terminal size: " + termW + "x" + termH + ""; - str += "
Charset: " + util.settingsValue("terminal/charset") + ""; - } - str += "
"; - return str; - } - onDismissed: { - util.setSettingsValue("state/showWelcomeScreen", false); - } - z: 1001 - } +PageStackWindow { + id: pageStackWindow - NotifyWin { - id: errorDialog - text: "" - z: 1002 - } + focus: true - UrlWindow { - id: urlWindow - z: 1000 + Keys.onPressed: { + window.vkbKeypress(event.key,event.modifiers); } - LayoutWindow { - id: layoutWindow - z: 1000 - } + initialPage:Page { + id: page + anchors.fill: parent + + orientationLock: window.getOrientationLockMode() + + Rectangle { + property string fgcolor: "black" + property string bgcolor: "#000000" + property int fontSize: 14 + + property int fadeOutTime: 80 + property int fadeInTime: 350 + + property string windowTitle: util.currentWindowTitle(); + + anchors.fill: parent + + id: window + objectName: "window" + color: bgcolor + + NotifyWin { + id: aboutDialog + property int termW: 0 + property int termH: 0 + text: { + var str = "FingerTerm " + util.versionString() + "
\n" + + "" + + "by Heikki Holstila <heikki.holstila@gmail.com>

\n\n" + + "Config files for adjusting settings are at:
\n" + + util.configPath() + "/

\n" + + "Documentation:
\nhttp://hqh.unlink.org/harmattan" + if (termH != 0 && termW != 0) { + str += "

Current window title: " + windowTitle.substring(0,40) + ""; //cut long window title + if(windowTitle.length>40) + str += "..."; + str += "
Current terminal size: " + termW + "x" + termH + ""; + str += "
Charset: " + util.settingsValue("terminal/charset") + ""; + } + str += "
"; + return str; + } + onDismissed: { + util.setSettingsValue("state/showWelcomeScreen", false); + } + z: 1001 + } + + NotifyWin { + id: errorDialog + text: "" + z: 1002 + } + UrlWindow { + id: urlWindow + z: 1000 + } - Lineview { - id: lineView - x: 0 - y: -(height+1) - z: 20 - property int duration: 0; - onFontPointSizeChanged: { - lineView.setPosition(vkb.active) + LayoutWindow { + id: layoutWindow + z: 1000 } - } - MouseArea { // the area above the keyboard ("wakes up" the keyboard when tapped) - x:0 - y:0 - z:0 - width: window.width - height: vkb.y - onClicked: { - if (util.settingsValue("ui/dragMode") !== "select") { - if (vkb.active) - sleepVKB(); - else - wakeVKB(); + + Lineview { + id: lineView + x: 0 + y: -(height+1) + z: 20 + property int duration: 0; + onFontPointSizeChanged: { + lineView.setPosition(vkb.active) } } - } - Rectangle { - //top right corner menu button - x: window.width - width - y: 0 - z: 1 - width: menuImg.width + 60 - height: menuImg.height + 30 - color: "transparent" - opacity: 0.5 - Image { - anchors.centerIn: parent - id: menuImg - source: "qrc:/icons/menu.png" - height: sourceSize.height - width: sourceSize.width - } - MouseArea { - anchors.fill: parent + MouseArea { // the area above the keyboard ("wakes up" the keyboard when tapped) + x:0 + y:0 + z:0 + width: window.width + height: vkb.y onClicked: { - menu.showMenu(); + if (util.settingsValue("ui/dragMode") !== "select") { + if (vkb.active) + window.sleepVKB(); + else + window.wakeVKB(); + } } } - } - - Image { - // terminal buffer scroll indicator - source: "qrc:/icons/scroll-indicator.png" - anchors.horizontalCenter: parent.horizontalCenter - anchors.bottom: parent.bottom - visible: textrender.showBufferScrollIndicator - z: 5 - } - Menu { - id: menu - x: window.width-width - y: 0 - } - - Keyboard { - id: vkb - x: 0 - y: parent.height-vkb.height - z: 0 - } - - focus: true - Keys.onPressed: { - vkbKeypress(event.key,event.modifiers); - } - - TextRender { - id: textrender - 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 - - Behavior on opacity { - NumberAnimation { duration: textrender.duration; easing.type: Easing.InOutQuad } + Rectangle { + //top right corner menu button + x: window.width - width + y: 0 + z: 1 + width: menuImg.width + 60 + height: menuImg.height + 30 + color: "transparent" + opacity: 0.5 + Image { + anchors.centerIn: parent + id: menuImg + source: "qrc:/icons/menu.png" + height: sourceSize.height + width: sourceSize.width + } + MouseArea { + anchors.fill: parent + onClicked: { + menu.showMenu(); + } + } } - Behavior on y { - NumberAnimation { duration: textrender.duration; easing.type: Easing.InOutQuad } + + Image { + // terminal buffer scroll indicator + source: "qrc:/icons/scroll-indicator.png" + anchors.horizontalCenter: parent.horizontalCenter + anchors.bottom: parent.bottom + visible: textrender.showBufferScrollIndicator + z: 5 } - onFontSizeChanged: { - lineView.fontPointSize = textrender.fontPointSize; + MenuFingerterm { + id: menu + x: window.width-width + y: 0 } - onCutAfterChanged: { - // this property is used in the paint function, so make sure that the element gets - // painted with the updated value (might not otherwise happen because of caching) - textrender.redraw(); + Keyboard { + id: vkb + x: 0 + y: parent.height-vkb.height + z: 0 } - z: 10 - } + TextRender { + id: textrender + 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 + + Behavior on opacity { + NumberAnimation { duration: textrender.duration; easing.type: Easing.InOutQuad } + } + Behavior on y { + NumberAnimation { duration: textrender.duration; easing.type: Easing.InOutQuad } + } - Timer { - id: fadeTimer - running: false - repeat: false - interval: menu.keyboardFadeOutDelay - onTriggered: { - sleepVKB(); - } - } + onFontSizeChanged: { + lineView.fontPointSize = textrender.fontPointSize; + } - Timer { - id: bellTimer - running: false - repeat: false - interval: 80 - onTriggered: { - window.color = window.bgcolor; - } - } + onCutAfterChanged: { + // this property is used in the paint function, so make sure that the element gets + // painted with the updated value (might not otherwise happen because of caching) + textrender.redraw(); + } - Connections { - target: util - onVisualBell: { - visualBell(); + z: 10 } - onGestureNotify: { - textNotify.text = msg; - textNotifyAnim.enabled = false; - textNotify.opacity = 1.0; - textNotifyAnim.enabled = true; - textNotify.opacity = 0; + + Timer { + id: fadeTimer + running: false + repeat: false + interval: menu.keyboardFadeOutDelay + onTriggered: { + window.sleepVKB(); + } } - onWindowTitleChanged: { - windowTitle = util.currentWindowTitle(); + + Timer { + id: bellTimer + running: false + repeat: false + interval: 80 + onTriggered: { + window.color = window.bgcolor; + } } - } - 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 - Behavior on opacity { - id: textNotifyAnim - NumberAnimation { duration: 500; } + Connections { + target: util + onVisualBell: { + window.visualBell(); + } + onGestureNotify: { + textNotify.text = msg; + textNotifyAnim.enabled = false; + textNotify.opacity = 1.0; + textNotifyAnim.enabled = true; + textNotify.opacity = 0; + } + onWindowTitleChanged: { + windowTitle = util.currentWindowTitle(); + } } - } - Rectangle { - // visual key press feedback... - // easier to work with the coordinates if it's here and not under keyboard element - id: visualKeyFeedbackRect - visible: false - x: 0 - y: 0 - z: 200 - width: 0 - height: 0 - radius: 5 - color: "#ffffff" - property string label: "" Text { - color: "#000000" - font.pointSize: 34 + // shows large text notification in the middle of the screen (for gestures) + id: textNotify anchors.centerIn: parent - text: visualKeyFeedbackRect.label + color: "#ffffff" + z: 100 + opacity: 0 + text: "" + font.pointSize: 40 + Behavior on opacity { + id: textNotifyAnim + NumberAnimation { duration: 500; } + } } - } - function vkbKeypress(key,modifiers) { - wakeVKB(); - term.keyPress(key,modifiers); - } + Rectangle { + // visual key press feedback... + // easier to work with the coordinates if it's here and not under keyboard element + id: visualKeyFeedbackRect + visible: false + x: 0 + y: 0 + z: 200 + width: 0 + height: 0 + radius: 5 + color: "#ffffff" + property string label: "" + Text { + color: "#000000" + font.pointSize: 34 + anchors.centerIn: parent + text: visualKeyFeedbackRect.label + } + } - function wakeVKB() - { - if(!vkb.visible) - return; - - lineView.duration = window.fadeOutTime; - textrender.duration = window.fadeOutTime; - vkb.keyFgColor = "#cccccc"; - fadeTimer.restart(); - vkb.active = true; - lineView.setPosition(vkb.active); - util.updateSwipeLock(!vkb.active); - setTextRenderAttributes(); - updateGesturesAllowed(); - } + function vkbKeypress(key,modifiers) { + wakeVKB(); + term.keyPress(key,modifiers); + } - function sleepVKB() - { - textrender.duration = window.fadeInTime; - lineView.duration = window.fadeInTime; - vkb.keyFgColor = "#565656"; - vkb.active = false; - lineView.setPosition(vkb.active); - util.updateSwipeLock(!vkb.active); - setTextRenderAttributes(); - updateGesturesAllowed(); - } + function wakeVKB() + { + if(!vkb.visible) + return; + + lineView.duration = window.fadeOutTime; + textrender.duration = window.fadeOutTime; + vkb.keyFgColor = "#cccccc"; + fadeTimer.restart(); + vkb.active = true; + lineView.setPosition(vkb.active); + util.updateSwipeLock(!vkb.active); + setTextRenderAttributes(); + updateGesturesAllowed(); + } - function setTextRenderAttributes() - { - if(util.settingsValue("ui/vkbShowMethod")==="move") + function sleepVKB() { - vkb.visible = true; - textrender.opacity = 1.0; - if(vkb.active) { - var move = textrender.cursorPixelPos().y + textrender.fontHeight/2 + textrender.fontHeight*util.settingsValue("ui/showExtraLinesFromCursor"); - if(move < vkb.y) { - textrender.y = 0; - textrender.cutAfter = vkb.y; + textrender.duration = window.fadeInTime; + lineView.duration = window.fadeInTime; + vkb.keyFgColor = "#565656"; + vkb.active = false; + lineView.setPosition(vkb.active); + util.updateSwipeLock(!vkb.active); + setTextRenderAttributes(); + updateGesturesAllowed(); + } + + function setTextRenderAttributes() + { + if(util.settingsValue("ui/vkbShowMethod")==="move") + { + vkb.visible = true; + textrender.opacity = 1.0; + if(vkb.active) { + var move = textrender.cursorPixelPos().y + textrender.fontHeight/2 + textrender.fontHeight*util.settingsValue("ui/showExtraLinesFromCursor"); + if(move < vkb.y) { + textrender.y = 0; + textrender.cutAfter = vkb.y; + } else { + textrender.y = 0 - move + vkb.y + textrender.cutAfter = move; + } } else { - textrender.y = 0 - move + vkb.y - textrender.cutAfter = move; + textrender.cutAfter = textrender.height; + textrender.y = 0; } - } else { + } + else if(util.settingsValue("ui/vkbShowMethod")==="fade") + { + vkb.visible = 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.visible = false; + textrender.cutAfter = textrender.height; + textrender.y = 0; + textrender.opacity = 1.0; } } - else if(util.settingsValue("ui/vkbShowMethod")==="fade") + + function displayBufferChanged() { - vkb.visible = true; - textrender.cutAfter = textrender.height; - textrender.y = 0; - if(vkb.active) - textrender.opacity = 0.3; - else - textrender.opacity = 1.0; + lineView.lines = term.printableLinesFromCursor(util.settingsValue("ui/showExtraLinesFromCursor")); + lineView.cursorX = textrender.cursorPixelPos().x; + lineView.cursorWidth = textrender.cursorPixelSize().width; + lineView.cursorHeight = textrender.cursorPixelSize().height; + setTextRenderAttributes(); } - else // "off" (vkb disabled) + + Component.onCompleted: { + util.updateSwipeLock(vkb.active) + if( util.settingsValue("state/showWelcomeScreen") === true ) + aboutDialog.state = "visible"; + } + + function showErrorMessage(string) { - vkb.visible = false; - textrender.cutAfter = textrender.height; - textrender.y = 0; - textrender.opacity = 1.0; + errorDialog.text = "" + string + ""; + errorDialog.state = "visible" } - } - function displayBufferChanged() - { - lineView.lines = term.printableLinesFromCursor(util.settingsValue("ui/showExtraLinesFromCursor")); - lineView.cursorX = textrender.cursorPixelPos().x; - lineView.cursorWidth = textrender.cursorPixelSize().width; - lineView.cursorHeight = textrender.cursorPixelSize().height; - setTextRenderAttributes(); - } + function visualBell() + { + bellTimer.start(); + window.color = "#ffffff" + } - Component.onCompleted: { - util.updateSwipeLock(vkb.active) - if( util.settingsValue("state/showWelcomeScreen") === true ) - aboutDialog.state = "visible"; - } + function updateGesturesAllowed() + { + if(vkb.active || menu.showing || urlWindow.state=="visible" || + aboutDialog.state=="visible" || layoutWindow.state=="visible") + util.allowGestures = false; + else + util.allowGestures = true; + } - function showErrorMessage(string) - { - errorDialog.text = "" + string + ""; - errorDialog.state = "visible" - } + function lockModeStringToQtEnum(stringMode) { + switch (stringMode) { + case "auto": + return PageOrientation.Automatic + case "landscape": + return PageOrientation.LockLandscape + case "portrait": + return PageOrientation.LockPortrait + } + } - function visualBell() - { - bellTimer.start(); - window.color = "#ffffff" - } + function getOrientationLockMode() + { + var stringMode = util.settingsValue("ui/orientationLockMode"); + page.orientationLock = lockModeStringToQtEnum(stringMode) + } - function updateGesturesAllowed() - { - if(vkb.active || menu.showing || urlWindow.state=="visible" || - aboutDialog.state=="visible" || layoutWindow.state=="visible") - util.allowGestures = false; - else - util.allowGestures = true; + function setOrientationLockMode(stringMode) + { + util.setSettingsValue("ui/orientationLockMode", stringMode); + page.orientationLock = lockModeStringToQtEnum(stringMode) + } + } } + } diff --git a/qml/Menu.qml b/qml/MenuFingerterm.qml similarity index 87% rename from qml/Menu.qml rename to qml/MenuFingerterm.qml index 7c39759..709767e 100644 --- a/qml/Menu.qml +++ b/qml/MenuFingerterm.qml @@ -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 { @@ -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: "Auto" + highlighted: currentOrientationLockMode=="auto" + onClicked: { + currentOrientationLockMode = "auto"; + window.setOrientationLockMode("auto"); + } + width: 60 + height: 48 + } + Button { + text: "L" + highlighted: currentOrientationLockMode=="landscape" + onClicked: { + currentOrientationLockMode = "landscape"; + window.setOrientationLockMode("landscape"); + } + width: 60 + height: 48 + } + Button { + text: "P" + highlighted: currentOrientationLockMode=="portrait" + onClicked: { + currentOrientationLockMode = "portrait"; + window.setOrientationLockMode("portrait"); + } + width: 60 + height: 48 + } + } + } + } Rectangle { width: 180 height: 68 @@ -281,7 +332,7 @@ Rectangle { onClicked: { util.setSettingsValue("ui/vkbShowMethod", "off"); currentShowMethod = "off"; - setTextRenderAttributes(); + window.setTextRenderAttributes(); hideMenu(); } width: 60 @@ -293,7 +344,7 @@ Rectangle { onClicked: { util.setSettingsValue("ui/vkbShowMethod", "fade"); currentShowMethod = "fade"; - setTextRenderAttributes(); + window.setTextRenderAttributes(); hideMenu(); } width: 60 @@ -305,7 +356,7 @@ Rectangle { onClicked: { util.setSettingsValue("ui/vkbShowMethod", "move"); currentShowMethod = "move"; - setTextRenderAttributes(); + window.setTextRenderAttributes(); hideMenu(); } width: 60 @@ -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(); } @@ -496,7 +547,7 @@ Rectangle { showing = false; fader.opacity = 0; rect.x = menuWin.width+1; - updateGesturesAllowed(); + window.updateGesturesAllowed(); } function changeSwipeLocking(state) diff --git a/qml/NotifyWin.qml b/qml/NotifyWin.qml index 887e28b..56151f0 100644 --- a/qml/NotifyWin.qml +++ b/qml/NotifyWin.qml @@ -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(); } } } ] diff --git a/qml/UrlWindow.qml b/qml/UrlWindow.qml index e97629c..4b52bb6 100644 --- a/qml/UrlWindow.qml +++ b/qml/UrlWindow.qml @@ -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(); } } } ] diff --git a/resources.qrc b/resources.qrc index fb07002..32823d1 100644 --- a/resources.qrc +++ b/resources.qrc @@ -5,7 +5,7 @@ qml/Keyboard.qml qml/Lineview.qml qml/Button.qml - qml/Menu.qml + qml/MenuFingerterm.qml qml/NotifyWin.qml icons/backspace.png icons/down.png diff --git a/rpm/fingerterm.spec b/rpm/fingerterm.spec index c64f96d..a69f51e 100644 --- a/rpm/fingerterm.spec +++ b/rpm/fingerterm.spec @@ -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 diff --git a/terminal.cpp b/terminal.cpp index 5270d6d..ff8ebb3 100644 --- a/terminal.cpp +++ b/terminal.cpp @@ -177,7 +177,6 @@ void Terminal::putString(QString str, bool unEscape) void Terminal::keyPress(int key, int modifiers) { QChar c(key); - //qDebug() << key; resetBackBufferScrollPos();