24#include <private/qfontdatabase_p.h>
25#include <private/qdialog_p.h>
26#include <private/qfont_p.h>
144 q->setSizeGripEnabled(
true);
145 q->setWindowTitle(QFontDialog::tr(
"Select Font"));
154#ifndef QT_NO_SHORTCUT
165#ifndef QT_NO_SHORTCUT
177#ifndef QT_NO_SHORTCUT
203#ifndef QT_NO_SHORTCUT
230 if (writingSystemName.
isEmpty())
244 int spacing = mainGrid->spacing();
246 mainGrid->setSpacing(0);
248 mainGrid->setColumnMinimumWidth(1,
spacing);
249 mainGrid->setColumnMinimumWidth(3,
spacing);
252 mainGrid->getContentsMargins(
nullptr,
nullptr,
nullptr, &margin);
254 mainGrid->setRowMinimumHeight(3, margin);
255 mainGrid->setRowMinimumHeight(6, 2);
256 mainGrid->setRowMinimumHeight(8, margin);
268 mainGrid->addWidget(
sizeEdit, 1, 4);
269 mainGrid->addWidget(
sizeList, 2, 4);
271 mainGrid->setColumnStretch(0, 38);
272 mainGrid->setColumnStretch(2, 24);
273 mainGrid->setColumnStretch(4, 10);
275 mainGrid->addWidget(
effects, 4, 0);
277 mainGrid->addWidget(
sample, 4, 2, 4, 3);
283 mainGrid->addWidget(
buttonBox, 9, 0, 1, 5);
339 FontDialogOptions options)
371 const QString &
title, QFontDialog::FontDialogOptions options)
375 dlg.setCurrentFont(initial);
377 dlg.setWindowTitle(
title);
383 return dlg.selectedFont();
401 if (
o ==
d->sizeEdit &&
407 int ci =
d->sizeList->currentItem();
410 if (ci !=
d->sizeList->currentItem()
412 d->sizeEdit->selectAll();
414 }
else if ((
o ==
d->familyList ||
o ==
d->styleList) &&
422 if (
o ==
d->familyList)
423 d->familyEdit->selectAll();
424 else if (
o ==
d->styleList)
425 d->styleEdit->selectAll();
426 else if (
o ==
d->sizeList)
427 d->sizeEdit->selectAll();
429 d->sizeEdit->setFocus();
439 fontDialogHelper->setCurrentFont(
q->currentFont());
460 enum match_t { MATCH_NONE = 0, MATCH_LAST_RESORT = 1, MATCH_APP = 2, MATCH_FAMILY = 3 };
472 if ((
options & scalableMask) && (
options & scalableMask) != scalableMask) {
476 if ((
options & spacingMask) && (
options & spacingMask) != spacingMask) {
485 QString foundryName1, familyName1, foundryName2, familyName2;
486 int bestFamilyMatch = -1;
487 match_t bestFamilyType = MATCH_NONE;
494 QStringList::const_iterator
it = familyNames.
constBegin();
500 if (familyName1 == familyName2) {
501 bestFamilyType = MATCH_FAMILY;
502 if (foundryName1 == foundryName2) {
506 if (bestFamilyMatch < MATCH_FAMILY)
511 match_t
type = MATCH_NONE;
512 if (bestFamilyType <= MATCH_NONE && familyName2 ==
"helvetica"_L1)
513 type = MATCH_LAST_RESORT;
514 if (bestFamilyType <= MATCH_LAST_RESORT && familyName2 ==
f.families().constFirst())
517 if (
type != MATCH_NONE) {
518 bestFamilyType =
type;
523 if (
i != -1 && bestFamilyType != MATCH_NONE)
545 if (styles.isEmpty()) {
562 if (!found &&
first) {
563 if (cstyle.contains(
"Italic"_L1)) {
564 cstyle.replace(
"Italic"_L1,
"Oblique"_L1);
567 }
else if (cstyle.contains(
"Oblique"_L1)) {
568 cstyle.replace(
"Oblique"_L1,
"Italic"_L1);
571 }
else if (cstyle.contains(
"Regular"_L1)) {
572 cstyle.replace(
"Regular"_L1,
"Normal"_L1);
575 }
else if (cstyle.contains(
"Normal"_L1)) {
576 cstyle.replace(
"Normal"_L1,
"Regular"_L1);
614 str_sizes.reserve(
sizes.size());
617 if (current == -1 && *
it ==
size)
656 emit q->currentFontChanged(newFont);
731 int size =
s.toInt();
732 if (this->size ==
size)
770 d->retranslateStrings();
797 d->size = fi.pointSize();
803 if (
d->nativeDialogInUse) {
805 helper->setCurrentFont(
font);
820 if (
d->nativeDialogInUse) {
822 return helper->currentFont();
824 return d->sampleEdit->font();
838 return d->selectedFont;
874 const QFontDialog::FontDialogOptions previousOptions =
options();
875 if (!(previousOptions &
option) != !on)
911 d->options->setOptions(QFontDialogOptions::FontDialogOptions(
int(
options)));
918 return QFontDialog::FontDialogOptions(
int(
d->options->options()));
933 d->receiverToDisconnectOnClose = receiver;
934 d->memberToDisconnectOnClose = member;
1017 d->selectedFont =
QFont();
1018 if (
d->receiverToDisconnectOnClose) {
1020 d->receiverToDisconnectOnClose,
d->memberToDisconnectOnClose);
1021 d->receiverToDisconnectOnClose =
nullptr;
1023 d->memberToDisconnectOnClose.clear();
1040 return strcmp(QFontDialog::staticMetaObject.
className(),
q->metaObject()->className()) == 0;
1045#include "qfontdialog.moc"
1046#include "moc_qfontdialog.cpp"
void setEditTriggers(EditTriggers triggers)
QAbstractItemModel * model() const
Returns the model that this view is presenting.
void setCurrentIndex(const QModelIndex &index)
Sets the current item to be the item at index.
QModelIndex currentIndex() const
Returns the model index of the current item.
virtual void setModel(QAbstractItemModel *model)
Sets the model for the view to present.
void clearSelection()
Deselects all selected items.
void addWidget(QWidget *, int stretch=0, Qt::Alignment alignment=Qt::Alignment())
Adds widget to the end of this box layout, with a stretch factor of stretch and alignment alignment.
The QCheckBox widget provides a checkbox with a text label.
The QComboBox widget combines a button with a dropdown list.
void activated(int index)
This signal is sent when the user chooses an item in the combobox.
void addItem(const QString &text, const QVariant &userData=QVariant())
Adds an item to the combobox with the given text, and containing the specified userData (stored in th...
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
static bool testAttribute(Qt::ApplicationAttribute attribute)
Returns true if attribute attribute is set; otherwise returns false.
bool setNativeDialogVisible(bool visible)
virtual void setVisible(bool visible)
The QDialog class is the base class of dialog windows.
bool eventFilter(QObject *, QEvent *) override
\reimp
virtual void reject()
Hides the modal dialog and sets the result code to Rejected.
virtual void done(int)
Closes the dialog and sets its result code to r.
void setVisible(bool visible) override
\reimp
virtual void accept()
Hides the modal dialog and sets the result code to Accepted.
Type type() const
Returns the event type.
void accept()
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
static void parseFontName(const QString &name, QString &foundry, QString &family)
\threadsafe \inmodule QtGui
static QString writingSystemName(WritingSystem writingSystem)
Returns the names the writingSystem (e.g.
WritingSystem
\value Any \value Latin \value Greek \value Cyrillic \value Armenian \value Hebrew \value Arabic \val...
static bool isSmoothlyScalable(const QString &family, const QString &style=QString())
Returns true if the font that has family family and style style is smoothly scalable; otherwise retur...
static bool isPrivateFamily(const QString &family)
static QString styleString(const QFont &font)
Returns a string that describes the style of the font.
static QFont font(const QString &family, const QString &style, int pointSize)
Returns a QFont object that has family family, style style and point size pointSize.
static QString writingSystemSample(WritingSystem writingSystem)
Returns a string with sample characters from writingSystem.
static QStringList families(WritingSystem writingSystem=Any)
Returns a sorted list of the available font families which support the writingSystem.
static QList< int > pointSizes(const QString &family, const QString &style=QString())
Returns a list of the point sizes available for the font that has family family and style styleName.
static QStringList styles(const QString &family)
Returns a list of the styles available for the font family family.
static bool isFixedPitch(const QString &family, const QString &style=QString())
Returns true if the font that has family family and style style is fixed pitch; otherwise returns fal...
void setWindowTitle(const QString &)
FontDialogOptions options() const
virtual void initHelper(QPlatformDialogHelper *) override
QFontListView * familyList
void setVisible(bool visible) override
void updateSampleFont(const QFont &newFont)
void sizeHighlighted(int)
void retranslateStrings()
void styleHighlighted(int)
bool canBeNativeDialog() const override
virtual void helperPrepareShow(QPlatformDialogHelper *) override
QLabel * writingSystemAccel
QSharedPointer< QFontDialogOptions > options
static QFont getFont(bool *ok, const QFont &initial, QWidget *parent, const QString &title, QFontDialog::FontDialogOptions options)
QComboBox * writingSystemCombo
void writingSystemHighlighted(int)
QDialogButtonBox * buttonBox
QFontListView * styleList
QFontDatabase::WritingSystem writingSystem
void familyHighlighted(int)
void sizeChanged(const QString &)
QFontDialog(QWidget *parent=nullptr)
void fontSelected(const QFont &font)
void setOption(FontDialogOption option, bool on=true)
Sets the given option to be enabled if on is true; otherwise, clears the given option.
void setVisible(bool visible) override
\reimp
void setOptions(FontDialogOptions options)
FontDialogOptions options
the various options that affect the look and feel of the dialog
bool testOption(FontDialogOption option) const
Returns true if the given option is enabled; otherwise, returns false.
QFont selectedFont() const
Returns the font that the user selected by clicking the \uicontrol{OK} or equivalent button.
QFont currentFont
the current font of the dialog.
bool eventFilter(QObject *object, QEvent *event) override
void changeEvent(QEvent *event) override
\reimp
static QFont getFont(bool *ok, QWidget *parent=nullptr)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void done(int result) override
Closes the dialog and sets its result code to result.
void currentFontChanged(const QFont &font)
void setCurrentFont(const QFont &font)
QStringListModel * model() const
QFontListView(QWidget *parent)
void setCurrentItem(int item)
void currentChanged(const QModelIndex ¤t, const QModelIndex &previous) override
This slot is called when a new item becomes the current item.
QString currentText() const
QString text(int i) const
bool strikeOut() const
Returns true if strikeout has been set; otherwise returns false.
bool underline() const
Returns true if underline has been set; otherwise returns false.
QStringList families() const
int pointSize() const
Returns the point size of the font.
The QGridLayout class lays out widgets in a grid.
The QGroupBox widget provides a group box frame with a title.
void setTitle(const QString &title)
The QHBoxLayout class lines up widgets horizontally.
The QIntValidator class provides a validator that ensures a string contains a valid integer within a ...
The QKeyEvent class describes a key event.
int key() const
Returns the code of the key that was pressed or released.
The QLabel widget provides a text or image display.
void setBuddy(QWidget *)
Sets this label's buddy to buddy.
void setText(const QString &)
The QLineEdit widget is a one-line text editor.
void setValidator(const QValidator *)
Sets the validator for values of line edit to v.
void setAlignment(Qt::Alignment flag)
void selectAll()
Selects all the text (highlights it) and moves the cursor to the end.
void clear()
Clears the contents of the line edit.
void textChanged(const QString &)
This signal is emitted whenever the text changes.
void setText(const QString &)
QString text
The line edit's text.
The QListView class provides a list or icon view onto a model.
void currentChanged(const QModelIndex ¤t, const QModelIndex &previous) override
\reimp
constexpr int row() const noexcept
Returns the row this model index refers to.
constexpr bool isValid() const noexcept
Returns {true} if this model index is valid; otherwise returns {false}.
static QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiverPrivate, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
void installEventFilter(QObject *filterObj)
Installs an event filter filterObj on this object.
QObject * parent() const
Returns a pointer to the parent object.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Q_WEAK_OVERLOAD void setObjectName(const QString &name)
Sets the object's name to name.
const_iterator constBegin() const noexcept
const_iterator constEnd() const noexcept
Exception-safe wrapper around QObject::blockSignals().
The QSizePolicy class is a layout attribute describing horizontal and vertical resizing policy.
QStringList stringList() const
Returns the string list used by the model to store data.
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of rows in the model.
void setStringList(const QStringList &strings)
Sets the model's internal string list to strings.
\macro QT_RESTRICTED_CAST_FROM_ASCII
int toInt(bool *ok=nullptr, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
@ SH_FontDialog_SelectAssociatedText
The QVBoxLayout class lines up widgets vertically.
QSet< QString >::iterator it
Combined button and popup list for selecting options.
@ AA_DontUseNativeDialogs
static const Qt::WindowFlags qfd_DefaultWindowFlags
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLfloat GLfloat GLfloat GLfloat h
GLuint GLsizei const GLuint const GLintptr const GLsizeiptr * sizes
GLdouble GLdouble GLdouble GLdouble q
GLenum GLenum GLsizei void * row
static QString windowTitle(HWND hwnd)
const char className[16]
[1]
myObject disconnect()
[26]