File indexing completed on 2024-09-15 04:14:00
0001 /* This file is part of the KDE project 0002 * Copyright (C) 2007 Jan Hambrecht <jaham@gmx.net> 0003 * Copyright (C) 2015 Jarosław Staniek <staniek@kde.org> 0004 * 0005 * This library is free software; you can redistribute it and/or 0006 * modify it under the terms of the GNU Library General Public 0007 * License as published by the Free Software Foundation; either 0008 * version 2 of the License, or (at your option) any later version. 0009 * 0010 * This library is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 * Library General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU Library General Public License 0016 * along with this library; see the file COPYING.LIB. If not, write to 0017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0018 * Boston, MA 02110-1301, USA. 0019 */ 0020 0021 #ifndef KPROPERTYLINESTYLESELECTOR_H 0022 #define KPROPERTYLINESTYLESELECTOR_H 0023 0024 #include "kpropertywidgets_export.h" 0025 0026 #include <QComboBox> 0027 0028 /** 0029 * A custom combobox widget for selecting line styles. 0030 */ 0031 class KPROPERTYWIDGETS_EXPORT KPropertyLineStyleSelector : public QComboBox 0032 { 0033 Q_OBJECT 0034 public: 0035 explicit KPropertyLineStyleSelector(QWidget *parent = nullptr); 0036 ~KPropertyLineStyleSelector() override; 0037 0038 //! @return the current line style 0039 Qt::PenStyle lineStyle() const; 0040 0041 //! @return the dashes of the current line style 0042 QVector<qreal> lineDashes() const; 0043 0044 public Q_SLOTS: 0045 /** 0046 * Adds a new line style to the combobox. 0047 * 0048 * If the style already exists, it is not added to the selector. 0049 * 0050 * @param style the line style to add 0051 * @return true if style is unique among the existing styles and was added, else false 0052 */ 0053 bool addCustomStyle(const QVector<qreal> &style); 0054 0055 /** 0056 * Selects the specified style. 0057 * 0058 * If the style was already added it gets selected. If the style was not added already 0059 * it gets temporary added and selected. 0060 * 0061 * @param style the style to display 0062 * @param dashes the dashes of the style if style == Qt::CustomDashLine 0063 */ 0064 void setLineStyle(Qt::PenStyle style, const QVector<qreal> &dashes = QVector<qreal>()); 0065 0066 protected: 0067 void paintEvent(QPaintEvent *pe) override; 0068 0069 private: 0070 Q_DISABLE_COPY(KPropertyLineStyleSelector) 0071 class Private; 0072 Private * const d; 0073 }; 0074 0075 #endif