KHtml

khtmlviewbarwidget.cpp
1 /* This file is part of the KDE project
2  *
3  * Copyright (C) 2008 Bernhard Beschow <bbeschow AT cs DOT tu-berlin 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 "khtmlviewbarwidget.h"
21 
22 #include <QHBoxLayout>
23 #include <QToolButton>
24 #include <QResizeEvent>
25 
26 KHTMLViewBarWidget::KHTMLViewBarWidget(bool addCloseButton, QWidget *parent)
27  : QWidget(parent)
28 {
30 
31  // NOTE: Here be cosmetics.
32  layout->setContentsMargins(2, 2, 2, 2);
33 
34  // hide button
35  if (addCloseButton) {
36  QToolButton *hideButton = new QToolButton(this);
37  hideButton->setAutoRaise(true);
38  hideButton->setIcon(QIcon::fromTheme("dialog-close"));
39  connect(hideButton, SIGNAL(clicked()), SIGNAL(hideMe()));
40  layout->addWidget(hideButton);
41  layout->setAlignment(hideButton, Qt::AlignLeft | Qt::AlignTop);
42  }
43 
44  // widget to be used as parent for the real content
45  m_centralWidget = new QWidget(this);
46  layout->addWidget(m_centralWidget);
47 
48  setLayout(layout);
49  setFocusProxy(m_centralWidget);
50 }
51 
52 void KHTMLViewBarWidget::resizeEvent(QResizeEvent *event)
53 {
54  if (event->size().width() != width()) {
55  resize(event->size().width(), minimumSize().height());
56  }
57  QWidget::resizeEvent(event);
58 }
void resize(int w, int h)
void setContentsMargins(int left, int top, int right, int bottom)
int width() const const
void setIcon(const QIcon &icon)
AlignLeft
int width() const const
QSize minimumSize() const const
void layout()
ensure the display is up to date
Definition: khtmlview.cpp:981
void addWidget(QWidget *widget, int stretch, Qt::Alignment alignment)
void setLayout(QLayout *layout)
void setFocusProxy(QWidget *w)
void setAutoRaise(bool enable)
const QSize & size() const const
bool setAlignment(QWidget *w, Qt::Alignment alignment)
QWidget(QWidget *parent, Qt::WindowFlags f)
int height() const const
QIcon fromTheme(const QString &name)
virtual void resizeEvent(QResizeEvent *event)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Oct 16 2021 22:47:56 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.