You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
610 lines
22 KiB
610 lines
22 KiB
15 years ago
|
/* This file is part of the KDE project
|
||
|
|
||
|
Copyright (C) 2002-2003 Konqueror Developers
|
||
|
2002-2003 Douglas Hanley <douglash@caltech.edu>
|
||
|
|
||
|
This program is free software; you can redistribute it and/or modify
|
||
|
it under the terms of the GNU General Public License as published by
|
||
|
the Free Software Foundation; either version 2 of the License, or
|
||
|
(at your option) any later version.
|
||
|
|
||
|
This program is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
GNU General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU General Public License
|
||
|
along with this program; if not, write to the Free Software
|
||
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||
|
MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
|
#include "konq_tabs.h"
|
||
|
|
||
14 years ago
|
#include <tqapplication.h>
|
||
13 years ago
|
#include <tqclipboard.h>
|
||
14 years ago
|
#include <tqptrlist.h>
|
||
|
#include <tqpopupmenu.h>
|
||
|
#include <tqtoolbutton.h>
|
||
|
#include <tqtooltip.h>
|
||
15 years ago
|
|
||
|
#include <kdebug.h>
|
||
|
#include <kiconloader.h>
|
||
12 years ago
|
#include <tdelocale.h>
|
||
15 years ago
|
#include <kurldrag.h>
|
||
|
#include <kstringhandler.h>
|
||
|
|
||
|
#include "konq_frame.h"
|
||
|
#include "konq_view.h"
|
||
|
#include "konq_viewmgr.h"
|
||
|
#include "konq_misc.h"
|
||
|
#include "konq_settingsxt.h"
|
||
|
|
||
12 years ago
|
#include <tdeaccelmanager.h>
|
||
15 years ago
|
#include <konq_pixmapprovider.h>
|
||
12 years ago
|
#include <tdestdaccel.h>
|
||
14 years ago
|
#include <tqtabbar.h>
|
||
|
#include <tqwhatsthis.h>
|
||
|
#include <tqstyle.h>
|
||
15 years ago
|
|
||
11 years ago
|
#define DUPLICATE_ID 3
|
||
|
#define RELOAD_ID 4
|
||
|
#define BREAKOFF_ID 5
|
||
|
#define CLOSETAB_ID 6
|
||
|
#define OTHERTABS_ID 7
|
||
|
#define MOVE_LEFT_ID 8
|
||
12 years ago
|
#define MOVE_RIGHT_ID 9
|
||
15 years ago
|
|
||
|
//###################################################################
|
||
|
|
||
14 years ago
|
KonqFrameTabs::KonqFrameTabs(TQWidget* parent, KonqFrameContainerBase* parentContainer,
|
||
15 years ago
|
KonqViewManager* viewManager, const char * name)
|
||
|
: KTabWidget(parent, name), m_rightWidget(0), m_leftWidget(0), m_alwaysTabBar(false),
|
||
|
m_closeOtherTabsId(0)
|
||
|
{
|
||
12 years ago
|
TDEAcceleratorManager::setNoAccel(this);
|
||
15 years ago
|
|
||
14 years ago
|
TQWhatsThis::add( tabBar(), i18n( "This bar contains the list of currently open tabs. Click on a tab to make it "
|
||
15 years ago
|
"active. The option to show a close button instead of the website icon in the left "
|
||
|
"corner of the tab is configurable. You can also use keyboard shortcuts to "
|
||
|
"navigate through tabs. The text on the tab is the title of the website "
|
||
|
"currently open in it, put your mouse over the tab too see the full title in "
|
||
|
"case it was truncated to fit the tab size." ) );
|
||
|
//kdDebug(1202) << "KonqFrameTabs::KonqFrameTabs()" << endl;
|
||
|
|
||
|
m_pParentContainer = parentContainer;
|
||
14 years ago
|
m_pChildFrameList = new TQPtrList<KonqFrameBase>;
|
||
15 years ago
|
m_pChildFrameList->setAutoDelete(false);
|
||
|
m_pActiveChild = 0L;
|
||
|
m_pViewManager = viewManager;
|
||
|
|
||
14 years ago
|
connect( this, TQT_SIGNAL( currentChanged ( TQWidget * ) ),
|
||
|
this, TQT_SLOT( slotCurrentChanged( TQWidget* ) ) );
|
||
15 years ago
|
|
||
14 years ago
|
m_pPopupMenu = new TQPopupMenu( this );
|
||
15 years ago
|
m_pPopupMenu->insertItem( SmallIcon( "tab_new" ),
|
||
|
i18n("&New Tab"),
|
||
|
m_pViewManager->mainWindow(),
|
||
14 years ago
|
TQT_SLOT( slotAddTab() ),
|
||
15 years ago
|
m_pViewManager->mainWindow()->action("newtab")->shortcut() );
|
||
|
m_pPopupMenu->insertItem( SmallIconSet( "reload" ),
|
||
|
i18n( "&Reload Tab" ),
|
||
|
m_pViewManager->mainWindow(),
|
||
14 years ago
|
TQT_SLOT( slotReloadPopup() ),
|
||
15 years ago
|
m_pViewManager->mainWindow()->action("reload")->shortcut(), RELOAD_ID );
|
||
|
m_pPopupMenu->insertItem( SmallIconSet( "tab_duplicate" ),
|
||
|
i18n("&Duplicate Tab"),
|
||
|
m_pViewManager->mainWindow(),
|
||
14 years ago
|
TQT_SLOT( slotDuplicateTabPopup() ),
|
||
11 years ago
|
m_pViewManager->mainWindow()->action("duplicatecurrenttab")->shortcut(),
|
||
15 years ago
|
DUPLICATE_ID );
|
||
|
m_pPopupMenu->insertItem( SmallIconSet( "tab_breakoff" ),
|
||
|
i18n("D&etach Tab"),
|
||
|
m_pViewManager->mainWindow(),
|
||
14 years ago
|
TQT_SLOT( slotBreakOffTabPopup() ),
|
||
15 years ago
|
m_pViewManager->mainWindow()->action("breakoffcurrenttab")->shortcut(),
|
||
|
BREAKOFF_ID );
|
||
|
m_pPopupMenu->insertSeparator();
|
||
12 years ago
|
m_pPopupMenu->insertItem( SmallIconSet( "tab_move_left" ),
|
||
|
i18n("Move Tab &Left"),
|
||
|
m_pViewManager->mainWindow(),
|
||
|
TQT_SLOT( slotMoveTabLeft() ),
|
||
|
m_pViewManager->mainWindow()->action("tab_move_left")->shortcut(),
|
||
|
MOVE_LEFT_ID );
|
||
|
m_pPopupMenu->insertItem( SmallIconSet( "tab_move_right" ),
|
||
|
i18n("Move Tab &Right"),
|
||
|
m_pViewManager->mainWindow(),
|
||
|
TQT_SLOT( slotMoveTabRight() ),
|
||
|
m_pViewManager->mainWindow()->action("tab_move_right")->shortcut(),
|
||
|
MOVE_RIGHT_ID );
|
||
|
m_pPopupMenu->insertSeparator();
|
||
14 years ago
|
m_pSubPopupMenuTab = new TQPopupMenu( this );
|
||
15 years ago
|
m_pPopupMenu->insertItem( i18n("Other Tabs" ), m_pSubPopupMenuTab, OTHERTABS_ID );
|
||
14 years ago
|
connect( m_pSubPopupMenuTab, TQT_SIGNAL( activated ( int ) ),
|
||
|
this, TQT_SLOT( slotSubPopupMenuTabActivated( int ) ) );
|
||
15 years ago
|
m_pPopupMenu->insertSeparator();
|
||
|
m_pPopupMenu->insertItem( SmallIconSet( "tab_remove" ),
|
||
|
i18n("&Close Tab"),
|
||
|
m_pViewManager->mainWindow(),
|
||
14 years ago
|
TQT_SLOT( slotRemoveTabPopup() ),
|
||
15 years ago
|
m_pViewManager->mainWindow()->action("removecurrenttab")->shortcut(),
|
||
|
CLOSETAB_ID );
|
||
14 years ago
|
connect( this, TQT_SIGNAL( contextMenu( TQWidget *, const TQPoint & ) ),
|
||
|
TQT_SLOT(slotContextMenu( TQWidget *, const TQPoint & ) ) );
|
||
|
connect( this, TQT_SIGNAL( contextMenu( const TQPoint & ) ),
|
||
|
TQT_SLOT(slotContextMenu( const TQPoint & ) ) );
|
||
15 years ago
|
|
||
|
m_MouseMiddleClickClosesTab = KonqSettings::mouseMiddleClickClosesTab();
|
||
|
|
||
|
m_permanentCloseButtons = KonqSettings::permanentCloseButton();
|
||
|
if (m_permanentCloseButtons) {
|
||
|
setHoverCloseButton( true );
|
||
|
setHoverCloseButtonDelayed( false );
|
||
|
}
|
||
|
else
|
||
|
setHoverCloseButton( KonqSettings::hoverCloseButton() );
|
||
|
setTabCloseActivatePrevious( KonqSettings::tabCloseActivatePrevious() );
|
||
|
if (KonqSettings::tabPosition()=="Bottom")
|
||
14 years ago
|
setTabPosition(TQTabWidget::Bottom);
|
||
|
connect( this, TQT_SIGNAL( closeRequest( TQWidget * )), TQT_SLOT(slotCloseRequest( TQWidget * )));
|
||
|
connect( this, TQT_SIGNAL( removeTabPopup() ),
|
||
|
m_pViewManager->mainWindow(), TQT_SLOT( slotRemoveTabPopup() ) );
|
||
15 years ago
|
|
||
|
if ( KonqSettings::addTabButton() ) {
|
||
14 years ago
|
m_leftWidget = new TQToolButton( this );
|
||
|
connect( m_leftWidget, TQT_SIGNAL( clicked() ),
|
||
|
m_pViewManager->mainWindow(), TQT_SLOT( slotAddTab() ) );
|
||
15 years ago
|
m_leftWidget->setIconSet( SmallIcon( "tab_new" ) );
|
||
|
m_leftWidget->adjustSize();
|
||
14 years ago
|
TQToolTip::add(m_leftWidget, i18n("Open a new tab"));
|
||
15 years ago
|
setCornerWidget( m_leftWidget, TopLeft );
|
||
|
}
|
||
|
if ( KonqSettings::closeTabButton() ) {
|
||
14 years ago
|
m_rightWidget = new TQToolButton( this );
|
||
|
connect( m_rightWidget, TQT_SIGNAL( clicked() ),
|
||
|
m_pViewManager->mainWindow(), TQT_SLOT( slotRemoveTab() ) );
|
||
15 years ago
|
m_rightWidget->setIconSet( SmallIconSet( "tab_remove" ) );
|
||
|
m_rightWidget->adjustSize();
|
||
14 years ago
|
TQToolTip::add(m_rightWidget, i18n("Close the current tab"));
|
||
15 years ago
|
setCornerWidget( m_rightWidget, TopRight );
|
||
|
}
|
||
|
|
||
|
setAutomaticResizeTabs( true );
|
||
|
setTabReorderingEnabled( true );
|
||
14 years ago
|
connect( this, TQT_SIGNAL( movedTab( int, int ) ),
|
||
|
TQT_SLOT( slotMovedTab( int, int ) ) );
|
||
|
connect( this, TQT_SIGNAL( mouseMiddleClick() ),
|
||
|
TQT_SLOT( slotMouseMiddleClick() ) );
|
||
|
connect( this, TQT_SIGNAL( mouseMiddleClick( TQWidget * ) ),
|
||
|
TQT_SLOT( slotMouseMiddleClick( TQWidget * ) ) );
|
||
|
connect( this, TQT_SIGNAL( mouseDoubleClick() ),
|
||
|
m_pViewManager->mainWindow(), TQT_SLOT( slotAddTab() ) );
|
||
|
|
||
|
connect( this, TQT_SIGNAL( testCanDecode(const TQDragMoveEvent *, bool & )),
|
||
|
TQT_SLOT( slotTestCanDecode(const TQDragMoveEvent *, bool & ) ) );
|
||
|
connect( this, TQT_SIGNAL( receivedDropEvent( TQDropEvent * )),
|
||
|
TQT_SLOT( slotReceivedDropEvent( TQDropEvent * ) ) );
|
||
|
connect( this, TQT_SIGNAL( receivedDropEvent( TQWidget *, TQDropEvent * )),
|
||
|
TQT_SLOT( slotReceivedDropEvent( TQWidget *, TQDropEvent * ) ) );
|
||
|
connect( this, TQT_SIGNAL( initiateDrag( TQWidget * )),
|
||
|
TQT_SLOT( slotInitiateDrag( TQWidget * ) ) );
|
||
11 years ago
|
|
||
|
setMouseWheelScroll(KonqSettings::tabsCycleWheel());
|
||
15 years ago
|
}
|
||
|
|
||
|
KonqFrameTabs::~KonqFrameTabs()
|
||
|
{
|
||
|
//kdDebug(1202) << "KonqFrameTabs::~KonqFrameTabs() " << this << " - " << className() << endl;
|
||
|
m_pChildFrameList->setAutoDelete(true);
|
||
|
delete m_pChildFrameList;
|
||
|
}
|
||
|
|
||
|
void KonqFrameTabs::listViews( ChildViewList *viewList ) {
|
||
14 years ago
|
for( TQPtrListIterator<KonqFrameBase> it( *m_pChildFrameList ); *it; ++it )
|
||
15 years ago
|
it.current()->listViews(viewList);
|
||
|
}
|
||
|
|
||
12 years ago
|
void KonqFrameTabs::saveConfig( TDEConfig* config, const TQString &prefix, bool saveURLs,
|
||
15 years ago
|
KonqFrameBase* docContainer, int id, int depth )
|
||
|
{
|
||
|
//write children
|
||
14 years ago
|
TQStringList strlst;
|
||
15 years ago
|
int i = 0;
|
||
14 years ago
|
TQString newPrefix;
|
||
15 years ago
|
for (KonqFrameBase* it = m_pChildFrameList->first(); it; it = m_pChildFrameList->next())
|
||
|
{
|
||
13 years ago
|
newPrefix = TQString::fromLatin1( it->frameType() ) + "T" + TQString::number(i);
|
||
15 years ago
|
strlst.append( newPrefix );
|
||
|
newPrefix.append( '_' );
|
||
|
it->saveConfig( config, newPrefix, saveURLs, docContainer, id, depth + i );
|
||
|
i++;
|
||
|
}
|
||
|
|
||
13 years ago
|
config->writeEntry( TQString::fromLatin1( "Children" ).prepend( prefix ), strlst );
|
||
15 years ago
|
|
||
13 years ago
|
config->writeEntry( TQString::fromLatin1( "activeChildIndex" ).prepend( prefix ),
|
||
15 years ago
|
currentPageIndex() );
|
||
|
}
|
||
|
|
||
|
void KonqFrameTabs::copyHistory( KonqFrameBase *other )
|
||
|
{
|
||
|
if( other->frameType() != "Tabs" ) {
|
||
|
kdDebug(1202) << "Frame types are not the same" << endl;
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
for (uint i = 0; i < m_pChildFrameList->count(); i++ )
|
||
|
{
|
||
13 years ago
|
m_pChildFrameList->at(i)->copyHistory( static_cast<KonqFrameTabs *>( other )->m_pChildFrameList->at(i) );
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
14 years ago
|
void KonqFrameTabs::printFrameInfo( const TQString& spaces )
|
||
15 years ago
|
{
|
||
|
kdDebug(1202) << spaces << "KonqFrameTabs " << this << " visible="
|
||
13 years ago
|
<< TQString("%1").arg(isVisible()) << " activeChild="
|
||
15 years ago
|
<< m_pActiveChild << endl;
|
||
|
|
||
|
if (!m_pActiveChild)
|
||
|
kdDebug(1202) << "WARNING: " << this << " has a null active child!" << endl;
|
||
|
|
||
|
KonqFrameBase* child;
|
||
|
int childFrameCount = m_pChildFrameList->count();
|
||
|
for (int i = 0 ; i < childFrameCount ; i++) {
|
||
13 years ago
|
child = m_pChildFrameList->at(i);
|
||
15 years ago
|
if (child != 0L)
|
||
|
child->printFrameInfo(spaces + " ");
|
||
|
else
|
||
|
kdDebug(1202) << spaces << " Null child" << endl;
|
||
|
}
|
||
|
}
|
||
|
|
||
14 years ago
|
void KonqFrameTabs::reparentFrame( TQWidget* parent, const TQPoint & p, bool showIt )
|
||
15 years ago
|
{
|
||
14 years ago
|
TQWidget::reparent( parent, p, showIt );
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
void KonqFrameTabs::setTitle( const TQString &title , TQWidget* sender)
|
||
15 years ago
|
{
|
||
|
// kdDebug(1202) << "KonqFrameTabs::setTitle( " << title << " , " << sender << " )" << endl;
|
||
|
setTabLabel( sender,title );
|
||
|
}
|
||
|
|
||
14 years ago
|
void KonqFrameTabs::setTabIcon( const KURL &url, TQWidget* sender )
|
||
15 years ago
|
{
|
||
|
//kdDebug(1202) << "KonqFrameTabs::setTabIcon( " << url << " , " << sender << " )" << endl;
|
||
14 years ago
|
TQIconSet iconSet;
|
||
15 years ago
|
if (m_permanentCloseButtons)
|
||
10 years ago
|
iconSet = SmallIcon( "window-close" );
|
||
15 years ago
|
else
|
||
|
iconSet = SmallIconSet( KonqPixmapProvider::self()->iconNameFor( url.url() ) );
|
||
|
if (tabIconSet( sender ).pixmap().serialNumber() != iconSet.pixmap().serialNumber())
|
||
|
setTabIconSet( sender, iconSet );
|
||
|
}
|
||
|
|
||
|
void KonqFrameTabs::activateChild()
|
||
|
{
|
||
|
if (m_pActiveChild)
|
||
|
{
|
||
|
showPage( m_pActiveChild->widget() );
|
||
|
m_pActiveChild->activateChild();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void KonqFrameTabs::insertChildFrame( KonqFrameBase* frame, int index )
|
||
|
{
|
||
|
//kdDebug(1202) << "KonqFrameTabs " << this << ": insertChildFrame " << frame << endl;
|
||
|
|
||
|
if (frame)
|
||
|
{
|
||
|
//kdDebug(1202) << "Adding frame" << endl;
|
||
|
bool showTabBar = (count() == 1);
|
||
|
insertTab(frame->widget(),"", index);
|
||
|
frame->setParentContainer(this);
|
||
|
if (index == -1) m_pChildFrameList->append(frame);
|
||
|
else m_pChildFrameList->insert(index, frame);
|
||
|
if (m_rightWidget)
|
||
|
m_rightWidget->setEnabled( m_pChildFrameList->count()>1 );
|
||
|
KonqView* activeChildView = frame->activeChildView();
|
||
|
if (activeChildView != 0L) {
|
||
|
activeChildView->setCaption( activeChildView->caption() );
|
||
|
activeChildView->setTabIcon( activeChildView->url() );
|
||
|
}
|
||
|
if (showTabBar)
|
||
|
setTabBarHidden(false);
|
||
|
else if ( count() == 1 )
|
||
|
this->hideTabBar();//the first frame inserted (initialization)
|
||
|
}
|
||
|
else
|
||
|
kdWarning(1202) << "KonqFrameTabs " << this << ": insertChildFrame(0L) !" << endl;
|
||
|
}
|
||
|
|
||
|
void KonqFrameTabs::removeChildFrame( KonqFrameBase * frame )
|
||
|
{
|
||
|
//kdDebug(1202) << "KonqFrameTabs::RemoveChildFrame " << this << ". Child " << frame << " removed" << endl;
|
||
|
if (frame) {
|
||
|
removePage(frame->widget());
|
||
|
m_pChildFrameList->remove(frame);
|
||
|
if (m_rightWidget)
|
||
|
m_rightWidget->setEnabled( m_pChildFrameList->count()>1 );
|
||
|
if (count() == 1)
|
||
|
hideTabBar();
|
||
|
}
|
||
|
else
|
||
|
kdWarning(1202) << "KonqFrameTabs " << this << ": removeChildFrame(0L) !" << endl;
|
||
|
|
||
|
//kdDebug(1202) << "KonqFrameTabs::RemoveChildFrame finished" << endl;
|
||
|
}
|
||
|
|
||
14 years ago
|
void KonqFrameTabs::slotCurrentChanged( TQWidget* newPage )
|
||
15 years ago
|
{
|
||
12 years ago
|
setTabColor( newPage, TDEGlobalSettings::textColor() );
|
||
14 years ago
|
KonqFrameBase* currentFrame = tqt_dynamic_cast<KonqFrameBase*>(newPage);
|
||
15 years ago
|
|
||
|
if (currentFrame && !m_pViewManager->isLoadingProfile()) {
|
||
|
m_pActiveChild = currentFrame;
|
||
|
currentFrame->activateChild();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void KonqFrameTabs::moveTabBackward( int index )
|
||
|
{
|
||
|
if ( index == 0 )
|
||
|
return;
|
||
|
moveTab( index, index-1 );
|
||
|
}
|
||
|
|
||
|
void KonqFrameTabs::moveTabForward( int index )
|
||
|
{
|
||
|
if ( index == count()-1 )
|
||
|
return;
|
||
|
moveTab( index, index+1 );
|
||
|
}
|
||
|
|
||
|
void KonqFrameTabs::slotMovedTab( int from, int to )
|
||
|
{
|
||
13 years ago
|
KonqFrameBase* fromFrame = m_pChildFrameList->at( from );
|
||
15 years ago
|
m_pChildFrameList->remove( fromFrame );
|
||
|
m_pChildFrameList->insert( to, fromFrame );
|
||
|
|
||
14 years ago
|
KonqFrameBase* currentFrame = tqt_dynamic_cast<KonqFrameBase*>( currentPage() );
|
||
15 years ago
|
if ( currentFrame && !m_pViewManager->isLoadingProfile() ) {
|
||
|
m_pActiveChild = currentFrame;
|
||
|
currentFrame->activateChild();
|
||
|
}
|
||
|
}
|
||
|
|
||
14 years ago
|
void KonqFrameTabs::slotContextMenu( const TQPoint &p )
|
||
15 years ago
|
{
|
||
|
refreshSubPopupMenuTab();
|
||
11 years ago
|
|
||
15 years ago
|
m_pPopupMenu->setItemEnabled( RELOAD_ID, false );
|
||
|
m_pPopupMenu->setItemEnabled( DUPLICATE_ID, false );
|
||
|
m_pPopupMenu->setItemEnabled( BREAKOFF_ID, false );
|
||
11 years ago
|
|
||
|
uint tabCount = m_pChildFrameList->count();
|
||
|
KonqView *kview = m_pViewManager->mainWindow()->currentView();
|
||
|
if (tabCount>1 && kview)
|
||
|
{
|
||
|
// Move tab left
|
||
|
bool left_enable = false, right_enable = false;
|
||
|
if (TQApplication::reverseLayout())
|
||
|
{
|
||
|
left_enable = (kview->frame() != m_pChildFrameList->last());
|
||
|
right_enable= (kview->frame() != m_pChildFrameList->first());
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
left_enable = (kview->frame() != m_pChildFrameList->first());
|
||
|
right_enable= (kview->frame() != m_pChildFrameList->last());
|
||
|
}
|
||
|
m_pPopupMenu->setItemEnabled( MOVE_LEFT_ID, left_enable);
|
||
|
m_pPopupMenu->setItemEnabled( MOVE_RIGHT_ID, right_enable);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
m_pPopupMenu->setItemEnabled(MOVE_LEFT_ID, false);
|
||
|
m_pPopupMenu->setItemEnabled(MOVE_RIGHT_ID, false);
|
||
|
}
|
||
|
|
||
15 years ago
|
m_pPopupMenu->setItemEnabled( CLOSETAB_ID, false );
|
||
|
m_pPopupMenu->setItemEnabled( OTHERTABS_ID, true );
|
||
|
m_pSubPopupMenuTab->setItemEnabled( m_closeOtherTabsId, false );
|
||
12 years ago
|
|
||
15 years ago
|
m_pPopupMenu->exec( p );
|
||
|
}
|
||
|
|
||
14 years ago
|
void KonqFrameTabs::slotContextMenu( TQWidget *w, const TQPoint &p )
|
||
15 years ago
|
{
|
||
|
refreshSubPopupMenuTab();
|
||
11 years ago
|
|
||
15 years ago
|
uint tabCount = m_pChildFrameList->count();
|
||
|
m_pPopupMenu->setItemEnabled( RELOAD_ID, true );
|
||
|
m_pPopupMenu->setItemEnabled( DUPLICATE_ID, true );
|
||
|
m_pPopupMenu->setItemEnabled( BREAKOFF_ID, tabCount>1 );
|
||
11 years ago
|
|
||
|
KonqView *kview = m_pViewManager->mainWindow()->currentView();
|
||
|
if (tabCount>1 && kview)
|
||
|
{
|
||
|
// Move tab left
|
||
|
bool left_enable = false, right_enable = false;
|
||
|
if (TQApplication::reverseLayout())
|
||
|
{
|
||
|
left_enable = (kview->frame() != m_pChildFrameList->last());
|
||
|
right_enable= (kview->frame() != m_pChildFrameList->first());
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
left_enable = (kview->frame() != m_pChildFrameList->first());
|
||
|
right_enable= (kview->frame() != m_pChildFrameList->last());
|
||
|
}
|
||
|
m_pPopupMenu->setItemEnabled( MOVE_LEFT_ID, left_enable);
|
||
|
m_pPopupMenu->setItemEnabled( MOVE_RIGHT_ID, right_enable);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
m_pPopupMenu->setItemEnabled(MOVE_LEFT_ID, false);
|
||
|
m_pPopupMenu->setItemEnabled(MOVE_RIGHT_ID, false);
|
||
|
}
|
||
|
|
||
15 years ago
|
m_pPopupMenu->setItemEnabled( CLOSETAB_ID, tabCount>1 );
|
||
|
m_pPopupMenu->setItemEnabled( OTHERTABS_ID, tabCount>1 );
|
||
|
m_pSubPopupMenuTab->setItemEnabled( m_closeOtherTabsId, true );
|
||
|
|
||
14 years ago
|
// Yes, I know this is an unchecked tqt_dynamic_cast - I'm casting sideways in a
|
||
15 years ago
|
// class hierarchy and it could crash one day, but I haven't checked
|
||
|
// setWorkingTab so I don't know if it can handle nulls.
|
||
|
|
||
14 years ago
|
m_pViewManager->mainWindow()->setWorkingTab( tqt_dynamic_cast<KonqFrameBase*>(w) );
|
||
15 years ago
|
m_pPopupMenu->exec( p );
|
||
|
}
|
||
|
|
||
|
void KonqFrameTabs::refreshSubPopupMenuTab()
|
||
|
{
|
||
|
m_pSubPopupMenuTab->clear();
|
||
|
int i=0;
|
||
|
m_pSubPopupMenuTab->insertItem( SmallIcon( "reload_all_tabs" ),
|
||
|
i18n( "&Reload All Tabs" ),
|
||
|
m_pViewManager->mainWindow(),
|
||
14 years ago
|
TQT_SLOT( slotReloadAllTabs() ),
|
||
15 years ago
|
m_pViewManager->mainWindow()->action("reload_all_tabs")->shortcut() );
|
||
|
m_pSubPopupMenuTab->insertSeparator();
|
||
|
for (KonqFrameBase* it = m_pChildFrameList->first(); it; it = m_pChildFrameList->next())
|
||
|
{
|
||
|
KonqFrame* frame = dynamic_cast<KonqFrame *>(it);
|
||
|
if ( frame && frame->activeChildView() )
|
||
|
{
|
||
14 years ago
|
TQString title = frame->title().stripWhiteSpace();
|
||
15 years ago
|
if ( title.isEmpty() )
|
||
|
title = frame->activeChildView()->url().url();
|
||
|
title = KStringHandler::csqueeze( title, 50 );
|
||
14 years ago
|
m_pSubPopupMenuTab->insertItem( TQIconSet( KonqPixmapProvider::self()->pixmapFor( frame->activeChildView()->url().url() ) ), title, i );
|
||
15 years ago
|
|
||
|
}
|
||
|
i++;
|
||
|
}
|
||
|
m_pSubPopupMenuTab->insertSeparator();
|
||
|
m_closeOtherTabsId =
|
||
|
m_pSubPopupMenuTab->insertItem( SmallIconSet( "tab_remove_other" ),
|
||
|
i18n( "Close &Other Tabs" ),
|
||
|
m_pViewManager->mainWindow(),
|
||
14 years ago
|
TQT_SLOT( slotRemoveOtherTabsPopup() ),
|
||
15 years ago
|
m_pViewManager->mainWindow()->action("removeothertabs")->shortcut() );
|
||
|
}
|
||
|
|
||
14 years ago
|
void KonqFrameTabs::slotCloseRequest( TQWidget *w )
|
||
15 years ago
|
{
|
||
|
if ( m_pChildFrameList->count() > 1 ) {
|
||
14 years ago
|
// Yes, I know this is an unchecked tqt_dynamic_cast - I'm casting sideways in a class hierarchy and it could crash one day, but I haven't checked setWorkingTab so I don't know if it can handle nulls.
|
||
|
m_pViewManager->mainWindow()->setWorkingTab( tqt_dynamic_cast<KonqFrameBase*>(w) );
|
||
15 years ago
|
emit ( removeTabPopup() );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void KonqFrameTabs::slotSubPopupMenuTabActivated( int _id)
|
||
|
{
|
||
|
setCurrentPage( _id );
|
||
|
}
|
||
|
|
||
|
void KonqFrameTabs::slotMouseMiddleClick()
|
||
|
{
|
||
13 years ago
|
TQApplication::clipboard()->setSelectionMode( TQClipboard::Selection );
|
||
|
KURL filteredURL ( KonqMisc::konqFilteredURL( this, TQApplication::clipboard()->text() ) );
|
||
15 years ago
|
if ( !filteredURL.isEmpty() ) {
|
||
14 years ago
|
KonqView* newView = m_pViewManager->addTab(TQString::null, TQString::null, false, false);
|
||
15 years ago
|
if (newView == 0L) return;
|
||
14 years ago
|
m_pViewManager->mainWindow()->openURL( newView, filteredURL, TQString::null );
|
||
15 years ago
|
m_pViewManager->showTab( newView );
|
||
|
m_pViewManager->mainWindow()->focusLocationBar();
|
||
|
}
|
||
|
}
|
||
|
|
||
14 years ago
|
void KonqFrameTabs::slotMouseMiddleClick( TQWidget *w )
|
||
15 years ago
|
{
|
||
|
if ( m_MouseMiddleClickClosesTab ) {
|
||
|
if ( m_pChildFrameList->count() > 1 ) {
|
||
14 years ago
|
// Yes, I know this is an unchecked tqt_dynamic_cast - I'm casting sideways in a class hierarchy and it could crash one day, but I haven't checked setWorkingTab so I don't know if it can handle nulls.
|
||
|
m_pViewManager->mainWindow()->setWorkingTab( tqt_dynamic_cast<KonqFrameBase*>(w) );
|
||
15 years ago
|
emit ( removeTabPopup() );
|
||
|
}
|
||
|
}
|
||
|
else {
|
||
13 years ago
|
TQApplication::clipboard()->setSelectionMode( TQClipboard::Selection );
|
||
|
KURL filteredURL ( KonqMisc::konqFilteredURL( this, TQApplication::clipboard()->text() ) );
|
||
15 years ago
|
if ( !filteredURL.isEmpty() ) {
|
||
14 years ago
|
KonqFrameBase* frame = tqt_dynamic_cast<KonqFrameBase*>(w);
|
||
15 years ago
|
if (frame) {
|
||
|
m_pViewManager->mainWindow()->openURL( frame->activeChildView(), filteredURL );
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
14 years ago
|
void KonqFrameTabs::slotTestCanDecode(const TQDragMoveEvent *e, bool &accept /* result */)
|
||
15 years ago
|
{
|
||
|
accept = KURLDrag::canDecode( e );
|
||
|
}
|
||
|
|
||
14 years ago
|
void KonqFrameTabs::slotReceivedDropEvent( TQDropEvent *e )
|
||
15 years ago
|
{
|
||
|
KURL::List lstDragURLs;
|
||
|
bool ok = KURLDrag::decode( e, lstDragURLs );
|
||
|
if ( ok && lstDragURLs.first().isValid() ) {
|
||
14 years ago
|
KonqView* newView = m_pViewManager->addTab(TQString::null, TQString::null, false, false);
|
||
15 years ago
|
if (newView == 0L) return;
|
||
14 years ago
|
m_pViewManager->mainWindow()->openURL( newView, lstDragURLs.first(), TQString::null );
|
||
15 years ago
|
m_pViewManager->showTab( newView );
|
||
|
m_pViewManager->mainWindow()->focusLocationBar();
|
||
|
}
|
||
|
}
|
||
|
|
||
14 years ago
|
void KonqFrameTabs::slotReceivedDropEvent( TQWidget *w, TQDropEvent *e )
|
||
15 years ago
|
{
|
||
|
KURL::List lstDragURLs;
|
||
|
bool ok = KURLDrag::decode( e, lstDragURLs );
|
||
14 years ago
|
KonqFrameBase* frame = tqt_dynamic_cast<KonqFrameBase*>(w);
|
||
15 years ago
|
if ( ok && lstDragURLs.first().isValid() && frame ) {
|
||
|
KURL lstDragURL = lstDragURLs.first();
|
||
|
if ( lstDragURL != frame->activeChildView()->url() )
|
||
|
m_pViewManager->mainWindow()->openURL( frame->activeChildView(), lstDragURL );
|
||
|
}
|
||
|
}
|
||
|
|
||
14 years ago
|
void KonqFrameTabs::slotInitiateDrag( TQWidget *w )
|
||
15 years ago
|
{
|
||
14 years ago
|
KonqFrameBase* frame = tqt_dynamic_cast<KonqFrameBase*>( w );
|
||
15 years ago
|
if (frame) {
|
||
|
KURL::List lst;
|
||
|
lst.append( frame->activeChildView()->url() );
|
||
|
KURLDrag *d = new KURLDrag( lst, this );
|
||
12 years ago
|
d->setPixmap( KMimeType::pixmapForURL( lst.first(), 0, TDEIcon::Small ) );
|
||
15 years ago
|
d->dragCopy();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void KonqFrameTabs::hideTabBar()
|
||
|
{
|
||
|
if ( !m_alwaysTabBar ) {
|
||
|
setTabBarHidden(true);
|
||
|
}
|
||
|
m_pPopupMenu->setItemEnabled( BREAKOFF_ID, false );
|
||
12 years ago
|
m_pPopupMenu->setItemEnabled( MOVE_LEFT_ID, false );
|
||
|
m_pPopupMenu->setItemEnabled( MOVE_RIGHT_ID, false );
|
||
15 years ago
|
m_pPopupMenu->setItemEnabled( CLOSETAB_ID, false );
|
||
|
}
|
||
|
|
||
|
void KonqFrameTabs::setAlwaysTabbedMode( bool enable )
|
||
|
{
|
||
|
bool update = ( enable != m_alwaysTabBar );
|
||
|
|
||
|
m_alwaysTabBar = enable;
|
||
|
if ( update ) {
|
||
|
if ( m_alwaysTabBar )
|
||
|
setTabBarHidden(false);
|
||
|
else
|
||
|
hideTabBar();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#include "konq_tabs.moc"
|