dialogs/qfontdialog.cpp

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

Generated by Squish Coco Non-Commercial