Git commit 0057256b1a0a601346f3a343bbbec81bf2e48fe3 by Dawit Alemayehu. Committed on 01/05/2012 at 01:17. Pushed by adawit into branch 'KDE/4.8'. Set the parent widget for message boxes created in KIO::SlaveInterface::mes= sageBox. REVIEW: 104351 M +10 -0 kio/kio/scheduler.cpp M +22 -8 kio/kio/slaveinterface.cpp M +17 -0 kio/kio/slaveinterface.h M +4 -1 kio/kio/slaveinterface_p.h http://commits.kde.org/kdelibs/0057256b1a0a601346f3a343bbbec81bf2e48fe3 diff --git a/kio/kio/scheduler.cpp b/kio/kio/scheduler.cpp index 8d144bb..802f8b8 100644 --- a/kio/kio/scheduler.cpp +++ b/kio/kio/scheduler.cpp @@ -536,6 +536,10 @@ Slave *ProtoQueue::createSlave(const QString &protocol= , SimpleJob *job, const KU QString errortext; Slave *slave =3D Slave::createSlave(protocol, url, error, errortext); if (slave) { + // Set the parent widget the slave should use to display message b= oxes. + if (job && job->ui()) { + slave->setWindow(job->ui()->window()); + } scheduler()->connect(slave, SIGNAL(slaveDied(KIO::Slave*)), SLOT(slotSlaveDied(KIO::Slave*))); scheduler()->connect(slave, SIGNAL(slaveStatus(pid_t,QByteArray,QS= tring,bool)), @@ -1222,6 +1226,12 @@ Slave *SchedulerPrivate::heldSlaveForJob(SimpleJob *= job) kDebug(7006) << "HOLD: Reusing klauncher held slave (" << slave <<= ")"; } = + // Reset the parent widget the ioslave should use when displaying mess= age + // boxes after being put on hold. + if (slave && job->ui()) { + slave->setWindow(job->ui()->window()); + } + return slave; } = diff --git a/kio/kio/slaveinterface.cpp b/kio/kio/slaveinterface.cpp index d2f9f93..86727bf 100644 --- a/kio/kio/slaveinterface.cpp +++ b/kio/kio/slaveinterface.cpp @@ -400,6 +400,18 @@ void SlaveInterface::messageBox( int type, const QStri= ng &text, const QString &c } } = +void SlaveInterface::setWindow (QWidget* window) +{ + Q_D(SlaveInterface); + d->parentWindow =3D window; +} + +QWidget* SlaveInterface::window() const +{ + const Q_D(SlaveInterface); + return d->parentWindow; +} + int SlaveInterfacePrivate::messageBox(int type, const QString &text, const QString &caption, const QStrin= g &buttonYes, const QString &buttonNo, const QStri= ng &dontAskAgainName) @@ -411,7 +423,7 @@ int SlaveInterfacePrivate::messageBox(int type, const Q= String &text, = // SMELL: the braindead way to support button icons KGuiItem buttonYesGui, buttonNoGui; - = + if (buttonYes =3D=3D i18n("&Details")) buttonYesGui =3D KGuiItem(buttonYes, "help-about"); else if (buttonYes =3D=3D i18n("&Forever")) @@ -429,32 +441,32 @@ int SlaveInterfacePrivate::messageBox(int type, const= QString &text, switch (type) { case KIO::SlaveBase::QuestionYesNo: result =3D KMessageBox::questionYesNo( - 0, text, caption, buttonYesGui, + parentWindow, text, caption, buttonYesGui, buttonNoGui, dontAskAgainName); break; case KIO::SlaveBase::WarningYesNo: result =3D KMessageBox::warningYesNo( - 0, text, caption, buttonYesGui, + parentWindow, text, caption, buttonYesGui, buttonNoGui, dontAskAgainName); break; case KIO::SlaveBase::WarningContinueCancel: result =3D KMessageBox::warningContinueCancel( - 0, text, caption, buttonYesGui, + parentWindow, text, caption, buttonYesGui, KStandardGuiItem::cancel(), dontAskAgainName); break; case KIO::SlaveBase::WarningYesNoCancel: result =3D KMessageBox::warningYesNoCancel( - 0, text, caption, buttonYesGui, buttonNoGui, + parentWindow, text, caption, buttonYesGui, buttonNoGu= i, KStandardGuiItem::cancel(), dontAskAgainName); break; case KIO::SlaveBase::Information: - KMessageBox::information(0, text, caption, dontAskAgainName); + KMessageBox::information(parentWindow, text, caption, dontAskAgain= Name); result =3D 1; // whatever break; case KIO::SlaveBase::SSLMessageBox: { KIO::MetaData meta =3D sslMetaData; - KSslInfoDialog *kid =3D new KSslInfoDialog(0); + QPointer kid (new KSslInfoDialog(parentWindow)); //### this is boilerplate code and appears in khtml_part.cpp almos= t unchanged! QStringList sl =3D meta["ssl_peer_chain"].split('\x01', QString::S= kipEmptyParts); QList certChain; @@ -476,6 +488,7 @@ int SlaveInterfacePrivate::messageBox(int type, const Q= String &text, meta["ssl_cipher_used_bits"].toInt(), meta["ssl_cipher_bits"].toInt(), KSslInfoDialog::errorsFromString(meta["ssl_cer= t_errors"])); + kDebug(7024) << "Showing SSL Info dialog"; kid->exec(); kDebug(7024) << "SSL Info dialog closed"; @@ -486,10 +499,11 @@ int SlaveInterfacePrivate::messageBox(int type, const= QString &text, } // KSslInfoDialog deletes itself (Qt::WA_DeleteOnClose). result =3D 1; // whatever + delete kid; break; } default: - kWarning() << "unknown type" << type; + kWarning(7024) << "Unknown type" << type; result =3D 0; break; } diff --git a/kio/kio/slaveinterface.h b/kio/kio/slaveinterface.h index 3cdc2ae..4bfcec8 100644 --- a/kio/kio/slaveinterface.h +++ b/kio/kio/slaveinterface.h @@ -114,6 +114,23 @@ public: void setOffset( KIO::filesize_t offset ); KIO::filesize_t offset() const; = + /** + * Returns the top level window used as parent when displaying + * dialogs. + * + * @see setWindow + * @since 4.8.2 + */ + QWidget* window() const; + + /** + * Sets the top level window used as a parent when displaying + * dialogs. + * @see window + * @since 4.8.2 + */ + void setWindow(QWidget* window); + Q_SIGNALS: /////////// // Messages sent by the slave diff --git a/kio/kio/slaveinterface_p.h b/kio/kio/slaveinterface_p.h index e2ccfe0..4c3ffae 100644 --- a/kio/kio/slaveinterface_p.h +++ b/kio/kio/slaveinterface_p.h @@ -26,12 +26,14 @@ = static const unsigned int max_nums =3D 8; = +class QWidget; + class KIO::SlaveInterfacePrivate { public: SlaveInterfacePrivate() : connection(0), filesize(0), offset(0), last_time(0), - nums(0), slave_calcs_speed(false) + nums(0), slave_calcs_speed(false), parentWindow(0) { start_time.tv_sec =3D 0; start_time.tv_usec =3D 0; @@ -55,6 +57,7 @@ public: struct timeval start_time; uint nums; bool slave_calcs_speed; + QWidget* parentWindow; = int messageBox(int type, const QString &text, const QString &caption, const QString &buttonYes, const QString &buttonNo, const = QString &dontAskAgainName);