QtBase  v6.3.1
qfontdialog.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the QtWidgets module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39 
40 #include "qwindowdefs.h"
41 #include "qfontdialog.h"
42 
43 #include "qfontdialog_p.h"
44 
45 #include <qapplication.h>
46 #include <qcheckbox.h>
47 #include <qcombobox.h>
48 #include <qevent.h>
49 #include <qgroupbox.h>
50 #include <qlabel.h>
51 #include <qlayout.h>
52 #include <qlineedit.h>
53 #include <qpushbutton.h>
54 #include <qstyle.h>
55 #include <qdialogbuttonbox.h>
56 #include <qheaderview.h>
57 #include <qlistview.h>
58 #include <qstringlistmodel.h>
59 #include <qvalidator.h>
60 #include <private/qfontdatabase_p.h>
61 #include <private/qdialog_p.h>
62 #include <private/qfont_p.h>
63 
65 
66 class QFontListView : public QListView
67 {
68  Q_OBJECT
69 public:
71  inline QStringListModel *model() const {
72  return static_cast<QStringListModel *>(QListView::model());
73  }
74  inline void setCurrentItem(int item) {
76  }
77  inline int currentItem() const {
78  return QListView::currentIndex().row();
79  }
80  inline int count() const {
81  return model()->rowCount();
82  }
83  inline QString currentText() const {
85  return row < 0 ? QString() : model()->stringList().at(row);
86  }
87  void currentChanged(const QModelIndex &current, const QModelIndex &previous) override {
88  QListView::currentChanged(current, previous);
89  if (current.isValid())
90  emit highlighted(current.row());
91  }
92  QString text(int i) const {
93  return model()->stringList().at(i);
94  }
95 signals:
96  void highlighted(int);
97 };
98 
100  : QListView(parent)
101 {
104 }
105 
106 static const Qt::WindowFlags DefaultWindowFlags =
108 
110  : writingSystem(QFontDatabase::Any),
111  options(QFontDialogOptions::create())
112 {
113 }
114 
116 {
117 }
118 
156  : QDialog(*new QFontDialogPrivate, parent, DefaultWindowFlags)
157 {
158  Q_D(QFontDialog);
159  d->init();
160 }
161 
170 {
171  setCurrentFont(initial);
172 }
173 
175 {
176  Q_Q(QFontDialog);
177 
178  q->setSizeGripEnabled(true);
179  q->setWindowTitle(QFontDialog::tr("Select Font"));
180 
181  // grid
182  familyEdit = new QLineEdit(q);
183  familyEdit->setReadOnly(true);
184  familyList = new QFontListView(q);
186 
187  familyAccel = new QLabel(q);
188 #ifndef QT_NO_SHORTCUT
190 #endif
192 
193  styleEdit = new QLineEdit(q);
194  styleEdit->setReadOnly(true);
195  styleList = new QFontListView(q);
197 
198  styleAccel = new QLabel(q);
199 #ifndef QT_NO_SHORTCUT
201 #endif
202  styleAccel->setIndent(2);
203 
204  sizeEdit = new QLineEdit(q);
206  QIntValidator *validator = new QIntValidator(1, 512, q);
207  sizeEdit->setValidator(validator);
208  sizeList = new QFontListView(q);
209 
210  sizeAccel = new QLabel(q);
211 #ifndef QT_NO_SHORTCUT
213 #endif
214  sizeAccel->setIndent(2);
215 
216  // effects box
217  effects = new QGroupBox(q);
218  QVBoxLayout *vbox = new QVBoxLayout(effects);
219  strikeout = new QCheckBox(effects);
220  vbox->addWidget(strikeout);
221  underline = new QCheckBox(effects);
222  vbox->addWidget(underline);
223 
224  sample = new QGroupBox(q);
225  QHBoxLayout *hbox = new QHBoxLayout(sample);
226  sampleEdit = new QLineEdit(sample);
229  // Note that the sample text is *not* translated with tr(), as the
230  // characters used depend on the charset encoding.
231  sampleEdit->setText(QLatin1String("AaBbYyZz"));
232  hbox->addWidget(sampleEdit);
233 
235 
236  writingSystemAccel = new QLabel(q);
237 #ifndef QT_NO_SHORTCUT
239 #endif
241 
242  size = 0;
243  smoothScalable = false;
244 
246  QObject::connect(familyList, SIGNAL(highlighted(int)), q, SLOT(_q_familyHighlighted(int)));
247  QObject::connect(styleList, SIGNAL(highlighted(int)), q, SLOT(_q_styleHighlighted(int)));
248  QObject::connect(sizeList, SIGNAL(highlighted(int)), q, SLOT(_q_sizeHighlighted(int)));
250 
253 
254  for (int i = 0; i < QFontDatabase::WritingSystemsCount; ++i) {
256  QString writingSystemName = QFontDatabase::writingSystemName(ws);
257  if (writingSystemName.isEmpty())
258  break;
259  writingSystemCombo->addItem(writingSystemName);
260  }
261 
262  updateFamilies();
263  if (familyList->count() != 0) {
266  }
267 
268  // grid layout
269  QGridLayout *mainGrid = new QGridLayout(q);
270 
271  int spacing = mainGrid->spacing();
272  if (spacing >= 0) { // uniform spacing
273  mainGrid->setSpacing(0);
274 
275  mainGrid->setColumnMinimumWidth(1, spacing);
276  mainGrid->setColumnMinimumWidth(3, spacing);
277 
278  int margin = 0;
279  mainGrid->getContentsMargins(nullptr, nullptr, nullptr, &margin);
280 
281  mainGrid->setRowMinimumHeight(3, margin);
282  mainGrid->setRowMinimumHeight(6, 2);
283  mainGrid->setRowMinimumHeight(8, margin);
284  }
285 
286  mainGrid->addWidget(familyAccel, 0, 0);
287  mainGrid->addWidget(familyEdit, 1, 0);
288  mainGrid->addWidget(familyList, 2, 0);
289 
290  mainGrid->addWidget(styleAccel, 0, 2);
291  mainGrid->addWidget(styleEdit, 1, 2);
292  mainGrid->addWidget(styleList, 2, 2);
293 
294  mainGrid->addWidget(sizeAccel, 0, 4);
295  mainGrid->addWidget(sizeEdit, 1, 4);
296  mainGrid->addWidget(sizeList, 2, 4);
297 
298  mainGrid->setColumnStretch(0, 38);
299  mainGrid->setColumnStretch(2, 24);
300  mainGrid->setColumnStretch(4, 10);
301 
302  mainGrid->addWidget(effects, 4, 0);
303 
304  mainGrid->addWidget(sample, 4, 2, 4, 3);
305 
306  mainGrid->addWidget(writingSystemAccel, 5, 0);
307  mainGrid->addWidget(writingSystemCombo, 7, 0);
308 
310  mainGrid->addWidget(buttonBox, 9, 0, 1, 5);
311 
314  QObject::connect(buttonBox, SIGNAL(accepted()), q, SLOT(accept()));
315  button->setDefault(true);
316 
318  QObject::connect(buttonBox, SIGNAL(rejected()), q, SLOT(reject()));
319 
320  q->resize(500, 360);
321 
323  familyList->installEventFilter(q);
324  styleList->installEventFilter(q);
325  sizeList->installEventFilter(q);
326 
327  familyList->setFocus();
329  sampleEdit->setObjectName(QLatin1String("qt_fontDialog_sampleEdit"));
330 }
331 
338 {
339 }
340 
365 QFont QFontDialog::getFont(bool *ok, const QFont &initial, QWidget *parent, const QString &title,
366  FontDialogOptions options)
367 {
368  return QFontDialogPrivate::getFont(ok, initial, parent, title, options);
369 }
370 
392 {
393  QFont initial;
394  return QFontDialogPrivate::getFont(ok, initial, parent, QString(), { });
395 }
396 
398  const QString &title, QFontDialog::FontDialogOptions options)
399 {
400  QFontDialog dlg(parent);
401  dlg.setOptions(options);
402  dlg.setCurrentFont(initial);
403  if (!title.isEmpty())
404  dlg.setWindowTitle(title);
405 
406  int ret = (dlg.exec() || (options & QFontDialog::NoButtons));
407  if (ok)
408  *ok = !!ret;
409  if (ret) {
410  return dlg.selectedFont();
411  } else {
412  return initial;
413  }
414 }
415 
424 {
425  Q_D(QFontDialog);
426  if (e->type() == QEvent::KeyPress) {
427  QKeyEvent *k = (QKeyEvent *)e;
428  if (o == d->sizeEdit &&
429  (k->key() == Qt::Key_Up ||
430  k->key() == Qt::Key_Down ||
431  k->key() == Qt::Key_PageUp ||
432  k->key() == Qt::Key_PageDown)) {
433 
434  int ci = d->sizeList->currentItem();
435  QCoreApplication::sendEvent(d->sizeList, k);
436 
437  if (ci != d->sizeList->currentItem()
438  && style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, this))
439  d->sizeEdit->selectAll();
440  return true;
441  } else if ((o == d->familyList || o == d->styleList) &&
442  (k->key() == Qt::Key_Return || k->key() == Qt::Key_Enter)) {
443  k->accept();
444  accept();
445  return true;
446  }
447  } else if (e->type() == QEvent::FocusIn
448  && style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, this)) {
449  if (o == d->familyList)
450  d->familyEdit->selectAll();
451  else if (o == d->styleList)
452  d->styleEdit->selectAll();
453  else if (o == d->sizeList)
454  d->sizeEdit->selectAll();
455  } else if (e->type() == QEvent::MouseButtonPress && o == d->sizeList) {
456  d->sizeEdit->setFocus();
457  }
458  return QDialog::eventFilter(o, e);
459 }
460 
461 void QFontDialogPrivate::initHelper(QPlatformDialogHelper *h)
462 {
463  QFontDialog *d = q_func();
464  QObject::connect(h, SIGNAL(currentFontChanged(QFont)), d, SIGNAL(currentFontChanged(QFont)));
465  QObject::connect(h, SIGNAL(fontSelected(QFont)), d, SIGNAL(fontSelected(QFont)));
466  static_cast<QPlatformFontDialogHelper *>(h)->setOptions(options);
467 }
468 
469 void QFontDialogPrivate::helperPrepareShow(QPlatformDialogHelper *)
470 {
471  options->setWindowTitle(q_func()->windowTitle());
472 }
473 
474 /*
475  Updates the contents of the "font family" list box. This
476  function can be reimplemented if you have special requirements.
477 */
478 
480 {
481  Q_Q(QFontDialog);
482 
483  enum match_t { MATCH_NONE = 0, MATCH_LAST_RESORT = 1, MATCH_APP = 2, MATCH_FAMILY = 3 };
484 
485  const QFontDialog::FontDialogOptions scalableMask = (QFontDialog::ScalableFonts | QFontDialog::NonScalableFonts);
486  const QFontDialog::FontDialogOptions spacingMask = (QFontDialog::ProportionalFonts | QFontDialog::MonospacedFonts);
487  const QFontDialog::FontDialogOptions options = q->options();
488 
489  QStringList familyNames;
490  const auto families = QFontDatabase::families(writingSystem);
491  for (const QString &family : families) {
493  continue;
494 
495  if ((options & scalableMask) && (options & scalableMask) != scalableMask) {
497  continue;
498  }
499  if ((options & spacingMask) && (options & spacingMask) != spacingMask) {
501  continue;
502  }
503  familyNames << family;
504  }
505 
506  familyList->model()->setStringList(familyNames);
507 
508  QString foundryName1, familyName1, foundryName2, familyName2;
509  int bestFamilyMatch = -1;
510  match_t bestFamilyType = MATCH_NONE;
511 
512  QFont f;
513 
514  // ##### do the right thing for a list of family names in the font.
515  QFontDatabasePrivate::parseFontName(family, foundryName1, familyName1);
516 
517  QStringList::const_iterator it = familyNames.constBegin();
518  int i = 0;
519  for(; it != familyNames.constEnd(); ++it, ++i) {
520  QFontDatabasePrivate::parseFontName(*it, foundryName2, familyName2);
521 
522  //try to match...
523  if (familyName1 == familyName2) {
524  bestFamilyType = MATCH_FAMILY;
525  if (foundryName1 == foundryName2) {
526  bestFamilyMatch = i;
527  break;
528  }
529  if (bestFamilyMatch < MATCH_FAMILY)
530  bestFamilyMatch = i;
531  }
532 
533  //and try some fall backs
534  match_t type = MATCH_NONE;
535  if (bestFamilyType <= MATCH_NONE && familyName2 == QStringLiteral("helvetica"))
536  type = MATCH_LAST_RESORT;
537  if (bestFamilyType <= MATCH_LAST_RESORT && familyName2 == f.families().first())
538  type = MATCH_APP;
539  // ### add fallback for writingSystem
540  if (type != MATCH_NONE) {
541  bestFamilyType = type;
542  bestFamilyMatch = i;
543  }
544  }
545 
546  if (i != -1 && bestFamilyType != MATCH_NONE)
547  familyList->setCurrentItem(bestFamilyMatch);
548  else
551  if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, q)
552  && familyList->hasFocus())
554 
555  updateStyles();
556 }
557 
558 /*
559  Updates the contents of the "font style" list box. This
560  function can be reimplemented if you have special requirements.
561 */
563 {
564  Q_Q(QFontDialog);
566  styleList->model()->setStringList(styles);
567 
568  if (styles.isEmpty()) {
569  styleEdit->clear();
570  smoothScalable = false;
571  } else {
572  if (!style.isEmpty()) {
573  bool found = false;
574  bool first = true;
575  QString cstyle = style;
576 
577  redo:
578  for (int i = 0; i < static_cast<int>(styleList->count()); i++) {
579  if (cstyle == styleList->text(i)) {
581  found = true;
582  break;
583  }
584  }
585  if (!found && first) {
586  if (cstyle.contains(QLatin1String("Italic"))) {
587  cstyle.replace(QLatin1String("Italic"), QLatin1String("Oblique"));
588  first = false;
589  goto redo;
590  } else if (cstyle.contains(QLatin1String("Oblique"))) {
591  cstyle.replace(QLatin1String("Oblique"), QLatin1String("Italic"));
592  first = false;
593  goto redo;
594  } else if (cstyle.contains(QLatin1String("Regular"))) {
595  cstyle.replace(QLatin1String("Regular"), QLatin1String("Normal"));
596  first = false;
597  goto redo;
598  } else if (cstyle.contains(QLatin1String("Normal"))) {
599  cstyle.replace(QLatin1String("Normal"), QLatin1String("Regular"));
600  first = false;
601  goto redo;
602  }
603  }
604  if (!found)
606  } else {
608  }
609 
611  if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, q)
612  && styleList->hasFocus())
613  styleEdit->selectAll();
614 
616  }
617 
618  updateSizes();
619 }
620 
628 {
629  Q_Q(QFontDialog);
630 
631  if (!familyList->currentText().isEmpty()) {
633 
634  int i = 0;
635  int current = -1;
636  QStringList str_sizes;
637  str_sizes.reserve(sizes.size());
638  for(QList<int>::const_iterator it = sizes.constBegin(); it != sizes.constEnd(); ++it) {
639  str_sizes.append(QString::number(*it));
640  if (current == -1 && *it == size)
641  current = i;
642  ++i;
643  }
644  sizeList->model()->setStringList(str_sizes);
645  if (current != -1)
646  sizeList->setCurrentItem(current);
647 
648  const QSignalBlocker blocker(sizeEdit);
650  if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, q)
651  && sizeList->hasFocus())
652  sizeEdit->selectAll();
653  } else {
654  sizeEdit->clear();
655  }
656 
657  _q_updateSample();
658 }
659 
661 {
662  // compute new font
663  int pSize = sizeEdit->text().toInt();
665  newFont.setStrikeOut(strikeout->isChecked());
666  newFont.setUnderline(underline->isChecked());
667 
668  if (familyList->currentText().isEmpty())
669  sampleEdit->clear();
670 
671  updateSampleFont(newFont);
672 }
673 
675 {
676  Q_Q(QFontDialog);
677  if (newFont != sampleEdit->font()) {
678  sampleEdit->setFont(newFont);
679  emit q->currentFontChanged(newFont);
680  }
681 }
682 
687 {
690  updateFamilies();
691 }
692 
697 {
698  Q_Q(QFontDialog);
699  family = familyList->text(i);
701  if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, q)
702  && familyList->hasFocus())
704 
705  updateStyles();
706 }
707 
708 
714 {
715  Q_Q(QFontDialog);
717  styleEdit->setText(s);
718  if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, q)
719  && styleList->hasFocus())
720  styleEdit->selectAll();
721 
722  style = s;
723 
724  updateSizes();
725 }
726 
727 
733 {
734  Q_Q(QFontDialog);
736  sizeEdit->setText(s);
737  if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, q)
738  && sizeEdit->hasFocus())
739  sizeEdit->selectAll();
740 
741  size = s.toInt();
742  _q_updateSample();
743 }
744 
752 {
753  // no need to check if the conversion is valid, since we have an QIntValidator in the size edit
754  int size = s.toInt();
755  if (this->size == size)
756  return;
757 
758  this->size = size;
759  if (sizeList->count() != 0) {
760  int i;
761  for (i = 0; i < sizeList->count() - 1; i++) {
762  if (sizeList->text(i).toInt() >= this->size)
763  break;
764  }
765  const QSignalBlocker blocker(sizeList);
766  if (sizeList->text(i).toInt() == this->size)
768  else
770  }
771  _q_updateSample();
772 }
773 
775 {
777  styleAccel->setText(QFontDialog::tr("Font st&yle"));
778  sizeAccel->setText(QFontDialog::tr("&Size"));
779  effects->setTitle(QFontDialog::tr("Effects"));
780  strikeout->setText(QFontDialog::tr("Stri&keout"));
781  underline->setText(QFontDialog::tr("&Underline"));
782  sample->setTitle(QFontDialog::tr("Sample"));
783  writingSystemAccel->setText(QFontDialog::tr("Wr&iting System"));
784 }
785 
790 {
791  Q_D(QFontDialog);
792  if (e->type() == QEvent::LanguageChange) {
793  d->retranslateStrings();
794  }
796 }
797 
813 {
814  Q_D(QFontDialog);
815  d->family = font.families().value(0);
817  d->size = font.pointSize();
818  if (d->size == -1) {
819  QFontInfo fi(font);
820  d->size = fi.pointSize();
821  }
822  d->strikeout->setChecked(font.strikeOut());
823  d->underline->setChecked(font.underline());
824  d->updateFamilies();
825  if (QPlatformFontDialogHelper *helper = d->platformFontDialogHelper())
826  helper->setCurrentFont(font);
827 }
828 
837 {
838  Q_D(const QFontDialog);
839  if (const QPlatformFontDialogHelper *helper = d->platformFontDialogHelper())
840  return helper->currentFont();
841  return d->sampleEdit->font();
842 }
843 
853 {
854  Q_D(const QFontDialog);
855  return d->selectedFont;
856 }
857 
890 {
891  const QFontDialog::FontDialogOptions previousOptions = options();
892  if (!(previousOptions & option) != !on)
893  setOptions(previousOptions ^ option);
894 }
895 
903 {
904  Q_D(const QFontDialog);
905  return d->options->testOption(static_cast<QFontDialogOptions::FontDialogOption>(option));
906 }
907 
921 void QFontDialog::setOptions(FontDialogOptions options)
922 {
923  Q_D(QFontDialog);
924 
925  if (QFontDialog::options() == options)
926  return;
927 
928  d->options->setOptions(QFontDialogOptions::FontDialogOptions(int(options)));
929  d->buttonBox->setVisible(!(options & NoButtons));
930 }
931 
932 QFontDialog::FontDialogOptions QFontDialog::options() const
933 {
934  Q_D(const QFontDialog);
935  return QFontDialog::FontDialogOptions(int(d->options->options()));
936 }
937 
946 void QFontDialog::open(QObject *receiver, const char *member)
947 {
948  Q_D(QFontDialog);
949  connect(this, SIGNAL(fontSelected(QFont)), receiver, member);
950  d->receiverToDisconnectOnClose = receiver;
951  d->memberToDisconnectOnClose = member;
952  QDialog::open();
953 }
954 
987 void QFontDialog::setVisible(bool visible)
988 {
990  return;
991  Q_D(QFontDialog);
992  if (d->canBeNativeDialog())
993  d->setNativeDialogVisible(visible);
994  if (d->nativeDialogInUse) {
995  // Set WA_DontShowOnScreen so that QDialog::setVisible(visible) below
996  // updates the state correctly, but skips showing the non-native version:
998  } else {
999  d->nativeDialogInUse = false;
1001  }
1003 }
1004 
1013 {
1014  Q_D(QFontDialog);
1015  if (result == Accepted) {
1016  // We check if this is the same font we had before, if so we emit currentFontChanged
1018  if (selectedFont != d->selectedFont)
1020  d->selectedFont = selectedFont;
1021  emit fontSelected(d->selectedFont);
1022  } else
1023  d->selectedFont = QFont();
1024  if (d->receiverToDisconnectOnClose) {
1026  d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose);
1027  d->receiverToDisconnectOnClose = nullptr;
1028  }
1029  d->memberToDisconnectOnClose.clear();
1031 }
1032 
1034 {
1035  // Don't use Q_Q here! This function is called from ~QDialog,
1036  // so Q_Q calling q_func() invokes undefined behavior (invalid cast in q_func()).
1037  const QDialog * const q = static_cast<const QDialog*>(q_ptr);
1038  if (nativeDialogInUse)
1039  return true;
1041  || q->testAttribute(Qt::WA_DontShowOnScreen)
1043  return false;
1044  }
1045 
1046  QLatin1String staticName(QFontDialog::staticMetaObject.className());
1047  QLatin1String dynamicName(q->metaObject()->className());
1048  return (staticName == dynamicName);
1049 }
1050 
1052 
1053 #include "qfontdialog.moc"
1054 #include "moc_qfontdialog.cpp"
small capitals from c petite p scientific i
[1]
Definition: afcover.h:80
void setText(const QString &text)
bool isChecked() const
void setEditTriggers(EditTriggers triggers)
QAbstractItemModel * model() const
void setCurrentIndex(const QModelIndex &index)
QModelIndex currentIndex() const
virtual void setModel(QAbstractItemModel *model)
The QAbstractListModel class provides an abstract model that can be subclassed to create one-dimensio...
void addWidget(QWidget *, int stretch=0, Qt::Alignment alignment=Qt::Alignment())
The QCheckBox widget provides a checkbox with a text label.
Definition: qcheckbox.h:55
The QComboBox widget is a combined button and popup list.
Definition: qcombobox.h:60
void addItem(const QString &text, const QVariant &userData=QVariant())
Definition: qcombobox.h:260
static bool sendEvent(QObject *receiver, QEvent *event)
static bool testAttribute(Qt::ApplicationAttribute attribute)
The QDialogButtonBox class is a widget that presents buttons in a layout that is appropriate to the c...
void addButton(QAbstractButton *button, ButtonRole role)
The QDialog class is the base class of dialog windows.
Definition: qdialog.h:55
bool eventFilter(QObject *, QEvent *) override
Definition: qdialog.cpp:684
virtual int exec()
Definition: qdialog.cpp:595
@ Accepted
Definition: qdialog.h:66
virtual void done(int)
Definition: qdialog.cpp:654
virtual void open()
Definition: qdialog.cpp:555
void setVisible(bool visible) override
Definition: qdialog.cpp:783
virtual void accept()
Definition: qdialog.cpp:667
bool nativeDialogInUse
Definition: qdialog_p.h:121
The QEvent class is the base class of all event classes. Event objects contain event parameters.
Definition: qcoreevent.h:58
@ KeyPress
Definition: qcoreevent.h:77
@ FocusIn
Definition: qcoreevent.h:79
@ MouseButtonPress
Definition: qcoreevent.h:73
@ LanguageChange
Definition: qcoreevent.h:136
void accept()
Definition: qcoreevent.h:313
The QFontDatabase class provides information about the fonts available in the underlying window syste...
Definition: qfontdatabase.h:55
static QString writingSystemName(WritingSystem writingSystem)
static bool isSmoothlyScalable(const QString &family, const QString &style=QString())
static bool isPrivateFamily(const QString &family)
static QString styleString(const QFont &font)
static QFont font(const QString &family, const QString &style, int pointSize)
static QString writingSystemSample(WritingSystem writingSystem)
static QStringList families(WritingSystem writingSystem=Any)
static QList< int > pointSizes(const QString &family, const QString &style=QString())
static QStringList styles(const QString &family)
static bool isFixedPitch(const QString &family, const QString &style=QString())
static void parseFontName(const QString &name, QString &foundry, QString &family)
The QFontDialog class provides a dialog widget for selecting a font.
Definition: qfontdialog.h:56
QFontDialog(QWidget *parent=nullptr)
void fontSelected(const QFont &font)
void setOption(FontDialogOption option, bool on=true)
void setVisible(bool visible) override
void setOptions(FontDialogOptions options)
@ NonScalableFonts
Definition: qfontdialog.h:67
@ DontUseNativeDialog
Definition: qfontdialog.h:65
@ ProportionalFonts
Definition: qfontdialog.h:69
FontDialogOptions options
the various options that affect the look and feel of the dialog
Definition: qfontdialog.h:60
bool testOption(FontDialogOption option) const
QFont selectedFont() const
QFont currentFont
the current font of the dialog.
Definition: qfontdialog.h:59
bool eventFilter(QObject *object, QEvent *event) override
void changeEvent(QEvent *event) override
static QFont getFont(bool *ok, QWidget *parent=nullptr)
void done(int result) override
void currentFontChanged(const QFont &font)
virtual void open()
Definition: qdialog.cpp:555
void setCurrentFont(const QFont &font)
void setWindowTitle(const QString &)
FontDialogOptions options() const
QFontListView * familyList
QLineEdit * styleEdit
void updateSampleFont(const QFont &newFont)
QLineEdit * sizeEdit
void _q_sizeHighlighted(int)
QGroupBox * effects
void _q_writingSystemHighlighted(int)
QLineEdit * familyEdit
QGroupBox * sample
bool canBeNativeDialog() const override
void _q_sizeChanged(const QString &)
QLabel * writingSystemAccel
void _q_styleHighlighted(int)
QSharedPointer< QFontDialogOptions > options
static QFont getFont(bool *ok, const QFont &initial, QWidget *parent, const QString &title, QFontDialog::FontDialogOptions options)
void _q_familyHighlighted(int)
QComboBox * writingSystemCombo
QDialogButtonBox * buttonBox
QFontListView * sizeList
QFontListView * styleList
QLineEdit * sampleEdit
QCheckBox * underline
QCheckBox * strikeout
QFontDatabase::WritingSystem writingSystem
The QFont class specifies a query for a font used for drawing text.
Definition: qfont.h:56
void setStrikeOut(bool)
Definition: qfont.cpp:1335
bool strikeOut() const
Definition: qfont.cpp:1324
bool underline() const
Definition: qfont.cpp:1271
QStringList families() const
Definition: qfont.cpp:2284
int pointSize() const
Definition: qfont.cpp:899
void setUnderline(bool)
Definition: qfont.cpp:1282
The QFontInfo class provides general information about fonts. \inmodule QtGui.
Definition: qfontinfo.h:51
QFontListView(QWidget *parent)
Definition: qfontdialog.cpp:99
int count() const
Definition: qfontdialog.cpp:80
void setCurrentItem(int item)
Definition: qfontdialog.cpp:74
void currentChanged(const QModelIndex &current, const QModelIndex &previous) override
Definition: qfontdialog.cpp:87
QStringListModel * model() const
Definition: qfontdialog.cpp:71
QString currentText() const
Definition: qfontdialog.cpp:83
void highlighted(int)
int currentItem() const
Definition: qfontdialog.cpp:77
QString text(int i) const
Definition: qfontdialog.cpp:92
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:57
void addWidget(QWidget *w)
Definition: qgridlayout.h:100
void setRowMinimumHeight(int row, int minSize)
void setColumnMinimumWidth(int column, int minSize)
void setSpacing(int spacing) override
int spacing() const override
void setColumnStretch(int column, int stretch)
The QGroupBox widget provides a group box frame with a title.
Definition: qgroupbox.h:53
void setTitle(const QString &title)
Definition: qgroupbox.cpp:223
The QHBoxLayout class lines up widgets horizontally.
Definition: qboxlayout.h:114
The QIntValidator class provides a validator that ensures a string contains a valid integer within a ...
Definition: qvalidator.h:92
The QKeyEvent class describes a key event.
Definition: qevent.h:471
int key() const
Definition: qevent.h:484
The QLabel widget provides a text or image display.
Definition: qlabel.h:56
void setBuddy(QWidget *)
Definition: qlabel.cpp:1201
void setText(const QString &)
Definition: qlabel.cpp:297
void setIndent(int)
Definition: qlabel.cpp:544
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal.
Definition: qstring.h:84
void getContentsMargins(int *left, int *top, int *right, int *bottom) const
Definition: qlayout.cpp:384
The QLineEdit widget is a one-line text editor.
Definition: qlineedit.h:64
void setValidator(const QValidator *)
Definition: qlineedit.cpp:622
void setAlignment(Qt::Alignment flag)
Definition: qlineedit.cpp:784
void selectAll()
Definition: qlineedit.cpp:1275
void clear()
Definition: qlineedit.cpp:1313
void setReadOnly(bool)
Definition: qlineedit.cpp:1364
void setText(const QString &)
Definition: qlineedit.cpp:316
QString text
the line edit's text.
Definition: qlineedit.h:68
The QListView class provides a list or icon view onto a model.
Definition: qlistview.h:53
void currentChanged(const QModelIndex &current, const QModelIndex &previous) override
Definition: qlistview.cpp:3429
The QModelIndex class is used to locate data in a data model.
constexpr int row() const noexcept
constexpr bool isValid() const noexcept
QObject * q_ptr
Definition: qobject.h:98
QObject * parent
Definition: qobject.h:99
The QObject class is the base class of all Qt objects.
Definition: qobject.h:125
void installEventFilter(QObject *filterObj)
Definition: qobject.cpp:2235
QObject * parent() const
Definition: qobject.h:409
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Definition: qobject.cpp:2772
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Definition: qobject.cpp:3048
void setObjectName(const QString &name)
Definition: qobject.cpp:1261
The QPushButton widget provides a command button.
Definition: qpushbutton.h:56
void setDefault(bool)
Exception-safe wrapper around QObject::blockSignals().
Definition: qobject.h:527
The QSizePolicy class is a layout attribute describing horizontal and vertical resizing policy.
Definition: qsizepolicy.h:54
The QString class provides a Unicode character string.
Definition: qstring.h:388
int toInt(bool *ok=nullptr, int base=10) const
Definition: qstring.h:848
QString & replace(qsizetype i, qsizetype len, QChar after)
Definition: qstring.cpp:3450
QString first(qsizetype n) const
Definition: qstring.h:576
bool isEmpty() const
Definition: qstring.h:1216
bool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.h:1353
static QString number(int, int base=10)
Definition: qstring.cpp:7538
The QStringList class provides a list of strings.
The QStringListModel class provides a model that supplies strings to views.
QStringList stringList() const
int rowCount(const QModelIndex &parent=QModelIndex()) const override
void setStringList(const QStringList &strings)
@ SH_FontDialog_SelectAssociatedText
Definition: qstyle.h:632
The QVBoxLayout class lines up widgets vertically.
Definition: qboxlayout.h:127
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:133
void setAttribute(Qt::WidgetAttribute, bool on=true)
Definition: qwidget.cpp:11088
void setSizePolicy(QSizePolicy)
void setFocusProxy(QWidget *)
Definition: qwidget.cpp:6382
void setFocusPolicy(Qt::FocusPolicy policy)
Definition: qwidget.cpp:7773
virtual void changeEvent(QEvent *)
Definition: qwidget.cpp:9283
void setWindowTitle(const QString &)
Definition: qwidget.cpp:6119
QStyle * style() const
Definition: qwidget.cpp:2612
void setFont(const QFont &)
Definition: qwidget.cpp:4673
QFont font
the font currently set for the widget
Definition: qwidget.h:167
bool hasFocus() const
Definition: qwidget.cpp:6430
bool testAttribute(Qt::WidgetAttribute) const
Definition: qwidget.h:943
bool visible
whether the widget is visible
Definition: qwidget.h:178
#define this
Definition: dialogs.cpp:56
qreal spacing
QPushButton * button
[2]
void textChanged(const QString &newText)
double e
typename C::const_iterator const_iterator
@ AlignCenter
Definition: qnamespace.h:188
@ WA_WState_ExplicitShowHide
Definition: qnamespace.h:360
@ WA_DontShowOnScreen
Definition: qnamespace.h:408
@ WA_WState_Hidden
Definition: qnamespace.h:322
@ ClickFocus
Definition: qnamespace.h:134
@ Key_Return
Definition: qnamespace.h:688
@ Key_Enter
Definition: qnamespace.h:689
@ Key_PageUp
Definition: qnamespace.h:702
@ Key_Up
Definition: qnamespace.h:699
@ Key_Down
Definition: qnamespace.h:701
@ Key_PageDown
Definition: qnamespace.h:703
@ AA_DontUseNativeDialogs
Definition: qnamespace.h:483
@ Dialog
Definition: qnamespace.h:233
@ WindowSystemMenuHint
Definition: qnamespace.h:252
@ WindowCloseButtonHint
Definition: qnamespace.h:266
Definition: helper.py:1
#define QString()
Definition: parse-defines.h:51
#define SLOT(a)
Definition: qobjectdefs.h:87
#define SIGNAL(a)
Definition: qobjectdefs.h:88
GLenum type
Definition: qopengl.h:270
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint index
[2]
GLfloat GLfloat f
GLint first
GLfloat GLfloat GLfloat GLfloat h
GLuint GLsizei const GLuint const GLintptr const GLsizeiptr * sizes
Definition: qopenglext.h:2587
GLdouble GLdouble GLdouble GLdouble q
Definition: qopenglext.h:259
GLenum GLenum GLsizei void * row
Definition: qopenglext.h:2747
GLuint64EXT * result
[6]
Definition: qopenglext.h:10932
GLdouble s
[6]
Definition: qopenglext.h:235
GLuint GLenum option
Definition: qopenglext.h:5929
#define QStringLiteral(str)
#define tr(X)
#define Q_OBJECT
Definition: qtmetamacros.h:158
#define signals
Definition: qtmetamacros.h:77
#define emit
Definition: qtmetamacros.h:85
const char className[16]
[1]
Definition: qwizard.cpp:135
QFileInfo fi("c:/temp/foo")
[newstuff]
QString title
[35]
QGraphicsItem * item
view create()
QStringList::Iterator it
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent