[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[vidalia-svn] r3120: Make exec() return the QDialogButtonBox::StandardButton enum (vidalia/trunk/src/vidalia)
Author: edmanm
Date: 2008-09-20 22:15:45 -0400 (Sat, 20 Sep 2008)
New Revision: 3120
Modified:
vidalia/trunk/src/vidalia/controlpasswordinputdialog.cpp
vidalia/trunk/src/vidalia/controlpasswordinputdialog.h
vidalia/trunk/src/vidalia/controlpasswordinputdialog.ui
Log:
Make exec() return the QDialogButtonBox::StandardButton enum value of the button
used to dismiss the dialog. Also disable the "Ok" button if the password field
is empty.
Modified: vidalia/trunk/src/vidalia/controlpasswordinputdialog.cpp
===================================================================
--- vidalia/trunk/src/vidalia/controlpasswordinputdialog.cpp 2008-09-21 01:52:57 UTC (rev 3119)
+++ vidalia/trunk/src/vidalia/controlpasswordinputdialog.cpp 2008-09-21 02:15:45 UTC (rev 3120)
@@ -15,6 +15,8 @@
** them the option to save or attempt to reset it.
*/
+#include <QPushButton>
+
#include "controlpasswordinputdialog.h"
@@ -29,6 +31,14 @@
| QDialogButtonBox::Cancel
| QDialogButtonBox::Reset
| QDialogButtonBox::Help);
+
+ connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton*)),
+ this, SLOT(clicked(QAbstractButton*)));
+ connect(ui.linePassword, SIGNAL(textEdited(QString)),
+ this, SLOT(passwordEdited(QString)));
+
+ /* The dialog starts with an empty password field */
+ passwordEdited(QString());
}
QString
@@ -43,3 +53,31 @@
return ui.chkSavePassword->isChecked();
}
+void
+ControlPasswordInputDialog::passwordEdited(const QString &text)
+{
+ QPushButton *okButton = ui.buttonBox->button(QDialogButtonBox::Ok);
+ if (okButton)
+ okButton->setEnabled(! text.isEmpty());
+}
+
+void
+ControlPasswordInputDialog::clicked(QAbstractButton *button)
+{
+ QDialogButtonBox::StandardButton btn = ui.buttonBox->standardButton(button);
+ switch (btn) {
+ case QDialogButtonBox::Ok:
+ case QDialogButtonBox::Reset:
+ case QDialogButtonBox::Cancel:
+ done(btn);
+ break;
+
+ case QDialogButtonBox::Help:
+ /* TODO: Display some help relevant to control passwords. */
+ break;
+
+ default:
+ break;
+ }
+}
+
Modified: vidalia/trunk/src/vidalia/controlpasswordinputdialog.h
===================================================================
--- vidalia/trunk/src/vidalia/controlpasswordinputdialog.h 2008-09-21 01:52:57 UTC (rev 3119)
+++ vidalia/trunk/src/vidalia/controlpasswordinputdialog.h 2008-09-21 02:15:45 UTC (rev 3120)
@@ -33,6 +33,19 @@
*/
bool isSavePasswordChecked() const;
+protected slots:
+ /** Called when one of the QDialogButtonBox's buttons is clicked. The dialog
+ * is closed if <b>button</b> is the "Ok", "Cancel", or "Reset" button, and
+ * the clicked button's QDialogButtonBox::StandardButton enum value is
+ * returned as the dialog's result code.
+ */
+ void clicked(QAbstractButton *button);
+
+ /** Called when the user changes the password QLineEdit. If the password is
+ * empty, then the "Ok" button will be disabled. Otherwise, it is enabled.
+ */
+ void passwordEdited(const QString &text);
+
private:
Ui::ControlPasswordInputDialog ui; /**< Qt Designer generated object. */
};
Modified: vidalia/trunk/src/vidalia/controlpasswordinputdialog.ui
===================================================================
--- vidalia/trunk/src/vidalia/controlpasswordinputdialog.ui 2008-09-21 01:52:57 UTC (rev 3119)
+++ vidalia/trunk/src/vidalia/controlpasswordinputdialog.ui 2008-09-21 02:15:45 UTC (rev 3120)
@@ -125,38 +125,4 @@
<resources>
<include location="res/vidalia.qrc" />
</resources>
- <connections>
- <connection>
- <sender>buttonBox</sender>
- <signal>accepted()</signal>
- <receiver>ControlPasswordInputDialog</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>ControlPasswordInputDialog</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>