Merge branch 'master' of git://anongit.kde.org/kdepim
[kdepim.git] / kalarm / fontcolourbutton.h
blob6ea4da44bf41f7db77a3e4e5a61fb45c8bcea0af
1 /*
2 * fontcolourbutton.h - pushbutton widget to select a font and colour
3 * Program: kalarm
4 * Copyright © 2003-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 FONTCOLOURBUTTON_H
22 #define FONTCOLOURBUTTON_H
24 #include "pushbutton.h"
26 #include <QDialog>
27 #include <QFont>
28 #include <QColor>
30 class FontColourChooser;
32 class FontColourButton : public PushButton
34 Q_OBJECT
35 public:
36 explicit FontColourButton(QWidget* parent = Q_NULLPTR);
37 void setDefaultFont();
38 void setFont(const QFont&);
39 void setBgColour(const QColor& c) { mBgColour = c; }
40 void setFgColour(const QColor& c) { mFgColour = c; }
41 bool defaultFont() const { return mDefaultFont; }
42 QFont font() const { return mFont; }
43 QColor bgColour() const { return mBgColour; }
44 QColor fgColour() const { return mFgColour; }
45 void setReadOnly(bool ro, bool noHighlight = false) Q_DECL_OVERRIDE
46 { mReadOnly = ro; PushButton::setReadOnly(ro, noHighlight); }
47 bool isReadOnly() const Q_DECL_OVERRIDE { return mReadOnly; }
49 Q_SIGNALS:
50 /** Signal emitted whenever a font or colour has been selected. */
51 void selected(const QColor& fg, const QColor& bg);
53 protected Q_SLOTS:
54 void slotButtonPressed();
56 private:
57 QColor mBgColour, mFgColour;
58 QFont mFont;
59 bool mDefaultFont;
60 bool mReadOnly;
64 // Font and colour selection dialog displayed by the push button
65 class FontColourDlg : public QDialog
67 Q_OBJECT
68 public:
69 FontColourDlg(const QColor& bg, const QColor& fg, const QFont&, bool defaultFont,
70 const QString& caption, QWidget* parent = Q_NULLPTR);
71 bool defaultFont() const { return mDefaultFont; }
72 QFont font() const { return mFont; }
73 QColor bgColour() const { return mBgColour; }
74 QColor fgColour() const { return mFgColour; }
75 void setReadOnly(bool);
76 bool isReadOnly() const { return mReadOnly; }
78 protected Q_SLOTS:
79 virtual void slotOk();
81 private:
82 FontColourChooser* mChooser;
83 QColor mBgColour, mFgColour;
84 QFont mFont;
85 bool mDefaultFont;
86 bool mReadOnly;
89 #endif // FONTCOLOURBUTTON_H
91 // vim: et sw=4: