summaryrefslogtreecommitdiff
path: root/sfx2/inc/commandpopup
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2018-05-22 14:44:39 +0900
committerTomaž Vajngerl <quikee@gmail.com>2021-05-11 16:08:36 +0200
commit83d91ebbbda2204af9a09a921055a850a16911e0 (patch)
treed18f2aca19fbc9d14e8c82392fdd61cef86276c8 /sfx2/inc/commandpopup
parent0409c4f5de99a125865af0323036516eb62c5a73 (diff)
tdf#91874 Command Popup - HUD to search and run LO commands
This adds Command Popup functionality, which is a HUD like pop-up window, which can be used to search and run commands presented in the main menu (but not limited to that only). This is the initial version, which has limitation in searching and running the command (doesn't work for some currently). Change-Id: I92cdd3130b8de42ee0863c9e7154e7c7246d9377 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115380 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sfx2/inc/commandpopup')
-rw-r--r--sfx2/inc/commandpopup/CommandPopup.hxx104
1 files changed, 104 insertions, 0 deletions
diff --git a/sfx2/inc/commandpopup/CommandPopup.hxx b/sfx2/inc/commandpopup/CommandPopup.hxx
new file mode 100644
index 000000000000..6344f9253b94
--- /dev/null
+++ b/sfx2/inc/commandpopup/CommandPopup.hxx
@@ -0,0 +1,104 @@
+/* -*- 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 <vcl/layout.hxx>
+
+#include <sfx2/dllapi.h>
+#include <sfx2/viewfrm.hxx>
+
+#include <vcl/weld.hxx>
+#include <vcl/window.hxx>
+
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+
+struct CurrentEntry final
+{
+ OUString m_aCommandURL;
+ OUString m_aTooltip;
+
+ CurrentEntry(OUString const& rCommandURL, OUString const& rTooltip)
+ : m_aCommandURL(rCommandURL)
+ , m_aTooltip(rTooltip)
+ {
+ }
+};
+
+struct MenuContent final
+{
+ OUString m_aCommandURL;
+ OUString m_aMenuLabel;
+ OUString m_aFullLabelWithPath;
+ OUString m_aTooltip;
+ std::vector<MenuContent> m_aSubMenuContent;
+};
+
+class MenuContentHandler final
+{
+private:
+ css::uno::Reference<css::frame::XFrame> m_xFrame;
+ MenuContent m_aMenuContent;
+ OUString m_sModuleLongName;
+
+public:
+ MenuContentHandler(css::uno::Reference<css::frame::XFrame> const& xFrame);
+
+ void gatherMenuContent(css::uno::Reference<css::container::XIndexAccess> const& xIndexAccess,
+ MenuContent& rMenuContent);
+
+ void findInMenu(OUString const& rText, std::unique_ptr<weld::TreeView>& rpCommandTreeView,
+ std::vector<CurrentEntry>& rCommandList);
+
+private:
+ void findInMenuRecursive(MenuContent const& rMenuContent, OUString const& rText,
+ std::unique_ptr<weld::TreeView>& rpCommandTreeView,
+ std::vector<CurrentEntry>& rCommandList);
+};
+
+class SFX2_DLLPUBLIC CommandListBox final
+{
+private:
+ std::unique_ptr<weld::Builder> mxBuilder;
+ std::unique_ptr<weld::Popover> mxPopover;
+ std::unique_ptr<weld::Entry> mpEntry;
+ std::unique_ptr<weld::TreeView> mpCommandTreeView;
+
+ std::vector<CurrentEntry> maCommandList;
+ OUString m_PreviousText;
+ std::unique_ptr<MenuContentHandler> mpMenuContentHandler;
+
+ DECL_LINK(QueryTooltip, const weld::TreeIter&, OUString);
+ DECL_LINK(RowActivated, weld::TreeView&, bool);
+ DECL_LINK(ModifyHdl, weld::Entry&, void);
+ DECL_LINK(SelectionChanged, weld::TreeView&, void);
+ DECL_LINK(TreeViewKeyPress, const KeyEvent&, bool);
+
+ void dispatchCommandAndClose(OUString const& rCommand);
+
+public:
+ CommandListBox(weld::Window* pParent, css::uno::Reference<css::frame::XFrame> const& xFrame);
+ void connect_closed(const Link<weld::Popover&, void>& rLink)
+ {
+ mxPopover->connect_closed(rLink);
+ }
+};
+
+class SFX2_DLLPUBLIC CommandPopupHandler final
+{
+private:
+ std::unique_ptr<CommandListBox> mpListBox;
+
+public:
+ void showPopup(weld::Window* pParent, css::uno::Reference<css::frame::XFrame> const& xFrame);
+ DECL_LINK(PopupModeEnd, weld::Popover&, void);
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */