summaryrefslogtreecommitdiffstats
path: root/vcl/unx/kf5
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
commit940b4d1848e8c70ab7642901a68594e8016caffc (patch)
treeeb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /vcl/unx/kf5
parentInitial commit. (diff)
downloadlibreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.tar.xz
libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.zip
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--vcl/unx/kf5/KF5FilePicker.cxx180
-rw-r--r--vcl/unx/kf5/KF5FilePicker.hxx63
-rw-r--r--vcl/unx/kf5/KF5SalFrame.cxx188
-rw-r--r--vcl/unx/kf5/KF5SalFrame.hxx43
-rw-r--r--vcl/unx/kf5/KF5SalInstance.cxx101
-rw-r--r--vcl/unx/kf5/KF5SalInstance.hxx36
6 files changed, 611 insertions, 0 deletions
diff --git a/vcl/unx/kf5/KF5FilePicker.cxx b/vcl/unx/kf5/KF5FilePicker.cxx
new file mode 100644
index 000000000..20e64007b
--- /dev/null
+++ b/vcl/unx/kf5/KF5FilePicker.cxx
@@ -0,0 +1,180 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "KF5FilePicker.hxx"
+#include <KF5FilePicker.moc>
+
+#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
+#include <cppuhelper/supportsservice.hxx>
+#include <osl/mutex.hxx>
+
+#include <qt5/Qt5Instance.hxx>
+
+#include <QtWidgets/QApplication>
+#include <QtWidgets/QGridLayout>
+#include <QtWidgets/QWidget>
+#include <KFileWidget>
+
+using namespace ::com::sun::star;
+using ::com::sun::star::ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION;
+
+namespace
+{
+uno::Sequence<OUString> FilePicker_getSupportedServiceNames()
+{
+ return { "com.sun.star.ui.dialogs.FilePicker", "com.sun.star.ui.dialogs.SystemFilePicker",
+ "com.sun.star.ui.dialogs.KF5FilePicker", "com.sun.star.ui.dialogs.KF5FolderPicker" };
+}
+}
+
+// KF5FilePicker
+
+KF5FilePicker::KF5FilePicker(css::uno::Reference<css::uno::XComponentContext> const& context,
+ QFileDialog::FileMode eMode)
+ // Native kf5 filepicker does not add file extension automatically
+ : Qt5FilePicker(context, eMode, true)
+ , _layout(new QGridLayout(m_pExtraControls))
+{
+ // only columns 0 and 1 are used by controls (s. Qt5FilePicker::addCustomControl);
+ // set stretch for (unused) column 2 in order for the controls to only take the space
+ // they actually need and avoid empty space in between
+ _layout->setColumnStretch(2, 1);
+
+ // set layout so custom widgets show up in our native file dialog
+ setCustomControlWidgetLayout(_layout.get());
+
+ m_pFileDialog->setSupportedSchemes({
+ QStringLiteral("file"), QStringLiteral("ftp"), QStringLiteral("http"),
+ QStringLiteral("https"), QStringLiteral("webdav"), QStringLiteral("webdavs"),
+ QStringLiteral("smb"),
+ QStringLiteral(""), // this makes removable devices shown
+ });
+
+ // used to set the custom controls
+ qApp->installEventFilter(this);
+}
+
+// XFilePickerControlAccess
+void SAL_CALL KF5FilePicker::setValue(sal_Int16 controlId, sal_Int16 nControlAction,
+ const uno::Any& value)
+{
+ if (CHECKBOX_AUTOEXTENSION == controlId)
+ // We ignore this one and rely on QFileDialog to provide the functionality
+ return;
+
+ Qt5FilePicker::setValue(controlId, nControlAction, value);
+}
+
+uno::Any SAL_CALL KF5FilePicker::getValue(sal_Int16 controlId, sal_Int16 nControlAction)
+{
+ SolarMutexGuard g;
+ auto* pSalInst(static_cast<Qt5Instance*>(GetSalData()->m_pInstance));
+ assert(pSalInst);
+ if (!pSalInst->IsMainThread())
+ {
+ uno::Any ret;
+ pSalInst->RunInMainThread([&ret, this, controlId, nControlAction]() {
+ ret = getValue(controlId, nControlAction);
+ });
+ return ret;
+ }
+
+ if (CHECKBOX_AUTOEXTENSION == controlId)
+ // We ignore this one and rely on QFileDialog to provide the function.
+ // Always return false, to pretend we do not support this, otherwise
+ // LO core would try to be smart and cut the extension in some places,
+ // interfering with QFileDialog's handling of it. QFileDialog also
+ // saves the value of the setting, so LO core is not needed for that either.
+ return uno::Any(false);
+
+ return Qt5FilePicker::getValue(controlId, nControlAction);
+}
+
+void SAL_CALL KF5FilePicker::enableControl(sal_Int16 controlId, sal_Bool enable)
+{
+ if (CHECKBOX_AUTOEXTENSION == controlId)
+ // We ignore this one and rely on QFileDialog to provide the functionality
+ return;
+
+ Qt5FilePicker::enableControl(controlId, enable);
+}
+
+void SAL_CALL KF5FilePicker::setLabel(sal_Int16 controlId, const OUString& label)
+{
+ if (CHECKBOX_AUTOEXTENSION == controlId)
+ // We ignore this one and rely on QFileDialog to provide the functionality
+ return;
+
+ Qt5FilePicker::setLabel(controlId, label);
+}
+
+OUString SAL_CALL KF5FilePicker::getLabel(sal_Int16 controlId)
+{
+ // We ignore this one and rely on QFileDialog to provide the functionality
+ if (CHECKBOX_AUTOEXTENSION == controlId)
+ return "";
+
+ return Qt5FilePicker::getLabel(controlId);
+}
+
+void KF5FilePicker::addCustomControl(sal_Int16 controlId)
+{
+ // native kf5 filepicker has its own autoextension checkbox,
+ // therefore avoid adding yet another one
+ if (controlId == CHECKBOX_AUTOEXTENSION)
+ return;
+
+ Qt5FilePicker::addCustomControl(controlId);
+}
+
+// XServiceInfo
+OUString SAL_CALL KF5FilePicker::getImplementationName()
+{
+ return "com.sun.star.ui.dialogs.KF5FilePicker";
+}
+
+sal_Bool SAL_CALL KF5FilePicker::supportsService(const OUString& ServiceName)
+{
+ return cppu::supportsService(this, ServiceName);
+}
+
+uno::Sequence<OUString> SAL_CALL KF5FilePicker::getSupportedServiceNames()
+{
+ return FilePicker_getSupportedServiceNames();
+}
+
+bool KF5FilePicker::eventFilter(QObject* o, QEvent* e)
+{
+ if (e->type() == QEvent::Show && o->isWidgetType())
+ {
+ auto* w = static_cast<QWidget*>(o);
+ if (!w->parentWidget() && w->isModal())
+ {
+ if (auto* fileWidget = w->findChild<KFileWidget*>({}, Qt::FindDirectChildrenOnly))
+ {
+ fileWidget->setCustomWidget(m_pExtraControls);
+ // remove event filter again; the only purpose was to set the custom widget here
+ qApp->removeEventFilter(this);
+ }
+ }
+ }
+ return QObject::eventFilter(o, e);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kf5/KF5FilePicker.hxx b/vcl/unx/kf5/KF5FilePicker.hxx
new file mode 100644
index 000000000..4cf84c7fe
--- /dev/null
+++ b/vcl/unx/kf5/KF5FilePicker.hxx
@@ -0,0 +1,63 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <Qt5FilePicker.hxx>
+#include <memory>
+
+class QGridLayout;
+
+class KF5FilePicker final : public Qt5FilePicker
+{
+ Q_OBJECT
+
+private:
+ //layout for extra custom controls
+ std::unique_ptr<QGridLayout> _layout;
+
+public:
+ explicit KF5FilePicker(css::uno::Reference<css::uno::XComponentContext> const& context,
+ QFileDialog::FileMode);
+
+ // XFilePickerControlAccess functions
+ virtual void SAL_CALL setValue(sal_Int16 nControlId, sal_Int16 nControlAction,
+ const css::uno::Any& rValue) override;
+ virtual css::uno::Any SAL_CALL getValue(sal_Int16 nControlId,
+ sal_Int16 nControlAction) override;
+ virtual void SAL_CALL enableControl(sal_Int16 nControlId, sal_Bool bEnable) override;
+ virtual void SAL_CALL setLabel(sal_Int16 nControlId, const OUString& rLabel) override;
+ virtual OUString SAL_CALL getLabel(sal_Int16 nControlId) override;
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName() override;
+ virtual sal_Bool SAL_CALL supportsService(const OUString& rServiceName) override;
+ virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
+
+private:
+ //add a custom control widget to the file dialog
+ void addCustomControl(sal_Int16 controlId) override;
+ bool eventFilter(QObject* watched, QEvent* event) override;
+
+private Q_SLOTS:
+ // the KF5 file picker has its own automatic extension handling
+ void updateAutomaticFileExtension() override {}
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kf5/KF5SalFrame.cxx b/vcl/unx/kf5/KF5SalFrame.cxx
new file mode 100644
index 000000000..1aa0b9008
--- /dev/null
+++ b/vcl/unx/kf5/KF5SalFrame.cxx
@@ -0,0 +1,188 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <memory>
+#include <QtGui/QColor>
+#include <QtWidgets/QStyle>
+#include <QtWidgets/QToolTip>
+#include <QtWidgets/QApplication>
+#include <QtWidgets/QMenuBar>
+
+#include <KConfig>
+#include <KConfigGroup>
+#include <KSharedConfig>
+
+#include <Qt5FontFace.hxx>
+#include "KF5SalFrame.hxx"
+
+#include <tools/color.hxx>
+
+#include <vcl/font.hxx>
+#include <vcl/settings.hxx>
+#include <sal/log.hxx>
+
+#include <unx/fontmanager.hxx>
+
+#include <svdata.hxx>
+
+#include <optional>
+
+KF5SalFrame::KF5SalFrame(KF5SalFrame* pParent, SalFrameStyleFlags nState, bool bUseCairo)
+ : Qt5Frame(pParent, nState, bUseCairo)
+ , m_bGraphicsInUse(false)
+{
+}
+
+/** Helper function to add information to Font from QFont.
+
+ Mostly grabbed from the Gtk+ vclplug (salnativewidgets-gtk.cxx).
+*/
+static vcl::Font toFont(const QFont& rQFont, const css::lang::Locale& rLocale)
+{
+ psp::FastPrintFontInfo aInfo;
+ QFontInfo qFontInfo(rQFont);
+
+ // set family name
+ aInfo.m_aFamilyName = OUString(static_cast<const char*>(rQFont.family().toUtf8()),
+ strlen(static_cast<const char*>(rQFont.family().toUtf8())),
+ RTL_TEXTENCODING_UTF8);
+
+ aInfo.m_eItalic = Qt5FontFace::toFontItalic(qFontInfo.style());
+ aInfo.m_eWeight = Qt5FontFace::toFontWeight(qFontInfo.weight());
+ aInfo.m_eWidth = Qt5FontFace::toFontWidth(rQFont.stretch());
+
+ SAL_INFO("vcl.kf5", "font name BEFORE system match: \"" << aInfo.m_aFamilyName << "\"");
+
+ // match font to e.g. resolve "Sans"
+ psp::PrintFontManager::get().matchFont(aInfo, rLocale);
+
+ SAL_INFO("vcl.kf5", "font match " << (aInfo.m_nID != 0 ? "succeeded" : "failed")
+ << ", name AFTER: \"" << aInfo.m_aFamilyName << "\"");
+
+ // font height
+ int nPointHeight = qFontInfo.pointSize();
+ if (nPointHeight <= 0)
+ nPointHeight = rQFont.pointSize();
+
+ // Create the font
+ vcl::Font aFont(aInfo.m_aFamilyName, Size(0, nPointHeight));
+ if (aInfo.m_eWeight != WEIGHT_DONTKNOW)
+ aFont.SetWeight(aInfo.m_eWeight);
+ if (aInfo.m_eWidth != WIDTH_DONTKNOW)
+ aFont.SetWidthType(aInfo.m_eWidth);
+ if (aInfo.m_eItalic != ITALIC_DONTKNOW)
+ aFont.SetItalic(aInfo.m_eItalic);
+ if (aInfo.m_ePitch != PITCH_DONTKNOW)
+ aFont.SetPitch(aInfo.m_ePitch);
+
+ return aFont;
+}
+
+/** Implementation of KDE integration's main method.
+*/
+void KF5SalFrame::UpdateSettings(AllSettings& rSettings)
+{
+ Qt5Frame::UpdateSettings(rSettings);
+
+ StyleSettings style(rSettings.GetStyleSettings());
+ bool bSetTitleFont = false;
+
+ // WM settings
+ /*KConfig *pConfig = KGlobal::config().data();
+ if ( pConfig )
+ {
+ const char *pKey;
+
+ {
+ KConfigGroup aWMGroup = pConfig->group( "WM" );
+
+ pKey = "titleFont";
+ if (aWMGroup.hasKey(pKey))
+ {
+ vcl::Font aFont = toFont(aWMGroup.readEntry(pKey, QFont()),
+ rSettings.GetUILanguageTag().getLocale());
+ style.SetTitleFont( aFont );
+ bSetTitleFont = true;
+ }
+ }
+
+ KConfigGroup aIconsGroup = pConfig->group("Icons");
+
+ pKey = "Theme";
+ if (aIconsGroup.hasKey(pKey))
+ style.SetPreferredIconTheme( readEntryUntranslated(&aIconsGroup, pKey));
+
+ //toolbar
+ pKey = "toolbarFont";
+ if (aIconsGroup.hasKey(pKey))
+ {
+ vcl::Font aFont = toFont(aIconsGroup.readEntry(pKey, QFont()),
+ rSettings.GetUILanguageTag().getLocale());
+ style.SetToolFont( aFont );
+ }
+ }*/
+
+ // Font
+ vcl::Font aFont = toFont(QApplication::font(), rSettings.GetUILanguageTag().getLocale());
+
+ style.BatchSetFonts(aFont, aFont);
+
+ aFont.SetWeight(WEIGHT_BOLD);
+ if (!bSetTitleFont)
+ {
+ style.SetTitleFont(aFont);
+ }
+ style.SetFloatTitleFont(aFont);
+ style.SetHelpFont(toFont(QToolTip::font(), rSettings.GetUILanguageTag().getLocale()));
+
+ int flash_time = QApplication::cursorFlashTime();
+ style.SetCursorBlinkTime(flash_time != 0 ? flash_time / 2 : STYLE_CURSOR_NOBLINKTIME);
+
+ // Menu
+ std::unique_ptr<QMenuBar> pMenuBar = std::make_unique<QMenuBar>();
+ aFont = toFont(pMenuBar->font(), rSettings.GetUILanguageTag().getLocale());
+ style.SetMenuFont(aFont);
+
+ rSettings.SetStyleSettings(style);
+}
+
+SalGraphics* KF5SalFrame::AcquireGraphics()
+{
+ if (m_bGraphicsInUse)
+ return nullptr;
+
+ m_bGraphicsInUse = true;
+
+ if (!m_pKF5Graphics)
+ {
+ m_pKF5Graphics.reset(new Qt5SvpGraphics(this));
+ Qt5Frame::InitQt5SvpGraphics(m_pKF5Graphics.get());
+ }
+
+ return m_pKF5Graphics.get();
+}
+
+void KF5SalFrame::ReleaseGraphics(SalGraphics* pSalGraph)
+{
+ (void)pSalGraph;
+ assert(pSalGraph == m_pKF5Graphics.get());
+ m_bGraphicsInUse = false;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kf5/KF5SalFrame.hxx b/vcl/unx/kf5/KF5SalFrame.hxx
new file mode 100644
index 000000000..f757535c2
--- /dev/null
+++ b/vcl/unx/kf5/KF5SalFrame.hxx
@@ -0,0 +1,43 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <memory>
+
+#include <qt5/Qt5Frame.hxx>
+#include <qt5/Qt5SvpGraphics.hxx>
+
+class QWidget;
+
+class KF5SalFrame : public Qt5Frame
+{
+private:
+ std::unique_ptr<Qt5SvpGraphics> m_pKF5Graphics;
+ bool m_bGraphicsInUse;
+
+public:
+ KF5SalFrame(KF5SalFrame* pParent, SalFrameStyleFlags nStyle, bool bUseCairo);
+
+ virtual SalGraphics* AcquireGraphics() override;
+ virtual void ReleaseGraphics(SalGraphics* pGraphics) override;
+ virtual void UpdateSettings(AllSettings& rSettings) override;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kf5/KF5SalInstance.cxx b/vcl/unx/kf5/KF5SalInstance.cxx
new file mode 100644
index 000000000..5b95ff8df
--- /dev/null
+++ b/vcl/unx/kf5/KF5SalInstance.cxx
@@ -0,0 +1,101 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sal/config.h>
+
+#include <utility>
+
+#include <QtWidgets/QApplication>
+
+#include <sal/log.hxx>
+
+#include <Qt5Data.hxx>
+
+#include "KF5FilePicker.hxx"
+#include "KF5SalFrame.hxx"
+#include "KF5SalInstance.hxx"
+
+using namespace com::sun::star;
+
+KF5SalInstance::KF5SalInstance(std::unique_ptr<QApplication>& pQApp)
+ : Qt5Instance(pQApp, true)
+{
+ ImplSVData* pSVData = ImplGetSVData();
+ pSVData->maAppData.mxToolkitName = OUString("kf5");
+}
+
+SalFrame* KF5SalInstance::CreateFrame(SalFrame* pParent, SalFrameStyleFlags nState)
+{
+ SalFrame* pRet(nullptr);
+ RunInMainThread([&pRet, pParent, nState]() {
+ pRet = new KF5SalFrame(static_cast<KF5SalFrame*>(pParent), nState, true);
+ });
+ assert(pRet);
+ return pRet;
+}
+
+bool KF5SalInstance::hasNativeFileSelection() const
+{
+ if (Application::GetDesktopEnvironment() == "PLASMA5")
+ return true;
+ return Qt5Instance::hasNativeFileSelection();
+}
+
+Qt5FilePicker*
+KF5SalInstance::createPicker(css::uno::Reference<css::uno::XComponentContext> const& context,
+ QFileDialog::FileMode eMode)
+{
+ if (!IsMainThread())
+ {
+ SolarMutexGuard g;
+ Qt5FilePicker* pPicker;
+ RunInMainThread([&, this]() { pPicker = createPicker(context, eMode); });
+ assert(pPicker);
+ return pPicker;
+ }
+
+ // In order to insert custom controls, KF5FilePicker currently relies on KFileWidget
+ // being used in the native file picker, which is only the case for KDE Plasma.
+ // Therefore, return the plain qt5 one in order to not lose custom controls.
+ if (Application::GetDesktopEnvironment() == "PLASMA5")
+ return new KF5FilePicker(context, eMode);
+ return Qt5Instance::createPicker(context, eMode);
+}
+
+extern "C" {
+VCLPLUG_KF5_PUBLIC SalInstance* create_SalInstance()
+{
+ std::unique_ptr<char* []> pFakeArgv;
+ std::unique_ptr<int> pFakeArgc;
+ std::vector<FreeableCStr> aFakeArgvFreeable;
+ Qt5Instance::AllocFakeCmdlineArgs(pFakeArgv, pFakeArgc, aFakeArgvFreeable);
+
+ std::unique_ptr<QApplication> pQApp
+ = Qt5Instance::CreateQApplication(*pFakeArgc, pFakeArgv.get());
+
+ KF5SalInstance* pInstance = new KF5SalInstance(pQApp);
+ pInstance->MoveFakeCmdlineArgs(pFakeArgv, pFakeArgc, aFakeArgvFreeable);
+
+ new Qt5Data(pInstance);
+
+ return pInstance;
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kf5/KF5SalInstance.hxx b/vcl/unx/kf5/KF5SalInstance.hxx
new file mode 100644
index 000000000..5dd306da5
--- /dev/null
+++ b/vcl/unx/kf5/KF5SalInstance.hxx
@@ -0,0 +1,36 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <qt5/Qt5Instance.hxx>
+
+class KF5SalInstance final : public Qt5Instance
+{
+ bool hasNativeFileSelection() const override;
+ Qt5FilePicker* createPicker(css::uno::Reference<css::uno::XComponentContext> const& context,
+ QFileDialog::FileMode) override;
+
+ SalFrame* CreateFrame(SalFrame* pParent, SalFrameStyleFlags nStyle) override;
+
+public:
+ explicit KF5SalInstance(std::unique_ptr<QApplication>& pQApp);
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */