2 * fontcolourbutton.h - pushbutton widget to select a font and colour
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"
30 class FontColourChooser
;
32 class FontColourButton
: public PushButton
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
; }
50 /** Signal emitted whenever a font or colour has been selected. */
51 void selected(const QColor
& fg
, const QColor
& bg
);
54 void slotButtonPressed();
57 QColor mBgColour
, mFgColour
;
64 // Font and colour selection dialog displayed by the push button
65 class FontColourDlg
: public QDialog
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
; }
79 virtual void slotOk();
82 FontColourChooser
* mChooser
;
83 QColor mBgColour
, mFgColour
;
89 #endif // FONTCOLOURBUTTON_H