File indexing completed on 2024-05-19 05:42:16
0001 // ct_lvtqtc_graphicsrectitem.h -*-C++-*- 0002 0003 /* 0004 // Copyright 2023 Codethink Ltd <codethink@codethink.co.uk> 0005 // SPDX-License-Identifier: Apache-2.0 0006 // 0007 // Licensed under the Apache License, Version 2.0 (the "License"); 0008 // you may not use this file except in compliance with the License. 0009 // You may obtain a copy of the License at 0010 // 0011 // http://www.apache.org/licenses/LICENSE-2.0 0012 // 0013 // Unless required by applicable law or agreed to in writing, software 0014 // distributed under the License is distributed on an "AS IS" BASIS, 0015 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 0016 // See the License for the specific language governing permissions and 0017 // limitations under the License. 0018 */ 0019 0020 #ifndef DEFINED_CT_LVTQTC_GRAPHICSRECTITEM 0021 #define DEFINED_CT_LVTQTC_GRAPHICSRECTITEM 0022 0023 #include <lvtqtc_export.h> 0024 0025 #include <QGraphicsRectItem> 0026 #include <QObject> 0027 0028 #include <memory> 0029 0030 namespace Codethink::lvtqtc { 0031 0032 class LVTQTC_EXPORT GraphicsRectItem : public QObject, public QGraphicsRectItem { 0033 // QGraphicsRectItem plus extra functionality 0034 Q_OBJECT 0035 Q_PROPERTY(QRectF rect READ rect WRITE setRectangle NOTIFY rectangleChanged) 0036 0037 public: 0038 explicit GraphicsRectItem(QGraphicsItem *parent = nullptr); 0039 ~GraphicsRectItem() override; 0040 0041 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override; 0042 void setRectangle(const QRectF& rect); 0043 0044 [[nodiscard]] QPainterPath shape() const override; 0045 0046 void setRoundRadius(qreal radius); 0047 [[nodiscard]] qreal roundRadius() const; 0048 0049 void setXRadius(qreal radius); 0050 void setYRadius(qreal radius); 0051 0052 void setNumOutlines(int numOutlines); 0053 0054 Q_SIGNAL void rectangleChanged(); 0055 // setRectangle was called. 0056 0057 private: 0058 using QGraphicsRectItem::setRect; 0059 0060 struct Private; 0061 std::unique_ptr<Private> d; 0062 }; 0063 0064 } // namespace Codethink::lvtqtc 0065 0066 #endif