MCPcopy Create free account
hub / github.com/OpenOrienteering/mapper / polish

Method polish

src/gui/widgets/mapper_proxystyle.cpp:151–208  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

149}
150
151void MapperProxyStyle::polish(QApplication* application)
152{
153 common_style = qobject_cast<QCommonStyle*>(baseStyle());
154
155 fixupProxyChain(baseStyle());
156 QProxyStyle::polish(application);
157 QApplication::setPalette(default_palette);
158
159 auto& settings = Settings::getInstance();
160 connect(&settings, &Settings::settingsChanged, this, &MapperProxyStyle::onSettingsChanged);
161 if (settings.touchModeEnabled())
162 {
163 touch_mode = true;
164
165 button_size = buttonSizePixel(settings);
166 auto const margin_size_pixel = button_size / 4;
167 toolbar.icon_size = button_size - margin_size_pixel;
168 {
169 auto const scale_factor = qreal(toolbar.icon_size) / QProxyStyle::pixelMetric(PM_ToolBarIconSize);
170 toolbar.item_spacing = std::max(1, margin_size_pixel - 2 * qRound(scale_factor));
171 toolbar.separator_extent = qRound(QProxyStyle::pixelMetric(PM_ToolBarSeparatorExtent) * scale_factor);
172 toolbar.extension_extent = qRound(QProxyStyle::pixelMetric(PM_ToolBarExtensionExtent) * scale_factor);
173 }
174
175 small_icon_size = qMax(QProxyStyle::pixelMetric(QStyle::PM_ButtonIconSize), int(0.7 * toolbar.icon_size));
176 {
177 auto const scale_factor = qreal(small_icon_size) / QProxyStyle::pixelMetric(QStyle::PM_ButtonIconSize);
178 menu.button_indicator = qRound(QProxyStyle::pixelMetric(PM_MenuButtonIndicator) * scale_factor);
179 if (baseStyle()->inherits("QFusionStyle"))
180 {
181 // QFusionStyle draws indicators no larger than 14 logical pixels,
182 // cf. qt_fusion_draw_array.
183 // If we return more than that, a tiny indicator is placed near
184 // the center of the button, interfering with the contents.
185 auto const fusion_style_bound = int(dpiScaled(14.0));
186 menu.button_indicator = qMin(menu.button_indicator, fusion_style_bound);
187 }
188 menu.h_margin = qMax(margin_size_pixel / 4, qRound(QProxyStyle::pixelMetric(PM_MenuHMargin) * scale_factor));
189 menu.v_margin = qMax(margin_size_pixel / 4, qRound(QProxyStyle::pixelMetric(PM_MenuVMargin) * scale_factor));
190 menu.panel_width = qRound(QProxyStyle::pixelMetric(PM_MenuPanelWidth) * scale_factor);
191
192 menu.item_height = button_size;
193 menu.scroller_height = qMax(QProxyStyle::pixelMetric(PM_MenuScrollerHeight), menu.item_height / 2);
194 }
195
196 menu_font = QApplication::font();
197 {
198 auto const menu_font_size = small_icon_size - 4; // cf. QMenu's action item rect calculation.
199 if (menu_font_size > original_font.pixelSize())
200 {
201 menu_font.setPixelSize(menu_font_size);
202 }
203 QApplication::setFont(QApplication::font());
204 QApplication::setFont(menu_font, "QMenu");
205 QApplication::setFont(menu_font, "QComboMenuItem");
206 }
207 }
208}

Callers

nothing calls this directly

Calls 3

buttonSizePixelFunction · 0.85
dpiScaledFunction · 0.85
touchModeEnabledMethod · 0.80

Tested by

no test coverage detected