| 1 |
|
| 2 |
|
| 3 |
> |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
#ifndef KIS_FONT_FAMILY_COMBO_BOX_H |
| 8 |
#define KIS_FONT_FAMILY_COMBO_BOX_H |
| 9 |
|
| 10 |
#include <QObject> |
| 11 |
#include <KisSqueezedComboBox.h> |
| 12 |
#include <QFont> |
| 13 |
#include <QFontDatabase> |
| 14 |
#include <QStyledItemDelegate> |
| 15 |
|
| 16 |
#include "kritawidgetutils_export.h" |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
class KRITAWIDGETUTILS_EXPORT KisFontComboBoxes : public QWidget |
| 26 |
{ |
| 27 |
Q_OBJECT |
| 28 |
public: |
| 29 |
KisFontComboBoxes(QWidget *parent = 0); |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
void setCurrentFont(QFont font); |
| 37 |
|
| 38 |
void setCurrentFamily(const QString family); |
| 39 |
void setCurrentStyle(QString style); |
| 40 |
|
| 41 |
|
| 42 |
QString currentFamily() const; |
| 43 |
|
| 44 |
QString currentStyle() const; |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
QFont currentFont(int pointSize = 10) const; |
| 52 |
|
| 53 |
void refillComboBox(QVector<QFontDatabase::WritingSystem> writingSystems = QVector<QFontDatabase::WritingSystem>()); |
| 54 |
void setInitialized(); |
| 55 |
|
| 56 |
Q_SIGNALS: |
| 57 |
void fontChanged(QString); |
| 58 |
private Q_SLOTS: |
| 59 |
void fontFamilyChanged(); |
| 60 |
void fontChange(); |
| 61 |
private: |
| 62 |
QComboBox *m_family; |
| 63 |
QComboBox *m_styles; |
| 64 |
}; |
| 65 |
|
| 66 |
class KRITAWIDGETUTILS_EXPORT PinnedFontsSeparator : public QStyledItemDelegate { |
| 67 |
public: |
| 68 |
PinnedFontsSeparator(QAbstractItemDelegate *_default, QWidget *parent = nullptr); |
| 69 |
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; |
| 70 |
void setSeparatorIndex(int index); |
| 71 |
void setSeparatorAdded(); |
| 72 |
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; |
| 73 |
|
| 74 |
private: |
| 75 |
int m_separatorIndex; |
| 76 |
bool m_separatorAdded; |
| 77 |
QAbstractItemDelegate *m_defaultDelegate; |
| 78 |
}; |
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
class KRITAWIDGETUTILS_EXPORT KisFontFamilyComboBox : public QComboBox |
| 88 |
{ |
| 89 |
Q_OBJECT |
| 90 |
public: |
| 91 |
KisFontFamilyComboBox(QWidget *parent = 0); |
| 92 |
|
| 93 |
|
| 94 |
void refillComboBox(QVector<QFontDatabase::WritingSystem> writingSystems = QVector<QFontDatabase::WritingSystem>()); |
| 95 |
void setTopFont(const QString &family); |
| 96 |
void setInitialized(); |
| 97 |
|
| 98 |
private Q_SLOTS: |
| 99 |
void slotTextChanged(const QString &input); |
| 100 |
|
| 101 |
private: |
| 102 |
QStringList m_pinnedFonts; |
| 103 |
QStringList m_blacklistedFonts; |
| 104 |
bool m_initialized {false}; |
| 105 |
bool m_initializeFromConfig; |
| 106 |
int m_separatorIndex; |
| 107 |
PinnedFontsSeparator *m_fontSeparator; |
| 108 |
}; |
| 109 |
|
| 110 |
#endif |