13#include <private/qcombobox_p.h>
96 if (!uiLanguages.isEmpty())
113 if (writingSystems.isEmpty())
118 if (writingSystems.contains(system))
131 system = writingSystems.constLast();
174 const QStyleOptionViewItem &
option,
188 truetype(
QStringLiteral(
":/qt-project.org/styles/commonstyle/images/fonttruetype-16.png")),
196 const QStyleOptionViewItem &
option,
231 r.setRight(
r.right() - actualSize.
width() - 4);
233 r.setLeft(
r.left() + actualSize.
width() + 4);
262 r.setRight(
r.right() -
w);
264 r.setLeft(
r.left() +
w);
308 for (
const auto &family :
list) {
312 if ((
filters & scalableMask) && (
filters & scalableMask) != scalableMask) {
316 if ((
filters & spacingMask) && (
filters & spacingMask) != spacingMask) {
321 if (family == fi.family() || family.startsWith(fi.family() +
" ["_L1))
333 #if QT_CONFIG(accessibility)
334 if (QAccessible::isActive()) {
335 QAccessibleTableModelChangeEvent accessibleEvent(
q->view(), QAccessibleTableModelChangeEvent::ModelReset);
336 QAccessible::updateAccessibility(&accessibleEvent);
356 if (families.isEmpty() || families.first() !=
text) {
402 d->currentFont =
font();
410 lview->setUniformItemSizes(
true);
502 return d->currentFont;
508 if (
font !=
d->currentFont) {
509 d->currentFont =
font;
511 if (
d->currentFont ==
font) {
534 lview->window()->setFixedWidth(
qMin(
width() * 5 / 3,
548 sz.
setWidth(fm.horizontalAdvance(u
'm') * 14);
587 d->sampleTextForFontFamily[fontFamily] = sampleText;
598 return d->sampleTextForFontFamily.value(fontFamily);
609 d->displayFontForFontFamily[fontFamily] =
font;
620 return d->displayFontForFontFamily.value(fontFamily, {});
625#include "qfontcombobox.moc"
626#include "moc_qfontcombobox.cpp"
The QAbstractItemDelegate class is used to display and edit data items from a model.
The QComboBox widget combines a button with a dropdown list.
QAbstractItemView * view() const
Returns the list view used for the combobox popup.
void setItemDelegate(QAbstractItemDelegate *delegate)
Sets the item delegate for the popup list view.
bool event(QEvent *event) override
\reimp
void currentTextChanged(const QString &)
QAbstractItemDelegate * itemDelegate() const
Returns the item delegate used by the popup list view.
virtual void setModel(QAbstractItemModel *model)
Sets the model to be model.
QSize sizeHint() const override
\reimp
void setEditable(bool editable)
static bool closingDown()
Returns true if the application objects are being destroyed; otherwise returns false.
Type type() const
Returns the event type.
QHash< QString, QFont > displayFontForFontFamily
void currentChanged(const QString &)
QFontComboBox::FontFilters filters
QHash< QString, QString > sampleTextForFontFamily
QHash< QFontDatabase::WritingSystem, QString > sampleTextForWritingSystem
std::array< QMetaObject::Connection, 2 > connections
The QFontComboBox widget is a combobox that lets the user select a font family.
void setDisplayFont(const QString &fontFamily, const QFont &font)
Sets the font to be used to display a given fontFamily (when the combo is open).
QFontComboBox(QWidget *parent=nullptr)
Constructs a font combobox with the given parent.
QFont currentFont
the currently selected font
bool event(QEvent *e) override
\reimp
QSize sizeHint() const override
\reimp
~QFontComboBox()
Destroys the combobox.
QString sampleTextForSystem(QFontDatabase::WritingSystem writingSystem) const
Returns the sample text to show after the font name (when the combo is open) for a given writingSyste...
QString sampleTextForFont(const QString &fontFamily) const
Returns the sample text to show after the font name (when the combo is open) for a given fontFamily.
std::optional< QFont > displayFont(const QString &fontFamily) const
Returns the font (if set) to be used to display a given fontFamily (when the combo is open).
void setFontFilters(FontFilters filters)
void currentFontChanged(const QFont &f)
This signal is emitted whenever the current font changes, with the new font.
void setSampleTextForSystem(QFontDatabase::WritingSystem writingSystem, const QString &sampleText)
Sets the sampleText to show after the font name (when the combo is open) for a given writingSystem.
void setWritingSystem(QFontDatabase::WritingSystem)
QFontDatabase::WritingSystem writingSystem
the writing system that serves as a filter for the combobox
FontFilters fontFilters
the filter for the combobox
void setCurrentFont(const QFont &f)
void setSampleTextForFont(const QString &fontFamily, const QString &sampleText)
Sets the sampleText to show after the font name (when the combo is open) for a given fontFamily.
\threadsafe \inmodule QtGui
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 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< WritingSystem > writingSystems()
Returns a sorted list of the available writing systems.
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 paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
This pure abstract function must be reimplemented if you want to provide custom rendering.
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override
This pure abstract function must be reimplemented if you want to provide custom rendering.
QFontComboBoxPrivate * comboPrivate
QFontFamilyDelegate(QObject *parent, QFontComboBoxPrivate *comboP)
QFontDatabase::WritingSystem writingSystem
\reentrant \inmodule QtGui
\reentrant \inmodule QtGui
int horizontalAdvance(const QString &, int len=-1) const
Returns the horizontal advance in pixels of the first len characters of text.
void setPointSize(int)
Sets the point size to pointSize.
void setFamilies(const QStringList &)
QStringList families() const
void fontDatabaseChanged()
This signal is emitted when the available fonts have changed.
T value(const Key &key) const noexcept
The QIcon class provides scalable icons in different modes and states.
void paint(QPainter *painter, const QRect &rect, Qt::Alignment alignment=Qt::AlignCenter, Mode mode=Normal, State state=Off) const
Uses the painter to paint the icon with specified alignment, required mode, and state into the rectan...
QSize actualSize(const QSize &size, Mode mode=Normal, State state=Off) const
Returns the actual size of the icon for the requested size, mode, and state.
The QListView class provides a list or icon view onto a model.
static QLocale system()
Returns a QLocale object initialized to the system locale.
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)
QObject * parent() const
Returns a pointer to the parent object.
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
\threadsafe
The QPainter class performs low-level painting on widgets and other paint devices.
void drawRect(const QRectF &rect)
Draws the current rectangle with the current pen and brush.
void setPen(const QColor &color)
This is an overloaded member function, provided for convenience. It differs from the above function o...
const QFont & font() const
Returns the currently set font used for drawing text.
void restore()
Restores the current painter state (pops a saved state off the stack).
QFontMetrics fontMetrics() const
Returns the font metrics for the painter if the painter is active.
void save()
Saves the current painter state (pushes the state onto a stack).
void setFont(const QFont &f)
Sets the painter's font to the given font.
void drawText(const QPointF &p, const QString &s)
Draws the given text with the currently defined text direction, beginning at the given position.
void setBrush(const QBrush &brush)
Sets the painter's brush to the given brush.
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
constexpr int height() const noexcept
Returns the height of the rectangle.
constexpr void setHeight(int h) noexcept
Sets the height of the rectangle to the given height.
Exception-safe wrapper around QObject::blockSignals().
constexpr int width() const noexcept
Returns the width.
constexpr void setWidth(int w) noexcept
Sets the width to the given width.
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
QChar * data()
Returns a pointer to the data stored in the QString.
static Qt::Alignment visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment)
Transforms an alignment of Qt::AlignLeft or Qt::AlignRight without Qt::AlignAbsolute into Qt::AlignLe...
static QRect alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment, const QSize &size, const QRect &rectangle)
Returns a new rectangle of the specified size that is aligned to the given rectangle according to the...
Combined button and popup list for selecting options.
DBusConnection * connection
static QFontDatabase::WritingSystem writingSystemFromLocale()
static QFontDatabase::WritingSystem writingSystemFromScript(QLocale::Script script)
static QFontDatabase::WritingSystem writingSystemForFont(const QFont &font, bool *hasLatin)
constexpr const T & qMin(const T &a, const T &b)
GLfloat GLfloat GLfloat w
[0]
GLenum GLuint GLintptr offset
GLsizei GLfixed GLfixed GLfixed GLfixed const GLubyte * bitmap
GLdouble GLdouble GLdouble GLdouble q
#define QStringLiteral(str)
const QStringList filters({"Image files (*.png *.xpm *.jpg)", "Text files (*.txt)", "Any files (*)" })
[6]