File indexing completed on 2024-05-19 04:36:40
0001 /* This file is part of the TikZKit project. 0002 * 0003 * Copyright (C) 2014 Dominik Haumann <dhaumann@kde.org> 0004 * 0005 * This code is based on the KisSliderSpinBox used in Krita: 0006 * Copyright (c) 2010 Justin Noel <justin@ics.com> 0007 * Copyright (c) 2010 Cyrille Berger <cberger@cberger.net> 0008 * 0009 * This library is free software; you can redistribute it and/or modify 0010 * it under the terms of the GNU Library General Public License as published 0011 * by the Free Software Foundation, either version 2 of the License, or 0012 * (at your option) any later version. 0013 * 0014 * This library is distributed in the hope that it will be useful, 0015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0017 * GNU Library General Public License for more details. 0018 * 0019 * You should have received a copy of the GNU Library General Public License 0020 * along with this library; see the file COPYING.LIB. If not, see 0021 * <http://www.gnu.org/licenses/>. 0022 */ 0023 0024 #ifndef TIKZUI_SLIDER_SPINBOX_H 0025 #define TIKZUI_SLIDER_SPINBOX_H 0026 0027 #include "tikzui_export.h" 0028 0029 #include <QSpinBox> 0030 0031 class SliderSpinBoxPrivate; 0032 0033 /** 0034 * A modified QSpinBox showing a progress bar instead of an line edit. 0035 */ 0036 class TIKZKITUI_EXPORT SliderSpinBox : public QSpinBox 0037 { 0038 Q_OBJECT 0039 0040 public: 0041 /** 0042 * Default constructor with an optional @p parent widget. 0043 */ 0044 explicit SliderSpinBox(QWidget * parent = nullptr); 0045 0046 /** 0047 * Virtual destructor. 0048 */ 0049 virtual ~SliderSpinBox(); 0050 0051 protected: 0052 /** 0053 * Reimplemented to draw progress bar on top of spin box. 0054 */ 0055 void paintEvent(QPaintEvent * event) override; 0056 0057 /** 0058 * Reimplemented, to show the line edit on demand. 0059 */ 0060 void mousePressEvent(QMouseEvent * event) override; 0061 0062 /** 0063 * Reimplemented for internal reasons. 0064 */ 0065 void mouseReleaseEvent(QMouseEvent * event) override; 0066 0067 /** 0068 * Reimplemented, to make the spin box behave as a slider in the main area. 0069 */ 0070 void mouseMoveEvent(QMouseEvent * event) override; 0071 0072 /** 0073 * Reimplemented, to avoid showing a context menu. 0074 */ 0075 void contextMenuEvent(QContextMenuEvent * event) override; 0076 0077 /** 0078 * Reimplemented, to make the spin box behave as a slider in the main area. 0079 */ 0080 void keyPressEvent(QKeyEvent * event) override; 0081 0082 private: 0083 friend SliderSpinBoxPrivate; 0084 SliderSpinBoxPrivate * const d; 0085 }; 0086 0087 #endif //TIKZUI_SLIDER_SPINBOX_H 0088 0089 // kate: indent-width 4; replace-tabs on;