mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Merge remote-tracking branch 'rku/contact-removal-dialog'
This commit is contained in:
commit
a4a52f9cc9
9
qtox.pro
9
qtox.pro
|
@ -34,7 +34,8 @@ FORMS += \
|
|||
src/widget/form/settings/advancedsettings.ui \
|
||||
src/widget/form/settings/avsettings.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
|
||||
|
||||
|
@ -493,7 +494,8 @@ SOURCES += \
|
|||
src/widget/genericchatitemwidget.cpp \
|
||||
src/widget/friendlistlayout.cpp \
|
||||
src/widget/genericchatitemlayout.cpp \
|
||||
src/widget/categorywidget.cpp
|
||||
src/widget/categorywidget.cpp \
|
||||
src/widget/tool/removefrienddialog.cpp
|
||||
|
||||
HEADERS += \
|
||||
src/audio/audio.h \
|
||||
|
@ -536,4 +538,5 @@ HEADERS += \
|
|||
src/widget/genericchatitemwidget.h \
|
||||
src/widget/friendlistlayout.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/profileform.h"
|
||||
#include "src/widget/form/settingswidget.h"
|
||||
#include "tool/removefrienddialog.h"
|
||||
#include <cassert>
|
||||
#include <QMessageBox>
|
||||
#include <QDebug>
|
||||
|
@ -994,14 +995,12 @@ void Widget::removeFriend(Friend* f, bool fake)
|
|||
{
|
||||
if (!fake)
|
||||
{
|
||||
QMessageBox::StandardButton removeFriendMB;
|
||||
removeFriendMB = QMessageBox::question(0,
|
||||
tr("Removal of friend ")+"\""+ f->getDisplayedName()+"\"",
|
||||
tr("Do you want to remove history as well?"),
|
||||
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
|
||||
if (removeFriendMB == QMessageBox::Cancel)
|
||||
RemoveFriendDialog ask(this, f);
|
||||
ask.exec();
|
||||
|
||||
if (!ask.accepted())
|
||||
return;
|
||||
else if (removeFriendMB == QMessageBox::Yes)
|
||||
else if (ask.removeHistory())
|
||||
HistoryKeeper::getInstance()->removeFriendHistory(f->getToxId().publicKey);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user