On Tuesday 24 Nov 2009 10:59:37 Sebastian Kügler wrote: > On Monday 23 November 2009 19:43:22 Andrew Manson wrote: > > Does anyone else like this idea? > > I like it, I see the same problem quite often here. I wonder how nm-applet > does it, I've never seemed to have this problem with that one... >
AHA! I did it! I have a real sense of achievement now that i've solved a problem that I was having all by myself! :D what do you guys think? This is based on the Kubuntu 9.10 sources, I haven't tried it against SVN or any branches. Should i submit it to KdeReview? -Andrew
From 2c351537955a834f9da52cd50a1fe0955e294a07 Mon Sep 17 00:00:00 2001 From: Andrew Manson <mans...@mansona-1501.(none)> Date: Wed, 25 Nov 2009 23:52:37 +0000 Subject: [PATCH] add the changes --- libs/ui/connectionsecretsjob.cpp | 47 ++++++++++++++++++++++++++++++++++++- libs/ui/connectionsecretsjob.h | 6 +++++ 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/libs/ui/connectionsecretsjob.cpp b/libs/ui/connectionsecretsjob.cpp index abcc7b1..9cf96d4 100644 --- a/libs/ui/connectionsecretsjob.cpp +++ b/libs/ui/connectionsecretsjob.cpp @@ -36,6 +36,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include <nm-setting-wireless-security.h> #include <QTimer> +#include <QFrame> +#include <QVBoxLayout> #include <KDialog> #include <KLocale> @@ -59,7 +61,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. ConnectionSecretsJob::ConnectionSecretsJob(Knm::Connection* connection, const QString &settingName, const QStringList& secrets, bool requestNew, const QDBusMessage& request) : m_connection(connection), m_connectionPersistence(0), mSettingName(settingName), mRequestNew(requestNew), - mRequest(request), m_askUserDialog(0), m_settingWidget(0) + mRequest(request), m_askUserDialog(0), m_settingWidget(0), m_retryLabel(0), m_retryTimeout(0) { // record the secrets that we are looking for foreach (QString secretKey, secrets) { @@ -106,6 +108,23 @@ void ConnectionSecretsJob::gotPersistedSecrets(uint result) } } +void ConnectionSecretsJob::updateTimout() +{ + if( m_retryTimoutCount == 0 ) + { + m_retryTimeout->stop(); + //Submit the button + dialogAccepted(); + m_retryTimoutCount = 30; + return; + } + if( m_retryLabel != 0 ) + { + m_retryLabel->setText(QString( "Automatically submitting in %1 Seconds").arg(m_retryTimoutCount)); + m_retryTimoutCount--; + } +} + void ConnectionSecretsJob::doAskUser() { // popup a dialog showing the appropriate UI for the type of connection @@ -147,12 +166,36 @@ void ConnectionSecretsJob::doAskUser() m_settingWidget->readSecrets(); m_askUserDialog = new KDialog(0); m_askUserDialog->setCaption(i18nc("@title:window for network secrets request", "Secrets for %1", m_connection->name())); - m_askUserDialog->setMainWidget(m_settingWidget); + + if( m_retryTimeout == 0 ) + { + m_retryTimeout = new QTimer(m_askUserDialog); + connect(m_retryTimeout, SIGNAL(timeout()), this, SLOT(updateTimout())); + } + + m_retryTimeout->setInterval(1000); + m_retryTimoutCount = 30; + + QFrame *dialogFrame = new QFrame(m_askUserDialog); + QVBoxLayout *dialogLayout = new QVBoxLayout(); + + if( m_retryLabel == 0 ) + { + m_retryLabel = new QLabel(m_askUserDialog); + } + + dialogLayout->addWidget(m_settingWidget); + dialogLayout->addStretch(); + dialogLayout->addWidget(m_retryLabel); + dialogFrame->setLayout(dialogLayout); + + m_askUserDialog->setMainWidget(dialogFrame); m_askUserDialog->setButtons(KDialog::Ok | KDialog::Cancel); connect(m_askUserDialog, SIGNAL(okClicked()), SLOT(dialogAccepted())); connect(m_askUserDialog, SIGNAL(cancelClicked()), SLOT(dialogRejected())); + m_retryTimeout->start(); m_askUserDialog->show(); } else { kDebug() << "Setting widget for" << mSettingName << "not yet ported, rejecting secrets request."; diff --git a/libs/ui/connectionsecretsjob.h b/libs/ui/connectionsecretsjob.h index 721af63..85ccce0 100644 --- a/libs/ui/connectionsecretsjob.h +++ b/libs/ui/connectionsecretsjob.h @@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include <QDBusMessage> #include <QStringList> +#include <QLabel> #include <KJob> @@ -67,6 +68,7 @@ public Q_SLOTS: protected Q_SLOTS: void gotPersistedSecrets(uint); + void updateTimout(); private: void doAskUser(); @@ -81,6 +83,10 @@ private: QDBusMessage mRequest; KDialog * m_askUserDialog; SettingWidget * m_settingWidget; + + int m_retryTimoutCount; + QLabel *m_retryLabel; + QTimer *m_retryTimeout; }; #endif // CONNECTIONSECRETSJOB_H -- 1.6.3.3
_______________________________________________ kde-networkmanager mailing list [email protected] https://mail.kde.org/mailman/listinfo/kde-networkmanager
