File indexing completed on 2023-05-30 09:09:59
0001 /* This file is part of the KDE project 0002 * 0003 * Copyright (C) 2008 Bernhard Beschow <bbeschow AT cs DOT tu-berlin de> 0004 * 0005 * This library is free software; you can redistribute it and/or 0006 * modify it under the terms of the GNU Library General Public 0007 * License as published by the Free Software Foundation; either 0008 * version 2 of the License, or (at your option) any later version. 0009 * 0010 * This library is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 * Library General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU Library General Public License 0016 * along with this library; see the file COPYING.LIB. If not, write to 0017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0018 * Boston, MA 02110-1301, USA. 0019 */ 0020 #include "khtmlviewbarwidget.h" 0021 0022 #include <QHBoxLayout> 0023 #include <QToolButton> 0024 #include <QResizeEvent> 0025 0026 KHTMLViewBarWidget::KHTMLViewBarWidget(bool addCloseButton, QWidget *parent) 0027 : QWidget(parent) 0028 { 0029 QHBoxLayout *layout = new QHBoxLayout; 0030 0031 // NOTE: Here be cosmetics. 0032 layout->setContentsMargins(2, 2, 2, 2); 0033 0034 // hide button 0035 if (addCloseButton) { 0036 QToolButton *hideButton = new QToolButton(this); 0037 hideButton->setAutoRaise(true); 0038 hideButton->setIcon(QIcon::fromTheme("dialog-close")); 0039 connect(hideButton, SIGNAL(clicked()), SIGNAL(hideMe())); 0040 layout->addWidget(hideButton); 0041 layout->setAlignment(hideButton, Qt::AlignLeft | Qt::AlignTop); 0042 } 0043 0044 // widget to be used as parent for the real content 0045 m_centralWidget = new QWidget(this); 0046 layout->addWidget(m_centralWidget); 0047 0048 setLayout(layout); 0049 setFocusProxy(m_centralWidget); 0050 } 0051 0052 void KHTMLViewBarWidget::resizeEvent(QResizeEvent *event) 0053 { 0054 if (event->size().width() != width()) { 0055 resize(event->size().width(), minimumSize().height()); 0056 } 0057 QWidget::resizeEvent(event); 0058 }