File indexing completed on 2024-12-22 04:40:20
0001 /* 0002 SPDX-FileCopyrightText: 2007-2009 Sergio Pistone <sergio_pistone@yahoo.com.ar> 0003 SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic <max@smoothware.net> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #include "layeredwidget.h" 0009 0010 #include <typeinfo> 0011 0012 #include <QResizeEvent> 0013 0014 LayeredWidget::LayeredWidget(QWidget *parent, Qt::WindowFlags f) : 0015 QWidget(parent, f) 0016 {} 0017 0018 void 0019 LayeredWidget::setWidgetMode(QWidget *widget, LayeredWidget::Mode mode) 0020 { 0021 m_ignoredWidgets.removeAll(widget); 0022 if(mode == IgnoreResize) 0023 m_ignoredWidgets.append(widget); 0024 } 0025 0026 void 0027 LayeredWidget::setMouseTracking(bool enable) 0028 { 0029 // propagates to our children and our children children's 0030 QWidget::setMouseTracking(enable); 0031 QList<QWidget *> children = findChildren<QWidget *>(); 0032 for(QList<QWidget *>::ConstIterator it = children.constBegin(), end = children.constEnd(); it != end; ++it) 0033 (*it)->setMouseTracking(enable); 0034 } 0035 0036 void 0037 LayeredWidget::resizeEvent(QResizeEvent *) 0038 { 0039 // propagated to our children but not our children children's 0040 QSize size = this->size(); 0041 const QObjectList &children = this->children(); 0042 for(QObjectList::ConstIterator it = children.begin(), end = children.end(); it != end; ++it) { 0043 if(!(*it)->isWidgetType() || m_ignoredWidgets.contains(*it)) 0044 continue; 0045 (static_cast<QWidget *>(*it))->resize(size); 0046 } 0047 } 0048 0049