File indexing completed on 2024-04-21 14:55:50

0001 /* This file is part of the KDE libraries
0002    Copyright (C) 2001, 2002 Frerich Raabe <raabe@kde.org>
0003 
0004    This library is free software; you can redistribute it and/or
0005    modify it under the terms of the GNU Library General Public
0006    License version 2 as published by the Free Software Foundation.
0007 
0008    This library is distributed in the hope that it will be useful,
0009    but WITHOUT ANY WARRANTY; without even the implied warranty of
0010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0011    Library General Public License for more details.
0012 
0013    You should have received a copy of the GNU Library General Public License
0014    along with this library; see the file COPYING.LIB.  If not, write to
0015    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0016    Boston, MA 02110-1301, USA.
0017 */
0018 
0019 #ifndef karrowbutton_h
0020 #define karrowbutton_h
0021 
0022 #include <kdelibs4support_export.h>
0023 #include <QPushButton>
0024 
0025 class KArrowButtonPrivate;
0026 /**
0027  * @deprecated Use a QToolButton with the arrowType property set instead
0028  *
0029  * @short Draws a button with an arrow.
0030  *
0031  * Draws a button which shows an arrow pointing into a certain direction. The
0032  * arrow's alignment on the button depends on the direction it's pointing to,
0033  * e.g. a left arrow is aligned at the left border, a upwards arrow at the top
0034  * border. This class honors the currently configured KStyle when drawing
0035  * the arrow.
0036  *
0037  * \image html karrowbutton.png "KDE Arrow Buttons"
0038  *
0039  * @author Frerich Raabe
0040  */
0041 class KDELIBS4SUPPORT_DEPRECATED_EXPORT KArrowButton : public QPushButton
0042 {
0043     Q_OBJECT
0044     /**
0045      * Arrow type for this button, from Qt::ArrowType.
0046      */
0047     Q_PROPERTY(int arrowType READ arrowTp WRITE setArrowTp)
0048 
0049 public:
0050     /**
0051      * Constructs an arrow button.
0052      *
0053      * @param parent This button's parent
0054      * @param arrow The direction the arrrow should be pointing in
0055      */
0056     KDELIBS4SUPPORT_DEPRECATED explicit KArrowButton(QWidget *parent = nullptr, Qt::ArrowType arrow = Qt::UpArrow);
0057 
0058     /**
0059      * Destructor.
0060      */
0061     ~KArrowButton() override;
0062 
0063     /**
0064      * Reimplemented from QPushButton.
0065      */
0066     QSize sizeHint() const override;
0067 
0068     /**
0069     * Returns the arrow type
0070     */
0071     Qt::ArrowType arrowType() const;
0072 
0073     /// hack for moc braindamage with enums, use arrowType() instead
0074     int arrowTp() const
0075     {
0076         return (int) arrowType();
0077     }
0078     /// hack for moc braindamage with enums, use setArrowType() instead
0079     void setArrowTp(int tp)
0080     {
0081         setArrowType((Qt::ArrowType) tp);
0082     }
0083 public Q_SLOTS:
0084     /**
0085      * Defines in what direction the arrow is pointing to. Will repaint the
0086      * button if necessary.
0087      *
0088      * @param a The direction this arrow should be pointing in
0089      */
0090     void setArrowType(Qt::ArrowType a);
0091 
0092 protected:
0093     /**
0094      * Reimplemented from QPushButton.
0095      */
0096     void paintEvent(QPaintEvent *) override;
0097 
0098 private:
0099     KArrowButtonPrivate *const d;
0100 };
0101 
0102 #endif // karrowbutton_h