• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KHTML

  • khtml
khtmlviewbar.cpp
Go to the documentation of this file.
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#include "khtmlviewbar.h"
21
22#include "khtmlview.h"
23#include "khtmlviewbarwidget.h"
24
25#include <kdebug.h>
26
27#include <QtGui/QBoxLayout>
28#include <QtGui/QKeyEvent>
29
30KHTMLViewBar::KHTMLViewBar( Position position, KHTMLView *view, QWidget *parent ) :
31 QWidget( parent ),
32 m_view( view ),
33 m_permanentBarWidget( 0 )
34{
35 const QBoxLayout::Direction direction = ( position == Top ? QBoxLayout::TopToBottom : QBoxLayout::BottomToTop );
36
37 setLayout( new QBoxLayout( direction, this ) );
38 layout()->setContentsMargins( 0, 0, 0, 0 );
39 layout()->setSpacing( 0 );
40}
41
42void KHTMLViewBar::addBarWidget (KHTMLViewBarWidget *newBarWidget)
43{
44 if (hasWidget(newBarWidget)) {
45 kDebug(6050) << "this bar widget is already added";
46 return;
47 }
48 // add new widget, invisible...
49 newBarWidget->hide();
50 layout()->addWidget( newBarWidget );
51 connect(newBarWidget, SIGNAL(hideMe()), SLOT(hideCurrentBarWidget()));
52
53 kDebug(6050) << "add barwidget " << newBarWidget;
54}
55
56void KHTMLViewBar::addPermanentBarWidget (KHTMLViewBarWidget *barWidget)
57{
58 // remove old widget from layout (if any)
59 if (m_permanentBarWidget) {
60 m_permanentBarWidget->hide();
61 layout()->removeWidget(m_permanentBarWidget);
62 }
63
64 layout()->addWidget(barWidget /*, 0, Qt::AlignBottom*/ ); // FIXME
65 m_permanentBarWidget = barWidget;
66 m_permanentBarWidget->show();
67
68 setViewBarVisible(true);
69}
70
71void KHTMLViewBar::removePermanentBarWidget (KHTMLViewBarWidget *barWidget)
72{
73 if (m_permanentBarWidget != barWidget) {
74 kDebug(6050) << "no such permanent widget exists in bar";
75 return;
76 }
77
78 if (!m_permanentBarWidget)
79 return;
80
81 m_permanentBarWidget->hide();
82 layout()->removeWidget(m_permanentBarWidget);
83 m_permanentBarWidget = 0;
84}
85
86bool KHTMLViewBar::hasPermanentWidget (KHTMLViewBarWidget *barWidget ) const
87{
88 return (m_permanentBarWidget == barWidget);
89}
90
91void KHTMLViewBar::showBarWidget (KHTMLViewBarWidget *barWidget)
92{
93 // raise correct widget
94// TODO m_stack->setCurrentWidget (barWidget);
95 barWidget->show();
96
97 // if we have any permanent widget, bar is always visible,
98 // no need to show it
99 if (!m_permanentBarWidget) {
100 setViewBarVisible(true);
101 }
102}
103
104bool KHTMLViewBar::hasWidget(KHTMLViewBarWidget* wid) const
105{
106 Q_UNUSED(wid);
107 return layout()->count() != 0;
108}
109
110void KHTMLViewBar::hideCurrentBarWidget ()
111{
112// m_stack->hide();
113
114 // if we have any permanent widget, bar is always visible,
115 // no need to hide it
116 if (!m_permanentBarWidget) {
117 setViewBarVisible(false);
118 }
119
120 m_view->setFocus();
121 kDebug(6050)<<"hide barwidget";
122}
123
124void KHTMLViewBar::setViewBarVisible (bool visible)
125{
126 setVisible( visible );
127}
128
129void KHTMLViewBar::keyPressEvent(QKeyEvent* event)
130{
131 if (event->key() == Qt::Key_Escape) {
132 hideCurrentBarWidget();
133 return;
134 }
135 QWidget::keyPressEvent(event);
136
137}
138
139void KHTMLViewBar::hideEvent(QHideEvent* event)
140{
141 Q_UNUSED(event);
142// if (!event->spontaneous())
143// m_view->setFocus();
144}
KHTMLViewBarWidget
Definition: khtmlviewbarwidget.h:26
KHTMLViewBar::hasPermanentWidget
bool hasPermanentWidget(KHTMLViewBarWidget *barWidget) const
Definition: khtmlviewbar.cpp:86
KHTMLViewBar::hideCurrentBarWidget
void hideCurrentBarWidget()
Hides currently shown bar widget.
Definition: khtmlviewbar.cpp:110
KHTMLViewBar::KHTMLViewBar
KHTMLViewBar(Position position, KHTMLView *view, QWidget *parent)
Definition: khtmlviewbar.cpp:30
KHTMLViewBar::addBarWidget
void addBarWidget(KHTMLViewBarWidget *newBarWidget)
Adds a widget to this viewbar.
Definition: khtmlviewbar.cpp:42
KHTMLViewBar::removePermanentBarWidget
void removePermanentBarWidget(KHTMLViewBarWidget *barWidget)
Removes permanent bar widget from viewbar.
Definition: khtmlviewbar.cpp:71
KHTMLViewBar::addPermanentBarWidget
void addPermanentBarWidget(KHTMLViewBarWidget *barWidget)
Adds widget that will be always shown in the viewbar.
Definition: khtmlviewbar.cpp:56
KHTMLViewBar::Position
Position
Definition: khtmlviewbar.h:32
KHTMLViewBar::Top
@ Top
Definition: khtmlviewbar.h:33
KHTMLViewBar::keyPressEvent
virtual void keyPressEvent(QKeyEvent *event)
Definition: khtmlviewbar.cpp:129
KHTMLViewBar::showBarWidget
void showBarWidget(KHTMLViewBarWidget *barWidget)
Shows barWidget that was previously added with addBarWidget.
Definition: khtmlviewbar.cpp:91
KHTMLViewBar::hideEvent
virtual void hideEvent(QHideEvent *event)
Definition: khtmlviewbar.cpp:139
KHTMLView
Renders and displays HTML in a QScrollArea.
Definition: khtmlview.h:93
QWidget
kDebug
#define kDebug
kdebug.h
khtmlview.h
khtmlviewbar.h
khtmlviewbarwidget.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KHTML

Skip menu "KHTML"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal