mirror of https://github.com/qTox/qTox.git
Browse Source
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.pull/1961/head
5 changed files with 175 additions and 10 deletions
@ -0,0 +1,97 @@
@@ -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> |
@ -0,0 +1,31 @@
@@ -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()); |
||||
} |
||||
|
@ -0,0 +1,35 @@
@@ -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
|
Loading…
Reference in new issue