mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
This dialog solves all confusion that arose from current verification method and is accident-proof. Current method asks if
user also wants to remove chat history. However confused user may not carefully read message and click "no" because he does not want to remve contact. However in this case contact is in fact removed but history is preserved. It is also open to possiblity that key smashing deletes contact by accident. This is very inconvenient because tox ids are long and hard to memorize. If someone removes contact by accident then he would need to find id of that contact in order to contact him/her. Sometimes this may be difficult. New contact removal confirmation dialog prompts use to enter "YES" in the text boxin order to enable "OK" button so removal can be accepted. It also has checkbox for history removal. Dialog will work with translations. Russian user would need to enter "Да" in order to accept removal.
This commit is contained in:
parent
2f6b5e052f
commit
74d98fd0c2
9
qtox.pro
9
qtox.pro
|
@ -34,7 +34,8 @@ FORMS += \
|
||||||
src/widget/form/settings/advancedsettings.ui \
|
src/widget/form/settings/advancedsettings.ui \
|
||||||
src/widget/form/settings/avsettings.ui \
|
src/widget/form/settings/avsettings.ui \
|
||||||
src/widget/form/settings/generalsettings.ui \
|
src/widget/form/settings/generalsettings.ui \
|
||||||
src/widget/form/settings/privacysettings.ui
|
src/widget/form/settings/privacysettings.ui \
|
||||||
|
src/widget/form/removefrienddialog.ui
|
||||||
|
|
||||||
CONFIG += c++11
|
CONFIG += c++11
|
||||||
|
|
||||||
|
@ -493,7 +494,8 @@ SOURCES += \
|
||||||
src/widget/genericchatitemwidget.cpp \
|
src/widget/genericchatitemwidget.cpp \
|
||||||
src/widget/friendlistlayout.cpp \
|
src/widget/friendlistlayout.cpp \
|
||||||
src/widget/genericchatitemlayout.cpp \
|
src/widget/genericchatitemlayout.cpp \
|
||||||
src/widget/categorywidget.cpp
|
src/widget/categorywidget.cpp \
|
||||||
|
src/widget/tool/removefrienddialog.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
src/audio/audio.h \
|
src/audio/audio.h \
|
||||||
|
@ -536,4 +538,5 @@ HEADERS += \
|
||||||
src/widget/genericchatitemwidget.h \
|
src/widget/genericchatitemwidget.h \
|
||||||
src/widget/friendlistlayout.h \
|
src/widget/friendlistlayout.h \
|
||||||
src/widget/genericchatitemlayout.h \
|
src/widget/genericchatitemlayout.h \
|
||||||
src/widget/categorywidget.h
|
src/widget/categorywidget.h \
|
||||||
|
src/widget/tool/removefrienddialog.h
|
||||||
|
|
97
src/widget/form/removefrienddialog.ui
Normal file
97
src/widget/form/removefrienddialog.ui
Normal file
|
@ -0,0 +1,97 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>RemoveFriendDialog</class>
|
||||||
|
<widget class="QDialog" name="RemoveFriendDialog">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>300</width>
|
||||||
|
<height>180</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Remove friend</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string><html><head/><body><p>Are you sure you want to remove <span style=" font-weight:600;">&lt;name&gt;</span> from your contacts list?</p></body></html></string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="yes">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>YES</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="removeHistory">
|
||||||
|
<property name="text">
|
||||||
|
<string>Also remove chat history</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>RemoveFriendDialog</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>248</x>
|
||||||
|
<y>254</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>RemoveFriendDialog</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
31
src/widget/tool/removefrienddialog.cpp
Normal file
31
src/widget/tool/removefrienddialog.cpp
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
#include "removefrienddialog.h"
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
|
|
||||||
|
RemoveFriendDialog::RemoveFriendDialog(QWidget *parent, const Friend *f)
|
||||||
|
: QDialog(parent)
|
||||||
|
{
|
||||||
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||||
|
setAttribute(Qt::WA_QuitOnClose, false);
|
||||||
|
ui.setupUi(this);
|
||||||
|
ui.label->setText(ui.label->text().replace("<name>", f->getDisplayedName()));
|
||||||
|
auto removeButton = ui.buttonBox->button(QDialogButtonBox::Ok);
|
||||||
|
removeButton->setEnabled(false);
|
||||||
|
removeButton->setText(tr("Remove"));
|
||||||
|
connect(ui.yes, &QLineEdit::textChanged, this, &RemoveFriendDialog::onTextChanged);
|
||||||
|
connect(ui.buttonBox, &QDialogButtonBox::accepted, this, &RemoveFriendDialog::onAccepted);
|
||||||
|
connect(ui.buttonBox, &QDialogButtonBox::rejected, this, &RemoveFriendDialog::close);
|
||||||
|
setFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RemoveFriendDialog::onAccepted()
|
||||||
|
{
|
||||||
|
_accepted = true;
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RemoveFriendDialog::onTextChanged(QString text)
|
||||||
|
{
|
||||||
|
ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(text == ui.yes->placeholderText());
|
||||||
|
}
|
||||||
|
|
35
src/widget/tool/removefrienddialog.h
Normal file
35
src/widget/tool/removefrienddialog.h
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
#ifndef DELETEFRIENDDIALOG_H
|
||||||
|
#define DELETEFRIENDDIALOG_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include "ui_removefrienddialog.h"
|
||||||
|
#include "src/friend.h"
|
||||||
|
|
||||||
|
|
||||||
|
class RemoveFriendDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit RemoveFriendDialog(QWidget *parent, const Friend* f);
|
||||||
|
|
||||||
|
inline bool removeHistory()
|
||||||
|
{
|
||||||
|
return ui.removeHistory->isChecked();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool accepted()
|
||||||
|
{
|
||||||
|
return _accepted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void onAccepted();
|
||||||
|
void onTextChanged(QString text);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Ui_RemoveFriendDialog ui;
|
||||||
|
bool _accepted = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DELETEFRIENDDIALOG_H
|
|
@ -47,6 +47,7 @@
|
||||||
#include "src/widget/form/filesform.h"
|
#include "src/widget/form/filesform.h"
|
||||||
#include "src/widget/form/profileform.h"
|
#include "src/widget/form/profileform.h"
|
||||||
#include "src/widget/form/settingswidget.h"
|
#include "src/widget/form/settingswidget.h"
|
||||||
|
#include "tool/removefrienddialog.h"
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
@ -994,14 +995,12 @@ void Widget::removeFriend(Friend* f, bool fake)
|
||||||
{
|
{
|
||||||
if (!fake)
|
if (!fake)
|
||||||
{
|
{
|
||||||
QMessageBox::StandardButton removeFriendMB;
|
RemoveFriendDialog ask(this, f);
|
||||||
removeFriendMB = QMessageBox::question(0,
|
ask.exec();
|
||||||
tr("Removal of friend ")+"\""+ f->getDisplayedName()+"\"",
|
|
||||||
tr("Do you want to remove history as well?"),
|
if (!ask.accepted())
|
||||||
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
|
|
||||||
if (removeFriendMB == QMessageBox::Cancel)
|
|
||||||
return;
|
return;
|
||||||
else if (removeFriendMB == QMessageBox::Yes)
|
else if (ask.removeHistory())
|
||||||
HistoryKeeper::getInstance()->removeFriendHistory(f->getToxId().publicKey);
|
HistoryKeeper::getInstance()->removeFriendHistory(f->getToxId().publicKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user