Changeset View
Changeset View
Standalone View
Standalone View
kcms/kfontinst/kcmfontinst/FontFilter.h
1 | #ifndef __FONT_FILTER_H__ | 1 | #ifndef __FONT_FILTER_H__ | ||
---|---|---|---|---|---|
2 | #define __FONT_FILTER_H__ | 2 | #define __FONT_FILTER_H__ | ||
3 | 3 | | |||
4 | /* | 4 | /* | ||
5 | * KFontInst - KDE Font Installer | 5 | * KFontInst - KDE Font Installer | ||
6 | * | 6 | * | ||
7 | * Copyright 2003-2007 Craig Drummond <craig@kde.org> | 7 | * Copyright 2003-2007 Craig Drummond <craig@kde.org> | ||
8 | * 2019 Guo Yunhe <i@guoyunhe.me> | ||||
8 | * | 9 | * | ||
9 | * ---- | 10 | * ---- | ||
10 | * | 11 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | 12 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | 13 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License, or | 14 | * the Free Software Foundation; either version 2 of the License, or | ||
14 | * (at your option) any later version. | 15 | * (at your option) any later version. | ||
15 | * | 16 | * | ||
16 | * This program is distributed in the hope that it will be useful, | 17 | * This program is distributed in the hope that it will be useful, | ||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
19 | * General Public License for more details. | 20 | * General Public License for more details. | ||
20 | * | 21 | * | ||
21 | * You should have received a copy of the GNU General Public License | 22 | * You should have received a copy of the GNU General Public License | ||
22 | * along with this program; see the file COPYING. If not, write to | 23 | * along with this program; see the file COPYING. If not, write to | ||
23 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 24 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
24 | * Boston, MA 02110-1301, USA. | 25 | * Boston, MA 02110-1301, USA. | ||
25 | */ | 26 | */ | ||
26 | 27 | | |||
27 | #include <KLineEdit> | 28 | #include <QActionGroup> | ||
28 | #include <QPixmap> | 29 | #include <QIcon> | ||
29 | #include <QFontDatabase> | 30 | #include <QFontDatabase> | ||
30 | 31 | #include <QHBoxLayout> | |||
31 | class QLabel; | 32 | #include <QMenu> | ||
32 | class QMenu; | 33 | #include <QPushButton> | ||
33 | class QActionGroup; | 34 | #include <QLineEdit> | ||
34 | 35 | | |||
35 | namespace KFI | 36 | namespace KFI | ||
36 | { | 37 | { | ||
37 | 38 | | |||
38 | class CFontFilter : public KLineEdit | 39 | class CFontFilter : public QWidget | ||
39 | { | 40 | { | ||
40 | Q_OBJECT | 41 | Q_OBJECT | ||
41 | 42 | | |||
42 | public: | 43 | public: | ||
43 | 44 | | |||
44 | enum ECriteria | 45 | enum ECriteria | ||
45 | { | 46 | { | ||
46 | CRIT_FAMILY, | 47 | CRIT_FAMILY, | ||
47 | CRIT_STYLE, | 48 | CRIT_STYLE, | ||
48 | CRIT_FOUNDRY, | 49 | CRIT_FOUNDRY, | ||
49 | CRIT_FONTCONFIG, | 50 | CRIT_FONTCONFIG, | ||
50 | CRIT_FILETYPE, | 51 | CRIT_FILETYPE, | ||
51 | CRIT_FILENAME, | 52 | CRIT_FILENAME, | ||
52 | CRIT_LOCATION, | 53 | CRIT_LOCATION, | ||
53 | CRIT_WS, | 54 | CRIT_WS, | ||
54 | 55 | | |||
55 | NUM_CRIT | 56 | NUM_CRIT | ||
56 | }; | 57 | }; | ||
57 | 58 | | |||
58 | CFontFilter(QWidget *parent); | 59 | CFontFilter(QWidget *parent); | ||
59 | ~CFontFilter() override { } | 60 | ~CFontFilter() override { } | ||
60 | 61 | | |||
61 | void setFoundries(const QSet<QString> ¤tFoundries); | 62 | void setFoundries(const QSet<QString> ¤tFoundries); | ||
62 | 63 | | |||
63 | QSize sizeHint() const override; | | |||
64 | | ||||
65 | Q_SIGNALS: | 64 | Q_SIGNALS: | ||
66 | 65 | | |||
67 | void criteriaChanged(int crit, qulonglong ws, const QStringList &ft); | 66 | void criteriaChanged(int crit, qulonglong ws, const QStringList &ft); | ||
67 | void queryChanged(QString text); | ||||
68 | 68 | | |||
69 | private Q_SLOTS: | 69 | private Q_SLOTS: | ||
70 | 70 | | |||
71 | void filterChanged(); | 71 | void filterChanged(); | ||
72 | void textChanged(const QString &text); | ||||
72 | void ftChanged(const QString &ft); | 73 | void ftChanged(const QString &ft); | ||
73 | void wsChanged(const QString &writingSystemName); | 74 | void wsChanged(const QString &writingSystemName); | ||
74 | void foundryChanged(const QString &foundry); | 75 | void foundryChanged(const QString &foundry); | ||
75 | 76 | | |||
76 | private: | 77 | private: | ||
77 | 78 | | |||
78 | void addAction(ECriteria crit, const QString &text, bool on); | 79 | void addAction(ECriteria crit, bool on); | ||
79 | void resizeEvent(QResizeEvent *ev) override; | | |||
80 | void mousePressEvent(QMouseEvent *ev) override; | | |||
81 | void setCriteria(ECriteria crit); | 80 | void setCriteria(ECriteria crit); | ||
82 | 81 | | |||
83 | private: | 82 | private: | ||
84 | 83 | | |||
85 | QLabel *itsMenuButton; | 84 | QHBoxLayout *m_layout; | ||
86 | QMenu *itsMenu; | 85 | QPushButton *m_menuButton; | ||
86 | QMenu *m_menu; | ||||
87 | QLineEdit *m_lineEdit; | ||||
87 | ECriteria itsCurrentCriteria; | 88 | ECriteria itsCurrentCriteria; | ||
88 | QFontDatabase::WritingSystem itsCurrentWs; | 89 | QFontDatabase::WritingSystem itsCurrentWs; | ||
89 | QStringList itsCurrentFileTypes; | 90 | QStringList itsCurrentFileTypes; | ||
90 | QPixmap itsPixmaps[NUM_CRIT]; | 91 | QIcon itsIcons[NUM_CRIT]; | ||
92 | QString itsTexts[NUM_CRIT]; | ||||
91 | QAction *itsActions[NUM_CRIT]; | 93 | QAction *itsActions[NUM_CRIT]; | ||
92 | QActionGroup *itsActionGroup; | 94 | QActionGroup *itsActionGroup; | ||
93 | }; | 95 | }; | ||
94 | 96 | | |||
95 | } | 97 | } | ||
96 | 98 | | |||
97 | #endif | 99 | #endif |