void KonqSidebarBookmarkModule::slotOpenTab() { KonqSidebarBookmarkItem *bi = dynamic_cast<KonqSidebarBookmarkItem*>( tree()->selectedItem() ); KBookmark bookmark; if (bi) { bookmark = bi->bookmark(); } else if(tree()->selectedItem() == m_topLevelItem) bookmark = s_bookmarkManager->root(); else return; KParts::OpenUrlArguments args; args.setActionRequestedByUser(true); KParts::BrowserArguments browserArguments; browserArguments.setNewTab(true); if (bookmark.isGroup()) { KBookmarkGroup group = bookmark.toGroup(); bookmark = group.first(); while (!bookmark.isNull()) { if (!bookmark.isGroup() && !bookmark.isSeparator()) { emit tree()->createNewWindow(bookmark.url(), args, browserArguments); } bookmark = group.next(bookmark); } } else { emit tree()->createNewWindow(bookmark.url(), args, browserArguments); } }
void KonqSidebarTree::slotOpenTab() { if (!m_currentTopLevelItem) return; KParts::BrowserArguments browserArgs; browserArgs.setNewTab(true); emit createNewWindow(m_currentTopLevelItem->externalURL(), KParts::OpenUrlArguments(), browserArgs); }
void KonqSidebarBookmarkModule::slotOpenNewWindow() { KonqSidebarBookmarkItem *bi = dynamic_cast<KonqSidebarBookmarkItem*>( tree()->selectedItem() ); if (!bi) return; KParts::OpenUrlArguments args; args.setActionRequestedByUser(true); KParts::BrowserArguments browserArgs; browserArgs.setForcesNewWindow(true); emit tree()->createNewWindow(bi->bookmark().url(), args, browserArgs); }
void KonqView::openUrl( const KUrl &url, const QString & locationBarURL, const QString & nameFilter, bool tempFile ) { kDebug() << "url=" << url << "locationBarURL=" << locationBarURL; setPartMimeType(); KParts::OpenUrlArguments args; if ( m_pPart ) args = m_pPart->arguments(); KParts::BrowserExtension *ext = browserExtension(); KParts::BrowserArguments browserArgs; if ( ext ) browserArgs = ext->browserArguments(); // Typing "Enter" again after the URL of an aborted view, triggers a reload. if ( m_bAborted && m_pPart && m_pPart->url() == url && !browserArgs.doPost()) { if ( !prepareReload( args, browserArgs, false /* not softReload */ ) ) return; m_pPart->setArguments( args ); } #ifdef DEBUG_HISTORY kDebug() << "m_bLockedLocation=" << m_bLockedLocation << "browserArgs.lockHistory()=" << browserArgs.lockHistory(); #endif if ( browserArgs.lockHistory() ) lockHistory(); if ( !m_bLockHistory ) { // Store this new URL in the history, removing any existing forward history. // We do this first so that everything is ready if a part calls completed(). createHistoryEntry(); } else m_bLockHistory = false; if ( m_pPart ) m_pPart->setProperty("nameFilter", nameFilter); if ( m_bDisableScrolling ) callExtensionMethod( "disableScrolling" ); // Set location-bar URL, except for error urls, where we know the browser component // will set back the url with the error anyway. if (url.protocol() != "error") setLocationBarURL(locationBarURL); setPageSecurity(KonqMainWindow::NotCrypted); if ( !args.reload() ) { // Save the POST data that is necessary to open this URL // (so that reload can re-post it) m_doPost = browserArgs.doPost(); m_postContentType = browserArgs.contentType(); m_postData = browserArgs.postData; // Save the referrer m_pageReferrer = args.metaData()["referrer"]; } if ( tempFile ) { // Store the path to the tempfile. Yes, we could store a bool only, // but this would be more dangerous. If anything goes wrong in the code, // we might end up deleting a real file. if ( url.isLocalFile() ) m_tempFile = url.toLocalFile(); else kWarning() << "Tempfile option is set, but URL is remote:" << url ; } aboutToOpenURL( url, args ); m_pPart->openUrl( url ); updateHistoryEntry(false /* don't save location bar URL yet */); // add pending history entry KonqHistoryManager::kself()->addPending( url, locationBarURL, QString()); #ifdef DEBUG_HISTORY kDebug() << "Current position:" << historyIndex(); #endif }
void WebView::contextMenuEvent(QContextMenuEvent* e) { m_result = page()->mainFrame()->hitTestContent(e->pos()); // Clear the previous collection entries first... m_actionCollection->clear(); KParts::BrowserExtension::PopupFlags flags = KParts::BrowserExtension::DefaultPopupItems; KParts::BrowserExtension::ActionGroupMap mapAction; QString mimeType (QL1S("text/html")); bool forcesNewWindow = false; QUrl emitUrl; if (m_result.isContentEditable()) { if (m_result.element().hasAttribute(QL1S("disabled"))) { e->accept(); return; } flags |= KParts::BrowserExtension::ShowTextSelectionItems; editableContentActionPopupMenu(mapAction); } else if (isMultimediaElement(m_result.element())) { multimediaActionPopupMenu(mapAction); } else if (!m_result.linkUrl().isValid()) { if (m_result.imageUrl().isValid()) { emitUrl = m_result.imageUrl(); extractMimeTypeFor(emitUrl, mimeType); } else { flags |= KParts::BrowserExtension::ShowBookmark; flags |= KParts::BrowserExtension::ShowReload; emitUrl = m_part->url(); if (m_result.isContentSelected()) { flags |= KParts::BrowserExtension::ShowTextSelectionItems; selectActionPopupMenu(mapAction); } else { flags |= KParts::BrowserExtension::ShowNavigationItems; } } partActionPopupMenu(mapAction); } else { flags |= KParts::BrowserExtension::ShowBookmark; flags |= KParts::BrowserExtension::ShowReload; flags |= KParts::BrowserExtension::IsLink; emitUrl = m_result.linkUrl(); linkActionPopupMenu(mapAction); if (emitUrl.isLocalFile()) mimeType = KMimeType::findByUrl(emitUrl, 0, true, false)->name(); else extractMimeTypeFor(emitUrl, mimeType); partActionPopupMenu(mapAction); // Show the OpenInThisWindow context menu item forcesNewWindow = (page()->currentFrame() != m_result.linkTargetFrame()); } if (!mapAction.isEmpty()) { KParts::OpenUrlArguments args; KParts::BrowserArguments bargs; args.setMimeType(mimeType); bargs.setForcesNewWindow(forcesNewWindow); e->accept(); emit m_part->browserExtension()->popupMenu(e->globalPos(), emitUrl, static_cast<mode_t>(-1), args, bargs, flags, mapAction); return; } KWebView::contextMenuEvent(e); }