[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-usability
Subject:    [PATCH] Improving the KSCD configuration dialog
From:       Dave Corrie <kde () davecorrie ! com>
Date:       2002-07-11 22:43:33
[Download RAW message or body]

Hi,

I've made a patch to improve the usability of the SMTP configuration page in 
kscd. I'd appreciate feedback on whether you think these changes are 
sensible.

Here's what I don't like about the existing config page:

1) The page provides 4 edit boxes for you to type in your email address and 
SMTP server information. You can only type into 1 of these boxes - the other 
3 are read-only, even though they are not "grayed out"! The only way these 
read-only boxes can be filled in is to enter details into the KDE Control 
Centre's Network->Email config page. I found this *most* confusing!

2) The "Current Email Profile" droplist is redundant because you can only set 
up a single email profile in the KDE Control Centre.

My patch removes the "Current Email Profile" droplist and makes all the edit 
boxes editable. Default settings are taken from the KDE Control Centre if 
they are available, but it is no longer compulsory to enter information into 
the Control Centre.

Let me know what you think.

Cheers,

Dave

["emailsettings.patch" (text/x-diff)]

Index: kscd.cpp
===================================================================
RCS file: /home/kde/kdemultimedia/kscd/kscd.cpp,v
retrieving revision 1.158
diff -u -3 -p -r1.158 kscd.cpp
--- kscd.cpp	2002/07/07 10:25:07	1.158
+++ kscd.cpp	2002/07/07 22:49:06
@@ -1708,21 +1708,30 @@ KSCD::readSettings()
 
     config->setGroup("SMTP");
     smtpConfigData->enabled = config->readBoolEntry("enabled", true);
-    smtpConfigData->mailProfile = config->readEntry("mailProfile", i18n("Default"));
+    smtpConfigData->serverHost = config->readEntry("serverHost");
+    smtpConfigData->serverPort = config->readEntry("serverPort");
+    smtpConfigData->senderAddress = config->readEntry("senderAddress");
+    smtpConfigData->senderReplyTo = config->readEntry("senderReplyTo");
 
-    // Same as follows happens in smtpconfig.cpp. Try to remove one.
-    KEMailSettings kes;
-    kes.setProfile( smtpConfigData->mailProfile );
-    smtpConfigData->serverHost = kes.getSetting( KEMailSettings::OutServer );
-    smtpConfigData->serverPort = "25";
-    smtpConfigData->senderAddress = kes.getSetting( KEMailSettings::EmailAddress );
-    smtpConfigData->senderReplyTo = kes.getSetting( KEMailSettings::ReplyToAddress \
                );
-    // Don't accept obviously bogus settings.
-    if( (smtpConfigData->serverHost == "") || \
(!smtpConfigData->senderAddress.contains("@")) ) +    if( \
smtpConfigData->serverHost.isNull() && smtpConfigData->serverPort.isNull() && +       \
smtpConfigData->senderAddress.isNull() && smtpConfigData->senderReplyTo.isNull() )  {
-        smtpConfigData->enabled = false;
+        // Support for legacy mailProfile option
+        QString mailProfile = config->readEntry("mailProfile", i18n("Default"));
+
+        // Attempt to pull default settings from Control Centre
+        KEMailSettings kes;
+        kes.setProfile( mailProfile );
+        smtpConfigData->serverHost = kes.getSetting( KEMailSettings::OutServer );
+        smtpConfigData->serverPort = "25";
+        smtpConfigData->senderAddress = kes.getSetting( KEMailSettings::EmailAddress \
); +        smtpConfigData->senderReplyTo = kes.getSetting( \
KEMailSettings::ReplyToAddress );  }
 
+    // Don't accept obviously bogus settings.
+    if(!smtpConfigData->isValid())
+        smtpConfigData->enabled = false;
+
     config->setGroup("CDDB");
 
     cddb.setTimeout(config->readNumEntry("CDDBTimeout",60));
@@ -1828,7 +1837,12 @@ KSCD::writeSettings()
 
     config->setGroup("SMTP");
     config->writeEntry("enabled", smtpConfigData->enabled);
-    config->writeEntry("mailProfile", smtpConfigData->mailProfile);
+    config->writeEntry("serverHost", smtpConfigData->serverHost);
+    config->writeEntry("serverPort", smtpConfigData->serverPort);
+    config->writeEntry("senderAddress", smtpConfigData->senderAddress);
+    config->writeEntry("senderReplyTo", smtpConfigData->senderReplyTo);
+    // delete legacy mailProfile option
+    config->deleteEntry("mailProfile");
 
     config->setGroup("CDDB");
     config->writeEntry("CDDBRemoteEnabled",cddb_remote_enabled);
Index: smtpconfig.h
===================================================================
RCS file: /home/kde/kdemultimedia/kscd/smtpconfig.h,v
retrieving revision 1.6
diff -u -3 -p -r1.6 smtpconfig.h
--- smtpconfig.h	2002/01/11 03:27:02	1.6
+++ smtpconfig.h	2002/07/07 22:49:06
@@ -41,7 +41,14 @@ struct SMTPConfigData 
     QString serverPort;
     QString senderAddress;
     QString senderReplyTo;
-    QString mailProfile;
+
+    bool isValid() const
+    {
+        // simple validation
+        return !serverHost.isEmpty() && !serverPort.isEmpty() &&
+               senderAddress.contains("@") &&
+               (senderReplyTo.contains("@") || senderReplyTo.isEmpty());
+    }
 };
 
 class SMTPConfig:public QWidget
@@ -55,15 +62,12 @@ public:
 public slots:
     void commitData();
     void enableClicked();
-    void mailProfileChanged(const QString &name);
 
 signals:
 
 protected:
     QGroupBox       *mainBox;
     QCheckBox       *enableCB;
-    QLabel          *mailProfileLabel;
-    KComboBox       *mailProfileCombo;
     QLabel          *serverHostLabel;
     QLineEdit       *serverHostEdit;
     QLabel          *serverPortLabel;
@@ -72,7 +76,8 @@ protected:
     QLineEdit       *senderAddressEdit;
     QLabel          *senderReplyToLabel;
     QLineEdit       *senderReplyToEdit;
-    KEMailSettings  *kes;
+
+	void enableWidgets(bool enable = true);
 
 private:
     SMTPConfigData *configData;
Index: smtpconfig.cpp
===================================================================
RCS file: /home/kde/kdemultimedia/kscd/smtpconfig.cpp,v
retrieving revision 1.17
diff -u -3 -p -r1.17 smtpconfig.cpp
--- smtpconfig.cpp	2002/07/07 21:02:28	1.17
+++ smtpconfig.cpp	2002/07/07 22:49:06
@@ -29,6 +29,7 @@
 
 #include <qlayout.h>
 #include <qfontmetrics.h>
+#include <qvalidator.h>
 
 #include <kemailsettings.h>
 #include <kmessagebox.h>
@@ -38,20 +39,7 @@ SMTPConfig::SMTPConfig(QWidget *parent, 
 {
     configData = _configData;
     QFontMetrics fm ( font() );
-    kes = new KEMailSettings();
 
-    kes->setProfile( configData->mailProfile );
-    configData->serverHost = kes->getSetting( KEMailSettings::OutServer );
-    configData->serverPort = "25";
-    configData->senderAddress = kes->getSetting( KEMailSettings::EmailAddress );
-    configData->senderReplyTo = kes->getSetting( KEMailSettings::ReplyToAddress );
-    // Don't accept obviously bogus settings.
-    if( (configData->serverHost == "") || \
                (!configData->senderAddress.contains("@")))
-      {
-	configData->enabled = false;
-      }
-    
-
     QBoxLayout * lay1 = new QVBoxLayout ( this );
     mainBox = new QGroupBox(this, "mainBox");
     lay1->addWidget ( mainBox );
@@ -65,99 +53,68 @@ SMTPConfig::SMTPConfig(QWidget *parent, 
     QGridLayout * glay = new QGridLayout ( lay2, 2, 4, 5 );
     glay->setColStretch ( 1, 1 );
 
-    mailProfileLabel = new QLabel(i18n("Current email profile:"), mainBox, \
                "mailProfileLabel");
-    glay->addWidget ( mailProfileLabel, 0, 0 );
-    mailProfileCombo = new KComboBox( FALSE, mainBox, "mailProfileCombo" );
-    glay->addMultiCellWidget( mailProfileCombo, 0,0, 1,3);
-    mailProfileCombo->insertStringList(kes->profiles());
-    mailProfileCombo->setEnabled(configData->enabled);
-    connect(mailProfileCombo, SIGNAL(activated(const QString &)), this, \
                SLOT(mailProfileChanged(const QString &)));
-    // *yuck*
-    int i = 0;
-    for( i=0; i < mailProfileCombo->count(); i++ )
-      {
-	if( configData->mailProfile == mailProfileCombo->text(i) )
-	  {
-	    mailProfileCombo->setCurrentItem( i );
-	  }
-      }
-
     serverHostLabel = new QLabel(i18n("SMTP address:port :"), mainBox, \
"serverHostLabel");  glay->addWidget ( serverHostLabel, 1, 0 );
     serverHostEdit = new QLineEdit(mainBox, "serverHostEdit");
     glay->addWidget ( serverHostEdit, 1, 1 );
     serverHostEdit->setText(configData->serverHost);
-    serverHostEdit->setEnabled(configData->enabled);
     serverPortLabel = new QLabel(":", mainBox, "serverPortLabel");
     glay->addWidget ( serverPortLabel, 1, 2 );
     serverPortEdit = new QLineEdit(mainBox, "serverPortEdit");
     serverPortEdit->setFixedWidth ( 5 * fm.maxWidth() );
+    serverPortEdit->setValidator( new QIntValidator(this) );
     glay->addWidget ( serverPortEdit, 1, 3 );
     serverPortEdit->setGeometry(475, 40, 45, 25);
     serverPortEdit->setText(configData->serverPort);
-    serverPortEdit->setEnabled(configData->enabled);
-    serverPortEdit->setReadOnly( true );
 
     senderAddressLabel = new QLabel(i18n("Your email address:"), mainBox, \
"senderAddressLabel");  glay->addWidget ( senderAddressLabel, 2, 0 );
     senderAddressEdit = new QLineEdit(mainBox, "senderAddressEdit");
     glay->addMultiCellWidget ( senderAddressEdit, 2,2, 1,3 );
     senderAddressEdit->setText(configData->senderAddress);
-    senderAddressEdit->setEnabled(configData->enabled);
-    senderAddressEdit->setReadOnly( true );
 
     senderReplyToLabel = new QLabel(i18n("Your reply address:"), mainBox, \
"senderReplyToLabel");  glay->addWidget ( senderReplyToLabel, 3, 0 );
     senderReplyToEdit = new QLineEdit(mainBox, "senderReplyToEdit");
     glay->addMultiCellWidget ( senderReplyToEdit, 3,3, 1,3 );
     senderReplyToEdit->setText(configData->senderReplyTo);
-    senderReplyToEdit->setEnabled(configData->enabled);
-    senderReplyToEdit->setReadOnly( true );
     
     lay1->addStretch ( 1 );
+
+    enableWidgets(configData->enabled);
 }
 
 void SMTPConfig::commitData(void)
 {
     configData->enabled = enableCB->isChecked();
     configData->serverHost = serverHostEdit->text();
-    kes->setSetting( KEMailSettings::OutServer, serverHostEdit->text() );
     configData->serverPort = serverPortEdit->text();
     configData->senderAddress = senderAddressEdit->text();
     configData->senderReplyTo = senderReplyToEdit->text();
-    configData->mailProfile = mailProfileCombo->currentText();
-    if( configData->enabled && ( (configData->serverHost == "") ||
-                                   (!configData->senderAddress.contains("@")) ) )
+    if( configData->enabled && !configData->isValid() )
       {
 	KMessageBox::sorry(this, i18n("freedb submissions via SMTP have been disabled\n"
-				      "because the email profile you selected is\n"
+				      "because the email details you have entered are\n"
 				      "incomplete. Please review your email settings\n"
 				      "and try again."), i18n("Freedb Submissions Disabled"));
 	configData->enabled = false;
+	enableCB->setChecked(false);
+	enableWidgets(false);
       } 
 } // commitData
 
 void SMTPConfig::enableClicked(void)
 {
-    bool c;
-
-    c = enableCB->isChecked();
-    mailProfileCombo->setEnabled(c);
-    serverHostEdit->setEnabled(c);
-    serverPortEdit->setEnabled(c);
-    senderAddressEdit->setEnabled(c);
-    senderReplyToEdit->setEnabled(c);
+    enableWidgets(enableCB->isChecked());
 } // enableClicked
+
 
-void SMTPConfig::mailProfileChanged( const QString &name )
+void SMTPConfig::enableWidgets(bool enable)
 {
-    kes->setProfile( name );
-    configData->serverHost = kes->getSetting( KEMailSettings::OutServer );
-    configData->senderAddress = kes->getSetting( KEMailSettings::EmailAddress );
-    configData->senderReplyTo = kes->getSetting( KEMailSettings::ReplyToAddress );
-    serverHostEdit->setText( configData->serverHost );
-    senderAddressEdit->setText( configData->senderAddress );
-    senderReplyToEdit->setText( configData->senderReplyTo );
-} // mailProfileChanged
+    serverHostEdit->setEnabled(enable);
+    serverPortEdit->setEnabled(enable);
+    senderAddressEdit->setEnabled(enable);
+    senderReplyToEdit->setEnabled(enable);
+} // enableWidgets
 
 #include <smtpconfig.moc>


_______________________________________________
kde-usability mailing list
kde-usability@mail.kde.org
http://mail.kde.org/mailman/listinfo/kde-usability

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic