delay a few things on startup, such as setting the visibility mode, which ensures...
[personal-kdebase.git] / apps / konqueror / src / konqtabs.h
blobb6f7c66bb33cb028f4287b81fe002d83f8e50273
1 /* This file is part of the KDE project
3 Copyright (C) 2002-2003 Konqueror Developers <konq-e@kde.org>
4 Copyright (C) 2002-2003 Douglas Hanley <douglash@caltech.edu>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 MA 02110-1301, USA.
22 #ifndef KONQTABS_H
23 #define KONQTABS_H
25 #include "konqframe.h"
26 #include "konqframecontainer.h"
28 #include <ktabwidget.h>
29 #include <QtGui/QKeyEvent>
30 #include <QtCore/QList>
32 class QMenu;
33 class QToolButton;
35 class KonqView;
36 class KonqViewManager;
37 class KonqFrameContainerBase;
38 class KonqFrameContainer;
39 class KonqTabsStyle;
40 class KConfig;
42 class NewTabToolButton;
44 class KonqFrameTabs : public KTabWidget, public KonqFrameContainerBase
46 Q_OBJECT
47 friend class KonqFrame; //for emitting ctrlTabPressed() only, aleXXX
49 public:
50 KonqFrameTabs(QWidget* parent, KonqFrameContainerBase* parentContainer,
51 KonqViewManager* viewManager);
52 virtual ~KonqFrameTabs();
54 virtual bool accept( KonqFrameVisitor* visitor );
56 virtual void saveConfig( KConfigGroup& config, const QString &prefix, const KonqFrameBase::Options &options,
57 KonqFrameBase* docContainer, int id = 0, int depth = 0 );
58 virtual void copyHistory( KonqFrameBase *other );
60 const QList<KonqFrameBase*>& childFrameList() const { return m_childFrameList; }
62 virtual void setTitle( const QString &title, QWidget* sender );
63 virtual void setTabIcon( const KUrl &url, QWidget* sender );
65 virtual QWidget* asQWidget() { return this; }
66 virtual KonqFrameBase::FrameType frameType() const { return KonqFrameBase::Tabs; }
68 void activateChild();
70 /**
71 * Insert a new frame into the container.
73 void insertChildFrame(KonqFrameBase * frame, int index = -1);
75 /**
76 * Call this before deleting one of our children.
78 void childFrameRemoved( KonqFrameBase * frame );
80 virtual void replaceChildFrame(KonqFrameBase* oldFrame, KonqFrameBase* newFrame);
82 void moveTabBackward(int index);
83 void moveTabForward(int index);
85 void setLoading(KonqFrameBase* frame, bool loading);
87 /**
88 * Returns the tab that contains (directly or indirectly) the frame @p frame,
89 * or 0 if the frame is not in the tab widget.
91 KonqFrameBase* tabContaining(KonqFrameBase* frame) const;
93 public Q_SLOTS:
94 void slotCurrentChanged( int index );
95 void setAlwaysTabbedMode( bool );
97 Q_SIGNALS:
98 void ctrlTabPressed();
99 void removeTabPopup();
100 void openUrl(KonqView* view, const KUrl& url);
102 private:
103 void refreshSubPopupMenuTab();
104 void updateTabBarVisibility();
105 void initPopupMenu();
107 * Returns the index position of the tab where the frame @p frame is, assuming that
108 * it's the active frame in that tab,
109 * or -1 if the frame is not in the tab widget or it's not active.
111 int tabWhereActive(KonqFrameBase* frame) const;
113 private Q_SLOTS:
114 void slotContextMenu( const QPoint& );
115 void slotContextMenu( QWidget*, const QPoint& );
116 void slotCloseRequest( QWidget* );
117 void slotMovedTab( int, int );
118 void slotMouseMiddleClick();
119 void slotMouseMiddleClick( QWidget* );
121 void slotTestCanDecode(const QDragMoveEvent *e, bool &accept /* result */);
122 void slotReceivedDropEvent( QDropEvent* );
123 void slotInitiateDrag( QWidget * );
124 void slotReceivedDropEvent( QWidget *, QDropEvent * );
125 void slotSubPopupMenuTabActivated( QAction * );
127 private:
128 QList<KonqFrameBase*> m_childFrameList;
130 KonqViewManager* m_pViewManager;
131 QMenu* m_pPopupMenu;
132 QMenu* m_pSubPopupMenuTab;
133 QToolButton* m_rightWidget;
134 NewTabToolButton* m_leftWidget;
135 bool m_permanentCloseButtons;
136 bool m_alwaysTabBar;
137 bool m_MouseMiddleClickClosesTab;
138 KonqTabsStyle *m_konqTabsStyle;
139 QMap<QString,QAction*> m_popupActions;
141 friend class KonqTabsStyle;
144 #include <QToolButton>
146 class NewTabToolButton : public QToolButton // subclass with drag'n'drop functionality for links
148 Q_OBJECT
149 public:
150 NewTabToolButton( QWidget *parent )
151 : QToolButton( parent ) {
152 setAcceptDrops( true );
155 Q_SIGNALS:
156 void testCanDecode( const QDragMoveEvent *event, bool &accept );
157 void receivedDropEvent( QDropEvent *event );
159 protected:
160 void dragEnterEvent( QDragEnterEvent *event )
162 bool accept = false;
163 emit testCanDecode( event, accept );
164 if ( accept ) {
165 event->acceptProposedAction();
169 void dropEvent( QDropEvent *event )
171 emit receivedDropEvent( event );
172 event->acceptProposedAction();
176 #endif // KONQTABS_H