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 ? 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__ ":" "249"), q, qFlagLocation("1""_q_writingSystemHighlighted(int)" "\0" __FILE__ ":" "249"));-
157 QObject::connect(familyList, qFlagLocation("2""highlighted(int)" "\0" __FILE__ ":" "250"), q, qFlagLocation("1""_q_familyHighlighted(int)" "\0" __FILE__ ":" "250"));-
158 QObject::connect(styleList, qFlagLocation("2""highlighted(int)" "\0" __FILE__ ":" "251"), q, qFlagLocation("1""_q_styleHighlighted(int)" "\0" __FILE__ ":" "251"));-
159 QObject::connect(sizeList, qFlagLocation("2""highlighted(int)" "\0" __FILE__ ":" "252"), q, qFlagLocation("1""_q_sizeHighlighted(int)" "\0" __FILE__ ":" "252"));-
160 QObject::connect(sizeEdit, qFlagLocation("2""textChanged(QString)" "\0" __FILE__ ":" "253"), q, qFlagLocation("1""_q_sizeChanged(QString)" "\0" __FILE__ ":" "253"));-
161-
162 QObject::connect(strikeout, qFlagLocation("2""clicked()" "\0" __FILE__ ":" "255"), q, qFlagLocation("1""_q_updateSample()" "\0" __FILE__ ":" "255"));-
163 QObject::connect(underline, qFlagLocation("2""clicked()" "\0" __FILE__ ":" "256"), q, qFlagLocation("1""_q_updateSample()" "\0" __FILE__ ":" "256"));-
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__ ":" "318"), q, qFlagLocation("1""accept()" "\0" __FILE__ ":" "318"));-
226 button->setDefault(true);-
227-
228 buttonBox->addButton(QDialogButtonBox::Cancel);-
229 QObject::connect(buttonBox, qFlagLocation("2""rejected()" "\0" __FILE__ ":" "322"), q, qFlagLocation("1""reject()" "\0" __FILE__ ":" "322"));-
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__ ":" "472"), d, qFlagLocation("2""currentFontChanged(QFont)" "\0" __FILE__ ":" "472"));-
326 QObject::connect(h, qFlagLocation("2""fontSelected(QFont)" "\0" __FILE__ ":" "473"), d, qFlagLocation("2""fontSelected(QFont)" "\0" __FILE__ ":" "473"));-
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 const auto families = fdb.families(writingSystem);-
354 for (const QString &family : families) {-
355 if (fdb.isPrivateFamily(family)
fdb.isPrivateFamily(family)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
356 continue;
never executed: continue;
0
357-
358 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
359 if (bool(options & QFontDialog::ScalableFonts) != fdb.isSmoothlyScalable(family)
bool(options &...alable(family)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
360 continue;
never executed: continue;
0
361 }
never executed: end of block
0
362 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
363 if (bool(options & QFontDialog::MonospacedFonts) != fdb.isFixedPitch(family)
bool(options &...dPitch(family)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
364 continue;
never executed: continue;
0
365 }
never executed: end of block
0
366 familyNames << family;-
367 }
never executed: end of block
0
368-
369 familyList->model()->setStringList(familyNames);-
370-
371 QString foundryName1, familyName1, foundryName2, familyName2;-
372 int bestFamilyMatch = -1;-
373 match_t bestFamilyType = MATCH_NONE;-
374-
375 QFont f;-
376-
377-
378 QFontDatabase::parseFontName(family, foundryName1, familyName1);-
379-
380 QStringList::const_iterator it = familyNames.constBegin();-
381 int i = 0;-
382 for(; it != familyNames.constEnd()
it != familyNames.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
; ++it, ++i) {
0
383 QFontDatabase::parseFontName(*it, foundryName2, familyName2);-
384-
385-
386 if (familyName1 == familyName2
familyName1 == familyName2Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
387 bestFamilyType = MATCH_FAMILY;-
388 if (foundryName1 == foundryName2
foundryName1 == foundryName2Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
389 bestFamilyMatch = i;-
390 break;
never executed: break;
0
391 }-
392 if (bestFamilyMatch < MATCH_FAMILY
bestFamilyMatch < MATCH_FAMILYDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
393 bestFamilyMatch = i;
never executed: bestFamilyMatch = i;
0
394 }
never executed: end of block
0
395-
396-
397 match_t type = MATCH_NONE;-
398 if (bestFamilyType <= MATCH_NONE
bestFamilyType <= MATCH_NONEDescription
TRUEnever evaluated
FALSEnever evaluated
&& familyName2 == f.lastResortFamily()
familyName2 ==...ResortFamily()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
399 type = MATCH_LAST_RESORT;
never executed: type = MATCH_LAST_RESORT;
0
400 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
401 type = MATCH_APP;
never executed: type = MATCH_APP;
0
402-
403 if (type != MATCH_NONE
type != MATCH_NONEDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
404 bestFamilyType = type;-
405 bestFamilyMatch = i;-
406 }
never executed: end of block
0
407 }
never executed: end of block
0
408-
409 if (i != -1
i != -1Description
TRUEnever evaluated
FALSEnever evaluated
&& bestFamilyType != MATCH_NONE
bestFamilyType != MATCH_NONEDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
410 familyList->setCurrentItem(bestFamilyMatch);
never executed: familyList->setCurrentItem(bestFamilyMatch);
0
411 else-
412 familyList->setCurrentItem(0);
never executed: familyList->setCurrentItem(0);
0
413 familyEdit->setText(familyList->currentText());-
414 if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q)
q->style()->st...tedText, 0, q)Description
TRUEnever evaluated
FALSEnever evaluated
0
415 && familyList->hasFocus()
familyList->hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
416 familyEdit->selectAll();
never executed: familyEdit->selectAll();
0
417-
418 updateStyles();-
419}
never executed: end of block
0
420-
421-
422-
423-
424-
425void QFontDialogPrivate::updateStyles()-
426{-
427 QFontDialog * const q = q_func();-
428 QStringList styles = fdb.styles(familyList->currentText());-
429 styleList->model()->setStringList(styles);-
430-
431 if (styles.isEmpty()
styles.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
432 styleEdit->clear();-
433 smoothScalable = false;-
434 }
never executed: end of block
else {
0
435 if (!style.isEmpty()
!style.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
436 bool found = false;-
437 bool first = true;-
438 QString cstyle = style;-
439-
440 redo:
code before this statement never executed: redo:
0
441 for (int i = 0; i < (int)styleList->count()
i < (int)styleList->count()Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
442 if (cstyle == styleList->text(i)
cstyle == styleList->text(i)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
443 styleList->setCurrentItem(i);-
444 found = true;-
445 break;
never executed: break;
0
446 }-
447 }
never executed: end of block
0
448 if (!found
!foundDescription
TRUEnever evaluated
FALSEnever evaluated
&& first
firstDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
449 if (cstyle.contains(QLatin1String("Italic"))
cstyle.contain...ing("Italic"))Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
450 cstyle.replace(QLatin1String("Italic"), QLatin1String("Oblique"));-
451 first = false;-
452 goto
never executed: goto redo;
redo;
never executed: goto redo;
0
453 } else if (cstyle.contains(QLatin1String("Oblique"))
cstyle.contain...ng("Oblique"))Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
454 cstyle.replace(QLatin1String("Oblique"), QLatin1String("Italic"));-
455 first = false;-
456 goto
never executed: goto redo;
redo;
never executed: goto redo;
0
457 }-
458 }
never executed: end of block
0
459 if (!found
!foundDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
460 styleList->setCurrentItem(0);
never executed: styleList->setCurrentItem(0);
0
461 }
never executed: end of block
else {
0
462 styleList->setCurrentItem(0);-
463 }
never executed: end of block
0
464-
465 styleEdit->setText(styleList->currentText());-
466 if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q)
q->style()->st...tedText, 0, q)Description
TRUEnever evaluated
FALSEnever evaluated
0
467 && styleList->hasFocus()
styleList->hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
468 styleEdit->selectAll();
never executed: styleEdit->selectAll();
0
469-
470 smoothScalable = fdb.isSmoothlyScalable(familyList->currentText(), styleList->currentText());-
471 }
never executed: end of block
0
472-
473 updateSizes();-
474}
never executed: end of block
0
475-
476-
477-
478-
479-
480-
481-
482void QFontDialogPrivate::updateSizes()-
483{-
484 QFontDialog * const q = q_func();-
485-
486 if (!familyList->currentText().isEmpty()
!familyList->c...xt().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
487 QList<int> sizes = fdb.pointSizes(familyList->currentText(), styleList->currentText());-
488-
489 int i = 0;-
490 int current = -1;-
491 QStringList str_sizes;-
492 str_sizes.reserve(sizes.size());-
493 for(QList<int>::const_iterator it = sizes.constBegin(); it != sizes.constEnd()
it != sizes.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
; ++it) {
0
494 str_sizes.append(QString::number(*it));-
495 if (current == -1
current == -1Description
TRUEnever evaluated
FALSEnever evaluated
&& *
*it == sizeDescription
TRUEnever evaluated
FALSEnever evaluated
it == size
*it == sizeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
496 current = i;
never executed: current = i;
0
497 ++i;-
498 }
never executed: end of block
0
499 sizeList->model()->setStringList(str_sizes);-
500 if (current != -1
current != -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
501 sizeList->setCurrentItem(current);
never executed: sizeList->setCurrentItem(current);
0
502-
503 const QSignalBlocker blocker(sizeEdit);-
504 sizeEdit->setText((smoothScalable ? QString::number(size) : sizeList->currentText()));-
505 if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q)
q->style()->st...tedText, 0, q)Description
TRUEnever evaluated
FALSEnever evaluated
0
506 && sizeList->hasFocus()
sizeList->hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
507 sizeEdit->selectAll();
never executed: sizeEdit->selectAll();
0
508 }
never executed: end of block
else {
0
509 sizeEdit->clear();-
510 }
never executed: end of block
0
511-
512 _q_updateSample();-
513}
never executed: end of block
0
514-
515void QFontDialogPrivate::_q_updateSample()-
516{-
517-
518 int pSize = sizeEdit->text().toInt();-
519 QFont newFont(fdb.font(familyList->currentText(), style, pSize));-
520 newFont.setStrikeOut(strikeout->isChecked());-
521 newFont.setUnderline(underline->isChecked());-
522-
523 if (familyList->currentText().isEmpty()
familyList->cu...xt().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
524 sampleEdit->clear();
never executed: sampleEdit->clear();
0
525-
526 updateSampleFont(newFont);-
527}
never executed: end of block
0
528-
529void QFontDialogPrivate::updateSampleFont(const QFont &newFont)-
530{-
531 QFontDialog * const q = q_func();-
532 if (newFont != sampleEdit->font()
newFont != sampleEdit->font()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
533 sampleEdit->setFont(newFont);-
534 q->currentFontChanged(newFont);-
535 }
never executed: end of block
0
536}
never executed: end of block
0
537-
538-
539-
540-
541void QFontDialogPrivate::_q_writingSystemHighlighted(int index)-
542{-
543 writingSystem = QFontDatabase::WritingSystem(index);-
544 sampleEdit->setText(fdb.writingSystemSample(writingSystem));-
545 updateFamilies();-
546}
never executed: end of block
0
547-
548-
549-
550-
551void QFontDialogPrivate::_q_familyHighlighted(int i)-
552{-
553 QFontDialog * const q = q_func();-
554 family = familyList->text(i);-
555 familyEdit->setText(family);-
556 if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q)
q->style()->st...tedText, 0, q)Description
TRUEnever evaluated
FALSEnever evaluated
0
557 && familyList->hasFocus()
familyList->hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
558 familyEdit->selectAll();
never executed: familyEdit->selectAll();
0
559-
560 updateStyles();-
561}
never executed: end of block
0
562-
563-
564-
565-
566-
567-
568void QFontDialogPrivate::_q_styleHighlighted(int index)-
569{-
570 QFontDialog * const q = q_func();-
571 QString s = styleList->text(index);-
572 styleEdit->setText(s);-
573 if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q)
q->style()->st...tedText, 0, q)Description
TRUEnever evaluated
FALSEnever evaluated
0
574 && styleList->hasFocus()
styleList->hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
575 styleEdit->selectAll();
never executed: styleEdit->selectAll();
0
576-
577 style = s;-
578-
579 updateSizes();-
580}
never executed: end of block
0
581-
582-
583-
584-
585-
586-
587void QFontDialogPrivate::_q_sizeHighlighted(int index)-
588{-
589 QFontDialog * const q = q_func();-
590 QString s = sizeList->text(index);-
591 sizeEdit->setText(s);-
592 if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q)
q->style()->st...tedText, 0, q)Description
TRUEnever evaluated
FALSEnever evaluated
0
593 && sizeEdit->hasFocus()
sizeEdit->hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
594 sizeEdit->selectAll();
never executed: sizeEdit->selectAll();
0
595-
596 size = s.toInt();-
597 _q_updateSample();-
598}
never executed: end of block
0
599-
600-
601-
602-
603-
604-
605-
606void QFontDialogPrivate::_q_sizeChanged(const QString &s)-
607{-
608-
609 int size = s.toInt();-
610 if (this->size == size
this->size == sizeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
611 return;
never executed: return;
0
612-
613 this->size = size;-
614 if (sizeList->count() != 0
sizeList->count() != 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
615 int i;-
616 for (i = 0; i < sizeList->count() - 1
i < sizeList->count() - 1Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
617 if (sizeList->text(i).toInt() >= this->size
sizeList->text... >= this->sizeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
618 break;
never executed: break;
0
619 }
never executed: end of block
0
620 const QSignalBlocker blocker(sizeList);-
621 if (sizeList->text(i).toInt() == this->size
sizeList->text... == this->sizeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
622 sizeList->setCurrentItem(i);
never executed: sizeList->setCurrentItem(i);
0
623 else-
624 sizeList->clearSelection();
never executed: sizeList->clearSelection();
0
625 }-
626 _q_updateSample();-
627}
never executed: end of block
0
628-
629void QFontDialogPrivate::retranslateStrings()-
630{-
631 familyAccel->setText(QFontDialog::tr("&Font"));-
632 styleAccel->setText(QFontDialog::tr("Font st&yle"));-
633 sizeAccel->setText(QFontDialog::tr("&Size"));-
634 effects->setTitle(QFontDialog::tr("Effects"));-
635 strikeout->setText(QFontDialog::tr("Stri&keout"));-
636 underline->setText(QFontDialog::tr("&Underline"));-
637 sample->setTitle(QFontDialog::tr("Sample"));-
638 writingSystemAccel->setText(QFontDialog::tr("Wr&iting System"));-
639}
never executed: end of block
0
640-
641-
642-
643-
644void QFontDialog::changeEvent(QEvent *e)-
645{-
646 QFontDialogPrivate * const d = d_func();-
647 if (e->type() == QEvent::LanguageChange
e->type() == Q...LanguageChangeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
648 d->retranslateStrings();-
649 }
never executed: end of block
0
650 QDialog::changeEvent(e);-
651}
never executed: end of block
0
652void QFontDialog::setCurrentFont(const QFont &font)-
653{-
654 QFontDialogPrivate * const d = d_func();-
655 d->family = font.family();-
656 d->style = d->fdb.styleString(font);-
657 d->size = font.pointSize();-
658 if (d->size == -1
d->size == -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
659 QFontInfo fi(font);-
660 d->size = fi.pointSize();-
661 }
never executed: end of block
0
662 d->strikeout->setChecked(font.strikeOut());-
663 d->underline->setChecked(font.underline());-
664 d->updateFamilies();-
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
668QFont QFontDialog::currentFont() const-
669{-
670 const QFontDialogPrivate * const d = d_func();-
671 if (const
const QPlatfor...DialogHelper()Description
TRUEnever evaluated
FALSEnever evaluated
QPlatformFontDialogHelper *helper = d->platformFontDialogHelper()
const QPlatfor...DialogHelper()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
672 return
never executed: return helper->currentFont();
helper->currentFont();
never executed: return helper->currentFont();
0
673 return
never executed: return d->sampleEdit->font();
d->sampleEdit->font();
never executed: return d->sampleEdit->font();
0
674}-
675QFont QFontDialog::selectedFont() const-
676{-
677 const QFontDialogPrivate * const d = d_func();-
678 return
never executed: return d->selectedFont;
d->selectedFont;
never executed: return d->selectedFont;
0
679}-
680void QFontDialog::setOption(FontDialogOption option, bool on)-
681{-
682 const QFontDialog::FontDialogOptions previousOptions = options();-
683 if (!(previousOptions & option) != !on
!(previousOpti...option) != !onDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
684 setOptions(previousOptions ^ option);
never executed: setOptions(previousOptions ^ option);
0
685}
never executed: end of block
0
686-
687-
688-
689-
690-
691-
692-
693bool QFontDialog::testOption(FontDialogOption option) const-
694{-
695 const QFontDialogPrivate * const d = d_func();-
696 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
697}-
698void QFontDialog::setOptions(FontDialogOptions options)-
699{-
700 QFontDialogPrivate * const d = d_func();-
701-
702 if (QFontDialog::options() == options
QFontDialog::o...s() == optionsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
703 return;
never executed: return;
0
704-
705 d->options->setOptions(QFontDialogOptions::FontDialogOptions(int(options)));-
706 d->buttonBox->setVisible(!(options & NoButtons));-
707}
never executed: end of block
0
708-
709QFontDialog::FontDialogOptions QFontDialog::options() const-
710{-
711 const QFontDialogPrivate * const d = d_func();-
712 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
713}-
714void QFontDialog::open(QObject *receiver, const char *member)-
715{-
716 QFontDialogPrivate * const d = d_func();-
717 connect(this, qFlagLocation("2""fontSelected(QFont)" "\0" __FILE__ ":" "953"), receiver, member);-
718 d->receiverToDisconnectOnClose = receiver;-
719 d->memberToDisconnectOnClose = member;-
720 QDialog::open();-
721}
never executed: end of block
0
722void QFontDialog::setVisible(bool visible)-
723{-
724 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
725 return;
never executed: return;
0
726 QFontDialogPrivate * const d = d_func();-
727 if (d->canBeNativeDialog()
d->canBeNativeDialog()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
728 d->setNativeDialogVisible(visible);
never executed: d->setNativeDialogVisible(visible);
0
729 if (d->nativeDialogInUse
d->nativeDialogInUseDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
730-
731-
732 setAttribute(Qt::WA_DontShowOnScreen, true);-
733 }
never executed: end of block
else {
0
734 d->nativeDialogInUse = false;-
735 setAttribute(Qt::WA_DontShowOnScreen, false);-
736 }
never executed: end of block
0
737 QDialog::setVisible(visible);-
738}
never executed: end of block
0
739void QFontDialog::done(int result)-
740{-
741 QFontDialogPrivate * const d = d_func();-
742 QDialog::done(result);-
743 if (result == Accepted
result == AcceptedDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
744-
745 QFont selectedFont = currentFont();-
746 if(selectedFont != d->selectedFont
selectedFont !...->selectedFontDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
747 (
never executed: (currentFontChanged(selectedFont));
currentFontChanged(selectedFont));
never executed: (currentFontChanged(selectedFont));
0
748 d->selectedFont = selectedFont;-
749 fontSelected(d->selectedFont);-
750 }
never executed: end of block
else
0
751 d->selectedFont = QFont();
never executed: d->selectedFont = QFont();
0
752 if (d->receiverToDisconnectOnClose
d->receiverToDisconnectOnCloseDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
753 disconnect(this, qFlagLocation("2""fontSelected(QFont)" "\0" __FILE__ ":" "1030"),-
754 d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose);-
755 d->receiverToDisconnectOnClose = 0;-
756 }
never executed: end of block
0
757 d->memberToDisconnectOnClose.clear();-
758}
never executed: end of block
0
759-
760bool QFontDialogPrivate::canBeNativeDialog() const-
761{-
762-
763-
764 const QDialog * const q = static_cast<const QDialog*>(q_ptr);-
765 if (nativeDialogInUse
nativeDialogInUseDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
766 return
never executed: return true;
true;
never executed: return true;
0
767 if (QCoreApplication::testAttribute(Qt::AA_DontUseNativeDialogs)
QCoreApplicati...NativeDialogs)Description
TRUEnever evaluated
FALSEnever evaluated
0
768 || q->testAttribute(Qt::WA_DontShowOnScreen)
q->testAttribu...tShowOnScreen)Description
TRUEnever evaluated
FALSEnever evaluated
0
769 || (
(options->opti...eNativeDialog)Description
TRUEnever evaluated
FALSEnever evaluated
options->options() & QFontDialog::DontUseNativeDialog)
(options->opti...eNativeDialog)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
770 return
never executed: return false;
false;
never executed: return false;
0
771 }-
772-
773 QLatin1String staticName(QFontDialog::staticMetaObject.className());-
774 QLatin1String dynamicName(q->metaObject()->className());-
775 return
never executed: return (staticName == dynamicName);
(staticName == dynamicName);
never executed: return (staticName == dynamicName);
0
776}-
777-
778-
779-
Switch to Source codePreprocessed file

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