1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Made the 'remove friend dialog' userfriendly

This commit is contained in:
Impyy 2015-09-23 17:06:57 +02:00
parent c7b5337723
commit 3d72a75ed3
3 changed files with 9 additions and 26 deletions

View File

@ -7,9 +7,15 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>300</width> <width>300</width>
<height>180</height> <height>110</height>
</rect> </rect>
</property> </property>
<property name="minimumSize">
<size>
<width>300</width>
<height>110</height>
</size>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>Remove friend</string> <string>Remove friend</string>
</property> </property>
@ -27,19 +33,6 @@
</property> </property>
</widget> </widget>
</item> </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> <item>
<widget class="QCheckBox" name="removeHistory"> <widget class="QCheckBox" name="removeHistory">
<property name="text"> <property name="text">
@ -53,7 +46,7 @@
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="standardButtons"> <property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> <set>QDialogButtonBox::No|QDialogButtonBox::Yes</set>
</property> </property>
</widget> </widget>
</item> </item>

View File

@ -9,10 +9,7 @@ RemoveFriendDialog::RemoveFriendDialog(QWidget *parent, const Friend *f)
setAttribute(Qt::WA_QuitOnClose, false); setAttribute(Qt::WA_QuitOnClose, false);
ui.setupUi(this); ui.setupUi(this);
ui.label->setText(ui.label->text().replace("&lt;name&gt;", f->getDisplayedName())); ui.label->setText(ui.label->text().replace("&lt;name&gt;", f->getDisplayedName()));
auto removeButton = ui.buttonBox->button(QDialogButtonBox::Ok); adjustSize();
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::accepted, this, &RemoveFriendDialog::onAccepted);
connect(ui.buttonBox, &QDialogButtonBox::rejected, this, &RemoveFriendDialog::close); connect(ui.buttonBox, &QDialogButtonBox::rejected, this, &RemoveFriendDialog::close);
setFocus(); setFocus();
@ -23,9 +20,3 @@ void RemoveFriendDialog::onAccepted()
_accepted = true; _accepted = true;
close(); close();
} }
void RemoveFriendDialog::onTextChanged(QString text)
{
ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(text == ui.yes->placeholderText());
}

View File

@ -25,7 +25,6 @@ public:
public slots: public slots:
void onAccepted(); void onAccepted();
void onTextChanged(QString text);
protected: protected:
Ui_RemoveFriendDialog ui; Ui_RemoveFriendDialog ui;