bump product version to 7.2.5.1
[LibreOffice.git] / vcl / inc / qt5 / Qt5Instance.hxx
blobdc347021b9bb7a562dbc3affd28a6ba6d293ae66
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #pragma once
22 #include <vclpluginapi.h>
23 #include <unx/geninst.h>
24 #include <salusereventlist.hxx>
25 #include <vcl/timer.hxx>
27 #include <osl/conditn.hxx>
29 #include <QtCore/QObject>
31 #include <cstdlib>
32 #include <functional>
33 #include <memory>
34 #include <vector>
36 #include "Qt5FilePicker.hxx"
38 class Qt5Timer;
40 class QApplication;
41 class SalYieldMutex;
42 class SalFrame;
44 struct StdFreeCStr
46 void operator()(char* arg) const noexcept { std::free(arg); }
48 using FreeableCStr = std::unique_ptr<char[], StdFreeCStr>;
50 class VCLPLUG_QT5_PUBLIC Qt5Instance : public QObject,
51 public SalGenericInstance,
52 public SalUserEventList
54 Q_OBJECT
56 osl::Condition m_aWaitingYieldCond;
57 const bool m_bUseCairo;
58 Qt5Timer* m_pTimer;
59 bool m_bSleeping;
60 std::unordered_map<OUString, css::uno::Reference<css::uno::XInterface>> m_aClipboards;
62 std::unique_ptr<QApplication> m_pQApplication;
63 std::vector<FreeableCStr> m_pFakeArgvFreeable;
64 std::unique_ptr<char* []> m_pFakeArgv;
65 std::unique_ptr<int> m_pFakeArgc;
67 Timer m_aUpdateStyleTimer;
68 bool m_bUpdateFonts;
70 DECL_LINK(updateStyleHdl, Timer*, void);
71 void AfterAppInit() override;
73 private Q_SLOTS:
74 bool ImplYield(bool bWait, bool bHandleAllCurrentEvents);
75 static void deleteObjectLater(QObject* pObject);
76 static void localeChanged();
78 Q_SIGNALS:
79 bool ImplYieldSignal(bool bWait, bool bHandleAllCurrentEvents);
80 void deleteObjectLaterSignal(QObject* pObject);
82 protected:
83 virtual rtl::Reference<Qt5FilePicker>
84 createPicker(css::uno::Reference<css::uno::XComponentContext> const& context,
85 QFileDialog::FileMode);
86 bool useCairo() const { return m_bUseCairo; }
87 // encodes cairo usage and Qt platform name into the ToolkitName
88 OUString constructToolkitID(std::u16string_view sTKname);
90 public:
91 explicit Qt5Instance(std::unique_ptr<QApplication>& pQApp, bool bUseCairo = false);
92 virtual ~Qt5Instance() override;
94 // handle common SalInstance setup
95 static void AllocFakeCmdlineArgs(std::unique_ptr<char* []>& rFakeArgv,
96 std::unique_ptr<int>& rFakeArgc,
97 std::vector<FreeableCStr>& rFakeArgvFreeable);
98 void MoveFakeCmdlineArgs(std::unique_ptr<char* []>& rFakeArgv, std::unique_ptr<int>& rFakeArgc,
99 std::vector<FreeableCStr>& rFakeArgvFreeable);
100 static std::unique_ptr<QApplication> CreateQApplication(int& nArgc, char** pArgv);
102 void RunInMainThread(std::function<void()> func);
104 virtual SalFrame* CreateFrame(SalFrame* pParent, SalFrameStyleFlags nStyle) override;
105 virtual SalFrame* CreateChildFrame(SystemParentData* pParent,
106 SalFrameStyleFlags nStyle) override;
107 virtual void DestroyFrame(SalFrame* pFrame) override;
109 virtual SalObject* CreateObject(SalFrame* pParent, SystemWindowData* pWindowData,
110 bool bShow) override;
111 virtual void DestroyObject(SalObject* pObject) override;
113 virtual std::unique_ptr<SalVirtualDevice>
114 CreateVirtualDevice(SalGraphics& rGraphics, tools::Long& nDX, tools::Long& nDY,
115 DeviceFormat eFormat, const SystemGraphicsData* pData = nullptr) override;
117 virtual SalInfoPrinter* CreateInfoPrinter(SalPrinterQueueInfo* pQueueInfo,
118 ImplJobSetup* pSetupData) override;
119 virtual void DestroyInfoPrinter(SalInfoPrinter* pPrinter) override;
120 virtual std::unique_ptr<SalPrinter> CreatePrinter(SalInfoPrinter* pInfoPrinter) override;
121 virtual void GetPrinterQueueInfo(ImplPrnQueueList* pList) override;
122 virtual void GetPrinterQueueState(SalPrinterQueueInfo* pInfo) override;
123 virtual OUString GetDefaultPrinter() override;
124 virtual void PostPrintersChanged() override;
126 virtual std::unique_ptr<SalMenu> CreateMenu(bool, Menu*) override;
127 virtual std::unique_ptr<SalMenuItem> CreateMenuItem(const SalItemParams&) override;
129 virtual SalTimer* CreateSalTimer() override;
130 virtual SalSystem* CreateSalSystem() override;
131 virtual std::shared_ptr<SalBitmap> CreateSalBitmap() override;
133 virtual bool DoYield(bool bWait, bool bHandleAllCurrentEvents) override;
134 virtual bool AnyInput(VclInputFlags nType) override;
136 // so we fall back to the default abort, instead of duplicating it...
137 #ifndef EMSCRIPTEN
138 virtual OpenGLContext* CreateOpenGLContext() override;
139 #endif
141 virtual OUString GetConnectionIdentifier() override;
143 virtual void AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType,
144 const OUString& rDocumentService) override;
146 virtual std::unique_ptr<GenPspGraphics> CreatePrintGraphics() override;
148 virtual bool IsMainThread() const override;
150 virtual void TriggerUserEventProcessing() override;
151 virtual void ProcessEvent(SalUserEvent aEvent) override;
153 bool hasNativeFileSelection() const override { return true; }
154 css::uno::Reference<css::ui::dialogs::XFilePicker2>
155 createFilePicker(const css::uno::Reference<css::uno::XComponentContext>&) override;
156 css::uno::Reference<css::ui::dialogs::XFolderPicker2>
157 createFolderPicker(const css::uno::Reference<css::uno::XComponentContext>&) override;
159 virtual css::uno::Reference<css::uno::XInterface>
160 CreateClipboard(const css::uno::Sequence<css::uno::Any>& i_rArguments) override;
161 virtual css::uno::Reference<css::uno::XInterface> CreateDragSource() override;
162 virtual css::uno::Reference<css::uno::XInterface> CreateDropTarget() override;
164 void UpdateStyle(bool bFontsChanged);
166 void* CreateGStreamerSink(const SystemChildWindow*) override;
169 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */