Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/dialogs/qfontdialog.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||||||||
2 | - | |||||||||||||||||||||||||
3 | - | |||||||||||||||||||||||||
4 | - | |||||||||||||||||||||||||
5 | - | |||||||||||||||||||||||||
6 | - | |||||||||||||||||||||||||
7 | - | |||||||||||||||||||||||||
8 | class QFontListView : public QListView | - | ||||||||||||||||||||||||
9 | { | - | ||||||||||||||||||||||||
10 | public: template <typename ThisObject> inline void qt_check_for_QOBJECT_macro(const ThisObject &_q_argument) const { int i = qYouForgotTheQ_OBJECT_Macro(this, &_q_argument); i = i + 1; } | - | ||||||||||||||||||||||||
11 | #pragma GCC diagnostic push | - | ||||||||||||||||||||||||
12 | static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); virtual int qt_metacall(QMetaObject::Call, int, void **); static inline QString tr(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } private: __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); | - | ||||||||||||||||||||||||
13 | #pragma GCC diagnostic pop | - | ||||||||||||||||||||||||
14 | struct QPrivateSignal {}; | - | ||||||||||||||||||||||||
15 | public: | - | ||||||||||||||||||||||||
16 | QFontListView(QWidget *parent); | - | ||||||||||||||||||||||||
17 | inline QStringListModel *model() const { | - | ||||||||||||||||||||||||
18 | return never executed: static_cast<QStringListModel *>(QListView::model());return static_cast<QStringListModel *>(QListView::model()); never executed: return static_cast<QStringListModel *>(QListView::model()); | 0 | ||||||||||||||||||||||||
19 | } | - | ||||||||||||||||||||||||
20 | inline void setCurrentItem(int item) { | - | ||||||||||||||||||||||||
21 | QListView::setCurrentIndex(static_cast<QAbstractListModel*>(model())->index(item)); | - | ||||||||||||||||||||||||
22 | } never executed: end of block | 0 | ||||||||||||||||||||||||
23 | inline int currentItem() const { | - | ||||||||||||||||||||||||
24 | return never executed: QListView::currentIndex().row();return QListView::currentIndex().row(); never executed: return QListView::currentIndex().row(); | 0 | ||||||||||||||||||||||||
25 | } | - | ||||||||||||||||||||||||
26 | inline int count() const { | - | ||||||||||||||||||||||||
27 | return never executed: model()->rowCount();return model()->rowCount(); never executed: return model()->rowCount(); | 0 | ||||||||||||||||||||||||
28 | } | - | ||||||||||||||||||||||||
29 | inline QString currentText() const { | - | ||||||||||||||||||||||||
30 | int row = QListView::currentIndex().row(); | - | ||||||||||||||||||||||||
31 | return never executed: row < 0return row < 0 ? QString() : model()->stringList().at(row);
never executed: return row < 0 ? QString() : model()->stringList().at(row); | 0 | ||||||||||||||||||||||||
32 | } | - | ||||||||||||||||||||||||
33 | void currentChanged(const QModelIndex ¤t, const QModelIndex &previous) override { | - | ||||||||||||||||||||||||
34 | QListView::currentChanged(current, previous); | - | ||||||||||||||||||||||||
35 | if (current.isValid()
| 0 | ||||||||||||||||||||||||
36 | highlighted(current.row()); never executed: highlighted(current.row()); | 0 | ||||||||||||||||||||||||
37 | } never executed: end of block | 0 | ||||||||||||||||||||||||
38 | QString text(int i) const { | - | ||||||||||||||||||||||||
39 | return never executed: model()->stringList().at(i);return model()->stringList().at(i); never executed: return model()->stringList().at(i); | 0 | ||||||||||||||||||||||||
40 | } | - | ||||||||||||||||||||||||
41 | public : | - | ||||||||||||||||||||||||
42 | void highlighted(int); | - | ||||||||||||||||||||||||
43 | }; | - | ||||||||||||||||||||||||
44 | - | |||||||||||||||||||||||||
45 | QFontListView::QFontListView(QWidget *parent) | - | ||||||||||||||||||||||||
46 | : QListView(parent) | - | ||||||||||||||||||||||||
47 | { | - | ||||||||||||||||||||||||
48 | setModel(new QStringListModel(parent)); | - | ||||||||||||||||||||||||
49 | setEditTriggers(NoEditTriggers); | - | ||||||||||||||||||||||||
50 | } never executed: end of block | 0 | ||||||||||||||||||||||||
51 | - | |||||||||||||||||||||||||
52 | static const Qt::WindowFlags DefaultWindowFlags = | - | ||||||||||||||||||||||||
53 | Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint; | - | ||||||||||||||||||||||||
54 | - | |||||||||||||||||||||||||
55 | QFontDialogPrivate::QFontDialogPrivate() | - | ||||||||||||||||||||||||
56 | : writingSystem(QFontDatabase::Any), | - | ||||||||||||||||||||||||
57 | options(QSharedPointer<QFontDialogOptions>::create()) | - | ||||||||||||||||||||||||
58 | { | - | ||||||||||||||||||||||||
59 | } never executed: end of block | 0 | ||||||||||||||||||||||||
60 | - | |||||||||||||||||||||||||
61 | QFontDialogPrivate::~QFontDialogPrivate() | - | ||||||||||||||||||||||||
62 | { | - | ||||||||||||||||||||||||
63 | } | - | ||||||||||||||||||||||||
64 | QFontDialog::QFontDialog(QWidget *parent) | - | ||||||||||||||||||||||||
65 | : QDialog(*new QFontDialogPrivate, parent, DefaultWindowFlags) | - | ||||||||||||||||||||||||
66 | { | - | ||||||||||||||||||||||||
67 | QFontDialogPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
68 | d->init(); | - | ||||||||||||||||||||||||
69 | } never executed: end of block | 0 | ||||||||||||||||||||||||
70 | - | |||||||||||||||||||||||||
71 | - | |||||||||||||||||||||||||
72 | - | |||||||||||||||||||||||||
73 | - | |||||||||||||||||||||||||
74 | - | |||||||||||||||||||||||||
75 | - | |||||||||||||||||||||||||
76 | - | |||||||||||||||||||||||||
77 | QFontDialog::QFontDialog(const QFont &initial, QWidget *parent) | - | ||||||||||||||||||||||||
78 | : QDialog(*new QFontDialogPrivate, parent, DefaultWindowFlags) | - | ||||||||||||||||||||||||
79 | { | - | ||||||||||||||||||||||||
80 | QFontDialogPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
81 | d->init(); | - | ||||||||||||||||||||||||
82 | setCurrentFont(initial); | - | ||||||||||||||||||||||||
83 | } never executed: end of block | 0 | ||||||||||||||||||||||||
84 | - | |||||||||||||||||||||||||
85 | void QFontDialogPrivate::init() | - | ||||||||||||||||||||||||
86 | { | - | ||||||||||||||||||||||||
87 | QFontDialog * const q = q_func(); | - | ||||||||||||||||||||||||
88 | - | |||||||||||||||||||||||||
89 | q->setSizeGripEnabled(true); | - | ||||||||||||||||||||||||
90 | q->setWindowTitle(QFontDialog::tr("Select Font")); | - | ||||||||||||||||||||||||
91 | - | |||||||||||||||||||||||||
92 | - | |||||||||||||||||||||||||
93 | familyEdit = new QLineEdit(q); | - | ||||||||||||||||||||||||
94 | familyEdit->setReadOnly(true); | - | ||||||||||||||||||||||||
95 | familyList = new QFontListView(q); | - | ||||||||||||||||||||||||
96 | familyEdit->setFocusProxy(familyList); | - | ||||||||||||||||||||||||
97 | - | |||||||||||||||||||||||||
98 | familyAccel = new QLabel(q); | - | ||||||||||||||||||||||||
99 | - | |||||||||||||||||||||||||
100 | familyAccel->setBuddy(familyList); | - | ||||||||||||||||||||||||
101 | - | |||||||||||||||||||||||||
102 | familyAccel->setIndent(2); | - | ||||||||||||||||||||||||
103 | - | |||||||||||||||||||||||||
104 | styleEdit = new QLineEdit(q); | - | ||||||||||||||||||||||||
105 | styleEdit->setReadOnly(true); | - | ||||||||||||||||||||||||
106 | styleList = new QFontListView(q); | - | ||||||||||||||||||||||||
107 | styleEdit->setFocusProxy(styleList); | - | ||||||||||||||||||||||||
108 | - | |||||||||||||||||||||||||
109 | styleAccel = new QLabel(q); | - | ||||||||||||||||||||||||
110 | - | |||||||||||||||||||||||||
111 | styleAccel->setBuddy(styleList); | - | ||||||||||||||||||||||||
112 | - | |||||||||||||||||||||||||
113 | styleAccel->setIndent(2); | - | ||||||||||||||||||||||||
114 | - | |||||||||||||||||||||||||
115 | sizeEdit = new QLineEdit(q); | - | ||||||||||||||||||||||||
116 | sizeEdit->setFocusPolicy(Qt::ClickFocus); | - | ||||||||||||||||||||||||
117 | QIntValidator *validator = new QIntValidator(1, 512, q); | - | ||||||||||||||||||||||||
118 | sizeEdit->setValidator(validator); | - | ||||||||||||||||||||||||
119 | sizeList = new QFontListView(q); | - | ||||||||||||||||||||||||
120 | - | |||||||||||||||||||||||||
121 | sizeAccel = new QLabel(q); | - | ||||||||||||||||||||||||
122 | - | |||||||||||||||||||||||||
123 | sizeAccel->setBuddy(sizeEdit); | - | ||||||||||||||||||||||||
124 | - | |||||||||||||||||||||||||
125 | sizeAccel->setIndent(2); | - | ||||||||||||||||||||||||
126 | - | |||||||||||||||||||||||||
127 | - | |||||||||||||||||||||||||
128 | effects = new QGroupBox(q); | - | ||||||||||||||||||||||||
129 | QVBoxLayout *vbox = new QVBoxLayout(effects); | - | ||||||||||||||||||||||||
130 | strikeout = new QCheckBox(effects); | - | ||||||||||||||||||||||||
131 | vbox->addWidget(strikeout); | - | ||||||||||||||||||||||||
132 | underline = new QCheckBox(effects); | - | ||||||||||||||||||||||||
133 | vbox->addWidget(underline); | - | ||||||||||||||||||||||||
134 | - | |||||||||||||||||||||||||
135 | sample = new QGroupBox(q); | - | ||||||||||||||||||||||||
136 | QHBoxLayout *hbox = new QHBoxLayout(sample); | - | ||||||||||||||||||||||||
137 | sampleEdit = new QLineEdit(sample); | - | ||||||||||||||||||||||||
138 | sampleEdit->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored)); | - | ||||||||||||||||||||||||
139 | sampleEdit->setAlignment(Qt::AlignCenter); | - | ||||||||||||||||||||||||
140 | - | |||||||||||||||||||||||||
141 | - | |||||||||||||||||||||||||
142 | sampleEdit->setText(QLatin1String("AaBbYyZz")); | - | ||||||||||||||||||||||||
143 | hbox->addWidget(sampleEdit); | - | ||||||||||||||||||||||||
144 | - | |||||||||||||||||||||||||
145 | writingSystemCombo = new QComboBox(q); | - | ||||||||||||||||||||||||
146 | - | |||||||||||||||||||||||||
147 | writingSystemAccel = new QLabel(q); | - | ||||||||||||||||||||||||
148 | - | |||||||||||||||||||||||||
149 | writingSystemAccel->setBuddy(writingSystemCombo); | - | ||||||||||||||||||||||||
150 | - | |||||||||||||||||||||||||
151 | writingSystemAccel->setIndent(2); | - | ||||||||||||||||||||||||
152 | - | |||||||||||||||||||||||||
153 | size = 0; | - | ||||||||||||||||||||||||
154 | smoothScalable = false; | - | ||||||||||||||||||||||||
155 | - | |||||||||||||||||||||||||
156 | QObject::connect(writingSystemCombo, qFlagLocation("2""activated(int)" "\0" __FILE__ ":" "243"), q, qFlagLocation("1""_q_writingSystemHighlighted(int)" "\0" __FILE__ ":" "243")); | - | ||||||||||||||||||||||||
157 | QObject::connect(familyList, qFlagLocation("2""highlighted(int)" "\0" __FILE__ ":" "244"), q, qFlagLocation("1""_q_familyHighlighted(int)" "\0" __FILE__ ":" "244")); | - | ||||||||||||||||||||||||
158 | QObject::connect(styleList, qFlagLocation("2""highlighted(int)" "\0" __FILE__ ":" "245"), q, qFlagLocation("1""_q_styleHighlighted(int)" "\0" __FILE__ ":" "245")); | - | ||||||||||||||||||||||||
159 | QObject::connect(sizeList, qFlagLocation("2""highlighted(int)" "\0" __FILE__ ":" "246"), q, qFlagLocation("1""_q_sizeHighlighted(int)" "\0" __FILE__ ":" "246")); | - | ||||||||||||||||||||||||
160 | QObject::connect(sizeEdit, qFlagLocation("2""textChanged(QString)" "\0" __FILE__ ":" "247"), q, qFlagLocation("1""_q_sizeChanged(QString)" "\0" __FILE__ ":" "247")); | - | ||||||||||||||||||||||||
161 | - | |||||||||||||||||||||||||
162 | QObject::connect(strikeout, qFlagLocation("2""clicked()" "\0" __FILE__ ":" "249"), q, qFlagLocation("1""_q_updateSample()" "\0" __FILE__ ":" "249")); | - | ||||||||||||||||||||||||
163 | QObject::connect(underline, qFlagLocation("2""clicked()" "\0" __FILE__ ":" "250"), q, qFlagLocation("1""_q_updateSample()" "\0" __FILE__ ":" "250")); | - | ||||||||||||||||||||||||
164 | - | |||||||||||||||||||||||||
165 | for (int i = 0; i < QFontDatabase::WritingSystemsCount
| 0 | ||||||||||||||||||||||||
166 | QFontDatabase::WritingSystem ws = QFontDatabase::WritingSystem(i); | - | ||||||||||||||||||||||||
167 | QString writingSystemName = QFontDatabase::writingSystemName(ws); | - | ||||||||||||||||||||||||
168 | if (writingSystemName.isEmpty()
| 0 | ||||||||||||||||||||||||
169 | break; never executed: break; | 0 | ||||||||||||||||||||||||
170 | writingSystemCombo->addItem(writingSystemName); | - | ||||||||||||||||||||||||
171 | } never executed: end of block | 0 | ||||||||||||||||||||||||
172 | - | |||||||||||||||||||||||||
173 | updateFamilies(); | - | ||||||||||||||||||||||||
174 | if (familyList->count() != 0
| 0 | ||||||||||||||||||||||||
175 | familyList->setCurrentItem(0); | - | ||||||||||||||||||||||||
176 | sizeList->setCurrentItem(0); | - | ||||||||||||||||||||||||
177 | } never executed: end of block | 0 | ||||||||||||||||||||||||
178 | - | |||||||||||||||||||||||||
179 | - | |||||||||||||||||||||||||
180 | QGridLayout *mainGrid = new QGridLayout(q); | - | ||||||||||||||||||||||||
181 | - | |||||||||||||||||||||||||
182 | int spacing = mainGrid->spacing(); | - | ||||||||||||||||||||||||
183 | if (spacing >= 0
| 0 | ||||||||||||||||||||||||
184 | mainGrid->setSpacing(0); | - | ||||||||||||||||||||||||
185 | - | |||||||||||||||||||||||||
186 | mainGrid->setColumnMinimumWidth(1, spacing); | - | ||||||||||||||||||||||||
187 | mainGrid->setColumnMinimumWidth(3, spacing); | - | ||||||||||||||||||||||||
188 | - | |||||||||||||||||||||||||
189 | int margin = 0; | - | ||||||||||||||||||||||||
190 | mainGrid->getContentsMargins(0, 0, 0, &margin); | - | ||||||||||||||||||||||||
191 | - | |||||||||||||||||||||||||
192 | mainGrid->setRowMinimumHeight(3, margin); | - | ||||||||||||||||||||||||
193 | mainGrid->setRowMinimumHeight(6, 2); | - | ||||||||||||||||||||||||
194 | mainGrid->setRowMinimumHeight(8, margin); | - | ||||||||||||||||||||||||
195 | } never executed: end of block | 0 | ||||||||||||||||||||||||
196 | - | |||||||||||||||||||||||||
197 | mainGrid->addWidget(familyAccel, 0, 0); | - | ||||||||||||||||||||||||
198 | mainGrid->addWidget(familyEdit, 1, 0); | - | ||||||||||||||||||||||||
199 | mainGrid->addWidget(familyList, 2, 0); | - | ||||||||||||||||||||||||
200 | - | |||||||||||||||||||||||||
201 | mainGrid->addWidget(styleAccel, 0, 2); | - | ||||||||||||||||||||||||
202 | mainGrid->addWidget(styleEdit, 1, 2); | - | ||||||||||||||||||||||||
203 | mainGrid->addWidget(styleList, 2, 2); | - | ||||||||||||||||||||||||
204 | - | |||||||||||||||||||||||||
205 | mainGrid->addWidget(sizeAccel, 0, 4); | - | ||||||||||||||||||||||||
206 | mainGrid->addWidget(sizeEdit, 1, 4); | - | ||||||||||||||||||||||||
207 | mainGrid->addWidget(sizeList, 2, 4); | - | ||||||||||||||||||||||||
208 | - | |||||||||||||||||||||||||
209 | mainGrid->setColumnStretch(0, 38); | - | ||||||||||||||||||||||||
210 | mainGrid->setColumnStretch(2, 24); | - | ||||||||||||||||||||||||
211 | mainGrid->setColumnStretch(4, 10); | - | ||||||||||||||||||||||||
212 | - | |||||||||||||||||||||||||
213 | mainGrid->addWidget(effects, 4, 0); | - | ||||||||||||||||||||||||
214 | - | |||||||||||||||||||||||||
215 | mainGrid->addWidget(sample, 4, 2, 4, 3); | - | ||||||||||||||||||||||||
216 | - | |||||||||||||||||||||||||
217 | mainGrid->addWidget(writingSystemAccel, 5, 0); | - | ||||||||||||||||||||||||
218 | mainGrid->addWidget(writingSystemCombo, 7, 0); | - | ||||||||||||||||||||||||
219 | - | |||||||||||||||||||||||||
220 | buttonBox = new QDialogButtonBox(q); | - | ||||||||||||||||||||||||
221 | mainGrid->addWidget(buttonBox, 9, 0, 1, 5); | - | ||||||||||||||||||||||||
222 | - | |||||||||||||||||||||||||
223 | QPushButton *button | - | ||||||||||||||||||||||||
224 | = static_cast<QPushButton *>(buttonBox->addButton(QDialogButtonBox::Ok)); | - | ||||||||||||||||||||||||
225 | QObject::connect(buttonBox, qFlagLocation("2""accepted()" "\0" __FILE__ ":" "312"), q, qFlagLocation("1""accept()" "\0" __FILE__ ":" "312")); | - | ||||||||||||||||||||||||
226 | button->setDefault(true); | - | ||||||||||||||||||||||||
227 | - | |||||||||||||||||||||||||
228 | buttonBox->addButton(QDialogButtonBox::Cancel); | - | ||||||||||||||||||||||||
229 | QObject::connect(buttonBox, qFlagLocation("2""rejected()" "\0" __FILE__ ":" "316"), q, qFlagLocation("1""reject()" "\0" __FILE__ ":" "316")); | - | ||||||||||||||||||||||||
230 | - | |||||||||||||||||||||||||
231 | - | |||||||||||||||||||||||||
232 | - | |||||||||||||||||||||||||
233 | - | |||||||||||||||||||||||||
234 | q->resize(500, 360); | - | ||||||||||||||||||||||||
235 | - | |||||||||||||||||||||||||
236 | - | |||||||||||||||||||||||||
237 | sizeEdit->installEventFilter(q); | - | ||||||||||||||||||||||||
238 | familyList->installEventFilter(q); | - | ||||||||||||||||||||||||
239 | styleList->installEventFilter(q); | - | ||||||||||||||||||||||||
240 | sizeList->installEventFilter(q); | - | ||||||||||||||||||||||||
241 | - | |||||||||||||||||||||||||
242 | familyList->setFocus(); | - | ||||||||||||||||||||||||
243 | retranslateStrings(); | - | ||||||||||||||||||||||||
244 | sampleEdit->setObjectName(QLatin1String("qt_fontDialog_sampleEdit")); | - | ||||||||||||||||||||||||
245 | } never executed: end of block | 0 | ||||||||||||||||||||||||
246 | - | |||||||||||||||||||||||||
247 | - | |||||||||||||||||||||||||
248 | - | |||||||||||||||||||||||||
249 | - | |||||||||||||||||||||||||
250 | - | |||||||||||||||||||||||||
251 | - | |||||||||||||||||||||||||
252 | QFontDialog::~QFontDialog() | - | ||||||||||||||||||||||||
253 | { | - | ||||||||||||||||||||||||
254 | } | - | ||||||||||||||||||||||||
255 | QFont QFontDialog::getFont(bool *ok, const QFont &initial, QWidget *parent, const QString &title, | - | ||||||||||||||||||||||||
256 | FontDialogOptions options) | - | ||||||||||||||||||||||||
257 | { | - | ||||||||||||||||||||||||
258 | return never executed: QFontDialogPrivate::getFont(ok, initial, parent, title, options);return QFontDialogPrivate::getFont(ok, initial, parent, title, options); never executed: return QFontDialogPrivate::getFont(ok, initial, parent, title, options); | 0 | ||||||||||||||||||||||||
259 | } | - | ||||||||||||||||||||||||
260 | QFont QFontDialog::getFont(bool *ok, QWidget *parent) | - | ||||||||||||||||||||||||
261 | { | - | ||||||||||||||||||||||||
262 | QFont initial; | - | ||||||||||||||||||||||||
263 | return never executed: QFontDialogPrivate::getFont(ok, initial, parent, QString(), 0);return QFontDialogPrivate::getFont(ok, initial, parent, QString(), 0); never executed: return QFontDialogPrivate::getFont(ok, initial, parent, QString(), 0); | 0 | ||||||||||||||||||||||||
264 | } | - | ||||||||||||||||||||||||
265 | - | |||||||||||||||||||||||||
266 | QFont QFontDialogPrivate::getFont(bool *ok, const QFont &initial, QWidget *parent, | - | ||||||||||||||||||||||||
267 | const QString &title, QFontDialog::FontDialogOptions options) | - | ||||||||||||||||||||||||
268 | { | - | ||||||||||||||||||||||||
269 | QFontDialog dlg(parent); | - | ||||||||||||||||||||||||
270 | dlg.setOptions(options); | - | ||||||||||||||||||||||||
271 | dlg.setCurrentFont(initial); | - | ||||||||||||||||||||||||
272 | if (!title.isEmpty()
| 0 | ||||||||||||||||||||||||
273 | dlg.setWindowTitle(title); never executed: dlg.setWindowTitle(title); | 0 | ||||||||||||||||||||||||
274 | - | |||||||||||||||||||||||||
275 | int ret = (dlg.exec()
| 0 | ||||||||||||||||||||||||
276 | if (ok
| 0 | ||||||||||||||||||||||||
277 | * never executed: ok = !!ret;*ok = !!ret; never executed: *ok = !!ret; | 0 | ||||||||||||||||||||||||
278 | if (ret
| 0 | ||||||||||||||||||||||||
279 | return never executed: dlg.selectedFont();return dlg.selectedFont(); never executed: return dlg.selectedFont(); | 0 | ||||||||||||||||||||||||
280 | } else { | - | ||||||||||||||||||||||||
281 | return never executed: initial;return initial; never executed: return initial; | 0 | ||||||||||||||||||||||||
282 | } | - | ||||||||||||||||||||||||
283 | } | - | ||||||||||||||||||||||||
284 | bool QFontDialog::eventFilter(QObject *o , QEvent *e) | - | ||||||||||||||||||||||||
285 | { | - | ||||||||||||||||||||||||
286 | QFontDialogPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
287 | if (e->type() == QEvent::KeyPress
| 0 | ||||||||||||||||||||||||
288 | QKeyEvent *k = (QKeyEvent *)e; | - | ||||||||||||||||||||||||
289 | if (o == d->sizeEdit
| 0 | ||||||||||||||||||||||||
290 | (k->key() == Qt::Key_Up
| 0 | ||||||||||||||||||||||||
291 | k->key() == Qt::Key_Down
| 0 | ||||||||||||||||||||||||
292 | k->key() == Qt::Key_PageUp
| 0 | ||||||||||||||||||||||||
293 | k->key() == Qt::Key_PageDown
| 0 | ||||||||||||||||||||||||
294 | - | |||||||||||||||||||||||||
295 | int ci = d->sizeList->currentItem(); | - | ||||||||||||||||||||||||
296 | (void)QApplication::sendEvent(d->sizeList, k); | - | ||||||||||||||||||||||||
297 | - | |||||||||||||||||||||||||
298 | if (ci != d->sizeList->currentItem()
| 0 | ||||||||||||||||||||||||
299 | && style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, this)
| 0 | ||||||||||||||||||||||||
300 | d->sizeEdit->selectAll(); never executed: d->sizeEdit->selectAll(); | 0 | ||||||||||||||||||||||||
301 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||||||||
302 | } else if ((o == d->familyList
| 0 | ||||||||||||||||||||||||
303 | (k->key() == Qt::Key_Return
| 0 | ||||||||||||||||||||||||
304 | k->accept(); | - | ||||||||||||||||||||||||
305 | accept(); | - | ||||||||||||||||||||||||
306 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||||||||
307 | } | - | ||||||||||||||||||||||||
308 | } never executed: else if (e->type() == QEvent::FocusInend of block
| 0 | ||||||||||||||||||||||||
309 | && style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, this)
| 0 | ||||||||||||||||||||||||
310 | if (o == d->familyList
| 0 | ||||||||||||||||||||||||
311 | d->familyEdit->selectAll(); never executed: d->familyEdit->selectAll(); | 0 | ||||||||||||||||||||||||
312 | else if (o == d->styleList
| 0 | ||||||||||||||||||||||||
313 | d->styleEdit->selectAll(); never executed: d->styleEdit->selectAll(); | 0 | ||||||||||||||||||||||||
314 | else if (o == d->sizeList
| 0 | ||||||||||||||||||||||||
315 | d->sizeEdit->selectAll(); never executed: d->sizeEdit->selectAll(); | 0 | ||||||||||||||||||||||||
316 | } never executed: else if (e->type() == QEvent::MouseButtonPressend of block
| 0 | ||||||||||||||||||||||||
317 | d->sizeEdit->setFocus(); | - | ||||||||||||||||||||||||
318 | } never executed: end of block | 0 | ||||||||||||||||||||||||
319 | return never executed: QDialog::eventFilter(o, e);return QDialog::eventFilter(o, e); never executed: return QDialog::eventFilter(o, e); | 0 | ||||||||||||||||||||||||
320 | } | - | ||||||||||||||||||||||||
321 | - | |||||||||||||||||||||||||
322 | void QFontDialogPrivate::initHelper(QPlatformDialogHelper *h) | - | ||||||||||||||||||||||||
323 | { | - | ||||||||||||||||||||||||
324 | QFontDialog *d = q_func(); | - | ||||||||||||||||||||||||
325 | QObject::connect(h, qFlagLocation("2""currentFontChanged(QFont)" "\0" __FILE__ ":" "466"), d, qFlagLocation("2""currentFontChanged(QFont)" "\0" __FILE__ ":" "466")); | - | ||||||||||||||||||||||||
326 | QObject::connect(h, qFlagLocation("2""fontSelected(QFont)" "\0" __FILE__ ":" "467"), d, qFlagLocation("2""fontSelected(QFont)" "\0" __FILE__ ":" "467")); | - | ||||||||||||||||||||||||
327 | static_cast<QPlatformFontDialogHelper *>(h)->setOptions(options); | - | ||||||||||||||||||||||||
328 | } never executed: end of block | 0 | ||||||||||||||||||||||||
329 | - | |||||||||||||||||||||||||
330 | void QFontDialogPrivate::helperPrepareShow(QPlatformDialogHelper *) | - | ||||||||||||||||||||||||
331 | { | - | ||||||||||||||||||||||||
332 | options->setWindowTitle(q_func()->windowTitle()); | - | ||||||||||||||||||||||||
333 | } never executed: end of block | 0 | ||||||||||||||||||||||||
334 | - | |||||||||||||||||||||||||
335 | - | |||||||||||||||||||||||||
336 | - | |||||||||||||||||||||||||
337 | - | |||||||||||||||||||||||||
338 | - | |||||||||||||||||||||||||
339 | - | |||||||||||||||||||||||||
340 | void QFontDialogPrivate::updateFamilies() | - | ||||||||||||||||||||||||
341 | { | - | ||||||||||||||||||||||||
342 | QFontDialog * const q = q_func(); | - | ||||||||||||||||||||||||
343 | - | |||||||||||||||||||||||||
344 | enum match_t { MATCH_NONE = 0, MATCH_LAST_RESORT = 1, MATCH_APP = 2, MATCH_FAMILY = 3 }; | - | ||||||||||||||||||||||||
345 | - | |||||||||||||||||||||||||
346 | const QFontDialog::FontDialogOptions scalableMask = (QFontDialog::ScalableFonts | QFontDialog::NonScalableFonts); | - | ||||||||||||||||||||||||
347 | const QFontDialog::FontDialogOptions spacingMask = (QFontDialog::ProportionalFonts | QFontDialog::MonospacedFonts); | - | ||||||||||||||||||||||||
348 | const QFontDialog::FontDialogOptions options = q->options(); | - | ||||||||||||||||||||||||
349 | - | |||||||||||||||||||||||||
350 | QFontDatabase fdb; | - | ||||||||||||||||||||||||
351 | - | |||||||||||||||||||||||||
352 | QStringList familyNames; | - | ||||||||||||||||||||||||
353 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(fdb.families(writingSystem))>::type> _container_((fdb.families(writingSystem))); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QString &family = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||||||||||||||
354 | if (fdb.isPrivateFamily(family)
| 0 | ||||||||||||||||||||||||
355 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
356 | - | |||||||||||||||||||||||||
357 | if ((
| 0 | ||||||||||||||||||||||||
358 | if (bool(options & QFontDialog::ScalableFonts) != fdb.isSmoothlyScalable(family)
| 0 | ||||||||||||||||||||||||
359 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
360 | } never executed: end of block | 0 | ||||||||||||||||||||||||
361 | if ((
| 0 | ||||||||||||||||||||||||
362 | if (bool(options & QFontDialog::MonospacedFonts) != fdb.isFixedPitch(family)
| 0 | ||||||||||||||||||||||||
363 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
364 | } never executed: end of block | 0 | ||||||||||||||||||||||||
365 | familyNames << family; | - | ||||||||||||||||||||||||
366 | } never executed: end of block | 0 | ||||||||||||||||||||||||
367 | - | |||||||||||||||||||||||||
368 | familyList->model()->setStringList(familyNames); | - | ||||||||||||||||||||||||
369 | - | |||||||||||||||||||||||||
370 | QString foundryName1, familyName1, foundryName2, familyName2; | - | ||||||||||||||||||||||||
371 | int bestFamilyMatch = -1; | - | ||||||||||||||||||||||||
372 | match_t bestFamilyType = MATCH_NONE; | - | ||||||||||||||||||||||||
373 | - | |||||||||||||||||||||||||
374 | QFont f; | - | ||||||||||||||||||||||||
375 | - | |||||||||||||||||||||||||
376 | - | |||||||||||||||||||||||||
377 | QFontDatabase::parseFontName(family, foundryName1, familyName1); | - | ||||||||||||||||||||||||
378 | - | |||||||||||||||||||||||||
379 | QStringList::const_iterator it = familyNames.constBegin(); | - | ||||||||||||||||||||||||
380 | int i = 0; | - | ||||||||||||||||||||||||
381 | for(; it != familyNames.constEnd()
| 0 | ||||||||||||||||||||||||
382 | QFontDatabase::parseFontName(*it, foundryName2, familyName2); | - | ||||||||||||||||||||||||
383 | - | |||||||||||||||||||||||||
384 | - | |||||||||||||||||||||||||
385 | if (familyName1 == familyName2
| 0 | ||||||||||||||||||||||||
386 | bestFamilyType = MATCH_FAMILY; | - | ||||||||||||||||||||||||
387 | if (foundryName1 == foundryName2
| 0 | ||||||||||||||||||||||||
388 | bestFamilyMatch = i; | - | ||||||||||||||||||||||||
389 | break; never executed: break; | 0 | ||||||||||||||||||||||||
390 | } | - | ||||||||||||||||||||||||
391 | if (bestFamilyMatch < MATCH_FAMILY
| 0 | ||||||||||||||||||||||||
392 | bestFamilyMatch = i; never executed: bestFamilyMatch = i; | 0 | ||||||||||||||||||||||||
393 | } never executed: end of block | 0 | ||||||||||||||||||||||||
394 | - | |||||||||||||||||||||||||
395 | - | |||||||||||||||||||||||||
396 | match_t type = MATCH_NONE; | - | ||||||||||||||||||||||||
397 | if (bestFamilyType <= MATCH_NONE
| 0 | ||||||||||||||||||||||||
398 | type = MATCH_LAST_RESORT; never executed: type = MATCH_LAST_RESORT; | 0 | ||||||||||||||||||||||||
399 | if (bestFamilyType <= MATCH_LAST_RESORT
| 0 | ||||||||||||||||||||||||
400 | type = MATCH_APP; never executed: type = MATCH_APP; | 0 | ||||||||||||||||||||||||
401 | - | |||||||||||||||||||||||||
402 | if (type != MATCH_NONE
| 0 | ||||||||||||||||||||||||
403 | bestFamilyType = type; | - | ||||||||||||||||||||||||
404 | bestFamilyMatch = i; | - | ||||||||||||||||||||||||
405 | } never executed: end of block | 0 | ||||||||||||||||||||||||
406 | } never executed: end of block | 0 | ||||||||||||||||||||||||
407 | - | |||||||||||||||||||||||||
408 | if (i != -1
| 0 | ||||||||||||||||||||||||
409 | familyList->setCurrentItem(bestFamilyMatch); never executed: familyList->setCurrentItem(bestFamilyMatch); | 0 | ||||||||||||||||||||||||
410 | else | - | ||||||||||||||||||||||||
411 | familyList->setCurrentItem(0); never executed: familyList->setCurrentItem(0); | 0 | ||||||||||||||||||||||||
412 | familyEdit->setText(familyList->currentText()); | - | ||||||||||||||||||||||||
413 | if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q)
| 0 | ||||||||||||||||||||||||
414 | && familyList->hasFocus()
| 0 | ||||||||||||||||||||||||
415 | familyEdit->selectAll(); never executed: familyEdit->selectAll(); | 0 | ||||||||||||||||||||||||
416 | - | |||||||||||||||||||||||||
417 | updateStyles(); | - | ||||||||||||||||||||||||
418 | } never executed: end of block | 0 | ||||||||||||||||||||||||
419 | - | |||||||||||||||||||||||||
420 | - | |||||||||||||||||||||||||
421 | - | |||||||||||||||||||||||||
422 | - | |||||||||||||||||||||||||
423 | - | |||||||||||||||||||||||||
424 | void QFontDialogPrivate::updateStyles() | - | ||||||||||||||||||||||||
425 | { | - | ||||||||||||||||||||||||
426 | QFontDialog * const q = q_func(); | - | ||||||||||||||||||||||||
427 | QStringList styles = fdb.styles(familyList->currentText()); | - | ||||||||||||||||||||||||
428 | styleList->model()->setStringList(styles); | - | ||||||||||||||||||||||||
429 | - | |||||||||||||||||||||||||
430 | if (styles.isEmpty()
| 0 | ||||||||||||||||||||||||
431 | styleEdit->clear(); | - | ||||||||||||||||||||||||
432 | smoothScalable = false; | - | ||||||||||||||||||||||||
433 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
434 | if (!style.isEmpty()
| 0 | ||||||||||||||||||||||||
435 | bool found = false; | - | ||||||||||||||||||||||||
436 | bool first = true; | - | ||||||||||||||||||||||||
437 | QString cstyle = style; | - | ||||||||||||||||||||||||
438 | - | |||||||||||||||||||||||||
439 | redo: code before this statement never executed: redo: | 0 | ||||||||||||||||||||||||
440 | for (int i = 0; i < (int)styleList->count()
| 0 | ||||||||||||||||||||||||
441 | if (cstyle == styleList->text(i)
| 0 | ||||||||||||||||||||||||
442 | styleList->setCurrentItem(i); | - | ||||||||||||||||||||||||
443 | found = true; | - | ||||||||||||||||||||||||
444 | break; never executed: break; | 0 | ||||||||||||||||||||||||
445 | } | - | ||||||||||||||||||||||||
446 | } never executed: end of block | 0 | ||||||||||||||||||||||||
447 | if (!found
| 0 | ||||||||||||||||||||||||
448 | if (cstyle.contains(QLatin1String("Italic"))
| 0 | ||||||||||||||||||||||||
449 | cstyle.replace(QLatin1String("Italic"), QLatin1String("Oblique")); | - | ||||||||||||||||||||||||
450 | first = false; | - | ||||||||||||||||||||||||
451 | goto never executed: redo;goto redo; never executed: goto redo; | 0 | ||||||||||||||||||||||||
452 | } else if (cstyle.contains(QLatin1String("Oblique"))
| 0 | ||||||||||||||||||||||||
453 | cstyle.replace(QLatin1String("Oblique"), QLatin1String("Italic")); | - | ||||||||||||||||||||||||
454 | first = false; | - | ||||||||||||||||||||||||
455 | goto never executed: redo;goto redo; never executed: goto redo; | 0 | ||||||||||||||||||||||||
456 | } | - | ||||||||||||||||||||||||
457 | } never executed: end of block | 0 | ||||||||||||||||||||||||
458 | if (!found
| 0 | ||||||||||||||||||||||||
459 | styleList->setCurrentItem(0); never executed: styleList->setCurrentItem(0); | 0 | ||||||||||||||||||||||||
460 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
461 | styleList->setCurrentItem(0); | - | ||||||||||||||||||||||||
462 | } never executed: end of block | 0 | ||||||||||||||||||||||||
463 | - | |||||||||||||||||||||||||
464 | styleEdit->setText(styleList->currentText()); | - | ||||||||||||||||||||||||
465 | if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q)
| 0 | ||||||||||||||||||||||||
466 | && styleList->hasFocus()
| 0 | ||||||||||||||||||||||||
467 | styleEdit->selectAll(); never executed: styleEdit->selectAll(); | 0 | ||||||||||||||||||||||||
468 | - | |||||||||||||||||||||||||
469 | smoothScalable = fdb.isSmoothlyScalable(familyList->currentText(), styleList->currentText()); | - | ||||||||||||||||||||||||
470 | } never executed: end of block | 0 | ||||||||||||||||||||||||
471 | - | |||||||||||||||||||||||||
472 | updateSizes(); | - | ||||||||||||||||||||||||
473 | } never executed: end of block | 0 | ||||||||||||||||||||||||
474 | - | |||||||||||||||||||||||||
475 | - | |||||||||||||||||||||||||
476 | - | |||||||||||||||||||||||||
477 | - | |||||||||||||||||||||||||
478 | - | |||||||||||||||||||||||||
479 | - | |||||||||||||||||||||||||
480 | - | |||||||||||||||||||||||||
481 | void QFontDialogPrivate::updateSizes() | - | ||||||||||||||||||||||||
482 | { | - | ||||||||||||||||||||||||
483 | QFontDialog * const q = q_func(); | - | ||||||||||||||||||||||||
484 | - | |||||||||||||||||||||||||
485 | if (!familyList->currentText().isEmpty()
| 0 | ||||||||||||||||||||||||
486 | QList<int> sizes = fdb.pointSizes(familyList->currentText(), styleList->currentText()); | - | ||||||||||||||||||||||||
487 | - | |||||||||||||||||||||||||
488 | int i = 0; | - | ||||||||||||||||||||||||
489 | int current = -1; | - | ||||||||||||||||||||||||
490 | QStringList str_sizes; | - | ||||||||||||||||||||||||
491 | str_sizes.reserve(sizes.size()); | - | ||||||||||||||||||||||||
492 | for(QList<int>::const_iterator it = sizes.constBegin(); it != sizes.constEnd()
| 0 | ||||||||||||||||||||||||
493 | str_sizes.append(QString::number(*it)); | - | ||||||||||||||||||||||||
494 | if (current == -1
| 0 | ||||||||||||||||||||||||
495 | current = i; never executed: current = i; | 0 | ||||||||||||||||||||||||
496 | ++i; | - | ||||||||||||||||||||||||
497 | } never executed: end of block | 0 | ||||||||||||||||||||||||
498 | sizeList->model()->setStringList(str_sizes); | - | ||||||||||||||||||||||||
499 | if (current != -1
| 0 | ||||||||||||||||||||||||
500 | sizeList->setCurrentItem(current); never executed: sizeList->setCurrentItem(current); | 0 | ||||||||||||||||||||||||
501 | - | |||||||||||||||||||||||||
502 | const QSignalBlocker blocker(sizeEdit); | - | ||||||||||||||||||||||||
503 | sizeEdit->setText((smoothScalable ? QString::number(size) : sizeList->currentText())); | - | ||||||||||||||||||||||||
504 | if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q)
| 0 | ||||||||||||||||||||||||
505 | && sizeList->hasFocus()
| 0 | ||||||||||||||||||||||||
506 | sizeEdit->selectAll(); never executed: sizeEdit->selectAll(); | 0 | ||||||||||||||||||||||||
507 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
508 | sizeEdit->clear(); | - | ||||||||||||||||||||||||
509 | } never executed: end of block | 0 | ||||||||||||||||||||||||
510 | - | |||||||||||||||||||||||||
511 | _q_updateSample(); | - | ||||||||||||||||||||||||
512 | } never executed: end of block | 0 | ||||||||||||||||||||||||
513 | - | |||||||||||||||||||||||||
514 | void QFontDialogPrivate::_q_updateSample() | - | ||||||||||||||||||||||||
515 | { | - | ||||||||||||||||||||||||
516 | - | |||||||||||||||||||||||||
517 | int pSize = sizeEdit->text().toInt(); | - | ||||||||||||||||||||||||
518 | QFont newFont(fdb.font(familyList->currentText(), style, pSize)); | - | ||||||||||||||||||||||||
519 | newFont.setStrikeOut(strikeout->isChecked()); | - | ||||||||||||||||||||||||
520 | newFont.setUnderline(underline->isChecked()); | - | ||||||||||||||||||||||||
521 | - | |||||||||||||||||||||||||
522 | if (familyList->currentText().isEmpty()
| 0 | ||||||||||||||||||||||||
523 | sampleEdit->clear(); never executed: sampleEdit->clear(); | 0 | ||||||||||||||||||||||||
524 | - | |||||||||||||||||||||||||
525 | updateSampleFont(newFont); | - | ||||||||||||||||||||||||
526 | } never executed: end of block | 0 | ||||||||||||||||||||||||
527 | - | |||||||||||||||||||||||||
528 | void QFontDialogPrivate::updateSampleFont(const QFont &newFont) | - | ||||||||||||||||||||||||
529 | { | - | ||||||||||||||||||||||||
530 | QFontDialog * const q = q_func(); | - | ||||||||||||||||||||||||
531 | if (newFont != sampleEdit->font()
| 0 | ||||||||||||||||||||||||
532 | sampleEdit->setFont(newFont); | - | ||||||||||||||||||||||||
533 | q->currentFontChanged(newFont); | - | ||||||||||||||||||||||||
534 | } never executed: end of block | 0 | ||||||||||||||||||||||||
535 | } never executed: end of block | 0 | ||||||||||||||||||||||||
536 | - | |||||||||||||||||||||||||
537 | - | |||||||||||||||||||||||||
538 | - | |||||||||||||||||||||||||
539 | - | |||||||||||||||||||||||||
540 | void QFontDialogPrivate::_q_writingSystemHighlighted(int index) | - | ||||||||||||||||||||||||
541 | { | - | ||||||||||||||||||||||||
542 | writingSystem = QFontDatabase::WritingSystem(index); | - | ||||||||||||||||||||||||
543 | sampleEdit->setText(fdb.writingSystemSample(writingSystem)); | - | ||||||||||||||||||||||||
544 | updateFamilies(); | - | ||||||||||||||||||||||||
545 | } never executed: end of block | 0 | ||||||||||||||||||||||||
546 | - | |||||||||||||||||||||||||
547 | - | |||||||||||||||||||||||||
548 | - | |||||||||||||||||||||||||
549 | - | |||||||||||||||||||||||||
550 | void QFontDialogPrivate::_q_familyHighlighted(int i) | - | ||||||||||||||||||||||||
551 | { | - | ||||||||||||||||||||||||
552 | QFontDialog * const q = q_func(); | - | ||||||||||||||||||||||||
553 | family = familyList->text(i); | - | ||||||||||||||||||||||||
554 | familyEdit->setText(family); | - | ||||||||||||||||||||||||
555 | if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q)
| 0 | ||||||||||||||||||||||||
556 | && familyList->hasFocus()
| 0 | ||||||||||||||||||||||||
557 | familyEdit->selectAll(); never executed: familyEdit->selectAll(); | 0 | ||||||||||||||||||||||||
558 | - | |||||||||||||||||||||||||
559 | updateStyles(); | - | ||||||||||||||||||||||||
560 | } never executed: end of block | 0 | ||||||||||||||||||||||||
561 | - | |||||||||||||||||||||||||
562 | - | |||||||||||||||||||||||||
563 | - | |||||||||||||||||||||||||
564 | - | |||||||||||||||||||||||||
565 | - | |||||||||||||||||||||||||
566 | - | |||||||||||||||||||||||||
567 | void QFontDialogPrivate::_q_styleHighlighted(int index) | - | ||||||||||||||||||||||||
568 | { | - | ||||||||||||||||||||||||
569 | QFontDialog * const q = q_func(); | - | ||||||||||||||||||||||||
570 | QString s = styleList->text(index); | - | ||||||||||||||||||||||||
571 | styleEdit->setText(s); | - | ||||||||||||||||||||||||
572 | if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q)
| 0 | ||||||||||||||||||||||||
573 | && styleList->hasFocus()
| 0 | ||||||||||||||||||||||||
574 | styleEdit->selectAll(); never executed: styleEdit->selectAll(); | 0 | ||||||||||||||||||||||||
575 | - | |||||||||||||||||||||||||
576 | style = s; | - | ||||||||||||||||||||||||
577 | - | |||||||||||||||||||||||||
578 | updateSizes(); | - | ||||||||||||||||||||||||
579 | } never executed: end of block | 0 | ||||||||||||||||||||||||
580 | - | |||||||||||||||||||||||||
581 | - | |||||||||||||||||||||||||
582 | - | |||||||||||||||||||||||||
583 | - | |||||||||||||||||||||||||
584 | - | |||||||||||||||||||||||||
585 | - | |||||||||||||||||||||||||
586 | void QFontDialogPrivate::_q_sizeHighlighted(int index) | - | ||||||||||||||||||||||||
587 | { | - | ||||||||||||||||||||||||
588 | QFontDialog * const q = q_func(); | - | ||||||||||||||||||||||||
589 | QString s = sizeList->text(index); | - | ||||||||||||||||||||||||
590 | sizeEdit->setText(s); | - | ||||||||||||||||||||||||
591 | if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q)
| 0 | ||||||||||||||||||||||||
592 | && sizeEdit->hasFocus()
| 0 | ||||||||||||||||||||||||
593 | sizeEdit->selectAll(); never executed: sizeEdit->selectAll(); | 0 | ||||||||||||||||||||||||
594 | - | |||||||||||||||||||||||||
595 | size = s.toInt(); | - | ||||||||||||||||||||||||
596 | _q_updateSample(); | - | ||||||||||||||||||||||||
597 | } never executed: end of block | 0 | ||||||||||||||||||||||||
598 | - | |||||||||||||||||||||||||
599 | - | |||||||||||||||||||||||||
600 | - | |||||||||||||||||||||||||
601 | - | |||||||||||||||||||||||||
602 | - | |||||||||||||||||||||||||
603 | - | |||||||||||||||||||||||||
604 | - | |||||||||||||||||||||||||
605 | void QFontDialogPrivate::_q_sizeChanged(const QString &s) | - | ||||||||||||||||||||||||
606 | { | - | ||||||||||||||||||||||||
607 | - | |||||||||||||||||||||||||
608 | int size = s.toInt(); | - | ||||||||||||||||||||||||
609 | if (this->size == size
| 0 | ||||||||||||||||||||||||
610 | return; never executed: return; | 0 | ||||||||||||||||||||||||
611 | - | |||||||||||||||||||||||||
612 | this->size = size; | - | ||||||||||||||||||||||||
613 | if (sizeList->count() != 0
| 0 | ||||||||||||||||||||||||
614 | int i; | - | ||||||||||||||||||||||||
615 | for (i = 0; i < sizeList->count() - 1
| 0 | ||||||||||||||||||||||||
616 | if (sizeList->text(i).toInt() >= this->size
| 0 | ||||||||||||||||||||||||
617 | break; never executed: break; | 0 | ||||||||||||||||||||||||
618 | } never executed: end of block | 0 | ||||||||||||||||||||||||
619 | const QSignalBlocker blocker(sizeList); | - | ||||||||||||||||||||||||
620 | if (sizeList->text(i).toInt() == this->size
| 0 | ||||||||||||||||||||||||
621 | sizeList->setCurrentItem(i); never executed: sizeList->setCurrentItem(i); | 0 | ||||||||||||||||||||||||
622 | else | - | ||||||||||||||||||||||||
623 | sizeList->clearSelection(); never executed: sizeList->clearSelection(); | 0 | ||||||||||||||||||||||||
624 | } | - | ||||||||||||||||||||||||
625 | _q_updateSample(); | - | ||||||||||||||||||||||||
626 | } never executed: end of block | 0 | ||||||||||||||||||||||||
627 | - | |||||||||||||||||||||||||
628 | void QFontDialogPrivate::retranslateStrings() | - | ||||||||||||||||||||||||
629 | { | - | ||||||||||||||||||||||||
630 | familyAccel->setText(QFontDialog::tr("&Font")); | - | ||||||||||||||||||||||||
631 | styleAccel->setText(QFontDialog::tr("Font st&yle")); | - | ||||||||||||||||||||||||
632 | sizeAccel->setText(QFontDialog::tr("&Size")); | - | ||||||||||||||||||||||||
633 | effects->setTitle(QFontDialog::tr("Effects")); | - | ||||||||||||||||||||||||
634 | strikeout->setText(QFontDialog::tr("Stri&keout")); | - | ||||||||||||||||||||||||
635 | underline->setText(QFontDialog::tr("&Underline")); | - | ||||||||||||||||||||||||
636 | sample->setTitle(QFontDialog::tr("Sample")); | - | ||||||||||||||||||||||||
637 | writingSystemAccel->setText(QFontDialog::tr("Wr&iting System")); | - | ||||||||||||||||||||||||
638 | } never executed: end of block | 0 | ||||||||||||||||||||||||
639 | - | |||||||||||||||||||||||||
640 | - | |||||||||||||||||||||||||
641 | - | |||||||||||||||||||||||||
642 | - | |||||||||||||||||||||||||
643 | void QFontDialog::changeEvent(QEvent *e) | - | ||||||||||||||||||||||||
644 | { | - | ||||||||||||||||||||||||
645 | QFontDialogPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
646 | if (e->type() == QEvent::LanguageChange
| 0 | ||||||||||||||||||||||||
647 | d->retranslateStrings(); | - | ||||||||||||||||||||||||
648 | } never executed: end of block | 0 | ||||||||||||||||||||||||
649 | QDialog::changeEvent(e); | - | ||||||||||||||||||||||||
650 | } never executed: end of block | 0 | ||||||||||||||||||||||||
651 | void QFontDialog::setCurrentFont(const QFont &font) | - | ||||||||||||||||||||||||
652 | { | - | ||||||||||||||||||||||||
653 | QFontDialogPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
654 | d->family = font.family(); | - | ||||||||||||||||||||||||
655 | d->style = d->fdb.styleString(font); | - | ||||||||||||||||||||||||
656 | d->size = font.pointSize(); | - | ||||||||||||||||||||||||
657 | if (d->size == -1
| 0 | ||||||||||||||||||||||||
658 | QFontInfo fi(font); | - | ||||||||||||||||||||||||
659 | d->size = fi.pointSize(); | - | ||||||||||||||||||||||||
660 | } never executed: end of block | 0 | ||||||||||||||||||||||||
661 | d->strikeout->setChecked(font.strikeOut()); | - | ||||||||||||||||||||||||
662 | d->underline->setChecked(font.underline()); | - | ||||||||||||||||||||||||
663 | d->updateFamilies(); | - | ||||||||||||||||||||||||
664 | if (d->canBeNativeDialog()
| 0 | ||||||||||||||||||||||||
665 | if (QPlatformFontDialogHelper *helper = d->platformFontDialogHelper()
| 0 | ||||||||||||||||||||||||
666 | helper->setCurrentFont(font); never executed: helper->setCurrentFont(font); | 0 | ||||||||||||||||||||||||
667 | } never executed: end of block | 0 | ||||||||||||||||||||||||
668 | } never executed: end of block | 0 | ||||||||||||||||||||||||
669 | QFont QFontDialog::currentFont() const | - | ||||||||||||||||||||||||
670 | { | - | ||||||||||||||||||||||||
671 | const QFontDialogPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
672 | if (d->canBeNativeDialog()
| 0 | ||||||||||||||||||||||||
673 | if (const
| 0 | ||||||||||||||||||||||||
674 | return never executed: helper->currentFont();return helper->currentFont(); never executed: return helper->currentFont(); | 0 | ||||||||||||||||||||||||
675 | } never executed: end of block | 0 | ||||||||||||||||||||||||
676 | return never executed: d->sampleEdit->font();return d->sampleEdit->font(); never executed: return d->sampleEdit->font(); | 0 | ||||||||||||||||||||||||
677 | } | - | ||||||||||||||||||||||||
678 | QFont QFontDialog::selectedFont() const | - | ||||||||||||||||||||||||
679 | { | - | ||||||||||||||||||||||||
680 | const QFontDialogPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
681 | return never executed: d->selectedFont;return d->selectedFont; never executed: return d->selectedFont; | 0 | ||||||||||||||||||||||||
682 | } | - | ||||||||||||||||||||||||
683 | void QFontDialog::setOption(FontDialogOption option, bool on) | - | ||||||||||||||||||||||||
684 | { | - | ||||||||||||||||||||||||
685 | const QFontDialog::FontDialogOptions previousOptions = options(); | - | ||||||||||||||||||||||||
686 | if (!(previousOptions & option) != !on
| 0 | ||||||||||||||||||||||||
687 | setOptions(previousOptions ^ option); never executed: setOptions(previousOptions ^ option); | 0 | ||||||||||||||||||||||||
688 | } never executed: end of block | 0 | ||||||||||||||||||||||||
689 | - | |||||||||||||||||||||||||
690 | - | |||||||||||||||||||||||||
691 | - | |||||||||||||||||||||||||
692 | - | |||||||||||||||||||||||||
693 | - | |||||||||||||||||||||||||
694 | - | |||||||||||||||||||||||||
695 | - | |||||||||||||||||||||||||
696 | bool QFontDialog::testOption(FontDialogOption option) const | - | ||||||||||||||||||||||||
697 | { | - | ||||||||||||||||||||||||
698 | const QFontDialogPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
699 | return never executed: d->options->testOption(static_cast<QFontDialogOptions::FontDialogOption>(option));return d->options->testOption(static_cast<QFontDialogOptions::FontDialogOption>(option)); never executed: return d->options->testOption(static_cast<QFontDialogOptions::FontDialogOption>(option)); | 0 | ||||||||||||||||||||||||
700 | } | - | ||||||||||||||||||||||||
701 | void QFontDialog::setOptions(FontDialogOptions options) | - | ||||||||||||||||||||||||
702 | { | - | ||||||||||||||||||||||||
703 | QFontDialogPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
704 | - | |||||||||||||||||||||||||
705 | if (QFontDialog::options() == options
| 0 | ||||||||||||||||||||||||
706 | return; never executed: return; | 0 | ||||||||||||||||||||||||
707 | - | |||||||||||||||||||||||||
708 | d->options->setOptions(QFontDialogOptions::FontDialogOptions(int(options))); | - | ||||||||||||||||||||||||
709 | d->buttonBox->setVisible(!(options & NoButtons)); | - | ||||||||||||||||||||||||
710 | } never executed: end of block | 0 | ||||||||||||||||||||||||
711 | - | |||||||||||||||||||||||||
712 | QFontDialog::FontDialogOptions QFontDialog::options() const | - | ||||||||||||||||||||||||
713 | { | - | ||||||||||||||||||||||||
714 | const QFontDialogPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
715 | return never executed: QFontDialog::FontDialogOptions(int(d->options->options()));return QFontDialog::FontDialogOptions(int(d->options->options())); never executed: return QFontDialog::FontDialogOptions(int(d->options->options())); | 0 | ||||||||||||||||||||||||
716 | } | - | ||||||||||||||||||||||||
717 | void QFontDialog::open(QObject *receiver, const char *member) | - | ||||||||||||||||||||||||
718 | { | - | ||||||||||||||||||||||||
719 | QFontDialogPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
720 | connect(this, qFlagLocation("2""fontSelected(QFont)" "\0" __FILE__ ":" "950"), receiver, member); | - | ||||||||||||||||||||||||
721 | d->receiverToDisconnectOnClose = receiver; | - | ||||||||||||||||||||||||
722 | d->memberToDisconnectOnClose = member; | - | ||||||||||||||||||||||||
723 | QDialog::open(); | - | ||||||||||||||||||||||||
724 | } never executed: end of block | 0 | ||||||||||||||||||||||||
725 | void QFontDialog::setVisible(bool visible) | - | ||||||||||||||||||||||||
726 | { | - | ||||||||||||||||||||||||
727 | if (testAttribute(Qt::WA_WState_ExplicitShowHide)
| 0 | ||||||||||||||||||||||||
728 | return; never executed: return; | 0 | ||||||||||||||||||||||||
729 | QFontDialogPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
730 | if (d->canBeNativeDialog()
| 0 | ||||||||||||||||||||||||
731 | d->setNativeDialogVisible(visible); never executed: d->setNativeDialogVisible(visible); | 0 | ||||||||||||||||||||||||
732 | if (d->nativeDialogInUse
| 0 | ||||||||||||||||||||||||
733 | - | |||||||||||||||||||||||||
734 | - | |||||||||||||||||||||||||
735 | setAttribute(Qt::WA_DontShowOnScreen, true); | - | ||||||||||||||||||||||||
736 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
737 | d->nativeDialogInUse = false; | - | ||||||||||||||||||||||||
738 | setAttribute(Qt::WA_DontShowOnScreen, false); | - | ||||||||||||||||||||||||
739 | } never executed: end of block | 0 | ||||||||||||||||||||||||
740 | QDialog::setVisible(visible); | - | ||||||||||||||||||||||||
741 | } never executed: end of block | 0 | ||||||||||||||||||||||||
742 | void QFontDialog::done(int result) | - | ||||||||||||||||||||||||
743 | { | - | ||||||||||||||||||||||||
744 | QFontDialogPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
745 | QDialog::done(result); | - | ||||||||||||||||||||||||
746 | if (result == Accepted
| 0 | ||||||||||||||||||||||||
747 | - | |||||||||||||||||||||||||
748 | QFont selectedFont = currentFont(); | - | ||||||||||||||||||||||||
749 | if(selectedFont != d->selectedFont
| 0 | ||||||||||||||||||||||||
750 | ( never executed: currentFontChanged(selectedFont));(currentFontChanged(selectedFont)); never executed: (currentFontChanged(selectedFont)); | 0 | ||||||||||||||||||||||||
751 | d->selectedFont = selectedFont; | - | ||||||||||||||||||||||||
752 | fontSelected(d->selectedFont); | - | ||||||||||||||||||||||||
753 | } never executed: elseend of block | 0 | ||||||||||||||||||||||||
754 | d->selectedFont = QFont(); never executed: d->selectedFont = QFont(); | 0 | ||||||||||||||||||||||||
755 | if (d->receiverToDisconnectOnClose
| 0 | ||||||||||||||||||||||||
756 | disconnect(this, qFlagLocation("2""fontSelected(QFont)" "\0" __FILE__ ":" "1027"), | - | ||||||||||||||||||||||||
757 | d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose); | - | ||||||||||||||||||||||||
758 | d->receiverToDisconnectOnClose = 0; | - | ||||||||||||||||||||||||
759 | } never executed: end of block | 0 | ||||||||||||||||||||||||
760 | d->memberToDisconnectOnClose.clear(); | - | ||||||||||||||||||||||||
761 | } never executed: end of block | 0 | ||||||||||||||||||||||||
762 | - | |||||||||||||||||||||||||
763 | bool QFontDialogPrivate::canBeNativeDialog() const | - | ||||||||||||||||||||||||
764 | { | - | ||||||||||||||||||||||||
765 | - | |||||||||||||||||||||||||
766 | - | |||||||||||||||||||||||||
767 | const QDialog * const q = static_cast<const QDialog*>(q_ptr); | - | ||||||||||||||||||||||||
768 | if (nativeDialogInUse
| 0 | ||||||||||||||||||||||||
769 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||||||||
770 | if (q->testAttribute(Qt::WA_DontShowOnScreen)
| 0 | ||||||||||||||||||||||||
771 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||
772 | if (options->options() & QFontDialog::DontUseNativeDialog
| 0 | ||||||||||||||||||||||||
773 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||
774 | - | |||||||||||||||||||||||||
775 | QLatin1String staticName(QFontDialog::staticMetaObject.className()); | - | ||||||||||||||||||||||||
776 | QLatin1String dynamicName(q->metaObject()->className()); | - | ||||||||||||||||||||||||
777 | return never executed: (staticName == dynamicName);return (staticName == dynamicName); never executed: return (staticName == dynamicName); | 0 | ||||||||||||||||||||||||
778 | } | - | ||||||||||||||||||||||||
779 | - | |||||||||||||||||||||||||
780 | - | |||||||||||||||||||||||||
781 | - | |||||||||||||||||||||||||
Switch to Source code | Preprocessed file |