summaryrefslogtreecommitdiff
path: root/extensions
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-05-12 20:39:28 +0100
committerCaolán McNamara <caolanm@redhat.com>2020-05-13 11:55:12 +0200
commitcd211e8485eb94ea4a1783f0b8404cae2cd106a4 (patch)
treee5ca1d9e301d79e93654c4cc36652d5f197ee173 /extensions
parent3ae3fe7a5758beb0fd27ae77e1f28d7825bc1e70 (diff)
weld bibliography ComboBox control ItemWindow
Change-Id: I6d944225188d2c4bdf36b5a9c730ab770d07a246 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94096 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'extensions')
-rw-r--r--extensions/UIConfig_sbibliography.mk1
-rw-r--r--extensions/source/bibliography/toolbar.cxx77
-rw-r--r--extensions/source/bibliography/toolbar.hxx33
-rw-r--r--extensions/uiconfig/sbibliography/ui/combobox.ui40
-rw-r--r--extensions/uiconfig/sbibliography/ui/toolbar.ui15
5 files changed, 113 insertions, 53 deletions
diff --git a/extensions/UIConfig_sbibliography.mk b/extensions/UIConfig_sbibliography.mk
index 00375d9fae1e..ad359f8dee25 100644
--- a/extensions/UIConfig_sbibliography.mk
+++ b/extensions/UIConfig_sbibliography.mk
@@ -14,6 +14,7 @@ $(eval $(call gb_UIConfig_add_menubarfiles,modules/sbibliography,\
))
$(eval $(call gb_UIConfig_add_uifiles,modules/sbibliography,\
+ extensions/uiconfig/sbibliography/ui/combobox \
extensions/uiconfig/sbibliography/ui/choosedatasourcedialog \
extensions/uiconfig/sbibliography/ui/generalpage \
extensions/uiconfig/sbibliography/ui/querydialog \
diff --git a/extensions/source/bibliography/toolbar.cxx b/extensions/source/bibliography/toolbar.cxx
index 740b6984ec88..ccdc2476e884 100644
--- a/extensions/source/bibliography/toolbar.cxx
+++ b/extensions/source/bibliography/toolbar.cxx
@@ -171,10 +171,33 @@ void BibTBEditListener::statusChanged(const frame::FeatureStateEvent& rEvt)
}
}
+ComboBoxControl::ComboBoxControl(vcl::Window* pParent)
+ : InterimItemWindow(pParent, "modules/sbibliography/ui/combobox.ui", "ComboBox")
+ , m_xFtSource(m_xBuilder->weld_label("label"))
+ , m_xLBSource(m_xBuilder->weld_combo_box("combobox"))
+{
+ m_xFtSource->set_toolbar_background();
+ m_xLBSource->set_toolbar_background();
+ m_xLBSource->set_size_request(100, -1);
+ SetSizePixel(get_preferred_size());
+}
+
+void ComboBoxControl::dispose()
+{
+ m_xLBSource.reset();
+ m_xFtSource.reset();
+ InterimItemWindow::dispose();
+}
+
+ComboBoxControl::~ComboBoxControl()
+{
+ disposeOnce();
+}
+
BibToolBar::BibToolBar(vcl::Window* pParent, Link<void*,void> aLink)
: ToolBox(pParent, "toolbar", "modules/sbibliography/ui/toolbar.ui")
- , aFtSource(VclPtr<FixedText>::Create(this,WB_VCENTER))
- , aLBSource(VclPtr<ListBox>::Create(this,WB_DROPDOWN))
+ , xSource(VclPtr<ComboBoxControl>::Create(this))
+ , pLbSource(xSource->get_widget())
, aFtQuery(VclPtr<FixedText>::Create(this,WB_VCENTER))
, aEdQuery(VclPtr<Edit>::Create(this))
, pPopupMenu(VclPtr<PopupMenu>::Create())
@@ -189,12 +212,8 @@ BibToolBar::BibToolBar(vcl::Window* pParent, Link<void*,void> aLink)
nOutStyle = aSvtMiscOptions.GetToolboxStyle();
SetOutStyle(TOOLBOX_STYLE_FLAT);
- Size a2Size(GetOutputSizePixel());
- a2Size.setWidth(100 );
- aLBSource->SetSizePixel(a2Size);
- aLBSource->SetDropDownLineCount(9);
- aLBSource->Show();
- aLBSource->SetSelectHdl(LINK( this, BibToolBar, SelHdl));
+ xSource->Show();
+ pLbSource->connect_changed(LINK( this, BibToolBar, SelHdl));
SvtMiscOptions().AddListenerLink( LINK( this, BibToolBar, OptionsChanged_Impl ) );
Application::AddEventListener( LINK( this, BibToolBar, SettingsChanged_Impl ) );
@@ -204,11 +223,10 @@ BibToolBar::BibToolBar(vcl::Window* pParent, Link<void*,void> aLink)
SetDropdownClickHdl( LINK( this, BibToolBar, MenuHdl));
- aEdQuery->SetSizePixel(aLBSource->GetSizePixel());
+ aEdQuery->SetSizePixel(pLbSource->get_preferred_size());
aEdQuery->Show();
- nTBC_FT_SOURCE = GetItemId("TBC_FT_SOURCE");
- nTBC_LB_SOURCE = GetItemId(".uno:Bib/source");
+ nTBC_SOURCE = GetItemId(".uno:Bib/source");
nTBC_FT_QUERY = GetItemId("TBC_FT_QUERY");
nTBC_ED_QUERY = GetItemId(".uno:Bib/query");
nTBC_BT_AUTOFILTER = GetItemId(".uno:Bib/autoFilter");
@@ -217,18 +235,12 @@ BibToolBar::BibToolBar(vcl::Window* pParent, Link<void*,void> aLink)
nTBC_BT_FILTERCRIT = GetItemId(".uno:Bib/standardFilter");
nTBC_BT_REMOVEFILTER = GetItemId(".uno:Bib/removeFilter");
- OUString aStr = GetItemText(nTBC_FT_SOURCE);
- aFtSource->SetText(aStr);
- aFtSource->SetSizePixel(aFtSource->get_preferred_size());
- aFtSource->SetBackground(Wallpaper( COL_TRANSPARENT ));
-
- aStr=GetItemText(nTBC_FT_QUERY);
+ OUString aStr=GetItemText(nTBC_FT_QUERY);
aFtQuery->SetText(aStr);
aFtQuery->SetSizePixel(aFtQuery->get_preferred_size());
aFtQuery->SetBackground(Wallpaper( COL_TRANSPARENT ));
- SetItemWindow(nTBC_FT_SOURCE, aFtSource.get());
- SetItemWindow(nTBC_LB_SOURCE, aLBSource.get());
+ SetItemWindow(nTBC_SOURCE, xSource.get());
SetItemWindow(nTBC_FT_QUERY , aFtQuery.get());
SetItemWindow(nTBC_ED_QUERY , aEdQuery.get());
@@ -247,10 +259,9 @@ void BibToolBar::dispose()
SvtMiscOptions().RemoveListenerLink( LINK( this, BibToolBar, OptionsChanged_Impl ) );
Application::RemoveEventListener( LINK( this, BibToolBar, SettingsChanged_Impl ) );
::bib::RemoveFromTaskPaneList( this );
- aFtSource.disposeAndClear();
aFtQuery.disposeAndClear();
aEdQuery.disposeAndClear();
- aLBSource.disposeAndClear();
+ xSource.disposeAndClear();
ToolBox::dispose();
}
@@ -272,7 +283,7 @@ void BibToolBar::InitListener()
for(ToolBox::ImplToolItems::size_type nPos=0;nPos<nCount;nPos++)
{
sal_uInt16 nId=GetItemId(nPos);
- if(!nId || nId== nTBC_FT_SOURCE || nId == nTBC_FT_QUERY)
+ if(!nId || nId == nTBC_FT_QUERY)
continue;
util::URL aURL;
@@ -283,7 +294,7 @@ void BibToolBar::InitListener()
xTrans->parseStrict( aURL );
css::uno::Reference< css::frame::XStatusListener> xListener;
- if (nId == nTBC_LB_SOURCE)
+ if (nId == nTBC_SOURCE)
{
xListener=new BibTBListBoxListener(this,aURL.Complete,nId);
}
@@ -401,28 +412,30 @@ void BibToolBar::SelectFilterItem(sal_uInt16 nId)
void BibToolBar::EnableSourceList(bool bFlag)
{
- aFtSource->Enable(bFlag);
- aLBSource->Enable(bFlag);
+ xSource->set_sensitive(bFlag);
}
void BibToolBar::ClearSourceList()
{
- aLBSource->Clear();
+ pLbSource->clear();
}
void BibToolBar::UpdateSourceList(bool bFlag)
{
- aLBSource->SetUpdateMode(bFlag);
+ if (bFlag)
+ pLbSource->thaw();
+ else
+ pLbSource->freeze();
}
void BibToolBar::InsertSourceEntry(const OUString& aEntry)
{
- aLBSource->InsertEntry(aEntry);
+ pLbSource->append_text(aEntry);
}
void BibToolBar::SelectSourceEntry(const OUString& aStr)
{
- aLBSource->SelectEntry(aStr);
+ pLbSource->set_active_text(aStr);
}
void BibToolBar::EnableQuery(bool bFlag)
@@ -466,7 +479,7 @@ bool BibToolBar::PreNotify( NotifyEvent& rNEvt )
return bResult;
}
-IMPL_LINK_NOARG( BibToolBar, SelHdl, ListBox&, void )
+IMPL_LINK_NOARG( BibToolBar, SelHdl, weld::ComboBox&, void )
{
aIdle.Start();
}
@@ -476,9 +489,9 @@ IMPL_LINK_NOARG( BibToolBar, SendSelHdl, Timer*, void )
Sequence<PropertyValue> aPropVal(1);
PropertyValue* pPropertyVal = const_cast<PropertyValue*>(aPropVal.getConstArray());
pPropertyVal[0].Name = "DataSourceName";
- OUString aEntry( MnemonicGenerator::EraseAllMnemonicChars( aLBSource->GetSelectedEntry() ) );
+ OUString aEntry( MnemonicGenerator::EraseAllMnemonicChars( pLbSource->get_active_text() ) );
pPropertyVal[0].Value <<= aEntry;
- SendDispatch(nTBC_LB_SOURCE, aPropVal);
+ SendDispatch(nTBC_SOURCE, aPropVal);
}
IMPL_LINK_NOARG( BibToolBar, MenuHdl, ToolBox*, void)
diff --git a/extensions/source/bibliography/toolbar.hxx b/extensions/source/bibliography/toolbar.hxx
index 810445e85c7e..34a4db9a867b 100644
--- a/extensions/source/bibliography/toolbar.hxx
+++ b/extensions/source/bibliography/toolbar.hxx
@@ -23,9 +23,8 @@
#include <com/sun/star/frame/XController.hpp>
#include <com/sun/star/frame/XStatusListener.hpp>
-
+#include <svtools/InterimItemWindow.hxx>
#include <vcl/toolbox.hxx>
-#include <vcl/lstbox.hxx>
#include <vcl/edit.hxx>
#include <vcl/fixed.hxx>
#include <vcl/timer.hxx>
@@ -98,6 +97,27 @@ public:
typedef std::vector< css::uno::Reference< css::frame::XStatusListener> > BibToolBarListenerArr;
+class ComboBoxControl final : public InterimItemWindow
+{
+public:
+ ComboBoxControl(vcl::Window* pParent);
+ virtual ~ComboBoxControl() override;
+ virtual void dispose() override;
+
+ weld::ComboBox* get_widget() { return m_xLBSource.get(); }
+
+ void set_sensitive(bool bSensitive)
+ {
+ m_xFtSource->set_sensitive(bSensitive);
+ m_xLBSource->set_sensitive(bSensitive);
+ Enable(bSensitive);
+ }
+
+private:
+ std::unique_ptr<weld::Label> m_xFtSource;
+ std::unique_ptr<weld::ComboBox> m_xLBSource;
+};
+
class BibToolBar: public ToolBox
{
private:
@@ -105,8 +125,8 @@ class BibToolBar: public ToolBox
BibToolBarListenerArr aListenerArr;
css::uno::Reference< css::frame::XController > xController;
Idle aIdle;
- VclPtr<FixedText> aFtSource;
- VclPtr<ListBox> aLBSource;
+ VclPtr<ComboBoxControl> xSource;
+ weld::ComboBox* pLbSource;
VclPtr<FixedText> aFtQuery;
VclPtr<Edit> aEdQuery;
ScopedVclPtr<PopupMenu> pPopupMenu;
@@ -117,8 +137,7 @@ class BibToolBar: public ToolBox
sal_Int16 nSymbolsSize;
sal_Int16 nOutStyle;
- sal_uInt16 nTBC_FT_SOURCE;
- sal_uInt16 nTBC_LB_SOURCE;
+ sal_uInt16 nTBC_SOURCE;
sal_uInt16 nTBC_FT_QUERY;
sal_uInt16 nTBC_ED_QUERY;
sal_uInt16 nTBC_BT_AUTOFILTER;
@@ -128,7 +147,7 @@ class BibToolBar: public ToolBox
sal_uInt16 nTBC_BT_REMOVEFILTER;
BibDataManager* pDatMan;
- DECL_LINK( SelHdl, ListBox&, void );
+ DECL_LINK( SelHdl, weld::ComboBox&, void );
DECL_LINK( SendSelHdl, Timer*, void );
DECL_LINK( MenuHdl, ToolBox*, void );
DECL_LINK( OptionsChanged_Impl, LinkParamNone*, void );
diff --git a/extensions/uiconfig/sbibliography/ui/combobox.ui b/extensions/uiconfig/sbibliography/ui/combobox.ui
new file mode 100644
index 000000000000..ff2e4b47d367
--- /dev/null
+++ b/extensions/uiconfig/sbibliography/ui/combobox.ui
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.2 -->
+<interface domain="svt">
+ <requires lib="gtk+" version="3.18"/>
+ <object class="GtkBox" id="ComboBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_left">6</property>
+ <property name="margin_right">6</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="valign">center</property>
+ <property name="label" translatable="yes" context="combobox|TBC_FT_SOURCE">Table</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">combobox</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBoxText" id="combobox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="valign">center</property>
+ <property name="hexpand">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+</interface>
diff --git a/extensions/uiconfig/sbibliography/ui/toolbar.ui b/extensions/uiconfig/sbibliography/ui/toolbar.ui
index 87eed09f0a8a..748ff95e69e4 100644
--- a/extensions/uiconfig/sbibliography/ui/toolbar.ui
+++ b/extensions/uiconfig/sbibliography/ui/toolbar.ui
@@ -7,20 +7,7 @@
<property name="can_focus">False</property>
<property name="show_arrow">False</property>
<child>
- <object class="GtkToolButton" id="TBC_FT_SOURCE">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="action_name">TBC_FT_SOURCE</property>
- <property name="label" translatable="yes" context="toolbar|TBC_FT_SOURCE">Table</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolButton" id="TBC_LB_SOURCE">
+ <object class="GtkToolButton" id="TBC_SOURCE">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="action_name">.uno:Bib/source</property>