qfontdialog.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/dialogs/qfontdialog.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8class 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 {};-
15public:-
16 QFontListView(QWidget *parent);-
17 inline QStringListModel *model() const {-
18 return
never executed: return static_cast<QStringListModel *>(QListView::model());
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: return QListView::currentIndex().row();
QListView::currentIndex().row();
never executed: return QListView::currentIndex().row();
0
25 }-
26 inline int count() const {-
27 return
never executed: return model()->rowCount();
model()->rowCount();
never executed: return model()->rowCount();
0
28 }-
29 inline QString currentText() const {-
30 int row = QListView::currentIndex().row();-
31 return
never executed: return row < 0 ? QString() : model()->stringList().at(row);
row < 0
row < 0Description
TRUEnever evaluated
FALSEnever evaluated
? QString() : model()->stringList().at(row);
never executed: return row < 0 ? QString() : model()->stringList().at(row);
0
32 }-
33 void currentChanged(const QModelIndex &current, const QModelIndex &previous) override {-
34 QListView::currentChanged(current, previous);-
35 if (current.isValid()
current.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
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: return model()->stringList().at(i);
model()->stringList().at(i);
never executed: return model()->stringList().at(i);
0
40 }-
41public :-
42 void highlighted(int);-
43};-
44-
45QFontListView::QFontListView(QWidget *parent)-
46 : QListView(parent)-
47{-
48 setModel(new QStringListModel(parent));-
49 setEditTriggers(NoEditTriggers);-
50}
never executed: end of block
0
51-
52static const Qt::WindowFlags DefaultWindowFlags =-
53 Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint;-
54-
55QFontDialogPrivate::QFontDialogPrivate()-
56 : writingSystem(QFontDatabase::Any),-
57 options(QSharedPointer<QFontDialogOptions>::create())-
58{-
59}
never executed: end of block
0
60-
61QFontDialogPrivate::~QFontDialogPrivate()-
62{-
63}-
64QFontDialog::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-
77QFontDialog::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-
85void 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
i < QFontDatab...ngSystemsCountDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
166 QFontDatabase::WritingSystem ws = QFontDatabase::WritingSystem(i);-
167 QString writingSystemName = QFontDatabase::writingSystemName(ws);-
168 if (writingSystemName.isEmpty()
writingSystemName.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
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
familyList->count() != 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
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
spacing >= 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
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-
252QFontDialog::~QFontDialog()-
253{-
254}-
255QFont QFontDialog::getFont(bool *ok, const QFont &initial, QWidget *parent, const QString &title,-
256 FontDialogOptions options)-
257{-
258 return
never executed: return QFontDialogPrivate::getFont(ok, initial, parent, title, options);
QFontDialogPrivate::getFont(ok, initial, parent, title, options);
never executed: return QFontDialogPrivate::getFont(ok, initial, parent, title, options);
0
259}-
260QFont QFontDialog::getFont(bool *ok, QWidget *parent)-
261{-
262 QFont initial;-
263 return
never executed: return QFontDialogPrivate::getFont(ok, initial, parent, QString(), 0);
QFontDialogPrivate::getFont(ok, initial, parent, QString(), 0);
never executed: return QFontDialogPrivate::getFont(ok, initial, parent, QString(), 0);
0
264}-
265-
266QFont 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()
!title.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
273 dlg.setWindowTitle(title);
never executed: dlg.setWindowTitle(title);
0
274-
275 int ret = (dlg.exec()
dlg.exec()Description
TRUEnever evaluated
FALSEnever evaluated
|| (
(options & QFo...og::NoButtons)Description
TRUEnever evaluated
FALSEnever evaluated
options & QFontDialog::NoButtons)
(options & QFo...og::NoButtons)Description
TRUEnever evaluated
FALSEnever evaluated
);
0
276 if (ok
okDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
277 *
never executed: *ok = !!ret;
ok = !!ret;
never executed: *ok = !!ret;
0
278 if (ret
retDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
279 return
never executed: return dlg.selectedFont();
dlg.selectedFont();
never executed: return dlg.selectedFont();
0
280 } else {-
281 return
never executed: return initial;
initial;
never executed: return initial;
0
282 }-
283}-
284bool QFontDialog::eventFilter(QObject *o , QEvent *e)-
285{-
286 QFontDialogPrivate * const d = d_func();-
287 if (e->type() == QEvent::KeyPress
e->type() == QEvent::KeyPressDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
288 QKeyEvent *k = (QKeyEvent *)e;-
289 if (o == d->sizeEdit
o == d->sizeEditDescription
TRUEnever evaluated
FALSEnever evaluated
&&
0
290 (k->key() == Qt::Key_Up
k->key() == Qt::Key_UpDescription
TRUEnever evaluated
FALSEnever evaluated
||
0
291 k->key() == Qt::Key_Down
k->key() == Qt::Key_DownDescription
TRUEnever evaluated
FALSEnever evaluated
||
0
292 k->key() == Qt::Key_PageUp
k->key() == Qt::Key_PageUpDescription
TRUEnever evaluated
FALSEnever evaluated
||
0
293 k->key() == Qt::Key_PageDown
k->key() == Qt::Key_PageDownDescription
TRUEnever evaluated
FALSEnever evaluated
)) {
0
294-
295 int ci = d->sizeList->currentItem();-
296 (void)QApplication::sendEvent(d->sizeList, k);-
297-
298 if (ci != d->sizeList->currentItem()
ci != d->sizeL...>currentItem()Description
TRUEnever evaluated
FALSEnever evaluated
0
299 && style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, this)
style()->style...Text, 0, this)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
300 d->sizeEdit->selectAll();
never executed: d->sizeEdit->selectAll();
0
301 return
never executed: return true;
true;
never executed: return true;
0
302 } else if ((o == d->familyList
o == d->familyListDescription
TRUEnever evaluated
FALSEnever evaluated
|| o == d->styleList
o == d->styleListDescription
TRUEnever evaluated
FALSEnever evaluated
) &&
0
303 (k->key() == Qt::Key_Return
k->key() == Qt::Key_ReturnDescription
TRUEnever evaluated
FALSEnever evaluated
|| k->key() == Qt::Key_Enter
k->key() == Qt::Key_EnterDescription
TRUEnever evaluated
FALSEnever evaluated
)) {
0
304 k->accept();-
305 accept();-
306 return
never executed: return true;
true;
never executed: return true;
0
307 }-
308 }
never executed: end of block
else if (e->type() == QEvent::FocusIn
e->type() == QEvent::FocusInDescription
TRUEnever evaluated
FALSEnever evaluated
0
309 && style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, this)
style()->style...Text, 0, this)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
310 if (o == d->familyList
o == d->familyListDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
311 d->familyEdit->selectAll();
never executed: d->familyEdit->selectAll();
0
312 else if (o == d->styleList
o == d->styleListDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
313 d->styleEdit->selectAll();
never executed: d->styleEdit->selectAll();
0
314 else if (o == d->sizeList
o == d->sizeListDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
315 d->sizeEdit->selectAll();
never executed: d->sizeEdit->selectAll();
0
316 }
never executed: end of block
else if (e->type() == QEvent::MouseButtonPress
e->type() == Q...useButtonPressDescription
TRUEnever evaluated
FALSEnever evaluated
&& o == d->sizeList
o == d->sizeListDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
317 d->sizeEdit->setFocus();-
318 }
never executed: end of block
0
319 return
never executed: return QDialog::eventFilter(o, e);
QDialog::eventFilter(o, e);
never executed: return QDialog::eventFilter(o, e);
0
320}-
321-
322void 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-
330void QFontDialogPrivate::helperPrepareShow(QPlatformDialogHelper *)-
331{-
332 options->setWindowTitle(q_func()->windowTitle());-
333}
never executed: end of block
0
334-
335-
336-
337-
338-
339-
340void 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)
fdb.isPrivateFamily(family)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
355 continue;
never executed: continue;
0
356-
357 if ((
(options & scalableMask)Description
TRUEnever evaluated
FALSEnever evaluated
options & scalableMask)
(options & scalableMask)Description
TRUEnever evaluated
FALSEnever evaluated
&& (
(options & sca...= scalableMaskDescription
TRUEnever evaluated
FALSEnever evaluated
options & scalableMask) != scalableMask
(options & sca...= scalableMaskDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
358 if (bool(options & QFontDialog::ScalableFonts) != fdb.isSmoothlyScalable(family)
bool(options &...alable(family)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
359 continue;
never executed: continue;
0
360 }
never executed: end of block
0
361 if ((
(options & spacingMask)Description
TRUEnever evaluated
FALSEnever evaluated
options & spacingMask)
(options & spacingMask)Description
TRUEnever evaluated
FALSEnever evaluated
&& (
(options & spa...!= spacingMaskDescription
TRUEnever evaluated
FALSEnever evaluated
options & spacingMask) != spacingMask
(options & spa...!= spacingMaskDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
362 if (bool(options & QFontDialog::MonospacedFonts) != fdb.isFixedPitch(family)
bool(options &...dPitch(family)Description
TRUEnever evaluated
FALSEnever evaluated
)
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()
it != familyNames.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
; ++it, ++i) {
0
382 QFontDatabase::parseFontName(*it, foundryName2, familyName2);-
383-
384-
385 if (familyName1 == familyName2
familyName1 == familyName2Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
386 bestFamilyType = MATCH_FAMILY;-
387 if (foundryName1 == foundryName2
foundryName1 == foundryName2Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
388 bestFamilyMatch = i;-
389 break;
never executed: break;
0
390 }-
391 if (bestFamilyMatch < MATCH_FAMILY
bestFamilyMatch < MATCH_FAMILYDescription
TRUEnever evaluated
FALSEnever evaluated
)
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
bestFamilyType <= MATCH_NONEDescription
TRUEnever evaluated
FALSEnever evaluated
&& familyName2 == f.lastResortFamily()
familyName2 ==...ResortFamily()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
398 type = MATCH_LAST_RESORT;
never executed: type = MATCH_LAST_RESORT;
0
399 if (bestFamilyType <= MATCH_LAST_RESORT
bestFamilyType...CH_LAST_RESORTDescription
TRUEnever evaluated
FALSEnever evaluated
&& familyName2 == f.family()
familyName2 == f.family()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
400 type = MATCH_APP;
never executed: type = MATCH_APP;
0
401-
402 if (type != MATCH_NONE
type != MATCH_NONEDescription
TRUEnever evaluated
FALSEnever evaluated
) {
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
i != -1Description
TRUEnever evaluated
FALSEnever evaluated
&& bestFamilyType != MATCH_NONE
bestFamilyType != MATCH_NONEDescription
TRUEnever evaluated
FALSEnever evaluated
)
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)
q->style()->st...tedText, 0, q)Description
TRUEnever evaluated
FALSEnever evaluated
0
414 && familyList->hasFocus()
familyList->hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
415 familyEdit->selectAll();
never executed: familyEdit->selectAll();
0
416-
417 updateStyles();-
418}
never executed: end of block
0
419-
420-
421-
422-
423-
424void 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()
styles.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
431 styleEdit->clear();-
432 smoothScalable = false;-
433 }
never executed: end of block
else {
0
434 if (!style.isEmpty()
!style.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
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()
i < (int)styleList->count()Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
441 if (cstyle == styleList->text(i)
cstyle == styleList->text(i)Description
TRUEnever evaluated
FALSEnever evaluated
) {
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
!foundDescription
TRUEnever evaluated
FALSEnever evaluated
&& first
firstDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
448 if (cstyle.contains(QLatin1String("Italic"))
cstyle.contain...ing("Italic"))Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
449 cstyle.replace(QLatin1String("Italic"), QLatin1String("Oblique"));-
450 first = false;-
451 goto
never executed: goto redo;
redo;
never executed: goto redo;
0
452 } else if (cstyle.contains(QLatin1String("Oblique"))
cstyle.contain...ng("Oblique"))Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
453 cstyle.replace(QLatin1String("Oblique"), QLatin1String("Italic"));-
454 first = false;-
455 goto
never executed: goto redo;
redo;
never executed: goto redo;
0
456 }-
457 }
never executed: end of block
0
458 if (!found
!foundDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
459 styleList->setCurrentItem(0);
never executed: styleList->setCurrentItem(0);
0
460 }
never executed: end of block
else {
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)
q->style()->st...tedText, 0, q)Description
TRUEnever evaluated
FALSEnever evaluated
0
466 && styleList->hasFocus()
styleList->hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
)
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-
481void QFontDialogPrivate::updateSizes()-
482{-
483 QFontDialog * const q = q_func();-
484-
485 if (!familyList->currentText().isEmpty()
!familyList->c...xt().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
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()
it != sizes.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
; ++it) {
0
493 str_sizes.append(QString::number(*it));-
494 if (current == -1
current == -1Description
TRUEnever evaluated
FALSEnever evaluated
&& *
*it == sizeDescription
TRUEnever evaluated
FALSEnever evaluated
it == size
*it == sizeDescription
TRUEnever evaluated
FALSEnever evaluated
)
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
current != -1Description
TRUEnever evaluated
FALSEnever evaluated
)
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)
q->style()->st...tedText, 0, q)Description
TRUEnever evaluated
FALSEnever evaluated
0
505 && sizeList->hasFocus()
sizeList->hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
506 sizeEdit->selectAll();
never executed: sizeEdit->selectAll();
0
507 }
never executed: end of block
else {
0
508 sizeEdit->clear();-
509 }
never executed: end of block
0
510-
511 _q_updateSample();-
512}
never executed: end of block
0
513-
514void 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()
familyList->cu...xt().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
523 sampleEdit->clear();
never executed: sampleEdit->clear();
0
524-
525 updateSampleFont(newFont);-
526}
never executed: end of block
0
527-
528void QFontDialogPrivate::updateSampleFont(const QFont &newFont)-
529{-
530 QFontDialog * const q = q_func();-
531 if (newFont != sampleEdit->font()
newFont != sampleEdit->font()Description
TRUEnever evaluated
FALSEnever evaluated
) {
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-
540void 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-
550void 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)
q->style()->st...tedText, 0, q)Description
TRUEnever evaluated
FALSEnever evaluated
0
556 && familyList->hasFocus()
familyList->hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
)
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-
567void 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)
q->style()->st...tedText, 0, q)Description
TRUEnever evaluated
FALSEnever evaluated
0
573 && styleList->hasFocus()
styleList->hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
)
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-
586void 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)
q->style()->st...tedText, 0, q)Description
TRUEnever evaluated
FALSEnever evaluated
0
592 && sizeEdit->hasFocus()
sizeEdit->hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
)
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-
605void QFontDialogPrivate::_q_sizeChanged(const QString &s)-
606{-
607-
608 int size = s.toInt();-
609 if (this->size == size
this->size == sizeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
610 return;
never executed: return;
0
611-
612 this->size = size;-
613 if (sizeList->count() != 0
sizeList->count() != 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
614 int i;-
615 for (i = 0; i < sizeList->count() - 1
i < sizeList->count() - 1Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
616 if (sizeList->text(i).toInt() >= this->size
sizeList->text... >= this->sizeDescription
TRUEnever evaluated
FALSEnever evaluated
)
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
sizeList->text... == this->sizeDescription
TRUEnever evaluated
FALSEnever evaluated
)
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-
628void 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-
643void QFontDialog::changeEvent(QEvent *e)-
644{-
645 QFontDialogPrivate * const d = d_func();-
646 if (e->type() == QEvent::LanguageChange
e->type() == Q...LanguageChangeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
647 d->retranslateStrings();-
648 }
never executed: end of block
0
649 QDialog::changeEvent(e);-
650}
never executed: end of block
0
651void 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
d->size == -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
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()
d->canBeNativeDialog()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
665 if (QPlatformFontDialogHelper *helper = d->platformFontDialogHelper()
QPlatformFontD...DialogHelper()Description
TRUEnever evaluated
FALSEnever evaluated
)
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
669QFont QFontDialog::currentFont() const-
670{-
671 const QFontDialogPrivate * const d = d_func();-
672 if (d->canBeNativeDialog()
d->canBeNativeDialog()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
673 if (const
const QPlatfor...DialogHelper()Description
TRUEnever evaluated
FALSEnever evaluated
QPlatformFontDialogHelper *helper = d->platformFontDialogHelper()
const QPlatfor...DialogHelper()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
674 return
never executed: return helper->currentFont();
helper->currentFont();
never executed: return helper->currentFont();
0
675 }
never executed: end of block
0
676 return
never executed: return d->sampleEdit->font();
d->sampleEdit->font();
never executed: return d->sampleEdit->font();
0
677}-
678QFont QFontDialog::selectedFont() const-
679{-
680 const QFontDialogPrivate * const d = d_func();-
681 return
never executed: return d->selectedFont;
d->selectedFont;
never executed: return d->selectedFont;
0
682}-
683void QFontDialog::setOption(FontDialogOption option, bool on)-
684{-
685 const QFontDialog::FontDialogOptions previousOptions = options();-
686 if (!(previousOptions & option) != !on
!(previousOpti...option) != !onDescription
TRUEnever evaluated
FALSEnever evaluated
)
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-
696bool QFontDialog::testOption(FontDialogOption option) const-
697{-
698 const QFontDialogPrivate * const d = d_func();-
699 return
never executed: return d->options->testOption(static_cast<QFontDialogOptions::FontDialogOption>(option));
d->options->testOption(static_cast<QFontDialogOptions::FontDialogOption>(option));
never executed: return d->options->testOption(static_cast<QFontDialogOptions::FontDialogOption>(option));
0
700}-
701void QFontDialog::setOptions(FontDialogOptions options)-
702{-
703 QFontDialogPrivate * const d = d_func();-
704-
705 if (QFontDialog::options() == options
QFontDialog::o...s() == optionsDescription
TRUEnever evaluated
FALSEnever evaluated
)
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-
712QFontDialog::FontDialogOptions QFontDialog::options() const-
713{-
714 const QFontDialogPrivate * const d = d_func();-
715 return
never executed: return QFontDialog::FontDialogOptions(int(d->options->options()));
QFontDialog::FontDialogOptions(int(d->options->options()));
never executed: return QFontDialog::FontDialogOptions(int(d->options->options()));
0
716}-
717void 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
725void QFontDialog::setVisible(bool visible)-
726{-
727 if (testAttribute(Qt::WA_WState_ExplicitShowHide)
testAttribute(...licitShowHide)Description
TRUEnever evaluated
FALSEnever evaluated
&& testAttribute(Qt::WA_WState_Hidden) != visible
testAttribute(...en) != visibleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
728 return;
never executed: return;
0
729 QFontDialogPrivate * const d = d_func();-
730 if (d->canBeNativeDialog()
d->canBeNativeDialog()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
731 d->setNativeDialogVisible(visible);
never executed: d->setNativeDialogVisible(visible);
0
732 if (d->nativeDialogInUse
d->nativeDialogInUseDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
733-
734-
735 setAttribute(Qt::WA_DontShowOnScreen, true);-
736 }
never executed: end of block
else {
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
742void QFontDialog::done(int result)-
743{-
744 QFontDialogPrivate * const d = d_func();-
745 QDialog::done(result);-
746 if (result == Accepted
result == AcceptedDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
747-
748 QFont selectedFont = currentFont();-
749 if(selectedFont != d->selectedFont
selectedFont !...->selectedFontDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
750 (
never executed: (currentFontChanged(selectedFont));
currentFontChanged(selectedFont));
never executed: (currentFontChanged(selectedFont));
0
751 d->selectedFont = selectedFont;-
752 fontSelected(d->selectedFont);-
753 }
never executed: end of block
else
0
754 d->selectedFont = QFont();
never executed: d->selectedFont = QFont();
0
755 if (d->receiverToDisconnectOnClose
d->receiverToDisconnectOnCloseDescription
TRUEnever evaluated
FALSEnever evaluated
) {
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-
763bool QFontDialogPrivate::canBeNativeDialog() const-
764{-
765-
766-
767 const QDialog * const q = static_cast<const QDialog*>(q_ptr);-
768 if (nativeDialogInUse
nativeDialogInUseDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
769 return
never executed: return true;
true;
never executed: return true;
0
770 if (q->testAttribute(Qt::WA_DontShowOnScreen)
q->testAttribu...tShowOnScreen)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
771 return
never executed: return false;
false;
never executed: return false;
0
772 if (options->options() & QFontDialog::DontUseNativeDialog
options->optio...seNativeDialogDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
773 return
never executed: return false;
false;
never executed: return false;
0
774-
775 QLatin1String staticName(QFontDialog::staticMetaObject.className());-
776 QLatin1String dynamicName(q->metaObject()->className());-
777 return
never executed: return (staticName == dynamicName);
(staticName == dynamicName);
never executed: return (staticName == dynamicName);
0
778}-
779-
780-
781-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9