|
Wireshark 5.1.0
The Wireshark network protocol analyzer
|
Text zoom scaling of pixel lengths and widget metrics. More...
Functions | |
| int | scaledPixels (int px, qreal factor) |
Scales a pixel value designed for zoom level 0 by factor. | |
| int | scaledSizeLimit (int design, qreal factor) |
Scales one component of a widget size limit by factor. | |
| QString | scaleStyleSheetLengths (const QString &qss, qreal factor) |
Scales the pixel lengths of a stylesheet by factor. | |
Current zoom level | |
| int | scaledPixels (int px) |
| int | scaledSizeLimit (int design) |
| void | scaleSizeLimits (QWidget *widget) |
| void | scaleIconSize (QWidget *widget) |
| void | scaleLayoutMetrics (QLayout *layout) |
| int | barIconSize () |
Text zoom scaling of pixel lengths and widget metrics.
The functions that take a factor depend on nothing but Qt and are covered by qt_zoom_scaling_test; the others use the current zoom level of FontManager and follow its zoom changes.
| int ZoomScaling::barIconSize | ( | ) |
Side in pixels of the display filter toolbar and status bar icons at the current zoom level (14 at zoom 0). Not derived from the status bar font, which is smaller on macOS, nor from a style metric.
| int ZoomScaling::scaledPixels | ( | int | px | ) |
Scales a pixel value that is designed for zoom level 0 by the current zoom factor, FontManager::zoomFactor(). 0 stays 0; any other value is at least 1.
| px | non-negative pixel value at zoom level 0. |
| int ZoomScaling::scaledPixels | ( | int | px, |
| qreal | factor ) |
Scales a pixel value designed for zoom level 0 by factor.
0 stays 0; any other value is at least 1.
| int ZoomScaling::scaledSizeLimit | ( | int | design | ) |
Scales one component of a widget size limit (minimum or maximum width or height) designed for zoom level 0. 0, 1 and QWIDGETSIZE_MAX (unlimited) are returned unchanged at every zoom level, so resets, hairlines and "no limit" stay; any other value goes through scaledPixels().
| design | the limit at zoom level 0. |
| int ZoomScaling::scaledSizeLimit | ( | int | design, |
| qreal | factor ) |
Scales one component of a widget size limit by factor.
0, 1 and QWIDGETSIZE_MAX (unlimited) are returned unchanged, so resets, hairlines and "no limit" stay; any other value goes through scaledPixels(design, factor).
| void ZoomScaling::scaleIconSize | ( | QWidget * | widget | ) |
Makes the icon size of widget follow the zoom level.
The first call stores the widget's current iconSize as its zoom level 0 design value (call it after setupUi() or after the one setIconSize() call), and updates the icon size on every zoom change for the widget's lifetime. Later calls only re-apply the stored value. Each component goes through scaledPixels(). Works on any widget with an iconSize property (QAbstractButton, QToolBar, QAbstractItemView); other widgets are ignored.
| widget | the widget to scale; nullptr is ignored. |
| void ZoomScaling::scaleLayoutMetrics | ( | QLayout * | layout | ) |
Makes the contents margins and spacing of layout follow the zoom level.
The first call stores the layout's current contentsMargins() and spacing() as their zoom level 0 design values (call it after setupUi() or after the layout's own margin and spacing calls), and updates them on every zoom change for the layout's lifetime. Later calls only re-apply the stored values. Each component goes through scaledPixels(); a negative spacing (the style default) stays negative.
| layout | the layout to scale; nullptr is ignored. |
| void ZoomScaling::scaleSizeLimits | ( | QWidget * | widget | ) |
Makes the minimum and maximum size of widget follow the zoom level.
The first call stores the widget's current minimumSize() and maximumSize() as its zoom level 0 design values (call it after setupUi() or after the widget's own size limit calls), and updates the limits on every zoom change for the widget's lifetime. Later calls only re-apply the stored values. Each component goes through scaledSizeLimit(). Do not use it on a widget that writes its own size limits at runtime (an animated AccordionFrame), as the two writers would overwrite each other.
| widget | the widget to scale; nullptr is ignored. |
| QString ZoomScaling::scaleStyleSheetLengths | ( | const QString & | qss, |
| qreal | factor ) |
Scales the pixel lengths of a stylesheet by factor.
Qt stylesheets only support absolute px/pt units (no relative em/%), so themed text and the lengths around it (heights, radii, padding, margins, sizes) are scaled here to follow the rest of the UI: