KDELibs4Support

kpushbutton.h
1 /* This file is part of the KDE libraries
2  Copyright (C) 2000 Carsten Pfeiffer <[email protected]>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #ifndef KPUSHBUTTON_H
21 #define KPUSHBUTTON_H
22 
23 #include <QPushButton>
24 
25 #include <kstandardguiitem.h>
26 
27 #include <kauthaction.h>
28 
29 #include <kdelibs4support_export.h>
30 
31 class QDrag;
32 class QMenu;
33 
47 class KDELIBS4SUPPORT_DEPRECATED_EXPORT KPushButton : public QPushButton
48 {
49  Q_OBJECT
50  Q_PROPERTY(bool isDragEnabled READ isDragEnabled WRITE setDragEnabled)
51 
52 public:
53 
57  KDELIBS4SUPPORT_DEPRECATED explicit KPushButton(QWidget *parent = nullptr);
58 
62  KDELIBS4SUPPORT_DEPRECATED explicit KPushButton(const QString &text, QWidget *parent = nullptr);
63 
67  KPushButton(const QIcon &icon, const QString &text, QWidget *parent = nullptr);
68 
74  KDELIBS4SUPPORT_DEPRECATED explicit KPushButton(const KGuiItem &item, QWidget *parent = nullptr);
75 
79  ~KPushButton();
80 
84  void setDragEnabled(bool enable);
85 
89  bool isDragEnabled() const;
90 
94  void setGuiItem(const KGuiItem &item);
95 
99  void setGuiItem(KStandardGuiItem::StandardItem item);
100 
104  KStandardGuiItem::StandardItem guiItem() const;
105 
110  void setIcon(const QIcon &icon);
111 
115  void setText(const QString &text);
116 
121  void setDelayedMenu(QMenu *delayed_menu);
122 
127  QMenu *delayedMenu();
128 
133  QSize sizeHint() const override;
134 
140  KAuth::Action authAction() const;
141 
152  void setAuthAction(const KAuth::Action &action);
153 
161  void setAuthAction(const QString &actionName);
162 
163 protected:
170  virtual QDrag *dragObject();
171 
175  void mousePressEvent(QMouseEvent *) override;
179  void mouseMoveEvent(QMouseEvent *) override;
180 
185  void paintEvent(QPaintEvent *) override;
186 
190  virtual void startDrag();
191 
192 Q_SIGNALS:
208  void authorized(const KAuth::Action &action);
209 
210 private:
215  void initWidget(const KGuiItem &item);
216 
217 private:
218  class KPushButtonPrivate;
219  KPushButtonPrivate *const d;
220 
221  Q_PRIVATE_SLOT(d, void slotPressedInternal())
222  Q_PRIVATE_SLOT(d, void slotClickedInternal())
223  Q_PRIVATE_SLOT(d, void slotDelayedMenuTimeout())
224 };
225 
226 #endif // KPUSHBUTTON_H
A QPushButton with drag-support and KGuiItem support.
Definition: kpushbutton.h:47
virtual QSize sizeHint() const const override
virtual void mouseMoveEvent(QMouseEvent *e) override
void setIcon(const QIcon &icon)
virtual void mousePressEvent(QMouseEvent *e) override
Q_PROPERTY(...)
virtual void paintEvent(QPaintEvent *) override
void setText(const QString &text)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri May 29 2020 22:53:34 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.