← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~verzegnassi-stefano/ubuntu-docviewer-app/fix-1418648 into lp:ubuntu-docviewer-app

 

Stefano Verzegnassi has proposed merging lp:~verzegnassi-stefano/ubuntu-docviewer-app/fix-1418648 into lp:ubuntu-docviewer-app.

Commit message:
Fixed keyboard focus in PDF GoToPage dialog.

Requested reviews:
  Ubuntu Document Viewer Developers (ubuntu-docviewer-dev)
Related bugs:
  Bug #1418648 in Ubuntu Document Viewer App: "[PDF - Go to page dialog] Lost keyboard focus"
  https://bugs.launchpad.net/ubuntu-docviewer-app/+bug/1418648

For more details, see:
https://code.launchpad.net/~verzegnassi-stefano/ubuntu-docviewer-app/fix-1418648/+merge/256354

Fixed keyboard focus in PDF GoToPage dialog.
-- 
Your team Ubuntu Document Viewer Developers is requested to review the proposed merge of lp:~verzegnassi-stefano/ubuntu-docviewer-app/fix-1418648 into lp:ubuntu-docviewer-app.
=== modified file 'po/com.ubuntu.docviewer.pot'
--- po/com.ubuntu.docviewer.pot	2015-04-13 15:56:00 +0000
+++ po/com.ubuntu.docviewer.pot	2015-04-15 16:13:49 +0000
@@ -8,7 +8,7 @@
 msgstr ""
 "Project-Id-Version: \n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2015-04-13 17:55+0200\n"
+"POT-Creation-Date: 2015-04-15 17:55+0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@xxxxxx>\n"
@@ -147,7 +147,7 @@
 
 #: ../src/app/qml/documentPage/DeleteFileDialog.qml:36
 #: ../src/app/qml/documentPage/DocumentPagePickModeHeader.qml:27
-#: ../src/app/qml/pdfView/PdfViewGotoDialog.qml:52
+#: ../src/app/qml/pdfView/PdfViewGotoDialog.qml:70
 msgid "Cancel"
 msgstr ""
 
@@ -215,7 +215,7 @@
 msgstr ""
 
 #: ../src/app/qml/documentPage/DocumentPage.qml:25
-#: /home/stefano/Progetti/doc-viewer/build-adv-import-handler-Desktop-Default/po/com.ubuntu.docviewer.desktop.in.in.h:1
+#: /home/stefano/Progetti/doc-viewer/build-ubuntu-docviewer-app-UbuntuSDK_for_armhf_GCC_ubuntu_sdk_14_10_utopic-Default/po/com.ubuntu.docviewer.desktop.in.in.h:1
 msgid "Document Viewer"
 msgstr ""
 
@@ -286,7 +286,7 @@
 msgid "Choose a page between 1 and %1"
 msgstr ""
 
-#: ../src/app/qml/pdfView/PdfViewGotoDialog.qml:44
+#: ../src/app/qml/pdfView/PdfViewGotoDialog.qml:62
 msgid "GO!"
 msgstr ""
 
@@ -304,6 +304,6 @@
 msgid "Open"
 msgstr ""
 
-#: /home/stefano/Progetti/doc-viewer/build-adv-import-handler-Desktop-Default/po/com.ubuntu.docviewer.desktop.in.in.h:2
+#: /home/stefano/Progetti/doc-viewer/build-ubuntu-docviewer-app-UbuntuSDK_for_armhf_GCC_ubuntu_sdk_14_10_utopic-Default/po/com.ubuntu.docviewer.desktop.in.in.h:2
 msgid "documents;viewer;pdf;reader;"
 msgstr ""

=== modified file 'src/app/qml/pdfView/PdfViewGotoDialog.qml'
--- src/app/qml/pdfView/PdfViewGotoDialog.qml	2015-03-03 15:41:11 +0000
+++ src/app/qml/pdfView/PdfViewGotoDialog.qml	2015-04-15 16:13:49 +0000
@@ -25,18 +25,36 @@
     title: i18n.tr("Go to page")
     text: i18n.tr("Choose a page between 1 and %1").arg(pdfView.count)
 
+    /*
+      WORKAROUND:
+      For some reason we need to delay the focus assignment to the TextField,
+      otherwise the focus is stolen. 168ms is the minimum value that works.
+
+      This seems to happen in any app that includes a TextField inside a Dialog
+      (e.g. filemanager-app, 'rename' dialog).
+
+      May these 168ms have some relation with UbuntuAnimation.FastDuration
+      (which is 165ms)?
+     */
+    Component.onCompleted: timer.start()
+    Timer {
+        id: timer
+        interval: 168
+
+        onTriggered: {
+            goToPageTextField.forceActiveFocus()
+        }
+    }
+
     TextField {
         id: goToPageTextField
         objectName:"goToPageTextField"
 
-        width: parent.width
-
         hasClearButton: true
         inputMethodHints: Qt.ImhFormattedNumbersOnly
-        validator: IntValidator{ bottom: 1; top: pdfView.count }
+        validator: IntValidator { bottom: 1; top: pdfView.count }
 
-        Keys.onReturnPressed: goToPage()
-        Component.onCompleted: forceActiveFocus()
+        onAccepted: goToPage()
     }
 
     Button {
@@ -54,7 +72,7 @@
     }
 
     function goToPage() {
-        pdfView.positionAtIndex((goToPageTextField.text - 1))
+        pdfView.positionAtIndex(goToPageTextField.text - 1)
         PopupUtils.close(goToPageDialog)
     }
 }


Follow ups