Wireshark 5.1.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
FontSelectionWidget Class Reference

Font selector with family, style and size lists, effects and a sample. More...

#include <font_selection_widget.h>

Inheritance diagram for FontSelectionWidget:

Classes

struct  Selection
 The edited value: family and point size. More...

Public Types

enum class  FamilyFilter { AllFamilies , FixedPitchOnly }
 Which families the family list offers. More...
enum class  FontClass { Regular , Monospace }
 What an empty family resolves to. More...
enum  Feature { StyleFeature = 0x1 , EffectsFeature = 0x2 , FamilyFilterFeature = 0x4 }
 Optional parts of the selector. More...

Signals

void changed ()
 Emitted when the user changes family, style, size or an effect.

Public Member Functions

 FontSelectionWidget (QWidget *parent=nullptr)
 Construct a FontSelectionWidget.
 ~FontSelectionWidget ()
 Destroy the widget and its UI form.
void setFamilyFilter (FamilyFilter filter)
 Choose which families are offered. The default is AllFamilies.
FamilyFilter familyFilter () const
 Return the active family filter.
void setFontClass (FontClass fontClass)
 Choose what an empty family resolves to. The default is Regular.
FontClass fontClass () const
 Return the font class.
void setFeatures (Features features)
 Show or hide the optional parts. The default is all features.
Features features () const
 Return the shown optional parts.
void setDefaultAllowed (bool allowed)
 Allow the "no explicit font" state.
bool defaultAllowed () const
 Return whether the default state is allowed.
void setSelection (const Selection &sel)
 Set the value from a Selection without emitting changed().
Selection selection () const
 Return the current Selection.
void setSelectedFont (const QFont &font)
 Set the value from a QFont without emitting changed().
QFont selectedFont () const
 Return the edited font.
QFont resolvedFont () const
 Return the font the sample is drawn with.
void setSampleText (const QString &text)
 Replace the sample text.

Protected Member Functions

void showEvent (QShowEvent *event) override
 Fill the lists on first show and refresh the sample.

Detailed Description

Font selector with family, style and size lists, effects and a sample.

The family list is built lazily, once per process, on the first show of any selector; until then it holds only the current family and the style and size lists stay empty. Setters never emit changed(); only user edits do. Every field (family, style, size, strikeout, underline) the user did not edit is kept exactly as set, so opening and closing a dialog does not rewrite a stored font.

Member Enumeration Documentation

◆ FamilyFilter

Which families the family list offers.

Enumerator
AllFamilies 

every installed family

FixedPitchOnly 

fixed-pitch families only

◆ Feature

Optional parts of the selector.

Enumerator
StyleFeature 

the style label and list

EffectsFeature 

the Effects group (strikeout, underline)

FamilyFilterFeature 

the "Show only monospaced fonts" checkbox

◆ FontClass

enum class FontSelectionWidget::FontClass
strong

What an empty family resolves to.

Enumerator
Regular 

the system general font

Monospace 

the system fixed font, guaranteed fixed-pitch

Constructor & Destructor Documentation

◆ FontSelectionWidget()

FontSelectionWidget::FontSelectionWidget ( QWidget * parent = nullptr)
explicit

Construct a FontSelectionWidget.

Parameters
parentThe parent widget; may be nullptr.

Member Function Documentation

◆ resolvedFont()

QFont FontSelectionWidget::resolvedFont ( ) const

Return the font the sample is drawn with.

For FontClass::Monospace this is the font FontManager applies for the monospace font preference, so it may differ from selectedFont() when the family is not installed.

◆ selectedFont()

QFont FontSelectionWidget::selectedFont ( ) const

Return the edited font.

This is the font given to setSelectedFont() (or built by setSelection()), with family, style, size, strikeout and underline replaced only once the user edited them.

◆ setDefaultAllowed()

void FontSelectionWidget::setDefaultAllowed ( bool allowed)

Allow the "no explicit font" state.

When allowed, the family list gets a "(Platform default)" entry and the size spin box shows "Default" at its minimum. Off by default.

Parameters
allowedtrue to allow the default state.

◆ setFamilyFilter()

void FontSelectionWidget::setFamilyFilter ( FamilyFilter filter)

Choose which families are offered. The default is AllFamilies.

Also sets the "Show only monospaced fonts" checkbox. Only the list changes; the selected family stays listed and changed() is not emitted.

Parameters
filterThe family filter.

◆ setFeatures()

void FontSelectionWidget::setFeatures ( Features features)

Show or hide the optional parts. The default is all features.

Parameters
featuresThe parts to show.

◆ setFontClass()

void FontSelectionWidget::setFontClass ( FontClass fontClass)

Choose what an empty family resolves to. The default is Regular.

Parameters
fontClassThe font class.

◆ setSampleText()

void FontSelectionWidget::setSampleText ( const QString & text)

Replace the sample text.

Parameters
textThe sample text.

◆ setSelectedFont()

void FontSelectionWidget::setSelectedFont ( const QFont & font)

Set the value from a QFont without emitting changed().

All attributes of font are kept by selectedFont() until the user edits the field they belong to.

Parameters
fontThe font to show.

◆ setSelection()

void FontSelectionWidget::setSelection ( const Selection & sel)

Set the value from a Selection without emitting changed().

Parameters
selThe family and point size to show.

The documentation for this class was generated from the following files: