summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-02-07 11:57:21 +0000
committerCaolán McNamara <caolanm@redhat.com>2020-02-07 15:30:15 +0100
commit91f54b1990153efd17ea5e33feffd1ec16b0387b (patch)
tree367bc38c21223a91f4089a408b5c8d0ae2254974 /sfx2
parent30ab660b07ab9aa72624a728d9e1f963507def7c (diff)
weld URLBox ItemWindow
Change-Id: I7dad000404a188e2f5588b90d73ea9b1236bd301 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88183 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/UIConfig_sfx.mk1
-rw-r--r--sfx2/inc/inettbc.hxx13
-rw-r--r--sfx2/source/inet/inettbc.cxx106
-rw-r--r--sfx2/uiconfig/ui/urlbox.ui29
4 files changed, 120 insertions, 29 deletions
diff --git a/sfx2/UIConfig_sfx.mk b/sfx2/UIConfig_sfx.mk
index af7247dd9e6d..15ccbcc24116 100644
--- a/sfx2/UIConfig_sfx.mk
+++ b/sfx2/UIConfig_sfx.mk
@@ -60,6 +60,7 @@ $(eval $(call gb_UIConfig_add_uifiles,sfx,\
sfx2/uiconfig/ui/templatedlg \
sfx2/uiconfig/ui/saveastemplatedlg \
sfx2/uiconfig/ui/templatecategorydlg \
+ sfx2/uiconfig/ui/urlbox \
sfx2/uiconfig/ui/versionsofdialog \
sfx2/uiconfig/ui/versioncommentdialog \
sfx2/uiconfig/ui/versionscmis \
diff --git a/sfx2/inc/inettbc.hxx b/sfx2/inc/inettbc.hxx
index 10bbf353fde3..d9c8f52a31c4 100644
--- a/sfx2/inc/inettbc.hxx
+++ b/sfx2/inc/inettbc.hxx
@@ -23,18 +23,21 @@
#include <rtl/ustring.hxx>
#include <sfx2/tbxctrl.hxx>
-class ComboBox;
-class SvtURLBox;
+namespace weld { class ComboBox; };
+class URLBoxItemWindow;
+class URLBox;
class SfxURLToolBoxControl_Impl final : public SfxToolBoxControl
{
private:
+ bool m_bModified;
- SvtURLBox* GetURLBox() const;
+ URLBox* GetURLBox() const;
+ URLBoxItemWindow* GetURLBoxItemWindow() const;
void OpenURL( const OUString& rName ) const;
- DECL_LINK( OpenHdl, SvtURLBox*, void );
- DECL_LINK( SelectHdl, ComboBox&, void );
+ DECL_LINK(OpenHdl, weld::ComboBox&, bool);
+ DECL_LINK(SelectHdl, weld::ComboBox&, void);
struct ExecuteInfo
{
diff --git a/sfx2/source/inet/inettbc.cxx b/sfx2/source/inet/inettbc.cxx
index c97e9d59bedf..283f0668cebd 100644
--- a/sfx2/source/inet/inettbc.cxx
+++ b/sfx2/source/inet/inettbc.cxx
@@ -34,6 +34,7 @@
#include <svtools/inettbc.hxx>
+#include <sfx2/InterimItemWindow.hxx>
#include <sfx2/sfxsids.hrc>
using namespace ::com::sun::star::uno;
@@ -50,6 +51,7 @@ SFX_IMPL_TOOLBOX_CONTROL(SfxURLToolBoxControl_Impl,SfxStringItem)
SfxURLToolBoxControl_Impl::SfxURLToolBoxControl_Impl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rBox )
: SfxToolBoxControl( nSlotId, nId, rBox )
+ , m_bModified(false)
{
addStatusListener( ".uno:CurrentURL");
}
@@ -58,11 +60,64 @@ SfxURLToolBoxControl_Impl::~SfxURLToolBoxControl_Impl()
{
}
-SvtURLBox* SfxURLToolBoxControl_Impl::GetURLBox() const
+class URLBoxItemWindow final : public InterimItemWindow
{
- return static_cast<SvtURLBox*>(GetToolBox().GetItemWindow( GetId() ));
+private:
+ std::unique_ptr<URLBox> m_xWidget;
+
+ DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
+public:
+ URLBoxItemWindow(vcl::Window* pParent)
+ : InterimItemWindow(pParent, "sfx/ui/urlbox.ui", "URLBox")
+ , m_xWidget(new URLBox(m_xBuilder->weld_combo_box("urlbox")))
+ {
+ m_xWidget->connect_key_press(LINK(this, URLBoxItemWindow, KeyInputHdl));
+
+ SetSizePixel(m_xWidget->get_preferred_size());
+ }
+
+ URLBox* GetURLBox()
+ {
+ return m_xWidget.get();
+ }
+
+ virtual void dispose() override
+ {
+ m_xWidget.reset();
+ InterimItemWindow::dispose();
+ }
+
+ virtual void GetFocus() override
+ {
+ m_xWidget->grab_focus();
+ }
+
+ void set_sensitive(bool bSensitive)
+ {
+ Enable(bSensitive);
+ m_xWidget->set_sensitive(bSensitive);
+ }
+
+ virtual ~URLBoxItemWindow() override
+ {
+ disposeOnce();
+ }
+};
+
+IMPL_LINK(URLBoxItemWindow, KeyInputHdl, const KeyEvent&, rKEvt, bool)
+{
+ return ChildKeyInput(rKEvt);
+}
+
+URLBoxItemWindow* SfxURLToolBoxControl_Impl::GetURLBoxItemWindow() const
+{
+ return static_cast<URLBoxItemWindow*>(GetToolBox().GetItemWindow(GetId()));
}
+URLBox* SfxURLToolBoxControl_Impl::GetURLBox() const
+{
+ return GetURLBoxItemWindow()->GetURLBox();
+}
void SfxURLToolBoxControl_Impl::OpenURL( const OUString& rName ) const
{
@@ -132,27 +187,29 @@ IMPL_STATIC_LINK( SfxURLToolBoxControl_Impl, ExecuteHdl_Impl, void*, p, void )
delete pExecuteInfo;
}
-
VclPtr<vcl::Window> SfxURLToolBoxControl_Impl::CreateItemWindow( vcl::Window* pParent )
{
- VclPtrInstance<SvtURLBox> pURLBox( pParent );
- pURLBox->SetOpenHdl( LINK( this, SfxURLToolBoxControl_Impl, OpenHdl ) );
- pURLBox->SetSelectHdl( LINK( this, SfxURLToolBoxControl_Impl, SelectHdl ) );
- return pURLBox.get();
+ VclPtrInstance<URLBoxItemWindow> xURLBox(pParent);
+ URLBox* pURLBox = xURLBox->GetURLBox();
+ pURLBox->connect_changed(LINK(this, SfxURLToolBoxControl_Impl, SelectHdl));
+ pURLBox->connect_entry_activate(LINK(this, SfxURLToolBoxControl_Impl, OpenHdl));
+ return xURLBox;
}
-IMPL_LINK_NOARG(SfxURLToolBoxControl_Impl, SelectHdl, ComboBox&, void)
+IMPL_LINK(SfxURLToolBoxControl_Impl, SelectHdl, weld::ComboBox&, rComboBox, void)
{
- SvtURLBox* pURLBox = GetURLBox();
+ m_bModified = true;
+
+ URLBox* pURLBox = GetURLBox();
OUString aName( pURLBox->GetURL() );
- if ( !pURLBox->IsTravelSelect() && !aName.isEmpty() )
+ if (rComboBox.changed_by_menu() && !aName.isEmpty())
OpenURL( aName );
}
-IMPL_LINK_NOARG(SfxURLToolBoxControl_Impl, OpenHdl, SvtURLBox*, void)
+IMPL_LINK_NOARG(SfxURLToolBoxControl_Impl, OpenHdl, weld::ComboBox&, bool)
{
- SvtURLBox* pURLBox = GetURLBox();
+ URLBox* pURLBox = GetURLBox();
OpenURL( pURLBox->GetURL() );
Reference< XDesktop2 > xDesktop = Desktop::create( m_xContext );
@@ -166,8 +223,9 @@ IMPL_LINK_NOARG(SfxURLToolBoxControl_Impl, OpenHdl, SvtURLBox*, void)
pWin->ToTop( ToTopFlags::RestoreWhenMin );
}
}
-}
+ return true;
+}
void SfxURLToolBoxControl_Impl::StateChanged
(
@@ -179,21 +237,21 @@ void SfxURLToolBoxControl_Impl::StateChanged
if ( nSID == SID_OPENURL )
{
// Disable URL box if command is disabled
- GetURLBox()->Enable( SfxItemState::DISABLED != eState );
+ GetURLBoxItemWindow()->set_sensitive( SfxItemState::DISABLED != eState );
}
- if ( !GetURLBox()->IsEnabled() )
+ if ( !GetURLBoxItemWindow()->IsEnabled() )
return;
if( nSID == SID_FOCUSURLBOX )
{
- if ( GetURLBox()->IsVisible() )
- GetURLBox()->GrabFocus();
+ if ( GetURLBoxItemWindow()->IsVisible() )
+ GetURLBoxItemWindow()->GrabFocus();
}
- else if ( !GetURLBox()->IsModified() && SfxItemState::DEFAULT == eState )
+ else if ( !m_bModified && SfxItemState::DEFAULT == eState )
{
- SvtURLBox* pURLBox = GetURLBox();
- pURLBox->Clear();
+ URLBox* pURLBox = GetURLBox();
+ pURLBox->clear();
const css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > lList = SvtHistoryOptions().GetList(ePICKLIST);
for (const css::uno::Sequence< css::beans::PropertyValue >& lProps : lList)
@@ -212,9 +270,9 @@ void SfxURLToolBoxControl_Impl::StateChanged
OUString sFile;
if (osl::FileBase::getSystemPathFromFileURL(sMainURL, sFile) == osl::FileBase::E_None)
- pURLBox->InsertEntry(sFile);
+ pURLBox->append_text(sFile);
else
- pURLBox->InsertEntry(sMainURL);
+ pURLBox->append_text(sMainURL);
}
}
@@ -224,10 +282,10 @@ void SfxURLToolBoxControl_Impl::StateChanged
INetProtocol eProt = aURL.GetProtocol();
if ( eProt == INetProtocol::File )
{
- pURLBox->SetText( aURL.PathToFileName() );
+ pURLBox->set_entry_text( aURL.PathToFileName() );
}
else
- pURLBox->SetText( aURL.GetURLNoPass() );
+ pURLBox->set_entry_text( aURL.GetURLNoPass() );
}
}
diff --git a/sfx2/uiconfig/ui/urlbox.ui b/sfx2/uiconfig/ui/urlbox.ui
new file mode 100644
index 000000000000..75079a12149c
--- /dev/null
+++ b/sfx2/uiconfig/ui/urlbox.ui
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
+<interface domain="sfx">
+ <requires lib="gtk+" version="3.18"/>
+ <object class="GtkBox" id="URLBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkComboBoxText" id="urlbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="has_entry">True</property>
+ <child internal-child="entry">
+ <object class="GtkEntry">
+ <property name="can_focus">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+</interface>