Skip to content

Commit

Permalink
Merge branch 'fixed_keyboard' into 'master'
Browse files Browse the repository at this point in the history
Add option for keyboard to be fixed open; add translations

See merge request mer-core/fingerterm!32
  • Loading branch information
llewelld committed Feb 5, 2021
2 parents 20fdef1 + 70b35b1 commit c6ed48a
Show file tree
Hide file tree
Showing 17 changed files with 323 additions and 126 deletions.
11 changes: 3 additions & 8 deletions fingerterm.desktop
@@ -1,10 +1,5 @@
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Name=FingerTerm
GenericName=FingerTerm
Comment=Terminal emulator
Exec=/usr/bin/invoker --single-instance --type=e /opt/fingerterm/bin/fingerterm
Terminal=false
Type=Application
Icon=/usr/share/icons/hicolor/80x80/apps/fingerterm.png
Name=Terminal
Exec=fingerterm
Icon=icon-launcher-shell
5 changes: 0 additions & 5 deletions fingerterm.desktop.nemo

This file was deleted.

46 changes: 39 additions & 7 deletions fingerterm.pro
Expand Up @@ -83,12 +83,44 @@ userdata.files = data/menu.xml \
userdata.path = $$DEPLOYMENT_PATH/data
INSTALLS += userdata

desktopfile.path = /usr/share/applications
desktopfile.files = $${TARGET}.desktop

# translations
TS_FILE = $$OUT_PWD/fingerterm.ts
EE_QM = $$OUT_PWD/fingerterm_eng_en.qm

ts.commands += lupdate $$PWD -ts $$TS_FILE
ts.CONFIG += no_check_exist
ts.output = $$TS_FILE
ts.input = .

ts_install.files = $$TS_FILE
ts_install.path = /usr/share/translations/source
ts_install.CONFIG += no_check_exist

# should add -markuntranslated "-" when proper translations are in place (or for testing)
engineering_english.commands += lrelease -idbased $$TS_FILE -qm $$EE_QM
engineering_english.CONFIG += no_check_exist
engineering_english.depends = ts
engineering_english.input = $$TS_FILE
engineering_english.output = $$EE_QM

TRANSLATIONS_PATH = /usr/share/translations
engineering_english_install.path = $$TRANSLATIONS_PATH
engineering_english_install.files = $$EE_QM
engineering_english_install.CONFIG += no_check_exist

DEFINES += TRANSLATIONS_PATH=\"\\\"\"$${TRANSLATIONS_PATH}\"\\\"\"

QMAKE_EXTRA_TARGETS += ts engineering_english
PRE_TARGETDEPS += ts engineering_english

target.path = /usr/bin
INSTALLS += target
INSTALLS += target desktopfile ts_install engineering_english_install

contains(MEEGO_EDITION,nemo) {
desktopfile.extra = cp $${TARGET}.desktop.nemo $${TARGET}.desktop
desktopfile.path = /usr/share/applications
desktopfile.files = $${TARGET}.desktop
INSTALLS += desktopfile
}
DISTFILES += \
data/* \
icons/*.png \
qml/*.qml \
rpm/fingerterm.spec
9 changes: 9 additions & 0 deletions main.cpp
Expand Up @@ -24,6 +24,8 @@
#include <QQuickView>
#include <QDir>
#include <QString>
#include <QLocale>
#include <QTranslator>

extern "C" {
#include <pty.h>
Expand Down Expand Up @@ -86,7 +88,14 @@ int main(int argc, char *argv[])
exit(0);
}

QScopedPointer<QTranslator> engineeringEnglish(new QTranslator);
engineeringEnglish->load("fingerterm_eng_en", TRANSLATIONS_PATH);
QScopedPointer<QTranslator> translator(new QTranslator);
translator->load(QLocale(), "fingerterm", "-", TRANSLATIONS_PATH);

QGuiApplication app(argc, argv);
app.installTranslator(engineeringEnglish.data());
app.installTranslator(translator.data());

QScreen* sc = app.primaryScreen();
if(sc){
Expand Down
3 changes: 2 additions & 1 deletion qml/Keyboard.qml
Expand Up @@ -129,7 +129,8 @@ Item {
onKeyboardLayoutChanged: {
var ret = keyLoader.loadLayout(util.keyboardLayout)
if (!ret) {
showErrorMessage("There was an error loading the keyboard layout.<br>\nUsing the default one instead.");
//% "There was an error loading the keyboard layout. Using the default one instead."
showErrorMessage(qsTrId("fingerterm-keyboard_la_erro-loading"));
util.keyboardLayout = "english"
ret = keyLoader.loadLayout(":/data/english.layout"); //try the default as a fallback (load from resources to ensure it will succeed)
if (!ret) {
Expand Down
7 changes: 5 additions & 2 deletions qml/LayoutWindow.qml
Expand Up @@ -65,7 +65,8 @@ PopupWindow {
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
color: "#ffffff"
text: "Keyboard layout"
//% "Keyboard layout"
text: qsTrId("fingerterm-keyboard-layout_la_keyboard-layout")
font.pointSize: window.uiFontSize + 4*window.pixelRatio;
}

Expand All @@ -83,7 +84,9 @@ PopupWindow {
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
anchors.bottomMargin: window.paddingMedium
text: "Back"
//: Return to the previous page
//% "Back"
text: qsTrId("fingerterm-keyboard-layout_la_back")
onClicked: layoutWindow.show = false
}
}
152 changes: 106 additions & 46 deletions qml/Main.qml
Expand Up @@ -89,6 +89,14 @@ Item {
anchors.fill: parent
color: bgcolor

Connections {
target: util
onKeyboardModeChanged: {
window.setTextRenderAttributes();
window.updateVKB();
}
}

Rectangle {
id: bellTimerRect
visible: opacity > 0
Expand Down Expand Up @@ -126,14 +134,16 @@ Item {

onPressed: {
touchPoints.forEach(function (touchPoint) {
if (multiTouchArea.firstTouchId == -1) {
multiTouchArea.firstTouchId = touchPoint.pointId;
var key = vkb.keyAt(touchPoint.x, touchPoint.y);
if ((key == null) || (!vkb.active)) {
if (multiTouchArea.firstTouchId == -1) {
multiTouchArea.firstTouchId = touchPoint.pointId;

//gestures c++ handler
textrender.mousePress(touchPoint.x, touchPoint.y);
//gestures c++ handler
textrender.mousePress(touchPoint.x, touchPoint.y - textrender.y);
}
}

var key = vkb.keyAt(touchPoint.x, touchPoint.y);
if (key != null) {
key.handlePress(multiTouchArea, touchPoint.x, touchPoint.y);
}
Expand All @@ -144,7 +154,7 @@ Item {
touchPoints.forEach(function (touchPoint) {
if (multiTouchArea.firstTouchId == touchPoint.pointId) {
//gestures c++ handler
textrender.mouseMove(touchPoint.x, touchPoint.y);
textrender.mouseMove(touchPoint.x, touchPoint.y - textrender.y);
}

var key = multiTouchArea.pressedKeys[touchPoint.pointId];
Expand All @@ -163,7 +173,8 @@ Item {
// - not in select mode, as it would be hard to select text
if (touchPoint.y < vkb.y && touchPoint.startY < vkb.y &&
Math.abs(touchPoint.y - touchPoint.startY) < 20 &&
util.dragMode !== Util.DragSelect) {
util.dragMode !== Util.DragSelect &&
util.keyboardMode != Util.KeyboardFixed) {
if (vkb.active) {
window.sleepVKB();
} else {
Expand All @@ -172,7 +183,7 @@ Item {
}

//gestures c++ handler
textrender.mouseRelease(touchPoint.x, touchPoint.y);
textrender.mouseRelease(touchPoint.x, touchPoint.y - textrender.y);
multiTouchArea.firstTouchId = -1;
}

Expand Down Expand Up @@ -202,13 +213,23 @@ Item {
}
}

Image {
// terminal buffer scroll indicator
source: "icons/scroll-indicator.png"
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom

MouseArea {
// terminal buffer scroll button
x: window.width - width
width: scrollImg.width + 60*window.pixelRatio
height: scrollImg.height + 30*window.pixelRatio
anchors.bottom: textrender.bottom
visible: textrender.showBufferScrollIndicator
scale: window.pixelRatio
onClicked: textrender.scrollToEnd()

Image {
id: scrollImg

anchors.centerIn: parent
source: "icons/scroll-indicator.png"
scale: window.pixelRatio
}
}

TextRender {
Expand All @@ -222,7 +243,9 @@ Item {
fontPointSize: util.fontSize
opacity: (util.keyboardMode == Util.KeyboardFade && vkb.active) ? 0.3
: 1.0
allowGestures: !vkb.active && !menu.showing && !urlWindow.show && !aboutDialog.show && !layoutWindow.show
allowGestures: (!vkb.active || util.keyboardMode !== Util.KeyboardFade)
&& !menu.showing && !urlWindow.show
&& !aboutDialog.show && !layoutWindow.show

Behavior on opacity {
NumberAnimation { duration: textrender.duration; easing.type: Easing.InOutQuad }
Expand All @@ -232,7 +255,7 @@ Item {
}

onCutAfterChanged: {
// this property is used in the paint function, so make sure that the element gets
// this property is used in the paint function, to make sure that the element gets
// painted with the updated value (might not otherwise happen because of caching)
textrender.redraw();
}
Expand All @@ -243,7 +266,9 @@ Item {

interval: util.keyboardFadeOutDelay
onTriggered: {
window.sleepVKB();
if (util.keyboardMode != Util.KeyboardFixed) {
window.sleepVKB();
}
}
}

Expand Down Expand Up @@ -288,18 +313,34 @@ Item {
id: aboutDialog

text: {
var str = "<font size=\"+3\">FingerTerm " + util.versionString() + "</font><br>\n" +
//% "Fingerterm"
var title = qsTrId("fingerterm-about_la_fingerterm")
//% "Author: "
var author = qsTrId("fingerterm-about_la_author")
//% "Config files for adjusting settings are at:"
var configFiles = qsTrId("fingerterm-about_la_config-files-location")
//% "Source code:"
var sourceCode = qsTrId("fingerterm-about_la_source-code")
//% "Current window title:"
var windowTitle = qsTrId("fingerterm-about_la_window-title")
//% "Current terminal size:"
var terminalSize = qsTrId("fingerterm-about_la_terminal-size")
//% "Charset:"
var charSet = qsTrId("fingerterm-about_la_charset")


var str = "<font size=\"+3\">" + title + " " + util.versionString() + "</font><br>\n" +
"<font size=\"+1\">" +
"by Heikki Holstila &lt;<a href=\"mailto:heikki.holstila@gmail.com?subject=FingerTerm\">heikki.holstila@gmail.com</a>&gt;<br><br>\n\n" +
"Config files for adjusting settings are at:<br>\n" +
author + "Heikki Holstila &lt;<a href=\"mailto:heikki.holstila@gmail.com?subject=FingerTerm\">heikki.holstila@gmail.com</a>&gt;<br><br>\n\n" +
configFiles + "<br>\n" +
util.configPath() + "/<br><br>\n" +
"Source code:<br>\n<a href=\"https://git.merproject.org/mer-core/fingerterm/\">https://git.merproject.org/mer-core/fingerterm/</a>"
sourceCode + "<br>\n<a href=\"https://git.merproject.org/mer-core/fingerterm/\">https://git.merproject.org/mer-core/fingerterm/</a>"
if (term.rows != 0 && term.columns != 0) {
str += "<br><br>Current window title: <font color=\"gray\">" + util.windowTitle.substring(0,40) + "</font>"; //cut long window title
str += "<br><br>" + windowTitle + " <font color=\"gray\">" + util.windowTitle.substring(0,40) + "</font>"; //cut long window title
if(util.windowTitle.length>40)
str += "...";
str += "<br>Current terminal size: <font color=\"gray\">" + term.columns + "×" + term.rows + "</font>";
str += "<br>Charset: <font color=\"gray\">" + util.charset + "</font>";
str += "<br>" + terminalSize + " <font color=\"gray\">" + term.columns + "×" + term.rows + "</font>";
str += "<br>" + charSet + " <font color=\"gray\">" + util.charset + "</font>";
}
str += "</font>";
return str;
Expand Down Expand Up @@ -338,46 +379,65 @@ Item {
fadeTimer.restart();
vkb.active = true;
setTextRenderAttributes();
// FIXME: This "duration = 0" hack prevents the animations running at
// other times (e.g. on screen rotation). It should be using States.
textrender.duration = 0;
}

function sleepVKB()
{
textrender.duration = window.fadeInTime;
vkb.active = false;
setTextRenderAttributes();
// FIXME: This "duration = 0" hack prevents the animations running at
// other times (e.g. on screen rotation). It should be using States.
textrender.duration = 0;
}

function setTextRenderAttributes()
function updateVKB()
{
if (util.keyboardMode == Util.KeyboardMove)
{
vkb.visibleSetting = true;
if(vkb.active) {
var move = textrender.cursorPixelPos().y + textrender.fontHeight/2
+ textrender.fontHeight*util.extraLinesFromCursor
if(move < vkb.y) {
textrender.y = 0;
textrender.cutAfter = vkb.y;
} else {
textrender.y = 0 - move + vkb.y
textrender.cutAfter = move;
}
} else {
textrender.cutAfter = textrender.height;
if(!vkb.visibleSetting)
return;

textrender.duration = 0;
fadeTimer.restart();
setTextRenderAttributes();
}

function _applyKeyboardOffset()
{
if(vkb.active) {
var move = textrender.cursorPixelPos().y + textrender.fontHeight/2
+ textrender.fontHeight*util.extraLinesFromCursor
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;
textrender.cutAfter = textrender.height;
}
else if (util.keyboardMode == Util.KeyboardFade)
}

function setTextRenderAttributes()
{
var solidKeyboard = (util.keyboardMode === Util.KeyboardMove)
|| (util.keyboardMode === Util.KeyboardFixed)

if (solidKeyboard)
{
vkb.active |= (util.keyboardMode === Util.KeyboardFixed);
vkb.visibleSetting = true;
textrender.cutAfter = textrender.height;
textrender.y = 0;
_applyKeyboardOffset()
}
else // "off" (vkb disabled)
else
{
vkb.visibleSetting = false;
textrender.cutAfter = textrender.height;
vkb.visibleSetting = (util.keyboardMode === Util.KeyboardFade);
textrender.y = 0;
textrender.cutAfter = textrender.height;
}
}

Expand Down

0 comments on commit c6ed48a

Please sign in to comment.