RFC: KSSL dialog usability

Helge Deller deller at gmx.de
Thu Jun 15 22:01:06 BST 2006


Hello all,

this is a proposal to make KDE's current (KDE 3.5) KSSL dialog IMHO a little bit more usable....

For me, the biggest problem is, that currently it's very hard to see which server requested a certificate.
As you can see at this example: http://gsyprf11.external.hp.com/~deller/old_dialog.jpg the requesting server is hidden in the title of the dialog window and often you have to resize the window to see the requesting server.
Furthermore, you always had to move the mouse to the radio buttons (Send/Do not send) and afterwards to the pushbutton at the bottom of the dialog.

With the attached patch (which changes only the c++ source file and does not touch the header file) applied, the dialog now looks like this: 
http://gsyprf11.external.hp.com/~deller/new_dialog.jpg

I would like to submit this patch to KDE-3.5 branch for KDE-3.5.4. 
Opinions ?

Regards,
Helge
-------------- next part --------------
Index: kdelibs/kio/kssl/ksslcertdlg.cc
===================================================================
--- kdelibs/kio/kssl/ksslcertdlg.cc	(revision 551537)
+++ kdelibs/kio/kssl/ksslcertdlg.cc	(working copy)
@@ -42,34 +42,44 @@
 class KSSLCertDlg::KSSLCertDlgPrivate {
 private:
     friend class KSSLCertDlg;
+    QLabel *p_message;
+    QPushButton *p_pb_dontsend;
+    bool p_send_flag;
 };
 
 KSSLCertDlg::KSSLCertDlg(QWidget *parent, const char *name, bool modal)
  : KDialog(parent, name, modal), d(new KSSLCertDlgPrivate) {
-   QGridLayout *grid = new QGridLayout(this, 8, 6, KDialog::marginHint(),
-                                                   KDialog::spacingHint() );
 
-   _send = new QRadioButton(i18n("Send certificate..."), this);
-   grid->addMultiCellWidget(_send, 0, 0, 0, 2);
-   connect(_send, SIGNAL(clicked()), SLOT(slotSend()));
+   QBoxLayout * grid = new QVBoxLayout( this, KDialog::marginHint(),
+                                              KDialog::spacingHint() );
 
-   _dont = new QRadioButton(i18n("Do not send a certificate"), this);
-   grid->addMultiCellWidget(_dont, 1, 1, 0, 2);
-   connect(_dont, SIGNAL(clicked()), SLOT(slotDont()));
+   d->p_message = new QLabel(QString::null, this);
+   grid->addWidget(d->p_message);
+   setHost(_host);
 
    _certs = new QListView(this);
-   grid->addMultiCellWidget(_certs, 0, 4, 3, 5);
    _certs->addColumn(i18n("Certificate"));
+   _certs->setResizeMode(QListView::LastColumn);
+   QFontMetrics fm( KGlobalSettings::generalFont() );
+   _certs->setMinimumHeight(4*fm.height());
+   grid->addWidget(_certs);
 
    _save = new QCheckBox(i18n("Save selection for this host."), this);
-   grid->addMultiCellWidget(_save, 5, 5, 0, 3);
+   grid->addWidget(_save);
 
-   grid->addMultiCellWidget(new KSeparator(KSeparator::HLine, this), 6, 6, 0, 5);
+   grid->addWidget(new KSeparator(KSeparator::HLine, this));
 
-   _ok = new KPushButton(KStdGuiItem::cont(), this);
-   grid->addWidget(_ok, 7, 5);
-   connect(_ok, SIGNAL(clicked()), SLOT(accept()));
+   QBoxLayout * h = new QHBoxLayout( grid );
+   h->insertStretch(0);
 
+   _ok = new KPushButton(i18n("Send certificate"), this);
+   h->addWidget(_ok);
+   connect(_ok, SIGNAL(clicked()), SLOT(slotSend()));
+
+   d->p_pb_dontsend = new KPushButton(i18n("Do not send a certificate"), this);
+   h->addWidget(d->p_pb_dontsend);
+   connect(d->p_pb_dontsend, SIGNAL(clicked()), SLOT(slotDont()));
+
 #ifndef QT_NO_WIDGET_TOPEXTRA
    setCaption(i18n("KDE SSL Certificate Dialog"));
 #endif
@@ -87,10 +97,13 @@
 
 void KSSLCertDlg::setupDialog(const QStringList& certs, bool saveChecked, bool sendChecked) {
   _save->setChecked(saveChecked);
-  _send->setChecked(sendChecked);
-  _dont->setChecked(!sendChecked);
-  _certs->setEnabled(sendChecked);
+  d->p_send_flag = sendChecked;
 
+  if (sendChecked)
+    _ok->setDefault(true); // "do send" is the "default action".
+  else
+    d->p_pb_dontsend->setDefault(true); // "do not send" is the "default action".
+
   for (QStringList::ConstIterator i = certs.begin(); i != certs.end(); ++i) {
     if ((*i).isEmpty())
       continue;
@@ -108,34 +121,36 @@
 
 
 bool KSSLCertDlg::wantsToSend() {
-  return _send->isChecked();
+  return d->p_send_flag;
 }
 
 
 QString KSSLCertDlg::getChoice() {
-   return _certs->selectedItem()->text(0);
+   QListViewItem *selected = _certs->selectedItem();
+   if (selected && d->p_send_flag)
+	return selected->text(0);
+   else
+	return QString::null;
 }
 
 
 void KSSLCertDlg::setHost(const QString& host) {
    _host = host;
-#ifndef QT_NO_WIDGET_TOPEXTRA
-   setCaption(i18n("KDE SSL Certificate Dialog")+" - "+host);
-#endif
+   d->p_message->setText(i18n("The server <b>%1</b> requests a certificate.<p>"
+			     "Please choose a certificate if you want to send one:")
+			 .arg(_host));
 }
 
 
 void KSSLCertDlg::slotSend() {
-   _dont->setChecked(false);
-   _send->setChecked(true);
-   _certs->setEnabled(true);
+   d->p_send_flag = true;
+   accept();
 }
 
 
 void KSSLCertDlg::slotDont() {
-   _send->setChecked(false);
-   _dont->setChecked(true);
-   _certs->setEnabled(false);
+   d->p_send_flag = false;
+   reject();
 }
 
 


More information about the kde-core-devel mailing list