nss: upgrade to release 3.73
[LibreOffice.git] / vcl / inc / qt5 / Qt5Instance.hxx
bloba2372e58f8c99bea92255e2f9553dc4dff0c6d34
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);
77 Q_SIGNALS:
78 bool ImplYieldSignal(bool bWait, bool bHandleAllCurrentEvents);
79 void deleteObjectLaterSignal(QObject* pObject);
81 protected:
82 virtual Qt5FilePicker*
83 createPicker(css::uno::Reference<css::uno::XComponentContext> const& context,
84 QFileDialog::FileMode);
85 bool useCairo() const { return m_bUseCairo; }
87 public:
88 explicit Qt5Instance(std::unique_ptr<QApplication>& pQApp, bool bUseCairo = false);
89 virtual ~Qt5Instance() override;
91 // handle common SalInstance setup
92 static void AllocFakeCmdlineArgs(std::unique_ptr<char* []>& rFakeArgv,
93 std::unique_ptr<int>& rFakeArgc,
94 std::vector<FreeableCStr>& rFakeArgvFreeable);
95 void MoveFakeCmdlineArgs(std::unique_ptr<char* []>& rFakeArgv, std::unique_ptr<int>& rFakeArgc,
96 std::vector<FreeableCStr>& rFakeArgvFreeable);
97 static std::unique_ptr<QApplication> CreateQApplication(int& nArgc, char** pArgv);
99 void RunInMainThread(std::function<void()> func);
101 virtual SalFrame* CreateFrame(SalFrame* pParent, SalFrameStyleFlags nStyle) override;
102 virtual SalFrame* CreateChildFrame(SystemParentData* pParent,
103 SalFrameStyleFlags nStyle) override;
104 virtual void DestroyFrame(SalFrame* pFrame) override;
106 virtual SalObject* CreateObject(SalFrame* pParent, SystemWindowData* pWindowData,
107 bool bShow) override;
108 virtual void DestroyObject(SalObject* pObject) override;
110 virtual std::unique_ptr<SalVirtualDevice>
111 CreateVirtualDevice(SalGraphics* pGraphics, tools::Long& nDX, tools::Long& nDY,
112 DeviceFormat eFormat, const SystemGraphicsData* pData = nullptr) override;
114 virtual SalInfoPrinter* CreateInfoPrinter(SalPrinterQueueInfo* pQueueInfo,
115 ImplJobSetup* pSetupData) override;
116 virtual void DestroyInfoPrinter(SalInfoPrinter* pPrinter) override;
117 virtual std::unique_ptr<SalPrinter> CreatePrinter(SalInfoPrinter* pInfoPrinter) override;
118 virtual void GetPrinterQueueInfo(ImplPrnQueueList* pList) override;
119 virtual void GetPrinterQueueState(SalPrinterQueueInfo* pInfo) override;
120 virtual OUString GetDefaultPrinter() override;
121 virtual void PostPrintersChanged() override;
123 virtual std::unique_ptr<SalMenu> CreateMenu(bool, Menu*) override;
124 virtual std::unique_ptr<SalMenuItem> CreateMenuItem(const SalItemParams&) override;
126 virtual SalTimer* CreateSalTimer() override;
127 virtual SalSystem* CreateSalSystem() override;
128 virtual std::shared_ptr<SalBitmap> CreateSalBitmap() override;
130 virtual bool DoYield(bool bWait, bool bHandleAllCurrentEvents) override;
131 virtual bool AnyInput(VclInputFlags nType) override;
133 virtual OpenGLContext* CreateOpenGLContext() override;
135 virtual OUString GetConnectionIdentifier() override;
137 virtual void AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType,
138 const OUString& rDocumentService) override;
140 virtual std::unique_ptr<GenPspGraphics> CreatePrintGraphics() override;
142 virtual bool IsMainThread() const override;
144 virtual void TriggerUserEventProcessing() override;
145 virtual void ProcessEvent(SalUserEvent aEvent) override;
147 bool hasNativeFileSelection() const override { return true; }
148 css::uno::Reference<css::ui::dialogs::XFilePicker2>
149 createFilePicker(const css::uno::Reference<css::uno::XComponentContext>&) override;
150 css::uno::Reference<css::ui::dialogs::XFolderPicker2>
151 createFolderPicker(const css::uno::Reference<css::uno::XComponentContext>&) override;
153 virtual css::uno::Reference<css::uno::XInterface>
154 CreateClipboard(const css::uno::Sequence<css::uno::Any>& i_rArguments) override;
155 virtual css::uno::Reference<css::uno::XInterface> CreateDragSource() override;
156 virtual css::uno::Reference<css::uno::XInterface> CreateDropTarget() override;
158 void UpdateStyle(bool bFontsChanged);
160 void* CreateGStreamerSink(const SystemChildWindow*) override;
163 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */