tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / include / svtools / inettbc.hxx
bloba4dcb5836228e0b0675712aba75fb83b64bcd839
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 <memory>
23 #include <rtl/ref.hxx>
24 #include <svtools/svtdllapi.h>
25 #include <tools/urlobj.hxx>
27 #include <vcl/idle.hxx>
28 #include <vcl/weld.hxx>
30 class SvtMatchContext_Impl;
31 class SvtURLBox_Impl;
33 class SVT_DLLPUBLIC SvtURLBox
35 friend class SvtMatchContext_Impl;
36 friend class SvtURLBox_Impl;
38 Idle aChangedIdle;
39 OUString aBaseURL;
40 OUString aPlaceHolder;
41 rtl::Reference<SvtMatchContext_Impl> pCtx;
42 std::unique_ptr<SvtURLBox_Impl> pImpl;
43 INetProtocol eSmartProtocol;
44 bool bOnlyDirectories : 1;
45 bool bHistoryDisabled : 1;
46 bool bNoSelection : 1;
48 Link<weld::ComboBox&, void> aChangeHdl;
49 Link<weld::Widget&, void> aFocusInHdl;
50 Link<weld::Widget&, void> aFocusOutHdl;
52 std::unique_ptr<weld::ComboBox> m_xWidget;
54 DECL_DLLPRIVATE_LINK( TryAutoComplete, Timer*, void);
55 SVT_DLLPRIVATE void UpdatePicklistForSmartProtocol_Impl();
56 DECL_DLLPRIVATE_LINK( ChangedHdl, weld::ComboBox&, void);
57 DECL_DLLPRIVATE_LINK( FocusInHdl, weld::Widget&, void);
58 DECL_DLLPRIVATE_LINK( FocusOutHdl, weld::Widget&, void);
59 SVT_DLLPRIVATE void Init();
61 public:
62 SvtURLBox(std::unique_ptr<weld::ComboBox> xWidget);
63 ~SvtURLBox();
65 void set_entry_text(const OUString& rStr) { m_xWidget->set_entry_text(rStr); }
66 void show() { m_xWidget->show(); }
67 void clear() { m_xWidget->clear(); }
68 void connect_entry_activate(const Link<weld::ComboBox&, bool>& rLink) { m_xWidget->connect_entry_activate(rLink); }
69 void connect_key_press(const Link<const KeyEvent&, bool>& rLink) { m_xWidget->connect_key_press(rLink); }
70 void connect_changed(const Link<weld::ComboBox&, void>& rLink) { aChangeHdl = rLink; }
71 void trigger_changed() { aChangeHdl.Call(*m_xWidget); }
72 void connect_focus_in(const Link<weld::Widget&, void>& rLink) { aFocusInHdl = rLink; }
73 void connect_focus_out(const Link<weld::Widget&, void>& rLink) { aFocusOutHdl = rLink; }
74 void append_text(const OUString& rStr) { m_xWidget->append_text(rStr); }
75 int find_text(const OUString& rStr) const { return m_xWidget->find_text(rStr); }
76 OUString get_active_text() const { return m_xWidget->get_active_text(); }
77 void grab_focus() { m_xWidget->grab_focus(); }
78 void set_sensitive(bool bSensitive) { m_xWidget->set_sensitive(bSensitive); }
79 void set_help_id(const OUString& rHelpId) { m_xWidget->set_help_id(rHelpId); }
80 void select_entry_region(int nStartPos, int nEndPos) { m_xWidget->select_entry_region(nStartPos, nEndPos); }
81 Size get_preferred_size() const { return m_xWidget->get_preferred_size(); }
83 void EnableAutocomplete(bool bEnable = true) { m_xWidget->set_entry_completion(bEnable); }
84 void SetBaseURL( const OUString& rURL );
85 const OUString& GetBaseURL() const { return aBaseURL; }
86 void SetOnlyDirectories( bool bDir );
87 void SetNoURLSelection( bool bSet );
88 void SetSmartProtocol( INetProtocol eProt );
89 INetProtocol GetSmartProtocol() const { return eSmartProtocol; }
90 OUString GetURL();
91 void DisableHistory();
93 weld::ComboBox* getWidget() { return m_xWidget.get(); }
95 static OUString ParseSmart( const OUString& aText, const OUString& aBaseURL );
97 void SetPlaceHolder(const OUString& sPlaceHolder) { aPlaceHolder = sPlaceHolder; }
98 const OUString& GetPlaceHolder() const { return aPlaceHolder; }
99 bool MatchesPlaceHolder(std::u16string_view sToMatch) const
101 return (!aPlaceHolder.isEmpty() && aPlaceHolder == sToMatch);
104 void SetFilter(std::u16string_view _sFilter);
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */