bump product version to 6.4.0.3
[LibreOffice.git] / vcl / inc / qt5 / Qt5Instance.hxx
blob361eca0fc51905916861bcf69c7a0d295c6dd2c2
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 QApplication;
39 class SalYieldMutex;
40 class SalFrame;
42 struct StdFreeCStr
44 void operator()(char* arg) const noexcept { std::free(arg); }
46 using FreeableCStr = std::unique_ptr<char[], StdFreeCStr>;
48 class VCLPLUG_QT5_PUBLIC Qt5Instance : public QObject,
49 public SalGenericInstance,
50 public SalUserEventList
52 Q_OBJECT
54 osl::Condition m_aWaitingYieldCond;
55 int m_postUserEventId;
56 const bool m_bUseCairo;
57 std::unordered_map<OUString, css::uno::Reference<css::uno::XInterface>> m_aClipboards;
59 std::unique_ptr<QApplication> m_pQApplication;
60 std::vector<FreeableCStr> m_pFakeArgvFreeable;
61 std::unique_ptr<char* []> m_pFakeArgv;
62 std::unique_ptr<int> m_pFakeArgc;
64 Timer m_aUpdateStyleTimer;
65 bool m_bUpdateFonts;
67 DECL_LINK(updateStyleHdl, Timer*, void);
68 void AfterAppInit() override;
70 private Q_SLOTS:
71 bool ImplYield(bool bWait, bool bHandleAllCurrentEvents);
72 void ImplRunInMain();
73 static void deleteObjectLater(QObject* pObject);
75 Q_SIGNALS:
76 bool ImplYieldSignal(bool bWait, bool bHandleAllCurrentEvents);
77 void ImplRunInMainSignal();
78 void deleteObjectLaterSignal(QObject* pObject);
80 protected:
81 virtual Qt5FilePicker*
82 createPicker(css::uno::Reference<css::uno::XComponentContext> const& context,
83 QFileDialog::FileMode);
85 public:
86 explicit Qt5Instance(std::unique_ptr<QApplication>& pQApp, bool bUseCairo = false);
87 virtual ~Qt5Instance() override;
89 // handle common SalInstance setup
90 static void AllocFakeCmdlineArgs(std::unique_ptr<char* []>& rFakeArgv,
91 std::unique_ptr<int>& rFakeArgc,
92 std::vector<FreeableCStr>& rFakeArgvFreeable);
93 void MoveFakeCmdlineArgs(std::unique_ptr<char* []>& rFakeArgv, std::unique_ptr<int>& rFakeArgc,
94 std::vector<FreeableCStr>& rFakeArgvFreeable);
95 static std::unique_ptr<QApplication> CreateQApplication(int& nArgc, char** pArgv);
97 void RunInMainThread(std::function<void()> func);
99 virtual SalFrame* CreateFrame(SalFrame* pParent, SalFrameStyleFlags nStyle) override;
100 virtual SalFrame* CreateChildFrame(SystemParentData* pParent,
101 SalFrameStyleFlags nStyle) override;
102 virtual void DestroyFrame(SalFrame* pFrame) override;
104 virtual SalObject* CreateObject(SalFrame* pParent, SystemWindowData* pWindowData,
105 bool bShow) override;
106 virtual void DestroyObject(SalObject* pObject) override;
108 virtual std::unique_ptr<SalVirtualDevice>
109 CreateVirtualDevice(SalGraphics* pGraphics, long& nDX, long& nDY, DeviceFormat eFormat,
110 const SystemGraphicsData* pData = nullptr) override;
112 virtual SalInfoPrinter* CreateInfoPrinter(SalPrinterQueueInfo* pQueueInfo,
113 ImplJobSetup* pSetupData) override;
114 virtual void DestroyInfoPrinter(SalInfoPrinter* pPrinter) override;
115 virtual std::unique_ptr<SalPrinter> CreatePrinter(SalInfoPrinter* pInfoPrinter) override;
116 virtual void GetPrinterQueueInfo(ImplPrnQueueList* pList) override;
117 virtual void GetPrinterQueueState(SalPrinterQueueInfo* pInfo) override;
118 virtual OUString GetDefaultPrinter() override;
119 virtual void PostPrintersChanged() override;
121 virtual std::unique_ptr<SalMenu> CreateMenu(bool, Menu*) override;
122 virtual std::unique_ptr<SalMenuItem> CreateMenuItem(const SalItemParams&) override;
124 virtual SalTimer* CreateSalTimer() override;
125 virtual SalSystem* CreateSalSystem() override;
126 virtual std::shared_ptr<SalBitmap> CreateSalBitmap() override;
128 virtual bool DoYield(bool bWait, bool bHandleAllCurrentEvents) override;
129 virtual bool AnyInput(VclInputFlags nType) override;
131 virtual OpenGLContext* CreateOpenGLContext() override;
133 virtual OUString GetConnectionIdentifier() override;
135 virtual void AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType,
136 const OUString& rDocumentService) override;
138 virtual std::unique_ptr<GenPspGraphics> CreatePrintGraphics() override;
140 virtual bool IsMainThread() const override;
142 virtual void TriggerUserEventProcessing() override;
143 virtual void ProcessEvent(SalUserEvent aEvent) override;
145 bool hasNativeFileSelection() const override { return true; }
146 css::uno::Reference<css::ui::dialogs::XFilePicker2>
147 createFilePicker(const css::uno::Reference<css::uno::XComponentContext>&) override;
148 css::uno::Reference<css::ui::dialogs::XFolderPicker2>
149 createFolderPicker(const css::uno::Reference<css::uno::XComponentContext>&) override;
151 virtual css::uno::Reference<css::uno::XInterface>
152 CreateClipboard(const css::uno::Sequence<css::uno::Any>& i_rArguments) override;
153 virtual css::uno::Reference<css::uno::XInterface> CreateDragSource() override;
154 virtual css::uno::Reference<css::uno::XInterface> CreateDropTarget() override;
156 void UpdateStyle(bool bFontsChanged);
158 void* CreateGStreamerSink(const SystemChildWindow*) override;
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */