[prev in list] [next in list] [prev in thread] [next in thread]
List: kfm-devel
Subject: Re: MMB opens in new tab
From: Doug Hanley <hanleyman () adelphia ! net>
Date: 2002-07-22 15:05:12
[Download RAW message or body]
On Friday 19 July 2002 12:45 pm, David Faure wrote:
> A much smaller solution (less code changes) would have been to add the
> newTab bool to the KonqOpenURLRequest struct. That's exactly what it's
> there for: to easily add new "do this when opening this URL" data, without
> having to change so much API. Sorry that I didn't think of mentionning this
> earlier. I understand if you don't want to rewrite this patch yet another
> time (but in all theory it would be cleaner to have it in
> KonqOpenURLRequest ;-) Do whichever way you prefer.
Alright, that wasn't too hard. Well I know you're on vacation right now (hope
you're enjoying it), so I guess I'll just say here's the patch, anyone have
any objections? If not, I'll commit.
Also, about the tabbed browsing options, can we come a concensus on where to
put these in KControl, because I have some code ready, I just need to know
where to put it.
-- Doug Hanley
["cvskonqtabs-072202.patch" (text/x-diff)]
Index: konq_mainwindow.cc
===================================================================
RCS file: /home/kde/kdebase/konqueror/konq_mainwindow.cc,v
retrieving revision 1.1022
diff -u -3 -p -r1.1022 konq_mainwindow.cc
--- konq_mainwindow.cc 2002/07/15 18:07:13 1.1022
+++ konq_mainwindow.cc 2002/07/22 14:57:07
@@ -383,7 +383,7 @@ void KonqMainWindow::openURL( KonqView *
}
KonqView *view = _view;
- if ( !view )
+ if ( !view && !req.newTab)
view = m_currentView; /* Note, this can be 0L, e.g. on startup */
if ( view )
@@ -481,8 +481,9 @@ bool KonqMainWindow::openView( QString s
//kdDebug(1202) << "req.followMode=" << req.followMode << endl;
//kdDebug(1202) << "req.nameFilter= " << req.nameFilter << endl;
//kdDebug(1202) << "req.typedURL= " << req.typedURL << endl;
+ //kdDebug(1202) << "req.newTab= " << req.newTab << endl;
+ //kdDebug(1202) << "req.newTabInFront= " << req.newTabInFront << endl;
-
bool bOthersFollowed = false;
// If linked view and if we are not already following another view (and if we are \
not reloading) if ( childView && childView->isLinkedView() && !req.followMode && \
!req.args.reload && !m_pViewManager->isLoadingProfile() ) @@ -602,26 +603,39 @@ bool \
KonqMainWindow::openView( QString s bool ok = true;
if ( !childView )
{
- // Create a new view
- // Initialize always uses force auto-embed even if user setting is "separate \
viewer",
- // since this window has no view yet - we don't want to keep an empty \
mainwindow.
- // This can happen with e.g. application/pdf from a target="_blank" link, or \
window.open.
- childView = m_pViewManager->Initialize( serviceType, serviceName );
+ if (req.newTab)
+ {
+ childView = m_pViewManager->addTab( serviceType, serviceName );
+ if (req.newTabInFront && childView)
+ {
+ KonqFrameTabs* tabContainer = \
static_cast<KonqFrameTabs*>(m_pViewManager->docContainer()); + \
tabContainer->setCurrentPage( tabContainer->count()-1 ); + }
+ }
+ else
+ {
+ // Create a new view
+ // Initialize always uses force auto-embed even if user setting is "separate \
viewer", + // since this window has no view yet - we don't want to keep an \
empty mainwindow. + // This can happen with e.g. application/pdf from a \
target="_blank" link, or window.open. + childView = \
m_pViewManager->Initialize( serviceType, serviceName ); +
+ enableAllActions( true );
+
+ m_pViewManager->setActivePart( childView->part() );
+
+ childView->setViewName( m_initialFrameName );
+ m_initialFrameName = QString::null;
+ }
+
if ( !childView )
{
KMessageBox::sorry( 0L, i18n( "Could not create view for %1\nThe \
diagnostics is:\n%2").arg(serviceType)
.arg(KLibLoader::self()->lastErrorMessage()) );
return true; // fake everything was ok, we don't want to propagate the \
error }
-
- enableAllActions( true );
-
- m_pViewManager->setActivePart( childView->part() );
-
- childView->setViewName( m_initialFrameName );
- m_initialFrameName = QString::null;
- }
+ }
else // We know the child view
{
//childView->stop();
@@ -807,11 +821,11 @@ void KonqMainWindow::slotCreateNewWindow
KConfig *config = KGlobal::config();
KConfigGroupSaver cs( config, QString::fromLatin1("FMSettings") );
if ( config->readBoolEntry( "MMBOpensTab", false ) ) {
- KFileItem item( url, 0 /*_mimeType*/, 0 /*_mode*/ ); // FIXME with real \
values
- KFileItemList items;
- items.append( &item );
- popupItems = items;
- popupNewTab(true); // False opens in background tab
+ KonqOpenURLRequest req;
+ req.newTab = true;
+ req.newTabInFront = true;
+ req.args = args;
+ openURL( 0L, url, QString::null, req );
}
else
KonqMisc::createNewWindow( url, args );
@@ -2005,27 +2019,16 @@ void KonqMainWindow::slotPopupNewTab()
void KonqMainWindow::popupNewTab(bool infront)
{
- KURL url;
+ kdDebug(1202) << "KonqMainWindow::popupNewTab()" << endl;
+
KFileItemListIterator it ( popupItems );
- QString mimeType, mimeComment;
- KonqView* newView = 0;
- KonqView* lastView = 0;
+ KonqOpenURLRequest req;
+ req.newTab = true;
+ req.newTabInFront = infront;
for ( ; it.current(); ++it )
{
- newView = 0L;
- url = (*it)->url();
- mimeType = (*it)->mimetype();
- mimeComment = (*it)->mimeComment();
- if (mimeType == "application/octet-stream") mimeType = mimeComment = "";
- newView = m_pViewManager->addTab(mimeType, mimeComment);
- if (newView != 0L)
- {
- newView->openURL( url, url.prettyURL() );
- lastView = newView;
- }
+ openURL( 0L, (*it)->url(), QString::null, req );
}
- if (infront)
- m_pViewManager->showTab(lastView);
}
void KonqMainWindow::slotRemoveView()
Index: konq_openurlrequest.h
===================================================================
RCS file: /home/kde/kdebase/konqueror/konq_openurlrequest.h,v
retrieving revision 1.4
diff -u -3 -p -r1.4 konq_openurlrequest.h
--- konq_openurlrequest.h 2000/08/29 07:35:23 1.4
+++ konq_openurlrequest.h 2002/07/22 14:57:08
@@ -8,16 +8,18 @@
struct KonqOpenURLRequest {
KonqOpenURLRequest() :
- followMode(false)
+ followMode(false), newTab(false), newTabInFront(false)
{}
KonqOpenURLRequest( const QString & url ) :
- typedURL(url), followMode(false)
+ typedURL(url), followMode(false), newTab(false), newTabInFront(false)
{}
QString typedURL; // empty if URL wasn't typed manually
bool followMode; // true if following another view - avoids loops
QString nameFilter; // like *.cpp, extracted from the URL
+ bool newTab; // open url in new tab
+ bool newTabInFront; // new tab in front or back
KParts::URLArgs args;
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic