diff --git a/RingWinClient.pro b/RingWinClient.pro index 23c6ee1c0e877914697cd2819f5eb3e3e84fb2c7..d7681cdb3abb2264fff3f871b006797a52d0052e 100644 --- a/RingWinClient.pro +++ b/RingWinClient.pro @@ -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 diff --git a/accountdetails.cpp b/accountdetails.cpp index 69606664cf524e0e70f2854eb33cad35d7207353..4225064ddc1bd47c0f15fd4406062f0414d79305 100644 --- a/accountdetails.cpp +++ b/accountdetails.cpp @@ -325,12 +325,6 @@ AccountDetails::stopRingtone() { RingtoneModel::instance().play(idx); } -QPushButton* -AccountDetails::getDeleteAccountButton() -{ - return ui->deleteAccountButton; -} - void AccountDetails::on_addDeviceButton_clicked() { diff --git a/accountdetails.h b/accountdetails.h index f0262bb225b83a748c19933e64c7d56dc996c7b6..3e28b35ce77ae3ca338050645d3f4220af3f8471 100644 --- a/accountdetails.h +++ b/accountdetails.h @@ -41,7 +41,6 @@ public: explicit AccountDetails(QWidget* parent = 0); ~AccountDetails(); - QPushButton* getDeleteAccountButton(); void setAccount(Account* currentAccount); void save(); diff --git a/accountdetails.ui b/accountdetails.ui index cfd13525f2ae5e6226c77a5e93db02b9fdc169c5..b0fa664bc9270d460ed4248b1d49cdcea4cde3cd 100644 --- a/accountdetails.ui +++ b/accountdetails.ui @@ -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"> diff --git a/configurationwidget.cpp b/configurationwidget.cpp index 5137b1923502ecaaf582a8f37bae688a39aecbeb..745dab30e53a60d570153398b2c5dd0ed87646e7 100644 --- a/configurationwidget.cpp +++ b/configurationwidget.cpp @@ -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)), diff --git a/configurationwidget.h b/configurationwidget.h index 517d2a9d2cc86938a2cbc4d0669cfc79b038e618..9564535938aa416ccb0ec07f490ffeb55d03d9d8 100644 --- a/configurationwidget.h +++ b/configurationwidget.h @@ -87,6 +87,7 @@ private: AccountStateDelegate *accountStateDelegate_; QSettings settings_; QErrorMessage errorDlg_; + void showPreview(); }; diff --git a/configurationwidget.ui b/configurationwidget.ui index f1dbdc3a6d2bf56216100fa50b144053011c8378..286078e41744eec18f4b4a468b90454927dd6999 100644 --- a/configurationwidget.ui +++ b/configurationwidget.ui @@ -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> diff --git a/deleteaccountdialog.cpp b/deleteaccountdialog.cpp new file mode 100644 index 0000000000000000000000000000000000000000..744d2b59489d06f4e134b79262fdcbe60bda4aaa --- /dev/null +++ b/deleteaccountdialog.cpp @@ -0,0 +1,59 @@ +/*************************************************************************** + * 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(); +} diff --git a/deleteaccountdialog.h b/deleteaccountdialog.h new file mode 100644 index 0000000000000000000000000000000000000000..c247cc997443b4c0ebb12b63b3a4087328fdd7fa --- /dev/null +++ b/deleteaccountdialog.h @@ -0,0 +1,50 @@ +/*************************************************************************** + * 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 diff --git a/deleteaccountdialog.ui b/deleteaccountdialog.ui new file mode 100644 index 0000000000000000000000000000000000000000..c5d9c9f707fab7415b8ddec16e03c8ebde227722 --- /dev/null +++ b/deleteaccountdialog.ui @@ -0,0 +1,187 @@ +<?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> diff --git a/stylesheet.css b/stylesheet.css index 3496e1b4f4e4c8a4e0eda8861cda42941e40dee4..8838f6101307a7a69a2d0f95bdbf145bbbca733d 100644 --- a/stylesheet.css +++ b/stylesheet.css @@ -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; +}