vcl/Library_vclplug_qt5.mk | 5 vcl/Library_vclplug_qt6.mk | 5 vcl/README.vars.md | 1 vcl/inc/qt5/QtData.hxx | 2 vcl/inc/qt5/QtInstance.hxx | 5 vcl/inc/qt5/QtInstanceContainer.hxx | 26 ++++ vcl/inc/qt5/QtInstanceDialog.hxx | 51 +++++++++ vcl/inc/qt5/QtInstanceMessageDialog.hxx | 34 ++++++ vcl/inc/qt5/QtInstanceWidget.hxx | 171 ++++++++++++++++++++++++++++++++ vcl/inc/qt5/QtInstanceWindow.hxx | 49 +++++++++ vcl/inc/qt5/QtTools.hxx | 7 + vcl/inc/qt6/QtInstanceContainer.hxx | 12 ++ vcl/inc/qt6/QtInstanceDialog.hxx | 12 ++ vcl/inc/qt6/QtInstanceMessageDialog.hxx | 12 ++ vcl/inc/qt6/QtInstanceWidget.hxx | 12 ++ vcl/inc/qt6/QtInstanceWindow.hxx | 12 ++ vcl/qt5/QtData.cxx | 5 vcl/qt5/QtInstance.cxx | 24 ++++ vcl/qt5/QtInstanceContainer.cxx | 23 ++++ vcl/qt5/QtInstanceDialog.cxx | 53 +++++++++ vcl/qt5/QtInstanceMessageDialog.cxx | 42 +++++++ vcl/qt5/QtInstanceWidget.cxx | 166 +++++++++++++++++++++++++++++++ vcl/qt5/QtInstanceWindow.cxx | 70 +++++++++++++ vcl/qt5/QtTools.cxx | 91 +++++++++++++++++ vcl/qt6/QtInstanceContainer.cxx | 12 ++ vcl/qt6/QtInstanceDialog.cxx | 12 ++ vcl/qt6/QtInstanceMessageDialog.cxx | 12 ++ vcl/qt6/QtInstanceWidget.cxx | 12 ++ vcl/qt6/QtInstanceWindow.cxx | 12 ++ 29 files changed, 950 insertions(+)
New commits: commit 1ace888823443b85d4a81b94656844f1b27e2987 Author: OmkarAcharekar <omkarachareka...@gmail.com> AuthorDate: Wed Dec 20 19:13:50 2023 +0530 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Mon Jan 8 22:52:59 2024 +0100 tdf#130857 Use native qt widgets - simple message dialog - Implements CreateMessageDialog method for QtInstance which would create message dialogs using native qt widgets. Example - MasterPasswordCreateDialog ( https://git.libreoffice.org/core/+/5e8c0575e877795aaca91346548cd0136fa22048/uui/source/masterpasscrtdlg.cxx#64 ). To trigger this : a) Go to "Tools" -> "Options". b) Select "LibreOfficeDev" -> "Security", then check "Persistently save passwords for web connections". c) In the master password dialog, enter two different passwords and click "OK". The message dialog appears now uses native qt widgets. - adds Env variable SAL_VCL_QT_NO_WELDED_WIDGETS which reverts to previous behavior using VCL widgets. Note: most of the methods from weld::Widget hierarchy are currently just dummy implementations for Qt case, only what's needed for simple message dialogs has been implemented in this patch. Change-Id: I522489b8befb92f0092eb248ea2b81ecfbadd737 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161073 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/vcl/Library_vclplug_qt5.mk b/vcl/Library_vclplug_qt5.mk index 2a72693e0e85..f29090d9dd9d 100644 --- a/vcl/Library_vclplug_qt5.mk +++ b/vcl/Library_vclplug_qt5.mk @@ -92,6 +92,11 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_qt5,\ vcl/qt5/QtGraphics_Text \ vcl/qt5/QtInstance \ vcl/qt5/QtInstance_Print \ + vcl/qt5/QtInstanceContainer \ + vcl/qt5/QtInstanceDialog \ + vcl/qt5/QtInstanceMessageDialog \ + vcl/qt5/QtInstanceWidget \ + vcl/qt5/QtInstanceWindow \ vcl/qt5/QtMainWindow \ vcl/qt5/QtMenu \ vcl/qt5/QtObject \ diff --git a/vcl/Library_vclplug_qt6.mk b/vcl/Library_vclplug_qt6.mk index a6b14da23f5c..f8a2c38bb836 100644 --- a/vcl/Library_vclplug_qt6.mk +++ b/vcl/Library_vclplug_qt6.mk @@ -91,6 +91,11 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_qt6,\ vcl/qt6/QtGraphics_Text \ vcl/qt6/QtInstance \ vcl/qt6/QtInstance_Print \ + vcl/qt6/QtInstanceContainer \ + vcl/qt6/QtInstanceDialog \ + vcl/qt6/QtInstanceMessageDialog \ + vcl/qt6/QtInstanceWidget \ + vcl/qt6/QtInstanceWindow \ vcl/qt6/QtMainWindow \ vcl/qt6/QtMenu \ vcl/qt6/QtObject \ diff --git a/vcl/README.vars.md b/vcl/README.vars.md index 44764cbb0a14..baceef575c7b 100644 --- a/vcl/README.vars.md +++ b/vcl/README.vars.md @@ -68,6 +68,7 @@ will be used to write the log under `instdir/uitest/`. * `SAL_VCL_QT_NO_FONTCONFIG` - ignore fontconfig provided font substitutions * `SAL_VCL_QT_NO_NATIVE` - disable `QStyle`'d controls * `SAL_VCL_QT_USE_QFONT` - use `QFont` for text layout and rendering (default is to use cairo) +* `SAL_VCL_QT_NO_WELDED_WIDGETS` - disable the use of welded Qt widgets, reverts to previous VCL widget behavior ## Mac diff --git a/vcl/inc/qt5/QtData.hxx b/vcl/inc/qt5/QtData.hxx index 82cfecd57e33..14450dee220d 100644 --- a/vcl/inc/qt5/QtData.hxx +++ b/vcl/inc/qt5/QtData.hxx @@ -42,6 +42,8 @@ public: QCursor& getCursor(PointerStyle ePointerStyle); static bool noNativeControls(); + + static bool noWeldedWidgets(); }; inline QtData* GetQtData() { return static_cast<QtData*>(GetSalData()); } diff --git a/vcl/inc/qt5/QtInstance.hxx b/vcl/inc/qt5/QtInstance.hxx index 2073c8ac05d8..3d3aba9a2048 100644 --- a/vcl/inc/qt5/QtInstance.hxx +++ b/vcl/inc/qt5/QtInstance.hxx @@ -34,6 +34,7 @@ #include <vector> #include "QtFilePicker.hxx" +#include <salinst.hxx> class QtFrame; class QtTimer; @@ -143,6 +144,10 @@ public: virtual bool DoYield(bool bWait, bool bHandleAllCurrentEvents) override; virtual bool AnyInput(VclInputFlags nType) override; + virtual weld::MessageDialog* CreateMessageDialog(weld::Widget* pParent, + VclMessageType eMessageType, + VclButtonsType eButtonType, + const OUString& rPrimaryMessage) override; // so we fall back to the default abort, instead of duplicating it... #ifndef EMSCRIPTEN diff --git a/vcl/inc/qt5/QtInstanceContainer.hxx b/vcl/inc/qt5/QtInstanceContainer.hxx new file mode 100644 index 000000000000..87a89c48bd46 --- /dev/null +++ b/vcl/inc/qt5/QtInstanceContainer.hxx @@ -0,0 +1,26 @@ +/* -*- 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/. + */ + +#pragma once + +#include "QtInstanceWidget.hxx" + +class QtInstanceContainer : public QtInstanceWidget, public virtual weld::Container +{ +public: + virtual void move(weld::Widget*, weld::Container*) override; + + virtual css::uno::Reference<css::awt::XWindow> CreateChildFrame() override; + + virtual void child_grab_focus() override; + + virtual void connect_container_focus_changed(const Link<Container&, void>&) override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/qt5/QtInstanceDialog.hxx b/vcl/inc/qt5/QtInstanceDialog.hxx new file mode 100644 index 000000000000..1eb7e5f63eb5 --- /dev/null +++ b/vcl/inc/qt5/QtInstanceDialog.hxx @@ -0,0 +1,51 @@ +/* -*- 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/. + */ + +#pragma once + +#include "QtInstanceWindow.hxx" + +class QtInstanceDialog : public QtInstanceWindow, public virtual weld::Dialog +{ +public: + std::unique_ptr<QDialog> m_pDialog; + + QtInstanceDialog(QDialog* pDialog); + + virtual bool runAsync(std::shared_ptr<Dialog> const&, + const std::function<void(sal_Int32)>&) override; + + virtual bool runAsync(const std::shared_ptr<weld::DialogController>&, + const std::function<void(sal_Int32)>&) override; + + virtual void collapse(weld::Widget*, weld::Widget*) override; + + virtual void undo_collapse() override; + + virtual void + SetInstallLOKNotifierHdl(const Link<void*, vcl::ILibreOfficeKitNotifier*>&) override; + + virtual int run() override; + + virtual void response(int) override; + + virtual void add_button(const OUString&, int, const OUString& rHelpId = {}) override; + + virtual void set_modal(bool) override; + + virtual bool get_modal() const override; + + virtual weld::Button* weld_widget_for_response(int) override; + + virtual void set_default_response(int) override; + + virtual weld::Container* weld_content_area() override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file diff --git a/vcl/inc/qt5/QtInstanceMessageDialog.hxx b/vcl/inc/qt5/QtInstanceMessageDialog.hxx new file mode 100644 index 000000000000..68d2010cb1fa --- /dev/null +++ b/vcl/inc/qt5/QtInstanceMessageDialog.hxx @@ -0,0 +1,34 @@ +/* -*- 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/. + */ + +#pragma once + +#include "QtInstanceDialog.hxx" +#include <QtWidgets/QMessageBox> + +class QtInstanceMessageDialog : public QtInstanceDialog, public virtual weld::MessageDialog +{ +private: + QMessageBox* m_pMessageDialog; + +public: + QtInstanceMessageDialog(QMessageBox* pMessageDialog); + + virtual void set_primary_text(const rtl::OUString& rText) override; + + virtual void set_secondary_text(const rtl::OUString& rText) override; + + virtual Container* weld_message_area() override; + + virtual OUString get_primary_text() const override; + + virtual OUString get_secondary_text() const override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/qt5/QtInstanceWidget.hxx b/vcl/inc/qt5/QtInstanceWidget.hxx new file mode 100644 index 000000000000..ee0c5b8c451d --- /dev/null +++ b/vcl/inc/qt5/QtInstanceWidget.hxx @@ -0,0 +1,171 @@ +/* -*- 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/. + */ + +#pragma once + +#include "QtInstance.hxx" +#include <QtWidgets/QApplication> +#include <QtWidgets/QWidget> +#include <QtWidgets/QMessageBox> +#include "QtTools.hxx" +#include <vcl/weld.hxx> +#include <string_view> +#include <rtl/ustring.hxx> +#include <vcl/sysdata.hxx> + +class QtInstanceWidget : public virtual weld::Widget +{ +public: + virtual void set_sensitive(bool) override; + + virtual bool get_sensitive() const override; + + virtual bool get_visible() const override; + + virtual bool is_visible() const override; + + virtual void set_can_focus(bool) override; + + virtual void grab_focus() override; + + virtual bool has_focus() const override; + + virtual bool is_active() const override; + + virtual bool has_child_focus() const override; + + virtual void show() override; + + virtual void hide() override; + + virtual void set_size_request(int, int) override; + + virtual Size get_size_request() const override; + + virtual Size get_preferred_size() const override; + + virtual float get_approximate_digit_width() const override; + + virtual int get_text_height() const override; + + virtual Size get_pixel_size(const OUString&) const override; + + virtual vcl::Font get_font() override; + + virtual OUString get_buildable_name() const override; + + virtual void set_buildable_name(const OUString&) override; + + virtual void set_help_id(const OUString&) override; + + virtual OUString get_help_id() const override; + + virtual void set_grid_left_attach(int) override; + + virtual int get_grid_left_attach() const override; + + virtual void set_grid_width(int) override; + + virtual void set_grid_top_attach(int) override; + + virtual int get_grid_top_attach() const override; + + virtual void set_hexpand(bool) override; + + virtual bool get_hexpand() const override; + + virtual void set_vexpand(bool) override; + + virtual bool get_vexpand() const override; + + virtual void set_margin_top(int) override; + + virtual void set_margin_bottom(int) override; + + virtual void set_margin_start(int) override; + + virtual void set_margin_end(int) override; + + virtual int get_margin_top() const override; + + virtual int get_margin_bottom() const override; + + virtual int get_margin_start() const override; + + virtual int get_margin_end() const override; + + virtual void set_accessible_name(const OUString&) override; + + virtual void set_accessible_description(const OUString&) override; + + virtual OUString get_accessible_name() const override; + + virtual OUString get_accessible_description() const override; + + virtual void set_accessible_relation_labeled_by(weld::Widget*) override; + + virtual void set_tooltip_text(const OUString&) override; + + virtual OUString get_tooltip_text() const override; + + virtual void set_cursor_data(void*) override; + + virtual void grab_add() override; + + virtual bool has_grab() const override; + + virtual void grab_remove() override; + + virtual bool get_extents_relative_to(const Widget&, int&, int&, int&, int&) const override; + + virtual bool get_direction() const override; + + virtual void set_direction(bool) override; + + virtual void freeze() override; + + virtual void thaw() override; + + virtual void set_busy_cursor(bool) override; + + virtual std::unique_ptr<weld::Container> weld_parent() const override; + + virtual void queue_resize() override; + + virtual void help_hierarchy_foreach(const std::function<bool(const OUString&)>&) override; + + virtual OUString strip_mnemonic(const OUString&) const override; + + virtual VclPtr<VirtualDevice> create_virtual_device() const override; + + virtual css::uno::Reference<css::datatransfer::dnd::XDropTarget> get_drop_target() override; + + virtual css::uno::Reference<css::datatransfer::clipboard::XClipboard> + get_clipboard() const override; + + virtual void connect_get_property_tree(const Link<tools::JsonWriter&, void>&) override; + + virtual void get_property_tree(tools::JsonWriter&) override; + + virtual void call_attention_to() override; + + virtual void set_stack_background() override; + + virtual void set_title_background() override; + + virtual void set_toolbar_background() override; + + virtual void set_highlight_background() override; + + virtual void set_background(const Color&) override; + + virtual void draw(OutputDevice&, const Point&, const Size&) override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/qt5/QtInstanceWindow.hxx b/vcl/inc/qt5/QtInstanceWindow.hxx new file mode 100644 index 000000000000..be6aec6623cd --- /dev/null +++ b/vcl/inc/qt5/QtInstanceWindow.hxx @@ -0,0 +1,49 @@ +/* -*- 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/. + */ + +#pragma once + +#include "QtInstanceContainer.hxx" + +class QtInstanceWindow : public QtInstanceContainer, public virtual weld::Window +{ + virtual void set_title(const OUString&) override; + virtual OUString get_title() const override; + virtual void window_move(int, int) override; + virtual void set_modal(bool) override; + virtual bool get_modal() const override; + virtual bool get_resizable() const override; + virtual Size get_size() const override; + virtual Point get_position() const override; + virtual AbsoluteScreenPixelRectangle get_monitor_workarea() const override; + virtual void set_centered_on_parent(bool) override; + + virtual bool has_toplevel_focus() const override; + virtual void present() override; + + virtual void change_default_widget(weld::Widget*, weld::Widget*) override; + virtual bool is_default_widget(const weld::Widget*) const override; + + virtual void set_window_state(const OUString&) override; + virtual OUString get_window_state(vcl::WindowDataMask) const override; + + virtual css::uno::Reference<css::awt::XWindow> GetXWindow() override; + + virtual SystemEnvData get_system_data() const override; + + virtual void resize_to_request() override; + + virtual weld::ScreenShotCollection collect_screenshot_data() override; + + virtual VclPtr<VirtualDevice> screenshot() override; + + virtual const vcl::ILibreOfficeKitNotifier* GetLOKNotifier() override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/qt5/QtTools.hxx b/vcl/inc/qt5/QtTools.hxx index 5a0032ccc352..20e0452188af 100644 --- a/vcl/inc/qt5/QtTools.hxx +++ b/vcl/inc/qt5/QtTools.hxx @@ -26,12 +26,14 @@ #include <QtCore/QSize> #include <QtCore/QString> #include <QtGui/QImage> +#include <QtWidgets/QMessageBox> #include <rtl/string.hxx> #include <rtl/ustring.hxx> #include <tools/color.hxx> #include <tools/gen.hxx> #include <vcl/bitmap/BitmapTypes.hxx> +#include <vcl/vclenum.hxx> #include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/datatransfer/dnd/DNDConstants.hpp> @@ -151,6 +153,11 @@ sal_uInt16 GetMouseModCode(Qt::MouseButtons eButtons); QImage toQImage(const Image& rImage); +QMessageBox::Icon vclMessageTypeToQtIcon(VclMessageType eType); +QString vclMessageTypeToQtTitle(VclMessageType eType); +QMessageBox::StandardButtons vclButtonsTypeToQtButton(VclButtonsType eButtonType); +int qtResponseTypeToVclResponseType(int ret); + template <typename charT, typename traits> inline std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& stream, const QString& rString) diff --git a/vcl/inc/qt6/QtInstanceContainer.hxx b/vcl/inc/qt6/QtInstanceContainer.hxx new file mode 100644 index 000000000000..bd64e6b7e76a --- /dev/null +++ b/vcl/inc/qt6/QtInstanceContainer.hxx @@ -0,0 +1,12 @@ +/* -*- 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/. + */ + +#include "../qt5/QtInstanceContainer.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/qt6/QtInstanceDialog.hxx b/vcl/inc/qt6/QtInstanceDialog.hxx new file mode 100644 index 000000000000..f27ac2bc88e0 --- /dev/null +++ b/vcl/inc/qt6/QtInstanceDialog.hxx @@ -0,0 +1,12 @@ +/* -*- 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/. + */ + +#include "../qt5/QtInstanceDialog.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/qt6/QtInstanceMessageDialog.hxx b/vcl/inc/qt6/QtInstanceMessageDialog.hxx new file mode 100644 index 000000000000..b66ecdab525e --- /dev/null +++ b/vcl/inc/qt6/QtInstanceMessageDialog.hxx @@ -0,0 +1,12 @@ +/* -*- 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/. + */ + +#include "../qt5/QtInstanceMessageDialog.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/qt6/QtInstanceWidget.hxx b/vcl/inc/qt6/QtInstanceWidget.hxx new file mode 100644 index 000000000000..f178186c7755 --- /dev/null +++ b/vcl/inc/qt6/QtInstanceWidget.hxx @@ -0,0 +1,12 @@ +/* -*- 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/. + */ + +#include "../qt5/QtInstanceWidget.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/qt6/QtInstanceWindow.hxx b/vcl/inc/qt6/QtInstanceWindow.hxx new file mode 100644 index 000000000000..90cfbc72d373 --- /dev/null +++ b/vcl/inc/qt6/QtInstanceWindow.hxx @@ -0,0 +1,12 @@ +/* -*- 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/. + */ + +#include "../qt5/QtInstanceWindow.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file diff --git a/vcl/qt5/QtData.cxx b/vcl/qt5/QtData.cxx index 2df26d05481e..27db3d1a9c7f 100644 --- a/vcl/qt5/QtData.cxx +++ b/vcl/qt5/QtData.cxx @@ -221,4 +221,9 @@ bool QtData::noNativeControls() return bNoNative; } +bool QtData::noWeldedWidgets() +{ + static const bool bNoWeldedWidgets = (getenv("SAL_VCL_QT_NO_WELDED_WIDGETS") != nullptr); + return bNoWeldedWidgets; +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/qt5/QtInstance.cxx b/vcl/qt5/QtInstance.cxx index 4880c1bdec55..718279f51496 100644 --- a/vcl/qt5/QtInstance.cxx +++ b/vcl/qt5/QtInstance.cxx @@ -35,6 +35,8 @@ #include <QtSystem.hxx> #include <QtTimer.hxx> #include <QtVirtualDevice.hxx> +#include <QtInstanceWidget.hxx> +#include <QtInstanceMessageDialog.hxx> #include <headless/svpvd.hxx> @@ -44,6 +46,7 @@ #include <QtGui/QScreen> #include <QtWidgets/QApplication> #include <QtWidgets/QWidget> +#include <QtWidgets/QMessageBox> #include <vclpluginapi.h> #include <tools/debug.hxx> @@ -748,6 +751,27 @@ void QtInstance::setActivePopup(QtFrame* pFrame) m_pActivePopup = pFrame; } +weld::MessageDialog* QtInstance::CreateMessageDialog(weld::Widget* pParent, + VclMessageType eMessageType, + VclButtonsType eButtonsType, + const OUString& rPrimaryMessage) +{ + if (QtData::noWeldedWidgets()) + { + return SalInstance::CreateMessageDialog(pParent, eMessageType, eButtonsType, + rPrimaryMessage); + } + else + { + QMessageBox* pMessageBox = new QMessageBox(); + pMessageBox->setText(toQString(rPrimaryMessage)); + pMessageBox->setIcon(vclMessageTypeToQtIcon(eMessageType)); + pMessageBox->setWindowTitle(vclMessageTypeToQtTitle(eMessageType)); + pMessageBox->setStandardButtons(vclButtonsTypeToQtButton(eButtonsType)); + return new QtInstanceMessageDialog(pMessageBox); + } +} + extern "C" { VCLPLUG_QT_PUBLIC SalInstance* create_SalInstance() { diff --git a/vcl/qt5/QtInstanceContainer.cxx b/vcl/qt5/QtInstanceContainer.cxx new file mode 100644 index 000000000000..e22b1afb2a55 --- /dev/null +++ b/vcl/qt5/QtInstanceContainer.cxx @@ -0,0 +1,23 @@ +/* -*- 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/. + */ + +#include <QtInstanceContainer.hxx> + +void QtInstanceContainer::move(weld::Widget*, weld::Container*) {} + +css::uno::Reference<css::awt::XWindow> QtInstanceContainer::CreateChildFrame() +{ + return css::uno::Reference<css::awt::XWindow>(); +} + +void QtInstanceContainer::child_grab_focus() {} + +void QtInstanceContainer::connect_container_focus_changed(const Link<Container&, void>&) {} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/qt5/QtInstanceDialog.cxx b/vcl/qt5/QtInstanceDialog.cxx new file mode 100644 index 000000000000..8d884688e247 --- /dev/null +++ b/vcl/qt5/QtInstanceDialog.cxx @@ -0,0 +1,53 @@ +/* -*- 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/. + */ + +#include <QtInstanceDialog.hxx> + +QtInstanceDialog::QtInstanceDialog(QDialog* pDialog) + : m_pDialog(pDialog) +{ +} + +bool QtInstanceDialog::runAsync(std::shared_ptr<Dialog> const&, + const std::function<void(sal_Int32)>&) +{ + return true; +} + +bool QtInstanceDialog::runAsync(const std::shared_ptr<weld::DialogController>&, + const std::function<void(sal_Int32)>&) +{ + return true; +} + +void QtInstanceDialog::collapse(weld::Widget*, weld::Widget*) {} + +void QtInstanceDialog::undo_collapse() {} + +void QtInstanceDialog::SetInstallLOKNotifierHdl(const Link<void*, vcl::ILibreOfficeKitNotifier*>&) +{ +} + +int QtInstanceDialog::run() { return qtResponseTypeToVclResponseType(m_pDialog->exec()); } + +void QtInstanceDialog::response(int) {} + +void QtInstanceDialog::add_button(const OUString&, int, const OUString&) {} + +void QtInstanceDialog::set_modal(bool) {} + +bool QtInstanceDialog::get_modal() const { return true; } + +weld::Button* QtInstanceDialog::weld_widget_for_response(int) { return nullptr; } + +void QtInstanceDialog::set_default_response(int) {} + +weld::Container* QtInstanceDialog::weld_content_area() { return nullptr; } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/qt5/QtInstanceMessageDialog.cxx b/vcl/qt5/QtInstanceMessageDialog.cxx new file mode 100644 index 000000000000..2ba386ded5c5 --- /dev/null +++ b/vcl/qt5/QtInstanceMessageDialog.cxx @@ -0,0 +1,42 @@ +/* -*- 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/. + */ + +#include <QtInstanceMessageDialog.hxx> + +QtInstanceMessageDialog::QtInstanceMessageDialog(QMessageBox* pMessageDialog) + : QtInstanceDialog(pMessageDialog) + , m_pMessageDialog(pMessageDialog) +{ +} + +void QtInstanceMessageDialog::set_primary_text(const rtl::OUString& rText) +{ + m_pMessageDialog->setText(toQString(rText)); +} + +void QtInstanceMessageDialog::set_secondary_text(const rtl::OUString& rText) +{ + m_pMessageDialog->setInformativeText(toQString(rText)); +} + +weld::Container* QtInstanceMessageDialog::weld_message_area() { return nullptr; } + +OUString QtInstanceMessageDialog::get_primary_text() const +{ + assert(m_pMessageDialog); + return toOUString(m_pMessageDialog->text()); +} + +OUString QtInstanceMessageDialog::get_secondary_text() const +{ + assert(m_pMessageDialog); + return toOUString(m_pMessageDialog->informativeText()); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/qt5/QtInstanceWidget.cxx b/vcl/qt5/QtInstanceWidget.cxx new file mode 100644 index 000000000000..cbccac8799db --- /dev/null +++ b/vcl/qt5/QtInstanceWidget.cxx @@ -0,0 +1,166 @@ +/* -*- 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/. + */ + +#include <QtInstanceWidget.hxx> + +void QtInstanceWidget::set_sensitive(bool) {} + +bool QtInstanceWidget::get_sensitive() const { return true; } + +bool QtInstanceWidget::get_visible() const { return true; } + +bool QtInstanceWidget::is_visible() const { return true; } + +void QtInstanceWidget::set_can_focus(bool) {} + +void QtInstanceWidget::grab_focus() {} + +bool QtInstanceWidget::has_focus() const { return true; } + +bool QtInstanceWidget::is_active() const { return true; } + +bool QtInstanceWidget::has_child_focus() const { return true; } + +void QtInstanceWidget::show() {} + +void QtInstanceWidget::hide() {} + +void QtInstanceWidget::set_size_request(int, int) {} + +Size QtInstanceWidget::get_size_request() const { return Size(); } + +Size QtInstanceWidget::get_preferred_size() const { return Size(); } + +float QtInstanceWidget::get_approximate_digit_width() const { return 1.0; } + +int QtInstanceWidget::get_text_height() const { return 1; } + +Size QtInstanceWidget::get_pixel_size(const OUString&) const { return Size(); } + +vcl::Font QtInstanceWidget::get_font() { return vcl::Font(); } + +OUString QtInstanceWidget::get_buildable_name() const { return OUString(); } + +void QtInstanceWidget::set_buildable_name(const OUString&) {} + +void QtInstanceWidget::set_help_id(const OUString&) {} + +OUString QtInstanceWidget::get_help_id() const { return OUString(); } + +void QtInstanceWidget::set_grid_left_attach(int) {} + +int QtInstanceWidget::get_grid_left_attach() const { return 1; } + +void QtInstanceWidget::set_grid_width(int) {} + +void QtInstanceWidget::set_grid_top_attach(int) {} + +int QtInstanceWidget::get_grid_top_attach() const { return 1; } + +void QtInstanceWidget::set_hexpand(bool) {} + +bool QtInstanceWidget::get_hexpand() const { return true; } + +void QtInstanceWidget::set_vexpand(bool) {} + +bool QtInstanceWidget::get_vexpand() const { return true; } + +void QtInstanceWidget::set_margin_top(int) {} + +void QtInstanceWidget::set_margin_bottom(int) {} + +void QtInstanceWidget::set_margin_start(int) {} + +void QtInstanceWidget::set_margin_end(int) {} + +int QtInstanceWidget::get_margin_top() const { return 1; } + +int QtInstanceWidget::get_margin_bottom() const { return 1; } + +int QtInstanceWidget::get_margin_start() const { return 1; } + +int QtInstanceWidget::get_margin_end() const { return 1; } + +void QtInstanceWidget::set_accessible_name(const OUString&) {} + +void QtInstanceWidget::set_accessible_description(const OUString&) {} + +OUString QtInstanceWidget::get_accessible_name() const { return OUString(); } + +OUString QtInstanceWidget::get_accessible_description() const { return OUString(); } + +void QtInstanceWidget::set_accessible_relation_labeled_by(weld::Widget*) {} + +void QtInstanceWidget::set_tooltip_text(const OUString&) {} + +OUString QtInstanceWidget::get_tooltip_text() const { return OUString(); } + +void QtInstanceWidget::set_cursor_data(void*) {} + +void QtInstanceWidget::grab_add() {} + +bool QtInstanceWidget::has_grab() const { return true; } + +void QtInstanceWidget::grab_remove() {} + +bool QtInstanceWidget::get_extents_relative_to(const Widget&, int&, int&, int&, int&) const +{ + return true; +} + +bool QtInstanceWidget::get_direction() const { return true; } + +void QtInstanceWidget::set_direction(bool) {} + +void QtInstanceWidget::freeze() {} + +void QtInstanceWidget::thaw() {} + +void QtInstanceWidget::set_busy_cursor(bool) {} + +std::unique_ptr<weld::Container> QtInstanceWidget::weld_parent() const { return nullptr; } + +void QtInstanceWidget::queue_resize() {} + +void QtInstanceWidget::help_hierarchy_foreach(const std::function<bool(const OUString&)>&) {} + +OUString QtInstanceWidget::strip_mnemonic(const OUString&) const { return OUString(); } + +VclPtr<VirtualDevice> QtInstanceWidget::create_virtual_device() const { return nullptr; } + +css::uno::Reference<css::datatransfer::dnd::XDropTarget> QtInstanceWidget::get_drop_target() +{ + return css::uno::Reference<css::datatransfer::dnd::XDropTarget>(); +} + +css::uno::Reference<css::datatransfer::clipboard::XClipboard> +QtInstanceWidget::get_clipboard() const +{ + return css::uno::Reference<css::datatransfer::clipboard::XClipboard>(); +} + +void QtInstanceWidget::connect_get_property_tree(const Link<tools::JsonWriter&, void>&) {} + +void QtInstanceWidget::get_property_tree(tools::JsonWriter&) {} + +void QtInstanceWidget::call_attention_to() {} + +void QtInstanceWidget::set_stack_background() {} + +void QtInstanceWidget::set_title_background() {} + +void QtInstanceWidget::set_toolbar_background() {} + +void QtInstanceWidget::set_highlight_background() {} + +void QtInstanceWidget::set_background(const Color&) {} + +void QtInstanceWidget::draw(OutputDevice&, const Point&, const Size&) {} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/qt5/QtInstanceWindow.cxx b/vcl/qt5/QtInstanceWindow.cxx new file mode 100644 index 000000000000..e0bf4bfdd2af --- /dev/null +++ b/vcl/qt5/QtInstanceWindow.cxx @@ -0,0 +1,70 @@ +/* -*- 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/. + */ + +#include <QtInstanceWindow.hxx> + +void QtInstanceWindow::set_title(const OUString&) {} + +OUString QtInstanceWindow::get_title() const { return OUString(); } + +void QtInstanceWindow::window_move(int, int) {} + +void QtInstanceWindow::set_modal(bool) {} + +bool QtInstanceWindow::get_modal() const { return true; } + +bool QtInstanceWindow::get_resizable() const { return true; } + +Size QtInstanceWindow::get_size() const { return Size(); } + +Point QtInstanceWindow::get_position() const { return Point(); } + +AbsoluteScreenPixelRectangle QtInstanceWindow::get_monitor_workarea() const +{ + return AbsoluteScreenPixelRectangle(); +} + +void QtInstanceWindow::set_centered_on_parent(bool) {} + +bool QtInstanceWindow::has_toplevel_focus() const { return true; } + +void QtInstanceWindow::present() {} + +void QtInstanceWindow::change_default_widget(weld::Widget*, weld::Widget*) {} + +bool QtInstanceWindow::is_default_widget(const weld::Widget*) const { return true; } + +void QtInstanceWindow::set_window_state(const OUString&) {} + +OUString QtInstanceWindow::get_window_state(vcl::WindowDataMask) const { return OUString(); } + +css::uno::Reference<css::awt::XWindow> QtInstanceWindow::GetXWindow() +{ + return css::uno::Reference<css::awt::XWindow>(); +} + +SystemEnvData QtInstanceWindow::get_system_data() const +{ + const SystemEnvData* pEnvData = nullptr; + + return *pEnvData; +} + +void QtInstanceWindow::resize_to_request() {} + +weld::ScreenShotCollection QtInstanceWindow::collect_screenshot_data() +{ + return weld::ScreenShotCollection(); +} + +VclPtr<VirtualDevice> QtInstanceWindow::screenshot() { return nullptr; } + +const vcl::ILibreOfficeKitNotifier* QtInstanceWindow::GetLOKNotifier() { return nullptr; } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/qt5/QtTools.cxx b/vcl/qt5/QtTools.cxx index 030b3af2b5a3..ef2bbd62037c 100644 --- a/vcl/qt5/QtTools.cxx +++ b/vcl/qt5/QtTools.cxx @@ -25,6 +25,8 @@ #include <vcl/event.hxx> #include <vcl/image.hxx> #include <vcl/filter/PngImageWriter.hxx> +#include <vcl/stdtext.hxx> +#include <vcl/svapp.hxx> #include <QtGui/QImage> @@ -120,4 +122,93 @@ QImage toQImage(const Image& rImage) return aImage; } +QMessageBox::Icon vclMessageTypeToQtIcon(VclMessageType eType) +{ + QMessageBox::Icon eRet = QMessageBox::Information; + switch (eType) + { + case VclMessageType::Info: + eRet = QMessageBox::Information; + break; + case VclMessageType::Warning: + eRet = QMessageBox::Warning; + break; + case VclMessageType::Question: + eRet = QMessageBox::Question; + break; + case VclMessageType::Error: + eRet = QMessageBox::Critical; + break; + case VclMessageType::Other: + eRet = QMessageBox::Information; + break; + } + return eRet; +} + +QString vclMessageTypeToQtTitle(VclMessageType eType) +{ + QString title; + switch (eType) + { + case VclMessageType::Info: + title = toQString(GetStandardInfoBoxText()); + break; + case VclMessageType::Warning: + title = toQString(GetStandardWarningBoxText()); + break; + case VclMessageType::Question: + title = toQString(GetStandardQueryBoxText()); + break; + case VclMessageType::Error: + title = toQString(GetStandardErrorBoxText()); + break; + case VclMessageType::Other: + title = toQString(Application::GetDisplayName()); + break; + } + return title; +} + +QMessageBox::StandardButtons vclButtonsTypeToQtButton(VclButtonsType eButtonType) +{ + QMessageBox::StandardButtons buttons = QMessageBox::NoButton; + switch (eButtonType) + { + case VclButtonsType::NONE: + buttons = QMessageBox::NoButton; + break; + case VclButtonsType::Ok: + buttons = QMessageBox::Ok; + break; + case VclButtonsType::Close: + buttons = QMessageBox::Close; + break; + case VclButtonsType::Cancel: + buttons = QMessageBox::Cancel; + break; + case VclButtonsType::YesNo: + buttons = QMessageBox::Yes | QMessageBox::No; + break; + case VclButtonsType::OkCancel: + buttons = QMessageBox::Ok | QMessageBox::Cancel; + break; + // Add more cases based on our needs + } + return buttons; +} + +int qtResponseTypeToVclResponseType(int ret) +{ + if (ret == QDialog::Accepted) + { + ret = RET_OK; + } + else + { + ret = RET_CANCEL; + } + return ret; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/qt6/QtInstanceContainer.cxx b/vcl/qt6/QtInstanceContainer.cxx new file mode 100644 index 000000000000..0d6e777c2ff4 --- /dev/null +++ b/vcl/qt6/QtInstanceContainer.cxx @@ -0,0 +1,12 @@ +/* -*- 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/. + */ + +#include "../qt5/QtInstanceContainer.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file diff --git a/vcl/qt6/QtInstanceDialog.cxx b/vcl/qt6/QtInstanceDialog.cxx new file mode 100644 index 000000000000..02216f08ec65 --- /dev/null +++ b/vcl/qt6/QtInstanceDialog.cxx @@ -0,0 +1,12 @@ +/* -*- 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/. + */ + +#include "../qt5/QtInstanceDialog.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file diff --git a/vcl/qt6/QtInstanceMessageDialog.cxx b/vcl/qt6/QtInstanceMessageDialog.cxx new file mode 100644 index 000000000000..3723e9b22707 --- /dev/null +++ b/vcl/qt6/QtInstanceMessageDialog.cxx @@ -0,0 +1,12 @@ +/* -*- 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/. + */ + +#include "../qt5/QtInstanceMessageDialog.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file diff --git a/vcl/qt6/QtInstanceWidget.cxx b/vcl/qt6/QtInstanceWidget.cxx new file mode 100644 index 000000000000..60da883791fb --- /dev/null +++ b/vcl/qt6/QtInstanceWidget.cxx @@ -0,0 +1,12 @@ +/* -*- 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/. + */ + +#include "../qt5/QtInstanceWidget.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file diff --git a/vcl/qt6/QtInstanceWindow.cxx b/vcl/qt6/QtInstanceWindow.cxx new file mode 100644 index 000000000000..1e1fe52374b2 --- /dev/null +++ b/vcl/qt6/QtInstanceWindow.cxx @@ -0,0 +1,12 @@ +/* -*- 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/. + */ + +#include "../qt5/QtInstanceWindow.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */