From c16d0f2191af1e4810391dbd1a06d7713fb38666 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sat, 19 Jan 2013 18:21:02 -0600 Subject: Fix popup menu in media kioslave --- libkonq/konq_popupmenu.cc | 48 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 4 deletions(-) (limited to 'libkonq/konq_popupmenu.cc') diff --git a/libkonq/konq_popupmenu.cc b/libkonq/konq_popupmenu.cc index cd86ac5bb..6b51047b5 100644 --- a/libkonq/konq_popupmenu.cc +++ b/libkonq/konq_popupmenu.cc @@ -19,6 +19,7 @@ */ #include +#include #include #include @@ -103,6 +104,10 @@ public: TQString m_urlTitle; TQWidget *m_parentWidget; KParts::BrowserExtension::PopupFlags m_itemFlags; + + bool localURLSlotFired; + KURL localURLResultURL; + bool localURLResultIsLocal; }; KonqPopupMenu::ProtocolInfo::ProtocolInfo() @@ -414,7 +419,26 @@ void KonqPopupMenu::setup(KonqPopupFlags kpf) if ( (*it)->mimetype().startsWith("media/") ) mediaFiles = true; } - url = m_sViewURL; + + // If a local path is available, monitor that instead of the given remote URL... + KURL realURL = m_sViewURL; + if (!realURL.isLocalFile()) { + KIO::LocalURLJob* localURLJob = KIO::localURL(m_sViewURL); + if (localURLJob) { + connect(localURLJob, TQT_SIGNAL(localURL(KIO::Job*, const KURL&, bool)), this, TQT_SLOT(slotLocalURL(KIO::Job*, const KURL&, bool))); + connect(localURLJob, TQT_SIGNAL(destroyed()), this, TQT_SLOT(slotLocalURLKIODestroyed())); + d->localURLSlotFired = false; + while (!d->localURLSlotFired) { + tqApp->eventLoop()->processEvents(TQEventLoop::ExcludeUserInput); + usleep(1000); + } + if (d->localURLResultIsLocal) { + realURL = d->localURLResultURL; + } + } + } + + url = realURL; url.cleanPath(); //check if url is current directory @@ -787,11 +811,11 @@ void KonqPopupMenu::setup(KonqPopupFlags kpf) } // if we have a mimetype, see if we have an exact or a type globbed match - if (!ok && + if ((!ok && (!m_sMimeType.isEmpty() && - *it == m_sMimeType) || + *it == m_sMimeType)) || (!mimeGroup.isEmpty() && - ((*it).right(1) == "*" && + (((*it).right(1) == "*") && (*it).left((*it).find('/')) == mimeGroup))) { checkTheMimetypes = true; @@ -1202,6 +1226,22 @@ KURL::List KonqPopupMenu::popupURLList() const return m_lstPopupURLs; } +void KonqPopupMenu::slotLocalURL(KIO::Job *job, const KURL& url, bool isLocal) +{ + d->localURLSlotFired = true; + d->localURLResultURL = url; + d->localURLResultIsLocal = isLocal; +} + +void KonqPopupMenu::slotLocalURLKIODestroyed() +{ + if (!d->localURLSlotFired) { + d->localURLSlotFired = true; + d->localURLResultURL = KURL(); + d->localURLResultIsLocal = false; + } +} + /** Plugin */ -- cgit v1.2.1