File indexing completed on 2024-05-12 16:02:09

0001 /* This file is part of the KDE project
0002  * SPDX-FileCopyrightText: 2007 Jan Hambrecht <jaham@gmx.net>
0003  *
0004  * SPDX-License-Identifier: LGPL-2.0-or-later
0005  */
0006 
0007 #ifndef _KOLINESTYLESELECTOR_H_
0008 #define _KOLINESTYLESELECTOR_H_
0009 
0010 #include "kritawidgets_export.h"
0011 #include <QComboBox>
0012 
0013 /**
0014  * A custom combobox widget for selecting line styles.
0015  */
0016 class KRITAWIDGETS_EXPORT KoLineStyleSelector : public QComboBox
0017 {
0018     Q_OBJECT
0019 public:
0020     explicit KoLineStyleSelector(QWidget *parent = 0);
0021     ~KoLineStyleSelector() override;
0022 
0023     /**
0024      * Adds a new line style to the combobox.
0025      *
0026      * If the style already exists, it is not added to the selector.
0027      *
0028      * @param style the line style to add
0029      * @return true if style is unique among the existing styles and was added, else false
0030      */
0031     bool addCustomStyle(const QVector<qreal> &style);
0032 
0033     /**
0034      * Selects the specified style.
0035      *
0036      * If the style was already added it gets selected. If the style was not added already
0037      * it gets temporary added and selected.
0038      *
0039      * @param style the style to display
0040      * @param dashes the dashes of the style if style == Qt::CustomDashLine
0041      */
0042     void setLineStyle(Qt::PenStyle style, const QVector<qreal> &dashes = QVector<qreal>());
0043 
0044     /// Returns the current line style
0045     Qt::PenStyle lineStyle() const;
0046     /// Returns the dashes of the current line style
0047     QVector<qreal> lineDashes() const;
0048 
0049 protected:
0050     void paintEvent(QPaintEvent *pe) override;
0051 
0052 private:
0053     class Private;
0054     Private * const d;
0055 };
0056 
0057 #endif // _KOLINESTYLESELECTOR_H_