File indexing completed on 2024-12-22 04:13:18

0001 /* This file is part of the KDE project
0002  * Made by Tomislav Lukman (tomislav.lukman@ck.tel.hr)
0003  * SPDX-FileCopyrightText: 2002 Tomislav Lukman <tomislav.lukman@ck.t-com.hr>
0004  * SPDX-FileCopyrightText: 2002 Rob Buis <buis@kde.org>
0005  * SPDX-FileCopyrightText: 2004 Laurent Montel <montel@kde.org>
0006  * SPDX-FileCopyrightText: 2005-2006 Tim Beaulen <tbscope@gmail.com>
0007  * SPDX-FileCopyrightText: 2005 Inge Wallin <inge@lysator.liu.se>
0008  * SPDX-FileCopyrightText: 2005, 2011 Thomas Zander <zander@kde.org>
0009  * SPDX-FileCopyrightText: 2005-2008 Jan Hambrecht <jaham@gmx.net>
0010  * SPDX-FileCopyrightText: 2006 C. Boemann <cbo@boemann.dk>
0011  * SPDX-FileCopyrightText: 2011 Jean-Nicolas Artaud <jeannicolasartaud@gmail.com>
0012  * SPDX-FileCopyrightText: 2011 Thorsten Zachmann <zachmann@kde.com>
0013  *
0014  * SPDX-License-Identifier: LGPL-2.0-or-later
0015  */
0016 
0017 #ifndef STROKECONFIGWIDGET_H
0018 #define STROKECONFIGWIDGET_H
0019 
0020 #include "kritaui_export.h"
0021 
0022 #include <QWidget>
0023 #include <QLabel>
0024 #include <KoFlakeTypes.h>
0025 #include <KoFlake.h>
0026 
0027 
0028 class KoUnit;
0029 class KoShapeStrokeModel;
0030 class KoShapeStroke;
0031 class KoMarker;
0032 class KoCanvasBase;
0033 class KoShapeStroke;
0034 class KisSpinBoxUnitManager;
0035 
0036 /// A widget for configuring the stroke of a shape
0037 class KRITAUI_EXPORT KoStrokeConfigWidget : public QWidget
0038 {
0039     Q_OBJECT
0040 public:
0041     explicit KoStrokeConfigWidget(KoCanvasBase *canvas, QWidget *parent);
0042     ~KoStrokeConfigWidget() override;
0043 
0044     void setNoSelectionTrackingMode(bool value);
0045 
0046     // Getters
0047     Qt::PenStyle lineStyle() const;
0048     QVector<qreal> lineDashes() const;
0049     qreal lineWidth() const;
0050     QColor color() const;
0051     qreal miterLimit() const;
0052     KoMarker *startMarker() const;
0053     KoMarker *endMarker() const;
0054     Qt::PenCapStyle capStyle() const;
0055     Qt::PenJoinStyle joinStyle() const;
0056     QLabel *thicknessLabel;
0057     QLabel *strokeStyleLabel;
0058     QFrame* separatorLine;
0059 
0060     /**
0061      * Creates KoShapeStroke object filled with the options
0062      * configured by the widget. The caller is in charge of
0063      * deletion of the returned object
0064      */
0065     KoShapeStrokeSP createShapeStroke();
0066 
0067     void setActive(bool active);
0068 
0069     void updateStyleControlsAvailability(bool enabled);
0070     void setUnitManagers(KisSpinBoxUnitManager* managerLineWidth, KisSpinBoxUnitManager* managerMitterLimit);
0071 
0072     void activate();
0073     void deactivate();
0074 
0075 private Q_SLOTS:
0076 
0077     void updateMarkers(const QList<KoMarker*> &markers);
0078 
0079     void canvasResourceChanged(int key, const QVariant &value);
0080 
0081     /// selection has changed
0082     void selectionChanged();
0083 
0084     /// apply line changes to the selected shapes
0085     void applyDashStyleChanges();
0086     void applyLineWidthChanges();
0087     void applyJoinCapChanges();
0088 
0089     /// apply marker changes to the selected shape
0090     void applyMarkerChanges(int rawPosition);
0091 
0092 Q_SIGNALS:
0093     void sigStrokeChanged();
0094 
0095 private:
0096     void setUnit(const KoUnit &unit, KoShape *representativeShape);
0097     void blockChildSignals(bool block);
0098     void loadCurrentStrokeFillFromResourceServer();
0099 
0100 private:
0101     class Private;
0102     Private * const d;
0103 };
0104 
0105 #endif // SHADOWCONFIGWIDGET_H