1 | /* This file is part of the KDE project |
2 | * |
3 | * Copyright (C) 2008 Bernhard Beschow <bbeschow AT cs DOT tu-berlin DOT de> |
4 | * |
5 | * This library is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU Library General Public |
7 | * License as published by the Free Software Foundation; either |
8 | * version 2 of the License, or (at your option) any later version. |
9 | * |
10 | * This library is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | * Library General Public License for more details. |
14 | * |
15 | * You should have received a copy of the GNU Library General Public License |
16 | * along with this library; see the file COPYING.LIB. If not, write to |
17 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 | * Boston, MA 02110-1301, USA. |
19 | */ |
20 | #ifndef _khtml_viewbar_h_ |
21 | #define _khtml_viewbar_h_ |
22 | |
23 | #include <QtGui/QWidget> |
24 | |
25 | class KHTMLView; |
26 | class KHTMLViewBarWidget; |
27 | |
28 | class KHTMLViewBar : public QWidget |
29 | { |
30 | Q_OBJECT |
31 | public: |
32 | enum Position { |
33 | Top, |
34 | Bottom |
35 | }; |
36 | |
37 | KHTMLViewBar(Position position, KHTMLView *view, QWidget *parent); |
38 | |
39 | /** |
40 | * Adds a widget to this viewbar. |
41 | * Widget is initially invisible, you should call showBarWidget, to show it. |
42 | * Several widgets can be added to the bar, but only one can be visible |
43 | */ |
44 | void addBarWidget(KHTMLViewBarWidget *newBarWidget); |
45 | |
46 | /** |
47 | * Shows barWidget that was previously added with addBarWidget. |
48 | * @see hideCurrentBarWidget |
49 | */ |
50 | void showBarWidget(KHTMLViewBarWidget *barWidget); |
51 | |
52 | /** |
53 | * Adds widget that will be always shown in the viewbar. |
54 | * After adding permanent widget viewbar is immediately shown. |
55 | * ViewBar with permanent widget won't hide itself |
56 | * until permanent widget is removed. |
57 | * OTOH showing/hiding regular barWidgets will work as usual |
58 | * (they will be shown above permanent widget) |
59 | * |
60 | * If permanent widget already exists, new one replaces old one |
61 | * Old widget is not deleted, caller can do it if it wishes |
62 | */ |
63 | void addPermanentBarWidget(KHTMLViewBarWidget *barWidget); |
64 | |
65 | /** |
66 | * Removes permanent bar widget from viewbar. |
67 | * If no other viewbar widgets are shown, viewbar gets hidden. |
68 | * |
69 | * barWidget is not deleted, caller must do it if it wishes |
70 | */ |
71 | void removePermanentBarWidget(KHTMLViewBarWidget *barWidget); |
72 | |
73 | /** |
74 | * @return if viewbar has permanent widget @p barWidget |
75 | */ |
76 | bool hasPermanentWidget(KHTMLViewBarWidget *barWidget) const; |
77 | |
78 | public Q_SLOTS: |
79 | /** |
80 | * Hides currently shown bar widget |
81 | */ |
82 | void hideCurrentBarWidget(); |
83 | |
84 | protected: |
85 | virtual void keyPressEvent(QKeyEvent* event); |
86 | virtual void hideEvent(QHideEvent* event); |
87 | |
88 | private: |
89 | bool hasWidget(KHTMLViewBarWidget*) const; |
90 | |
91 | /** |
92 | * Shows or hides whole viewbar |
93 | */ |
94 | void setViewBarVisible(bool visible); |
95 | |
96 | private: |
97 | KHTMLView *m_view; |
98 | KHTMLViewBarWidget *m_permanentBarWidget; |
99 | }; |
100 | |
101 | #endif |
102 | |