avmedia/source/qt6/QtPlayer.cxx | 11 ----- include/vcl/qt/QtUtils.hxx | 39 +++++++++++++++++ svtools/uiconfig/ui/printersetupdialog.ui | 66 +++++++++++++++--------------- 3 files changed, 74 insertions(+), 42 deletions(-)
New commits: commit 2386540edfb015632ad5771ed048aa4bead315f8 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Oct 23 23:21:23 2024 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Oct 24 09:10:00 2024 +0200 tdf#130857 qt: Move pixmap helper to new include/vcl/qt/QtUtils.hxx Introduce include/vcl/qt/QtUtils.hxx as a new header for Qt-specific utility functions that can be used in multiple modules, e.g. avmedia and the Qt VCL plugins in vcl. This is meant to be used only by code that already links in Qt. There's already vcl/inc/qt{5,6}/QtTools.hxx for helpers needed in vcl only. Initially, add a `loadQPixmapIcon` helper function that can be used to retrieve a QPixmap for an icon name and is extracted from QtPlayer::createMediaPlayerWidget in avmedia. It will be reused to implement the QtInstanceButton::set_from_icon_name logic in an upcoming commit. Change-Id: I9f25aa5ca8f00da97d06ecdd164a8fae10e492dd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175524 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/avmedia/source/qt6/QtPlayer.cxx b/avmedia/source/qt6/QtPlayer.cxx index 5cd19a3c2df5..fe2cf7fc4d76 100644 --- a/avmedia/source/qt6/QtPlayer.cxx +++ b/avmedia/source/qt6/QtPlayer.cxx @@ -21,8 +21,8 @@ #include <rtl/string.hxx> #include <tools/link.hxx> #include <vcl/BitmapTools.hxx> -#include <vcl/filter/PngImageWriter.hxx> #include <vcl/graph.hxx> +#include <vcl/qt/QtUtils.hxx> #include <vcl/svapp.hxx> #include <vcl/syschild.hxx> #include <vcl/sysdata.hxx> @@ -351,14 +351,7 @@ void QtPlayer::createMediaPlayerWidget() } else { - BitmapEx aPlaceholderIcon(u"avmedia/res/avaudiologo.png"_ustr); - SvMemoryStream aMemoryStream; - vcl::PngImageWriter aWriter(aMemoryStream); - aWriter.write(aPlaceholderIcon); - QPixmap aAudioPixmap; - aAudioPixmap.loadFromData(static_cast<const uchar*>(aMemoryStream.GetData()), - aMemoryStream.TellEnd()); - assert(!aAudioPixmap.isNull() && "Failed to load audio logo"); + QPixmap aAudioPixmap = loadQPixmapIcon(u"avmedia/res/avaudiologo.png"_ustr); aAudioPixmap = aAudioPixmap.scaled(QSize(m_aPlayerWidgetRect.Width, m_aPlayerWidgetRect.Height)); diff --git a/include/vcl/qt/QtUtils.hxx b/include/vcl/qt/QtUtils.hxx new file mode 100644 index 000000000000..aa0f4f765cf9 --- /dev/null +++ b/include/vcl/qt/QtUtils.hxx @@ -0,0 +1,39 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +/** + * Utilities/helpers for use in Qt-specific LO code used in multiple modules + * (e.g. avmedia and vcl). + * + * Helpers only needed in a specific module should be defined + * in that module instead, e.g. helper functions only relevant for the Qt-based + * VCL plugins are defined in `vcl/inc/qt5/QtTools.hxx`. + **/ + +#include <rtl/ustring.hxx> +#include <vcl/filter/PngImageWriter.hxx> + +#include <QtGui/QPixmap> + +QPixmap loadQPixmapIcon(const OUString& rIconName) +{ + BitmapEx aIcon(rIconName); + SvMemoryStream aMemoryStream; + vcl::PngImageWriter aWriter(aMemoryStream); + aWriter.write(aIcon); + QPixmap aPixmap; + aPixmap.loadFromData(static_cast<const uchar*>(aMemoryStream.GetData()), + aMemoryStream.TellEnd()); + assert(!aPixmap.isNull() && "Failed to create icon pixmap"); + return aPixmap; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 0fe7b3cebc1a070b13b825635f4bd387a22e41ab Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Oct 23 22:43:10 2024 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Oct 24 09:09:50 2024 +0200 tdf#130857 printersetupdialog.ui: Define focusable widgets in order Align the order in which the focusable widgets (combobox, "Properties" button) are defined in the .ui (XML) file with the order in which they should receive focus. While the position in the GtkGrid is defined by the "left-attach" and "top-attach" packing properties and QtBuilder evaluates those, the tab order in Qt by default matches the order in which widgets are created (s. e.g. [1]). Without this commit in place the "properties" button was constructed before the "name" combobox (because it was further up in the .ui file, i.e. the XML parser processed it earlier), resulting in an unexpected order when using the Tab key to navigate through the "Tools" -> "Printer Settings" dialog: From the "Options" button in the button box, focus would jump to the "Properties" button, and only then to the combobox, and from there, it would jump to the "Help" button in the button box. Now, it jumps from the "Options" button to the combobox, and after selecting the printer there, pressing Tab another time moves focus to the "Properties" button as expected, which can be used to open another dialog that allows to change properties of the previously selected printer. A potential alternative to adjusting the .ui file could be to explicitly set the tab order using QWidget::setTabOrder [2] in QtBuilder. [1] https://doc.qt.io/qt-6/designer-tab-order.html [2] https://doc.qt.io/qt-6/qwidget.html#setTabOrder Change-Id: If3aa014e20b97fe8bb772ef212741af1433b0244 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175523 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/svtools/uiconfig/ui/printersetupdialog.ui b/svtools/uiconfig/ui/printersetupdialog.ui index 1524f9e0f9a4..4ac431e582f7 100644 --- a/svtools/uiconfig/ui/printersetupdialog.ui +++ b/svtools/uiconfig/ui/printersetupdialog.ui @@ -116,6 +116,39 @@ <property name="top-attach">0</property> </packing> </child> + <child> + <object class="GtkComboBoxText" id="name"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="hexpand">True</property> + <child internal-child="accessible"> + <object class="AtkObject" id="name-atkobject"> + <property name="AtkObject::accessible-description" translatable="yes" context="printersetupdialog|extended_tip|name">Lists the installed printers on your operating system. To change the default printer, select a printer name from the list.</property> + </object> + </child> + </object> + <packing> + <property name="left-attach">1</property> + <property name="top-attach">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="properties"> + <property name="label" translatable="yes" context="printersetupdialog|properties">Properties...</property> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="receives-default">True</property> + <child internal-child="accessible"> + <object class="AtkObject" id="properties-atkobject"> + <property name="AtkObject::accessible-description" translatable="yes" context="printersetupdialog|extended_tip|properties">Changes the printer settings of your operating system for the current document.</property> + </object> + </child> + </object> + <packing> + <property name="left-attach">2</property> + <property name="top-attach">0</property> + </packing> + </child> <child> <object class="GtkLabel" id="label3"> <property name="visible">True</property> @@ -212,39 +245,6 @@ <property name="width">2</property> </packing> </child> - <child> - <object class="GtkButton" id="properties"> - <property name="label" translatable="yes" context="printersetupdialog|properties">Properties...</property> - <property name="visible">True</property> - <property name="can-focus">True</property> - <property name="receives-default">True</property> - <child internal-child="accessible"> - <object class="AtkObject" id="properties-atkobject"> - <property name="AtkObject::accessible-description" translatable="yes" context="printersetupdialog|extended_tip|properties">Changes the printer settings of your operating system for the current document.</property> - </object> - </child> - </object> - <packing> - <property name="left-attach">2</property> - <property name="top-attach">0</property> - </packing> - </child> - <child> - <object class="GtkComboBoxText" id="name"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="hexpand">True</property> - <child internal-child="accessible"> - <object class="AtkObject" id="name-atkobject"> - <property name="AtkObject::accessible-description" translatable="yes" context="printersetupdialog|extended_tip|name">Lists the installed printers on your operating system. To change the default printer, select a printer name from the list.</property> - </object> - </child> - </object> - <packing> - <property name="left-attach">1</property> - <property name="top-attach">0</property> - </packing> - </child> </object> </child> <child type="label">