Commit f4c20d8c authored by Martin Straka's avatar Martin Straka
Browse files

Listview insted of popupmenu in the account properties (issue #33)

parent 7231e9bf
......@@ -51,6 +51,7 @@ ApplicationWindow {
property Component messageDetailPage: MessageDetailPage {}
property Component accountDetailPage: AccountDetailPage {}
property Component accountSettingsPage: AccountSettingsPage {}
property Component accountMenuPage: AccountMenuPage {}
property Component aboutPage: AboutPage {}
property Component settingsMainPage: SettingsMainPage {}
property Component settingsGeneralPage: SettingsGeneralPage {}
......@@ -58,7 +59,6 @@ ApplicationWindow {
property Component settingsStoragePage: SettingsStoragePage {}
property Component pinPage: PinPage {}
// header background color
property string mainHeaderBgColor: "#00539b"
property int statusBarTimer: 5000
......
......@@ -168,65 +168,6 @@ Component {
text: rAcntName
color: datovkaPalette.text
font.bold: true
Menu {
id: accountContextMenu
implicitWidth: 800 // Chosen to be large enough
MenuItem {
text: qsTr("Account settings")
//iconSource: "qrc:/ui/account-key.svg"
onTriggered: {
gAcntName = rAcntName
gUserName = rUserName
pageView.push(accountSettingsPage, {"userName": rUserName}, StackView.Immediate)
}
}
MenuItem {
text: qsTr("View account info")
//iconSource: "qrc:/ui/account-search.svg"
onTriggered: {
gAcntName = rAcntName
gUserName = rUserName
pageView.push(accountDetailPage, StackView.Immediate)
accounts.fillAccountInfo(rUserName)
}
}
MenuItem {
text: qsTr("Update account info")
//iconSource: "qrc:/ui/account-box.svg"
onTriggered: {
gAcntName = rAcntName
gUserName = rUserName
isds.getAccountInfo(rUserName, false)
}
}
MenuItem {
text: qsTr("Change password")
//iconSource: "qrc:/ui/account-key.svg"
onTriggered: {
gAcntName = rAcntName
gUserName = rUserName
isds.changePassword(rUserName, rAcntName)
}
}
MenuItem {
text: qsTr("Clean up the file database")
//iconSource: "qrc:/ui/database.svg"
onTriggered: {
gAcntName = rAcntName
gUserName = rUserName
files.deleteFileDb(gUserName)
}
}
MenuItem {
text: qsTr("Delete account")
//iconSource: "qrc:/ui/account-remove.svg"
onTriggered: {
gAcntName = rAcntName
gUserName = rUserName
accounts.removeAccount(gUserName, true)
}
}
}
}
Text {
id: uName
......@@ -254,13 +195,11 @@ Component {
color: "transparent"
MouseArea {
anchors.fill: parent
onPressAndHold: {
onClicked: {
statusBar.visible = false
accountContextMenu.implicitWidth = computeMenuWidth(accountContextMenu)
// Located in left top corner.
accountContextMenu.x = mouse.x
accountContextMenu.y = mouse.y
accountContextMenu.open()
gAcntName = rAcntName
gUserName = rUserName
pageView.push(accountMenuPage, StackView.Immediate)
}
}
}
......
......@@ -105,5 +105,6 @@
<file>../qml/pages/SettingsGeneralPage.qml</file>
<file>../qml/pages/SettingsMainPage.qml</file>
<file>../qml/pages/SettingsStoragePage.qml</file>
<file>../qml/pages/AccountMenuPage.qml</file>
</qresource>
</RCC>
......@@ -104,7 +104,7 @@ void Accounts::getAccountData(const QString &userName)
/*
* Slot: Remove account.
*/
void Accounts::removeAccount(const QString &userName, bool showDialog)
bool Accounts::removeAccount(const QString &userName, bool showDialog)
/* ========================================================================= */
{
qDebug("%s()", __func__);
......@@ -119,12 +119,12 @@ void Accounts::removeAccount(const QString &userName, bool showDialog)
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::No);
if (msgBox.exec() == QMessageBox::No) {
return;
return false;
}
}
if (!AccountListModel::globAccounts.contains(userName)) {
return;
return false;
}
/* Delete file database */
......@@ -132,11 +132,11 @@ void Accounts::removeAccount(const QString &userName, bool showDialog)
fDb = globFileDbsPtr->accessFileDb(globSet.dbsLocation, userName);
if (fDb == NULL) {
qDebug() << "ERROR: File database open error!";
return;
return false;
}
if (!globFileDbsPtr->deleteDb(fDb)) {
qDebug() << "ERROR: File database could not delete!";
return;
return false;
}
/* Delete message database */
......@@ -144,23 +144,23 @@ void Accounts::removeAccount(const QString &userName, bool showDialog)
msgDb = globMessageDbsPtr->accessMessageDb(globSet.dbsLocation, userName);
if (msgDb == NULL) {
qDebug() << "ERROR: Message database open error!";
return;
return false;
}
if (!globMessageDbsPtr->deleteDb(msgDb)) {
qDebug() << "ERROR: Message database could not delete!";
return;
return false;
}
/* Delete account info from account database */
if (!globAccountDbPtr->deleteAccountInfoFromDb(userName)) {
qDebug() << "ERROR: Account info could not delete!";
return;
return false;
}
/* Delete user info from account database */
if (!globAccountDbPtr->deleteUserInfoFromDb(userName)) {
qDebug() << "ERROR: User info could not delete!";
return;
return false;
}
/* Delete isds session context */
......@@ -169,6 +169,8 @@ void Accounts::removeAccount(const QString &userName, bool showDialog)
/* Delete account from settings */
globAccountsModelPtr->deleteAccount(userName);
saveAllSettings();
return true;
}
......
......@@ -90,7 +90,7 @@ public:
/*!
* @brief Remove account.
*/
Q_INVOKABLE void removeAccount(const QString &userName, bool showDialog);
Q_INVOKABLE bool removeAccount(const QString &userName, bool showDialog);
/*!
* @brief Loads model counters from database.
......
......@@ -56,6 +56,7 @@ static const struct {
{ "MessageDetailPage", 1, 0 },
{ "AccountDetailPage", 1, 0 },
{ "AccountSettingsPage", 1, 0 },
{ "AccountMenuPage", 1, 0 },
{ "AboutPage", 1, 0 },
{ "PinPage", 1, 0 },
{ "SettingsMainPage", 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