File indexing completed on 2024-05-12 17:18:55
0001 /* 0002 * SPDX-FileCopyrightText: 2008 Peter Penz <peter.penz19@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef DOLPHINFONTREQUESTER_H 0008 #define DOLPHINFONTREQUESTER_H 0009 0010 #include <QFont> 0011 #include <QWidget> 0012 0013 class QComboBox; 0014 class QPushButton; 0015 0016 /** 0017 * @brief Allows to select between using the system font or a custom font. 0018 */ 0019 class DolphinFontRequester : public QWidget 0020 { 0021 Q_OBJECT 0022 0023 public: 0024 enum Mode { SystemFont = 0, CustomFont = 1 }; 0025 0026 explicit DolphinFontRequester(QWidget *parent); 0027 ~DolphinFontRequester() override; 0028 0029 void setMode(Mode mode); 0030 Mode mode() const; 0031 0032 /** 0033 * Returns the custom font (see DolphinFontRequester::customFont()), 0034 * if the mode is \a CustomFont, otherwise the system font is 0035 * returned. 0036 */ 0037 QFont currentFont() const; 0038 0039 void setCustomFont(const QFont &font); 0040 QFont customFont() const; 0041 0042 Q_SIGNALS: 0043 /** Is emitted, if the font has been changed. */ 0044 void changed(); 0045 0046 private Q_SLOTS: 0047 void openFontDialog(); 0048 void changeMode(int index); 0049 0050 private: 0051 QComboBox *m_modeCombo; 0052 QPushButton *m_chooseFontButton; 0053 0054 Mode m_mode; 0055 QFont m_customFont; 0056 }; 0057 0058 #endif