SVN_SILENT made messages (.desktop file) - always resolve ours
[kdepim.git] / kalarm / lib / pushbutton.h
blob8b3eabed2340d471f686886fc599e59ddbe956a9
1 /*
2 * pushbutton.h - push button with read-only option
3 * Program: kalarm
4 * Copyright © 2002,2003,2005,2006,2009 by David Jarvie <djarvie@kde.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #ifndef PUSHBUTTON_H
22 #define PUSHBUTTON_H
24 #include <QPushButton>
25 class QMouseEvent;
26 class QKeyEvent;
27 class KGuiItem;
28 class QIcon;
31 /**
32 * @short A QPushButton with read-only option.
34 * The PushButton class is a QPushButton with a read-only option.
36 * The widget may be set as read-only. This has the same effect as disabling it, except
37 * that its appearance is unchanged.
39 * @author David Jarvie <djarvie@kde.org>
41 class PushButton : public QPushButton
43 Q_OBJECT
44 Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
45 public:
46 /** Constructor.
47 * @param parent The parent object of this widget.
49 explicit PushButton(QWidget* parent);
50 /** Constructor for a push button which displays a text.
51 * @param gui The text, icon etc. to show on the button.
52 * @param parent The parent object of this widget.
54 PushButton(const KGuiItem& gui, QWidget* parent);
55 /** Constructor for a push button which displays a text.
56 * @param text The text to show on the button.
57 * @param parent The parent object of this widget.
59 PushButton(const QString& text, QWidget* parent);
60 /** Constructor for a push button which displays an icon and a text.
61 * @param icon The icon to show on the button.
62 * @param text The text to show on the button.
63 * @param parent The parent object of this widget.
65 PushButton(const QIcon &icon, const QString& text, QWidget* parent);
66 /** Sets whether the push button is read-only for the user.
67 * @param readOnly True to set the widget read-only, false to enable its action.
68 * @param noHighlight True to prevent the button being highlighted on mouse-over.
70 virtual void setReadOnly(bool readOnly, bool noHighlight = false);
71 /** Returns true if the widget is read only. */
72 virtual bool isReadOnly() const { return mReadOnly; }
73 protected:
74 void mousePressEvent(QMouseEvent*) Q_DECL_OVERRIDE;
75 void mouseReleaseEvent(QMouseEvent*) Q_DECL_OVERRIDE;
76 void mouseMoveEvent(QMouseEvent*) Q_DECL_OVERRIDE;
77 void keyPressEvent(QKeyEvent*) Q_DECL_OVERRIDE;
78 void keyReleaseEvent(QKeyEvent*) Q_DECL_OVERRIDE;
79 bool event(QEvent*) Q_DECL_OVERRIDE;
80 private:
81 Qt::FocusPolicy mFocusPolicy; // default focus policy for the PushButton
82 bool mReadOnly; // value cannot be changed
83 bool mNoHighlight; // don't highlight on mouse hover, if read-only
86 #endif // PUSHBUTTON_H
88 // vim: et sw=4: