avmedia/source/qt6/QtFrameGrabber.cxx | 6 ----- include/vcl/qt/QtUtils.hxx | 6 +++++ vcl/inc/qt5/QtTools.hxx | 10 +++------ vcl/qt5/QtFrame.cxx | 35 ---------------------------------- vcl/qt5/QtTools.cxx | 35 ++++++++++++++++++++++++++++++++++ 5 files changed, 46 insertions(+), 46 deletions(-)
New commits: commit 0acf18f1c30abe66dfe7480a06e0b3a24fb61baf Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Apr 11 17:29:31 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Apr 11 19:45:35 2025 +0200 tdf#130857 qt: Move toVclFont helper to QtTools ... in order to reuse it when implementing QtInstanceWidget::get_font in an upcoming commit. Change-Id: I5053c24fecd791ef8b5b9b92d9319df9df83f6c6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184058 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/inc/qt5/QtTools.hxx b/vcl/inc/qt5/QtTools.hxx index 5204731e789d..345beb60a79a 100644 --- a/vcl/inc/qt5/QtTools.hxx +++ b/vcl/inc/qt5/QtTools.hxx @@ -38,6 +38,7 @@ #include <vcl/qt/QtUtils.hxx> #include <vcl/vclenum.hxx> +#include <com/sun/star/lang/Locale.hpp> #include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/datatransfer/dnd/DNDConstants.hpp> @@ -152,6 +153,8 @@ MouseEvent toVclMouseEvent(QMouseEvent& rEvent); QImage toQImage(const Image& rImage); +bool toVclFont(const QFont& rQFont, const css::lang::Locale& rLocale, vcl::Font& rVclFont); + QMessageBox::Icon vclMessageTypeToQtIcon(VclMessageType eType); QString vclMessageTypeToQtTitle(VclMessageType eType); diff --git a/vcl/qt5/QtFrame.cxx b/vcl/qt5/QtFrame.cxx index 1d0414ef3782..691e017e2aff 100644 --- a/vcl/qt5/QtFrame.cxx +++ b/vcl/qt5/QtFrame.cxx @@ -67,8 +67,6 @@ #include <cairo.h> #include <headless/svpgdi.hxx> -#include <unx/fontmanager.hxx> - static void SvpDamageHandler(void* handle, sal_Int32 nExtentsX, sal_Int32 nExtentsY, sal_Int32 nExtentsWidth, sal_Int32 nExtentsHeight) { @@ -1040,39 +1038,6 @@ void QtFrame::setInputLanguage(LanguageType nInputLanguage) CallCallback(SalEvent::InputLanguageChange, nullptr); } -static bool toVclFont(const QFont& rQFont, const css::lang::Locale& rLocale, vcl::Font& rVclFont) -{ - FontAttributes aFA; - QtFontFace::fillAttributesFromQFont(rQFont, aFA); - - bool bFound = psp::PrintFontManager::get().matchFont(aFA, rLocale); - SAL_INFO("vcl.qt", - "font match result for '" - << rQFont.family() << "': " - << (bFound ? OUString::Concat("'") + aFA.GetFamilyName() + "'" : u"failed"_ustr)); - - if (!bFound) - return false; - - QFontInfo qFontInfo(rQFont); - int nPointHeight = qFontInfo.pointSize(); - if (nPointHeight <= 0) - nPointHeight = rQFont.pointSize(); - - vcl::Font aFont(aFA.GetFamilyName(), Size(0, nPointHeight)); - if (aFA.GetWeight() != WEIGHT_DONTKNOW) - aFont.SetWeight(aFA.GetWeight()); - if (aFA.GetWidthType() != WIDTH_DONTKNOW) - aFont.SetWidthType(aFA.GetWidthType()); - if (aFA.GetItalic() != ITALIC_DONTKNOW) - aFont.SetItalic(aFA.GetItalic()); - if (aFA.GetPitch() != PITCH_DONTKNOW) - aFont.SetPitch(aFA.GetPitch()); - - rVclFont = aFont; - return true; -} - void QtFrame::UpdateSettings(AllSettings& rSettings) { SolarMutexGuard g; diff --git a/vcl/qt5/QtTools.cxx b/vcl/qt5/QtTools.cxx index 51517bd1aca5..20091f005ae5 100644 --- a/vcl/qt5/QtTools.cxx +++ b/vcl/qt5/QtTools.cxx @@ -18,6 +18,8 @@ */ #include <QtTools.hxx> +#include <QtFontFace.hxx> +#include <unx/fontmanager.hxx> #include <cairo.h> @@ -133,6 +135,39 @@ QImage toQImage(const Image& rImage) return aImage; } +bool toVclFont(const QFont& rQFont, const css::lang::Locale& rLocale, vcl::Font& rVclFont) +{ + FontAttributes aFA; + QtFontFace::fillAttributesFromQFont(rQFont, aFA); + + bool bFound = psp::PrintFontManager::get().matchFont(aFA, rLocale); + SAL_INFO("vcl.qt", + "font match result for '" + << rQFont.family() << "': " + << (bFound ? OUString::Concat("'") + aFA.GetFamilyName() + "'" : u"failed"_ustr)); + + if (!bFound) + return false; + + QFontInfo qFontInfo(rQFont); + int nPointHeight = qFontInfo.pointSize(); + if (nPointHeight <= 0) + nPointHeight = rQFont.pointSize(); + + vcl::Font aFont(aFA.GetFamilyName(), Size(0, nPointHeight)); + if (aFA.GetWeight() != WEIGHT_DONTKNOW) + aFont.SetWeight(aFA.GetWeight()); + if (aFA.GetWidthType() != WIDTH_DONTKNOW) + aFont.SetWidthType(aFA.GetWidthType()); + if (aFA.GetItalic() != ITALIC_DONTKNOW) + aFont.SetItalic(aFA.GetItalic()); + if (aFA.GetPitch() != PITCH_DONTKNOW) + aFont.SetPitch(aFA.GetPitch()); + + rVclFont = aFont; + return true; +} + QMessageBox::Icon vclMessageTypeToQtIcon(VclMessageType eType) { QMessageBox::Icon eRet = QMessageBox::Information; commit d023035acf83ee1b61dfc03333bfc6e612bb58f6 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Apr 11 17:19:20 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Apr 11 19:45:26 2025 +0200 qt: Consolidate to one toOUString helper Instead of having one for vcl in vcl/inc/qt5/QtTools.hxx and one in avmedia/source/qt6/QtFrameGrabber.cxx, move the existing implementation to include/vcl/qt/QtUtils.hxx and use it everywhere. Change-Id: I8576ab0fe2fd12bb25ae262e59acb8412ef8be0c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184057 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/avmedia/source/qt6/QtFrameGrabber.cxx b/avmedia/source/qt6/QtFrameGrabber.cxx index a9cf99fadc7f..b82b02005d9a 100644 --- a/avmedia/source/qt6/QtFrameGrabber.cxx +++ b/avmedia/source/qt6/QtFrameGrabber.cxx @@ -14,6 +14,7 @@ #include <vcl/filter/PngImageReader.hxx> #include <vcl/graph.hxx> #include <vcl/image.hxx> +#include <vcl/qt/QtUtils.hxx> #include <vcl/scheduler.hxx> #include "QtFrameGrabber.hxx" @@ -23,11 +24,6 @@ using namespace ::com::sun::star; namespace { -inline OUString toOUString(const QString& s) -{ - return OUString(reinterpret_cast<const sal_Unicode*>(s.data()), s.length()); -} - uno::Reference<css::graphic::XGraphic> toXGraphic(const QImage& rImage) { QByteArray aData; diff --git a/include/vcl/qt/QtUtils.hxx b/include/vcl/qt/QtUtils.hxx index 87f21d96315c..3ab5f19f02cb 100644 --- a/include/vcl/qt/QtUtils.hxx +++ b/include/vcl/qt/QtUtils.hxx @@ -31,6 +31,12 @@ inline QString toQString(const OUString& rStr) return QString::fromUtf16(rStr.getStr(), rStr.getLength()); } +inline OUString toOUString(const QString& s) +{ + // QString stores UTF16, just like OUString + return OUString(reinterpret_cast<const sal_Unicode*>(s.data()), s.length()); +} + inline QPixmap toQPixmap(const BitmapEx& rBitmapEx) { SvMemoryStream aMemoryStream; diff --git a/vcl/inc/qt5/QtTools.hxx b/vcl/inc/qt5/QtTools.hxx index cf3bd7e952b1..5204731e789d 100644 --- a/vcl/inc/qt5/QtTools.hxx +++ b/vcl/inc/qt5/QtTools.hxx @@ -35,6 +35,7 @@ #include <tools/gen.hxx> #include <vcl/bitmap/BitmapTypes.hxx> #include <vcl/event.hxx> +#include <vcl/qt/QtUtils.hxx> #include <vcl/vclenum.hxx> #include <com/sun/star/uno/Sequence.hxx> @@ -45,12 +46,6 @@ class Image; class QImage; -inline OUString toOUString(const QString& s) -{ - // QString stores UTF16, just like OUString - return OUString(reinterpret_cast<const sal_Unicode*>(s.data()), s.length()); -} - inline QRect toQRect(const tools::Rectangle& rRect) { return QRect(rRect.Left(), rRect.Top(), rRect.GetWidth(), rRect.GetHeight());