Commit 646a9086 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add new feature : Open new tab after current active page (as mozilla/galeon)

svn path=/trunk/kdebase/konqueror/; revision=194600
parent 8f9eef0c
......@@ -518,13 +518,14 @@ bool KonqMainWindow::openView( QString serviceType, const KURL &_url, KonqView *
return false; // execute, don't open
// Contract: the caller of this method should ensure the view is stopped first.
//kdDebug(1202) << "KonqMainWindow::openView " << serviceType << " " << _url.url() << " " << childView << endl;
//kdDebug(1202) << "req.args.frameName= " << req.args.frameName << endl;
//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;
kdDebug(1202) << "KonqMainWindow::openView " << serviceType << " " << _url.url() << " " << childView << endl;
kdDebug(1202) << "req.args.frameName= " << req.args.frameName << endl;
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;
kdDebug(1202) << "req.openAfterCurrentPage= " << req.openAfterCurrentPage << endl;
bool bOthersFollowed = false;
if ( childView )
......@@ -658,12 +659,23 @@ bool KonqMainWindow::openView( QString serviceType, const KURL &_url, KonqView *
{
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 );
}
KonqFrameTabs* tabContainer = 0L;
int index = 0;
if ( m_pViewManager->docContainer() )
{
tabContainer = static_cast<KonqFrameTabs*>(m_pViewManager->docContainer());
index = tabContainer->currentPageIndex();
}
childView = m_pViewManager->addTab( serviceType, serviceName, false, req.openAfterCurrentPage );
if (req.newTabInFront && childView)
{
if ( !tabContainer )
tabContainer = static_cast<KonqFrameTabs*>(m_pViewManager->docContainer());
if ( req.openAfterCurrentPage )
tabContainer->setCurrentPage( index + 1 );
else
tabContainer->setCurrentPage( tabContainer->count()-1 );
}
}
else
......@@ -2095,15 +2107,22 @@ void KonqMainWindow::slotBreakOffTabPopup()
void KonqMainWindow::slotPopupNewTabAtFront()
{
popupNewTab(true);
KConfig *config = KGlobal::config();
KConfigGroupSaver cs( config, QString::fromLatin1("FMSettings") );
bool openAfterCurrentPage = config->readBoolEntry( "OpenAfterCurrentPage", false );
popupNewTab(true , openAfterCurrentPage);
}
void KonqMainWindow::slotPopupNewTab()
{
popupNewTab(false);
KConfig *config = KGlobal::config();
KConfigGroupSaver cs( config, QString::fromLatin1("FMSettings") );
bool openAfterCurrentPage = config->readBoolEntry( "OpenAfterCurrentPage", false );
popupNewTab(false, openAfterCurrentPage);
}
void KonqMainWindow::popupNewTab(bool infront)
void KonqMainWindow::popupNewTab(bool infront, bool openAfterCurrentPage)
{
kdDebug(1202) << "KonqMainWindow::popupNewTab()" << endl;
......@@ -2111,6 +2130,7 @@ void KonqMainWindow::popupNewTab(bool infront)
KonqOpenURLRequest req;
req.newTab = true;
req.newTabInFront = infront;
req.openAfterCurrentPage = openAfterCurrentPage;
for ( ; it.current(); ++it )
{
openURL( 0L, (*it)->url(), QString::null, req );
......
......@@ -512,7 +512,7 @@ private:
void initCombo();
void initActions();
void popupNewTab(bool infront);
void popupNewTab(bool infront, bool openAfterCurrentPage);
/**
* Tries to find a index.html (.kde.html) file in the specified directory
......
......@@ -8,11 +8,11 @@
struct KonqOpenURLRequest {
KonqOpenURLRequest() :
followMode(false), newTab(false), newTabInFront(false)
followMode(false), newTab(false), newTabInFront(false), openAfterCurrentPage( false )
{}
KonqOpenURLRequest( const QString & url ) :
typedURL(url), followMode(false), newTab(false), newTabInFront(false)
typedURL(url), followMode(false), newTab(false), newTabInFront(false), openAfterCurrentPage(false)
{}
QString typedURL; // empty if URL wasn't typed manually
......@@ -20,6 +20,7 @@ struct KonqOpenURLRequest {
QString nameFilter; // like *.cpp, extracted from the URL
bool newTab; // open url in new tab
bool newTabInFront; // new tab in front or back
bool openAfterCurrentPage;
KParts::URLArgs args;
};
......
......@@ -343,7 +343,7 @@ void KonqViewManager::revertDocContainer()
}
KonqView* KonqViewManager::addTab(const QString &serviceType, const QString &serviceName, bool passiveMode)
KonqView* KonqViewManager::addTab(const QString &serviceType, const QString &serviceName, bool passiveMode, bool openAfterCurrentPage )
{
#ifndef NDEBUG
kdDebug(1202) << "------------- KonqViewManager::addTab starting -------------" << endl;
......@@ -373,7 +373,7 @@ KonqView* KonqViewManager::addTab(const QString &serviceType, const QString &ser
if (m_pDocContainer->frameType() != "Tabs") convertDocContainer();
KonqView* childView = setupView( static_cast<KonqFrameTabs*>(m_pDocContainer), newViewFactory, service, partServiceOffers, appServiceOffers, serviceType, passiveMode );
KonqView* childView = setupView( static_cast<KonqFrameTabs*>(m_pDocContainer), newViewFactory, service, partServiceOffers, appServiceOffers, serviceType, passiveMode, openAfterCurrentPage );
#ifndef NDEBUG
m_pMainWindow->dumpViewList();
......@@ -918,9 +918,10 @@ KonqView *KonqViewManager::setupView( KonqFrameContainerBase *parentContainer,
const KTrader::OfferList &partServiceOffers,
const KTrader::OfferList &appServiceOffers,
const QString &serviceType,
bool passiveMode )
bool passiveMode,
bool openAfterCurrentPage )
{
//kdDebug(1202) << "KonqViewManager::setupView passiveMode=" << passiveMode << endl;
kdDebug(1202) << "KonqViewManager::setupView passiveMode=" << passiveMode << endl;
QString sType = serviceType;
......@@ -941,7 +942,14 @@ KonqView *KonqViewManager::setupView( KonqFrameContainerBase *parentContainer,
m_pMainWindow->insertChildView( v );
parentContainer->insertChildFrame( newViewFrame );
int index = -1;
KonqFrameTabs* tabContainer = static_cast<KonqFrameTabs*>(m_pDocContainer);
if ( openAfterCurrentPage )
index = tabContainer->currentPageIndex() +1 ;
parentContainer->insertChildFrame( newViewFrame, index );
if (parentContainer->frameType() != "Tabs") newViewFrame->show();
......
......@@ -100,7 +100,7 @@ public:
*/
KonqView* addTab(const QString &serviceType = QString::null,
const QString &serviceName = QString::null,
bool passiveMode = false);
bool passiveMode = false, bool openAfterCurrentPage = false );
......@@ -317,7 +317,7 @@ private:
const KTrader::OfferList &partServiceOffers,
const KTrader::OfferList &appServiceOffers,
const QString &serviceType,
bool passiveMode);
bool passiveMode, bool openAfterCurrentPage = false);
#ifndef NDEBUG
//just for debugging
......
......@@ -78,6 +78,13 @@ KMiscHTMLOptions::KMiscHTMLOptions(KConfig *config, QString group, QWidget *pare
row++;
connect(m_pNewTabsInFront, SIGNAL(clicked()), this, SLOT(slotChanged()));
m_pOpenAfterCurrentPage = new QCheckBox( i18n( "Open links after current page" ), this );
lay->addMultiCellWidget( m_pOpenAfterCurrentPage, row, row, 0, 1);
row++;
connect(m_pOpenAfterCurrentPage, SIGNAL(clicked()), this, SLOT(slotChanged()));
m_pTabConfirm = new QCheckBox( i18n( "Confirm &when closing windows with multiple tabs" ), this );
QWhatsThis::add( m_pTabConfirm, i18n("This will ask you whether you are sure you want to close "
"a window when it has multiple tabs opened in it.") );
......@@ -207,6 +214,7 @@ void KMiscHTMLOptions::load()
m_pConfig->setGroup("FMSettings");
m_pShowMMBInTabs->setChecked( m_pConfig->readBoolEntry( "MMBOpensTab", false ) );
m_pNewTabsInFront->setChecked( m_pConfig->readBoolEntry( "NewTabsInFront", true ) );
m_pOpenAfterCurrentPage->setChecked( m_pConfig->readBoolEntry( "OpenAfterCurrentPage", false ) );
m_pConfig->setGroup("Notification Messages");
m_pTabConfirm->setChecked( !m_pConfig->hasKey("MultipleTabConfirm") );
......@@ -270,6 +278,7 @@ void KMiscHTMLOptions::save()
m_pConfig->setGroup("FMSettings");
m_pConfig->writeEntry( "MMBOpensTab", m_pShowMMBInTabs->isChecked() );
m_pConfig->writeEntry( "NewTabsInFront", m_pNewTabsInFront->isChecked() );
m_pConfig->writeEntry( "OpenAfterCurrentPage", m_pOpenAfterCurrentPage->isChecked() );
// It only matters wether the key is present, its value has no meaning
m_pConfig->setGroup("Notification Messages");
......
......@@ -58,6 +58,7 @@ private:
QCheckBox* m_pNewTabsInFront;
QCheckBox* m_pTabConfirm;
QCheckBox* m_pFormCompletionCheckBox;
QCheckBox* m_pOpenAfterCurrentPage;
KIntNumInput* m_pMaxFormCompletionItems;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment