Commit 9b7e80d9 authored by Olivier SOLDANO's avatar Olivier SOLDANO Committed by Anthony Léonard

change account deletion process

The account deletion was performed by solely clicking the bin icon
in the configuration account panel of a selected account.
This was done without warning nor confirmation.

This patch moves the dedicated button to the account list bottom
as in the other desktop clients, and adds a confimation popup,
summarising the account identifiers (in order, alias, registered name,
ringID), and displays a warning about losing the account in case
it hasn't been exported or added to another device.

Change-Id: I259388da9e143400ab65e88d1fb7c223dbfbff19
Reviewed-by: default avatarAnthony Léonard <anthony.leonard@savoirfairelinux.com>
parent a3cc5f0d
......@@ -77,7 +77,8 @@ SOURCES += main.cpp\
contactrequestwidget.cpp \
contactrequestitemdelegate.cpp \
quickactcontactrequestwidget.cpp \
contactrequestlistwidget.cpp
contactrequestlistwidget.cpp \
deleteaccountdialog.cpp
HEADERS += mainwindow.h \
callwidget.h \
......@@ -118,7 +119,8 @@ HEADERS += mainwindow.h \
contactrequestwidget.h \
contactrequestitemdelegate.h \
quickactcontactrequestwidget.h \
contactrequestlistwidget.h
contactrequestlistwidget.h \
deleteaccountdialog.h
contains(DEFINES, URI_PROTOCOL) {
HEADERS += shmclient.h
......@@ -145,7 +147,8 @@ FORMS += mainwindow.ui \
sendcontactrequestwidget.ui \
currentaccountwidget.ui \
contactrequestwidget.ui \
quickactcontactrequestwidget.ui
quickactcontactrequestwidget.ui \
deleteaccountdialog.ui
win32: LIBS += -lole32 -luuid -lshlwapi
LIBS += -lqrencode
......
......@@ -325,12 +325,6 @@ AccountDetails::stopRingtone() {
RingtoneModel::instance().play(idx);
}
QPushButton*
AccountDetails::getDeleteAccountButton()
{
return ui->deleteAccountButton;
}
void
AccountDetails::on_addDeviceButton_clicked()
{
......
......@@ -41,7 +41,6 @@ public:
explicit AccountDetails(QWidget* parent = 0);
~AccountDetails();
QPushButton* getDeleteAccountButton();
void setAccount(Account* currentAccount);
void save();
......
......@@ -94,8 +94,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>843</width>
<height>692</height>
<width>829</width>
<height>756</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_12">
......@@ -103,38 +103,6 @@
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QPushButton" name="deleteAccountButton">
<property name="minimumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="toolTip">
<string>delete account</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="ressources.qrc">
<normaloff>:/images/icons/ic_delete_black_18dp_2x.png</normaloff>:/images/icons/ic_delete_black_18dp_2x.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="accountLabel">
<property name="sizePolicy">
......@@ -1170,8 +1138,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>809</width>
<height>930</height>
<width>811</width>
<height>956</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_11">
......@@ -2027,8 +1995,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>827</width>
<height>907</height>
<width>829</width>
<height>923</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_13">
......
......@@ -60,6 +60,8 @@
#include "winsparkle.h"
#include "deleteaccountdialog.h"
ConfigurationWidget::ConfigurationWidget(QWidget *parent) :
NavWidget(parent),
ui(new Ui::ConfigurationWidget),
......@@ -78,13 +80,6 @@ ConfigurationWidget::ConfigurationWidget(QWidget *parent) :
accountDetails_->save();
});
connect(accountDetails_->getDeleteAccountButton(), &QPushButton::clicked, this, [=]() {
auto account = accountModel_->getAccountByModelIndex(
ui->accountView->currentIndex());
accountModel_->remove(account);
accountModel_->save();
});
connect(ui->exitSettingsButton, &QPushButton::clicked, this, [=]() {
emit NavigationRequested(ScreenEnum::CallScreen);
});
......@@ -93,6 +88,13 @@ ConfigurationWidget::ConfigurationWidget(QWidget *parent) :
accountStateDelegate_ = new AccountStateDelegate();
ui->accountView->setItemDelegate(accountStateDelegate_);
// connect delete button to popup trigger
connect(ui->deleteAccountBtn, &QPushButton::clicked, [=](){
auto idx = ui->accountView->currentIndex();
DeleteAccountDialog dialog(idx);
dialog.exec();
});
isLoading_ = true;
ui->deviceBox->setModel(deviceModel_);
connect(deviceModel_, SIGNAL(currentIndexChanged(int)),
......
......@@ -87,6 +87,7 @@ private:
AccountStateDelegate *accountStateDelegate_;
QSettings settings_;
QErrorMessage errorDlg_;
void showPreview();
};
......@@ -1194,6 +1194,41 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="deleteAccountBtn">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="ressources.qrc">
<normaloff>:/images/icons/ic_delete_black_18dp_2x.png</normaloff>:/images/icons/ic_delete_black_18dp_2x.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
......
/***************************************************************************
* Copyright (C) 2015-2017 by Savoir-faire Linux *
* Author: Olivier Soldano <olivier.soldano@savoirfairelinux.com> *
* *
* 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/>. *
**************************************************************************/
#include "deleteaccountdialog.h"
#include "ui_deleteaccountdialog.h"
// LRC
#include "accountmodel.h"
#include "itemdataroles.h"
#include "account.h"
DeleteAccountDialog::DeleteAccountDialog(const QModelIndex & idx, QWidget *parent) :
QDialog(parent),
ui(new Ui::DeleteAccountDialog),
index_(idx)
{
ui->setupUi(this);
ui->accountAliasLabel->setText(AccountModel::instance().data(index_, Qt::DisplayRole).toString());
auto ac = AccountModel::instance().getAccountByModelIndex(index_);
if (ac->protocol() == Account::Protocol::RING){
ui->accountIdLabel->setAlignment(Qt::AlignCenter);
ui->accountIdLabel->setText((ac->registeredName().isEmpty())? ac->username(): ac->registeredName() + "\n" + ac->username());
} else {
ui->warningLabel->hide();
}
}
DeleteAccountDialog::~DeleteAccountDialog()
{
delete ui;
}
void DeleteAccountDialog::on_deleteCancelBtn_clicked()
{
close();
}
void DeleteAccountDialog::on_deleteAcceptBtn_clicked()
{
auto account = AccountModel::instance().getAccountByModelIndex(index_);
AccountModel::instance().remove(account);
AccountModel::instance().save();
close();
}
/***************************************************************************
* Copyright (C) 2015-2017 by Savoir-faire Linux *
* Author: Olivier Soldano <olivier.soldano@savoirfairelinux.com> *
* *
* 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/>. *
**************************************************************************/
#ifndef DELETEACCOUNTDIALOG_H
#define DELETEACCOUNTDIALOG_H
#include <QDialog>
#include <QModelIndex>
namespace Ui {
class DeleteAccountDialog;
}
class DeleteAccountDialog : public QDialog
{
Q_OBJECT
public:
DeleteAccountDialog(const QModelIndex & idx, QWidget *parent = 0);
~DeleteAccountDialog();
signals:
deleteAcceptClicked();
private slots:
void on_deleteCancelBtn_clicked();
void on_deleteAcceptBtn_clicked();
private:
Ui::DeleteAccountDialog *ui;
QModelIndex index_;
};
#endif // DELETEACCOUNTDIALOG_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DeleteAccountDialog</class>
<widget class="QDialog" name="DeleteAccountDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>240</height>
</rect>
</property>
<property name="windowTitle">
<string>Ring - account deletion</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="3,3,1,1,1,0,3,0">
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="deletionLabel1">
<property name="text">
<string>Do you realy want to delete account ?</string>
</property>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="accountAliasLabel">
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="accountIdLabel">
<property name="minimumSize">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="deletionLabel2">
<property name="text">
<string>This action is irrevocable</string>
</property>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="warningLabel">
<property name="text">
<string>If this account hasn't been exported, or added to another device, it will be lost</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="deleteCancelBtn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>130</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="deleteAcceptBtn">
<property name="minimumSize">
<size>
<width>130</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>Ok</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
......@@ -223,7 +223,7 @@ QToolButton#qrButton:checked {
background-color: #34acbd;
}
QPushButton#deleteAccountButton, QToolButton#addAccountButton{
QPushButton#deleteAccountBtn, QToolButton#addAccountButton{
background: transparent;
}
......@@ -259,7 +259,8 @@ QScrollBar::handle:vertical{
background: rgb(77, 77, 77);
}
QDialog#WizardDialog, QWidget#welcomePage, QWidget#sendContactRequestPage{
QDialog#WizardDialog, QWidget#welcomePage, QWidget#sendContactRequestPage,
QDialog#DeleteAccountDialog{
background: rgb(242, 242, 242);
background-image : url(:/images/background-light.png);
background-repeat : repeat-x;
......@@ -295,14 +296,14 @@ QPushButton#checkUpdateButton, QPushButton#photoButton, QPushButton#takePhotoBut
QPushButton#existingPushButton, QPushButton#newAccountButton, QPushButton#previousButton, QPushButton#exportButton,
QPushButton#cancelAddButton, QPushButton#exportOnRingButton, QPushButton#addDeviceButton, QPushButton#exportEndedOkButton,
QPushButton#errorPushButton, QPushButton#registerButton, QPushButton#sendContactRequestPageButton,
QPushButton#sendContactRequestButton, QPushButton#acceptCRButton, QPushButton#discardCRButton{
QPushButton#sendContactRequestButton, QPushButton#acceptCRButton, QPushButton#discardCRButton, QPushButton#deleteCancelBtn{
background-color: #3AC0D2;
border: 0px;
color: white;
font: 14px;
}
QPushButton#blockCRButton{
QPushButton#blockCRButton, QPushButton#deleteAcceptBtn{
background-color: rgb(251, 72, 71);
border: 0px;
color: white;
......@@ -316,11 +317,12 @@ QPushButton#existingPushButton:hover, QPushButton#newAccountButton:hover, QPushB
QPushButton#exportButton:hover, QPushButton#cancelAddButton:hover, QPushButton#exportOnRingButton:hover,
QPushButton#addDeviceButton:hover, QPushButton#exportEndedOkButton:hover, QPushButton#errorPushButton:hover,
QPushButton#registerButton:hover, QPushButton#sendContactRequestPageButton:hover,
QPushButton#sendContactRequestButton:hover, QPushButton#acceptCRButton:hover, QPushButton#discardCRButton:hover{
QPushButton#sendContactRequestButton:hover, QPushButton#acceptCRButton:hover, QPushButton#discardCRButton:hover,
QPushButton#deleteCancelBtn:hover{
background-color: #4dc6d6;
}
QPushButton#blockCRButton:hover{
QPushButton#blockCRButton:hover, QPushButton#deleteAcceptBtn:hover{
background-color: rgb(252, 91, 90);
}
......@@ -332,10 +334,11 @@ QPushButton#existingPushButton:pressed, QPushButton#newAccountButton:pressed, QP
QPushButton#exportButton:pressed, QPushButton#cancelAddButton:pressed, QPushButton#exportOnRingButton:pressed,
QPushButton#addDeviceButton:pressed, QPushButton#exportEndedOkButton:pressed, QPushButton#errorPushButton:pressed,
QPushButton#registerButton:pressed, QPushButton#sendContactRequestPageButton:pressed,
QPushButton#sendContactRequestButton:pressed, QPushButton#acceptCRButton:pressed, QPushButton#discardCRButton:pressed{
QPushButton#sendContactRequestButton:pressed, QPushButton#acceptCRButton:pressed, QPushButton#discardCRButton:pressed,
QPushButton#deleteCancelBtn:pressed{
background-color: #34acbd;
}
QPushButton#blockCRButton:pressed{
QPushButton#blockCRButton:pressed, QPushButton#deleteAcceptBtn:pressed{
background-color: rgb(219, 55, 54);
}
......@@ -629,3 +632,26 @@ QSlider::add-page:vertical{
QToolButton::menu-button {image:none;}
QToolButton::menu-arrow {image:none;}
QLabel#accountIdLabel, QLabel#accountAliasLabel, QLabel#deletionLabel1, QLabel#deletionLabel2,
QLabel#warningLabel{
background: transparent;
font: 11pt "Sans Serif";
}
QLabel#accountAliasLabel, QLabel#deletionLabel1, QLabel#deletionLabel2{
color: black;
}
QLabel#warningLabel{
color: red;
}
QLabel#accountIdLabel{
color: LightSlateGrey;
font-style: italic;
}
QLabel#accountAliasLabel{
font-weight: bold;
}
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