Commit 11e23813 authored by Karel Slaný's avatar Karel Slaný

Setting combo box in account settings page according to the key value.

parent 32da0826
......@@ -63,6 +63,21 @@ ComboBox {
return root.model.get(root.currentIndex).key
}
/*
* Selects entry with given key.
*/
function selectCurrentKey(key) {
for (var i = 0; i < root.model.count; ++i) {
//root.model.get(i)["key"]
if (root.model.get(i).key === key) {
root.currentIndex = i;
return;
}
}
/* Not found. */
console.log("No entry found for key '" + key + "'.");
}
delegate: ItemDelegate {
width: root.width
height: inputItemHeight
......@@ -73,7 +88,6 @@ ComboBox {
elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter
onClicked: {
console.log("Clicked " + label)
root.currentIndex = index
root.popup.close()
}
......@@ -85,7 +99,6 @@ ComboBox {
Accessible.description: accessibleDescription
Accessible.name: root.currentText
Accessible.onPressAction: {
console.log("Accessible combo box pressed")
root.popup.open()
}
}
......@@ -77,7 +77,7 @@ ListView {
* Returns -1 if nothing found.
*/
function get_model_index(model, property, value) {
for(var i = 0; i < model.count; ++i) {
for (var i = 0; i < model.count; ++i) {
if (model.get(i)[property] === value) {
return i;
}
......
......@@ -162,10 +162,11 @@ Item {
accessibleDescription: qsTr("Select login method")
model: ListModel {
id: loginMethodModel
ListElement { label: qsTr("Username + Password"); key: "pwd" }
ListElement { label: qsTr("Certificate + Password"); key: "cert" }
ListElement { label: qsTr("Password + Security code"); key: "hotp" }
ListElement { label: qsTr("Password + Security SMS"); key: "totp" }
/* Key values must be equivalent to constants defined in C++ code! */
ListElement { label: qsTr("Username + Password"); key: "pwd" } // USERNAME_PWD_ONLY
ListElement { label: qsTr("Certificate + Password"); key: "cert" } // USERNAME_PWD_CERT
ListElement { label: qsTr("Password + Security code"); key: "hotp" } // USERNAME_PWD_HOTP
ListElement { label: qsTr("Password + Security SMS"); key: "totp" } // USERNAME_PWD_TOTP
}
onCurrentIndexChanged: {
sLoginMethod = currentKey()
......@@ -316,7 +317,7 @@ Item {
testAccount.checked = isTestAccount
useLS.checked = storeToDisk
certPathLabelId.text = certPath
loginMethodComboBox.currentIndex = loginMethod
loginMethodComboBox.selectCurrentKey(loginMethod)
userNameTextField.enabled = false
testAccount.enabled = false
headerBar.title = qsTr("Account settings")
......
......@@ -90,24 +90,8 @@ void Accounts::getAccountData(const QString &userName)
const AcntData &acntData(AccountListModel::globAccounts[userName]);
/* Set login method model index for combobox in QML page.
* See AccountSettingsPage.qml for logim method order. Default is:
* 0 .. Username + Password
* 1 .. Certificate + Password
* 2 .. Password + Security code
* 3 .. Password + Security SMS
*/
int qmlLoginMethodIndex = 0;
if (acntData.loginMethod() == USERNAME_PWD_CERT) {
qmlLoginMethodIndex = 1;
} else if (acntData.loginMethod() == USERNAME_PWD_HOTP) {
qmlLoginMethodIndex = 2;
} else if (acntData.loginMethod() == USERNAME_PWD_TOTP) {
qmlLoginMethodIndex = 3;
}
emit sendAccountData(acntData.accountName(), userName,
qmlLoginMethodIndex, acntData.password(), acntData.isTestAccount(),
acntData.loginMethod(), acntData.password(), acntData.isTestAccount(),
acntData.rememberPwd(), acntData.storeToDisk(), acntData.certPath());
}
......
......@@ -156,7 +156,7 @@ signals:
* @param[in] certPath Certificate path (can be null).
*/
void sendAccountData(QString acntName, QString userName,
int loginMethod, QString password, bool isTestAccount,
QString loginMethod, QString password, bool isTestAccount,
bool rememberPwd, bool storeToDisk, QString certPath);
/*!
......
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