File indexing completed on 2025-01-26 05:06:22
0001 /* 0002 SPDX-FileCopyrightText: 2014-2015 Eike Hein <hein@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "rubberband.h" 0008 0009 #include <QApplication> 0010 #include <QStyleOptionRubberBand> 0011 0012 RubberBand::RubberBand(QQuickItem *parent) 0013 : QQuickPaintedItem(parent) 0014 { 0015 } 0016 0017 RubberBand::~RubberBand() 0018 { 0019 } 0020 0021 void RubberBand::paint(QPainter *painter) 0022 { 0023 if (!qApp || !qApp->style()) { 0024 return; 0025 } 0026 0027 QStyleOptionRubberBand opt; 0028 opt.state = QStyle::State_None; 0029 opt.direction = qApp->layoutDirection(); 0030 opt.styleObject = this; 0031 opt.palette = qApp->palette(); 0032 opt.shape = QRubberBand::Rectangle; 0033 opt.opaque = false; 0034 opt.rect = contentsBoundingRect().toRect(); 0035 qApp->style()->drawControl(QStyle::CE_RubberBand, &opt, painter); 0036 } 0037 0038 bool RubberBand::intersects(const QRectF &rect) const 0039 { 0040 return m_geometry.intersects(rect); 0041 } 0042 0043 void RubberBand::geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) 0044 { 0045 Q_UNUSED(oldGeometry); 0046 0047 m_geometry = newGeometry; 0048 QQuickItem::geometryChange(newGeometry, oldGeometry); 0049 }