1/* 2 * Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Library General Public License for more details. 13 * 14 * You should have received a copy of the GNU Library General Public License 15 * along with this library; see the file COPYING.LIB. If not, write to 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 * 19 */ 20 21#include "config.h" 22#include "QWidgetPluginImpl.h" 23 24#include <QWidget> 25 26QWidgetPluginImpl::~QWidgetPluginImpl() 27{ 28 m_widget->deleteLater(); 29} 30 31void QWidgetPluginImpl::update(const QRect &rect) 32{ 33 m_widget->update(rect); 34} 35 36void QWidgetPluginImpl::setGeometryAndClip(const QRect &geometry, const QRect &clipRect, bool isVisible) 37{ 38 m_widget->setGeometry(geometry); 39 if (!clipRect.isNull()) { 40 QRect clip(clipRect.intersected(m_widget->rect())); 41 m_widget->setMask(QRegion(clip)); 42 } 43 m_widget->update(); 44 setVisible(isVisible); 45} 46 47void QWidgetPluginImpl::setVisible(bool visible) 48{ 49 // If setMask is set with an empty QRegion, no clipping will 50 // be performed, so in that case we hide the platformWidget. 51 QRegion mask = m_widget->mask(); 52 m_widget->setVisible(visible && !mask.isEmpty()); 53} 54 55void QWidgetPluginImpl::setStyleSheet(const QString &stylesheet) 56{ 57 m_widget->setStyleSheet(stylesheet); 58} 59 60void QWidgetPluginImpl::setWidgetParent(QObject *parent) 61{ 62 if (!parent->isWidgetType()) 63 return; 64 m_widget->setParent(qobject_cast<QWidget*>(parent)); 65} 66 67QObject* QWidgetPluginImpl::handle() const 68{ 69 return m_widget; 70} 71 72#include "moc_QWidgetPluginImpl.cpp" 73