Commit 6670229b authored by Martin Straka's avatar Martin Straka

Input controls resize according application scale + Popup menu as compomnet

parent 4d6b61ce
/*
* Copyright (C) 2014-2017 CZ.NIC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations including
* the two.
*/
import QtQuick 2.7
import QtQuick.Controls 2.0
/*
* Popup menu component for text input controls (used for Android).
*/
Menu {
property var inputTextControl /* input text item (TextField, TextArea, ...) */
property bool isPassword /* it is input text item for password? */
id: root
implicitWidth: 800 // Chosen to be large enough
MenuItem {
text: qsTr("Clear")
enabled: inputTextControl.text != ""
onTriggered: {
inputTextControl.clear()
}
}
MenuItem {
text: qsTr("Copy")
visible: !isPassword
enabled: !isPassword || inputTextControl.text != ""
onTriggered: {
inputTextControl.selectAll()
inputTextControl.copy()
inputTextControl.deselect()
}
}
MenuItem {
text: qsTr("Paste")
enabled: inputTextControl.canPaste
onTriggered: {
inputTextControl.paste()
}
}
}
......@@ -24,6 +24,7 @@
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Dialogs 1.2
import cz.nic.mobileDatovka 1.0
import cz.nic.mobileDatovka.dialogues 1.0
/*
......@@ -98,7 +99,6 @@ Item {
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width * 0.75
text: ""
placeholderText: ""
......@@ -110,30 +110,17 @@ Item {
(dialogue.dlgEchoMode == Dialogues.EM_PWD_ECHOONEDIT) ? TextInput.PasswordEchoOnEdit : TextInput.Normal
passwordMaskDelay: 500 // milliseconds
Menu {
InputLineMenu {
id: textInputMenu
implicitWidth: 800 // Chosen to be large enough
MenuItem {
text: qsTr("Clear")
enabled: textInput.text != ""
onTriggered: {
textInput.clear()
}
}
MenuItem {
text: qsTr("Paste")
enabled: textInput.canPaste
onTriggered: {
textInput.paste()
}
}
inputTextControl: textInput
isPassword: true
}
onPressAndHold: {
if (dialogue.explicitPasteMenu) {
textInputMenu.implicitWidth = content.computeMenuWidth(textInputMenu)
textInputMenu.x = mouse.x
textInputMenu.y = mouse.y
textInputMenu.x = textInput.x
textInputMenu.y = textInput.y + textInput.height
textInputMenu.open()
}
}
......
......@@ -112,33 +112,10 @@ Component {
width: searchOptionComboBox.width - defaultMargin - searchButton.width
height: inputItemHeight
onAccepted: emptyList.visible = searchPanel.doSearchRequest()
/* TODO - the menu can be removed */
Menu {
InputLineMenu {
id: searchPhraseTextMenu
implicitWidth: 800 // Chosen to be large enough
MenuItem {
text: qsTr("Clear")
enabled: searchPhraseText.text != ""
onTriggered: {
searchPhraseText.clear()
}
}
MenuItem {
text: qsTr("Copy")
enabled: searchPhraseText.text != ""
onTriggered: {
searchPhraseText.selectAll()
searchPhraseText.copy()
searchPhraseText.deselect()
}
}
MenuItem {
text: qsTr("Paste")
enabled: searchPhraseText.canPaste
onTriggered: {
searchPhraseText.paste()
}
}
inputTextControl: searchPhraseText
isPassword: false
}
onPressAndHold: {
if (settings.useExplicitClipboardOperations()) {
......
......@@ -79,11 +79,10 @@ Component {
}
}
}
Rectangle {
Item {
anchors.top: headerBar.bottom
anchors.bottom: parent.bottom
width: parent.width
color: "transparent"
Component {
id: aSettingsComponent
Column {
......@@ -120,6 +119,7 @@ Component {
Button {
id: certPathButtonId
text: qsTr("Choose file")
height: inputItemHeight
onClicked: {
fileDialog.open()
}
......@@ -135,6 +135,7 @@ Component {
id: loginMethodComboBox
currentIndex: 0
width: myWidht
height: inputItemHeight
textRole: "key"
model: ListModel {
id: loginMethodModel
......@@ -163,41 +164,18 @@ Component {
TextField {
id: accountNameTextField
width: myWidht
height: inputItemHeight
placeholderText: qsTr("Enter your account name")
Menu {
InputLineMenu {
id: accountNameMenu
implicitWidth: 800 // Chosen to be large enough
MenuItem {
text: qsTr("Clear")
enabled: accountNameTextField.text != ""
onTriggered: {
accountNameTextField.clear()
}
}
MenuItem {
text: qsTr("Copy")
enabled: accountNameTextField.text != ""
onTriggered: {
accountNameTextField.selectAll()
accountNameTextField.copy()
accountNameTextField.deselect()
}
}
MenuItem {
text: qsTr("Paste")
enabled: accountNameTextField.canPaste
onTriggered: {
accountNameTextField.paste()
}
}
inputTextControl: accountNameTextField
isPassword: false
}
onPressAndHold: {
if (settings.useExplicitClipboardOperations()) {
accountNameMenu.implicitWidth = computeMenuWidth(accountNameMenu)
accountNameMenu.x = mouse.x
accountNameMenu.y = mouse.y
accountNameMenu.x = accountNameTextField.x
accountNameMenu.y = accountNameTextField.y + accountNameTextField.height
accountNameMenu.open()
}
}
......@@ -212,42 +190,19 @@ Component {
TextField {
id: userNameTextField
width: myWidht
height: inputItemHeight
inputMethodHints: Qt.ImhLowercaseOnly
placeholderText: qsTr("Enter username")
Menu {
InputLineMenu {
id: userNameMenu
implicitWidth: 800 // Chosen to be large enough
MenuItem {
text: qsTr("Clear")
enabled: userNameTextField.text != ""
onTriggered: {
userNameTextField.clear()
}
}
MenuItem {
text: qsTr("Copy")
enabled: userNameTextField.text != ""
onTriggered: {
userNameTextField.selectAll()
userNameTextField.copy()
userNameTextField.deselect()
}
}
MenuItem {
text: qsTr("Paste")
enabled: userNameTextField.canPaste
onTriggered: {
userNameTextField.paste()
}
}
inputTextControl: userNameTextField
isPassword: false
}
onPressAndHold: {
if (settings.useExplicitClipboardOperations()) {
userNameMenu.implicitWidth = computeMenuWidth(userNameMenu)
userNameMenu.x = mouse.x
userNameMenu.y = mouse.y
userNameMenu.x = userNameTextField.x
userNameMenu.y = userNameTextField.y + userNameTextField.height
userNameMenu.open()
}
}
......@@ -262,34 +217,20 @@ Component {
TextField {
id: passwordTextField
width: myWidht
height: inputItemHeight
echoMode: TextInput.Password
passwordMaskDelay: 500 // milliseconds
placeholderText: qsTr("Enter password")
Menu {
InputLineMenu {
id: passwordMenu
implicitWidth: 800 // Chosen to be large enough
MenuItem {
text: qsTr("Clear")
enabled: passwordTextField.text != ""
onTriggered: {
passwordTextField.clear()
}
}
MenuItem {
text: qsTr("Paste")
enabled: passwordTextField.canPaste
onTriggered: {
passwordTextField.paste()
}
}
inputTextControl: passwordTextField
isPassword: true
}
onPressAndHold: {
if (settings.useExplicitClipboardOperations()) {
passwordMenu.implicitWidth = computeMenuWidth(passwordMenu)
passwordMenu.x = mouse.x
passwordMenu.y = mouse.y
passwordMenu.x = passwordTextField.x
passwordMenu.y = passwordTextField.y + userNameTextField.height
passwordMenu.open()
}
}
......@@ -388,15 +329,15 @@ Component {
}
ListView {
id: aSettingsList
anchors.fill: parent
anchors.margins: defaultMargin
clip: true
spacing: 0
opacity: 1
visible: true
interactive: true
model: aSettingsModel
delegate: aSettingsComponent
anchors.fill: parent
anchors.margins: defaultMargin
clip: true
spacing: 0
opacity: 1
visible: true
interactive: true
model: aSettingsModel
delegate: aSettingsComponent
}
}
}
......
......@@ -94,6 +94,7 @@ Component {
id: languageComboBoxId
currentIndex: 0
width: myWidht
height: inputItemHeight
textRole: "key"
model: ListModel {
id: langMethodModel
......@@ -122,17 +123,14 @@ Component {
SpinBox {
/* Actually holds font pixel size. */
id: fontSizeSpinBox
height: inputItemHeight
property int dflt: 16
from: 14
to: 20
stepSize: 1
function val() {
return value
}
function setVal(v) {
if (v < from) {
value = from
......
......@@ -244,6 +244,7 @@ Component {
}
Button {
id: setPinButton
height: inputItemHeight
anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("Set PIN")
onClicked: {
......@@ -253,6 +254,7 @@ Component {
Button {
id: changePinButton
anchors.horizontalCenter: parent.horizontalCenter
height: inputItemHeight
text: qsTr("Change PIN")
onClicked: {
actionName = "change"
......@@ -261,6 +263,7 @@ Component {
Button {
id: disablePinButton
anchors.horizontalCenter: parent.horizontalCenter
height: inputItemHeight
text: qsTr("Disable PIN")
onClicked: {
actionName = "disable"
......@@ -270,6 +273,7 @@ Component {
id: pinValueField
anchors.horizontalCenter: parent.horizontalCenter
width: myWidht * 0.5
height: inputItemHeight
echoMode: TextInput.Password
passwordMaskDelay: 500 // milliseconds
inputMethodHints: Qt.ImhDigitsOnly
......@@ -280,6 +284,7 @@ Component {
id: pinConfirmField1
anchors.horizontalCenter: parent.horizontalCenter
width: myWidht * 0.5
height: inputItemHeight
echoMode: TextInput.Password
passwordMaskDelay: 500 // milliseconds
inputMethodHints: Qt.ImhDigitsOnly
......@@ -290,6 +295,7 @@ Component {
id: pinConfirmField2
anchors.horizontalCenter: parent.horizontalCenter
width: myWidht * 0.5
height: inputItemHeight
echoMode: TextInput.Password
passwordMaskDelay: 500 // milliseconds
inputMethodHints: Qt.ImhDigitsOnly
......@@ -317,13 +323,11 @@ Component {
SpinBoxZeroMax {
/* Holds value in seconds. */
id: lockIntervalSpinBox
anchors.horizontalCenter: parent.horizontalCenter
height: inputItemHeight
/* Must be a non-decreasing list ending with infinity. */
items: [15, 30, 60, 90, 120, 150, 180, qsTr("don't lock")]
dfltIdx: 0
onValueChanged: {
/* Enable accept button. Always visible? */
acceptElement.visible = val() != settings.inactivityInterval()
......
......@@ -94,7 +94,7 @@ Component {
SpinBoxZeroMax {
/* Holds value in days. */
id: messageLifeSpinBox
height: inputItemHeight
/* Must be a non-decreasing list ending with infinity. */
items: [90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175, 180, qsTr("don't delete")]
dfltIdx: 0
......@@ -121,7 +121,7 @@ Component {
SpinBoxZeroMax {
/* Holds value in days. */
id: attachLifeSpinBox
height: inputItemHeight
/* Must be a non-decreasing list ending with infinity. */
items: [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, qsTr("like messages")]
dfltIdx: 1
......@@ -158,6 +158,7 @@ Component {
spacing: defaultMargin
Button {
id: dbPathButton
height: inputItemHeight
text: qsTr("Change location")
onClicked: {
var newLocation = settings.changeDbPath(dbPathText.text.toString(), false)
......@@ -174,6 +175,7 @@ Component {
Button {
id: dbResetPathButton
text: qsTr("Set default")
height: inputItemHeight
onClicked: {
var newLocation = settings.changeDbPath(dbPathText.text.toString(), true)
if (newLocation != "") {
......@@ -198,9 +200,10 @@ Component {
}
Button {
id: vacuumButton
height: inputItemHeight
text: qsTr("Clean now")
onClicked: {
statusBarText.text = ""
statusBar.text = ""
files.vacuumFileDbs()
}
}
......
......@@ -95,6 +95,7 @@
<file>datovka.png</file>
<file>cznic.png</file>
<file>ui/datovka@2x.png</file>
<file>../qml/components/InputLineMenu.qml</file>
<file>../qml/components/MessageList.qml</file>
<file>../qml/components/OverlaidImage.qml</file>
<file>../qml/components/PageHeader.qml</file>
......
......@@ -101,6 +101,7 @@ const struct QmlTypeEntry qmlPages[] = {
*/
static
const struct QmlTypeEntry qmlComponents[] = {
{ "InputLineMenu", 1, 0 },
{ "MessageList", 1, 0 },
{ "OverlaidImage", 1, 0 },
{ "PageHeader", 1, 0 },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment