Kaydet (Commit) 358c94ee authored tarafından Caolán McNamara's avatar Caolán McNamara

weld OfaSmartTagOptionsTabPage

Change-Id: I34b6c654e65fa827e8efc8fd6ba97dc73d15df17
Reviewed-on: https://gerrit.libreoffice.org/64505
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst c61b6668
...@@ -422,9 +422,9 @@ class OfaSmartTagOptionsTabPage : public SfxTabPage ...@@ -422,9 +422,9 @@ class OfaSmartTagOptionsTabPage : public SfxTabPage
private: private:
// controls // controls
VclPtr<CheckBox> m_pMainCB; std::unique_ptr<weld::CheckButton> m_xMainCB;
VclPtr<SvxCheckListBox> m_pSmartTagTypesLB; std::unique_ptr<weld::TreeView> m_xSmartTagTypesLB;
VclPtr<PushButton> m_pPropertiesPB; std::unique_ptr<weld::Button> m_xPropertiesPB;
/** Inserts items into m_aSmartTagTypesLB /** Inserts items into m_aSmartTagTypesLB
...@@ -442,27 +442,26 @@ private: ...@@ -442,27 +442,26 @@ private:
Enables/disables all controls in the tab page (except from the Enables/disables all controls in the tab page (except from the
check box. check box.
*/ */
DECL_LINK(CheckHdl, CheckBox&, void); DECL_LINK(CheckHdl, weld::ToggleButton&, void);
/** Handler for the push button /** Handler for the push button
Calls the displayPropertyPage function of the smart tag recognizer Calls the displayPropertyPage function of the smart tag recognizer
associated with the currently selected smart tag type. associated with the currently selected smart tag type.
*/ */
DECL_LINK(ClickHdl, Button*, void); DECL_LINK(ClickHdl, weld::Button&, void);
/** Handler for the list box /** Handler for the list box
Enables/disables the properties push button if selection in the Enables/disables the properties push button if selection in the
smart tag types list box changes. smart tag types list box changes.
*/ */
DECL_LINK(SelectHdl, SvTreeListBox*, void); DECL_LINK(SelectHdl, weld::TreeView&, void);
public: public:
/// construction via Create() /// construction via Create()
OfaSmartTagOptionsTabPage( vcl::Window* pParent, const SfxItemSet& rSet ); OfaSmartTagOptionsTabPage(TabPageParent pParent, const SfxItemSet& rSet);
virtual ~OfaSmartTagOptionsTabPage() override; virtual ~OfaSmartTagOptionsTabPage() override;
virtual void dispose() override;
static VclPtr<SfxTabPage> Create( TabPageParent pParent, const SfxItemSet* rAttrSet); static VclPtr<SfxTabPage> Create( TabPageParent pParent, const SfxItemSet* rAttrSet);
......
...@@ -2233,25 +2233,24 @@ IMPL_LINK(OfaAutoCompleteTabPage, KeyReleaseHdl, const KeyEvent&, rEvent, bool) ...@@ -2233,25 +2233,24 @@ IMPL_LINK(OfaAutoCompleteTabPage, KeyReleaseHdl, const KeyEvent&, rEvent, bool)
// class OfaSmartTagOptionsTabPage --------------------------------------------- // class OfaSmartTagOptionsTabPage ---------------------------------------------
OfaSmartTagOptionsTabPage::OfaSmartTagOptionsTabPage( vcl::Window* pParent, OfaSmartTagOptionsTabPage::OfaSmartTagOptionsTabPage(TabPageParent pParent,
const SfxItemSet& rSet ) const SfxItemSet& rSet )
: SfxTabPage(pParent, "SmartTagOptionsPage", "cui/ui/smarttagoptionspage.ui", &rSet) : SfxTabPage(pParent, "cui/ui/smarttagoptionspage.ui", "SmartTagOptionsPage", &rSet)
, m_xMainCB(m_xBuilder->weld_check_button("main"))
, m_xSmartTagTypesLB(m_xBuilder->weld_tree_view("list"))
, m_xPropertiesPB(m_xBuilder->weld_button("properties"))
{ {
get(m_pMainCB, "main"); m_xSmartTagTypesLB->set_size_request(m_xSmartTagTypesLB->get_approximate_digit_width() * 50,
get(m_pSmartTagTypesLB, "list"); m_xSmartTagTypesLB->get_height_rows(6));
get(m_pPropertiesPB, "properties");
// some options for the list box: std::vector<int> aWidths;
m_pSmartTagTypesLB->SetStyle( m_pSmartTagTypesLB->GetStyle() | WB_HSCROLL | WB_HIDESELECTION ); aWidths.push_back(m_xSmartTagTypesLB->get_approximate_digit_width() * 3 + 6);
m_pSmartTagTypesLB->SetHighlightRange(); m_xSmartTagTypesLB->set_column_fixed_widths(aWidths);
Size aControlSize(LogicToPixel(Size(172, 154), MapMode(MapUnit::MapAppFont)));
m_pSmartTagTypesLB->set_width_request(aControlSize.Width());
m_pSmartTagTypesLB->set_height_request(aControlSize.Height());
// set the handlers: // set the handlers:
m_pMainCB->SetToggleHdl(LINK(this, OfaSmartTagOptionsTabPage, CheckHdl)); m_xMainCB->connect_toggled(LINK(this, OfaSmartTagOptionsTabPage, CheckHdl));
m_pPropertiesPB->SetClickHdl(LINK(this, OfaSmartTagOptionsTabPage, ClickHdl)); m_xPropertiesPB->connect_clicked(LINK(this, OfaSmartTagOptionsTabPage, ClickHdl));
m_pSmartTagTypesLB->SetSelectHdl(LINK(this, OfaSmartTagOptionsTabPage, SelectHdl)); m_xSmartTagTypesLB->connect_changed(LINK(this, OfaSmartTagOptionsTabPage, SelectHdl));
} }
OfaSmartTagOptionsTabPage::~OfaSmartTagOptionsTabPage() OfaSmartTagOptionsTabPage::~OfaSmartTagOptionsTabPage()
...@@ -2259,17 +2258,9 @@ OfaSmartTagOptionsTabPage::~OfaSmartTagOptionsTabPage() ...@@ -2259,17 +2258,9 @@ OfaSmartTagOptionsTabPage::~OfaSmartTagOptionsTabPage()
disposeOnce(); disposeOnce();
} }
void OfaSmartTagOptionsTabPage::dispose() VclPtr<SfxTabPage> OfaSmartTagOptionsTabPage::Create(TabPageParent pParent, const SfxItemSet* rSet)
{
m_pMainCB.clear();
m_pSmartTagTypesLB.clear();
m_pPropertiesPB.clear();
SfxTabPage::dispose();
}
VclPtr<SfxTabPage> OfaSmartTagOptionsTabPage::Create( TabPageParent pParent, const SfxItemSet* rSet)
{ {
return VclPtr<OfaSmartTagOptionsTabPage>::Create( pParent.pParent, *rSet ); return VclPtr<OfaSmartTagOptionsTabPage>::Create(pParent, *rSet);
} }
/** This struct is used to associate list box entries with smart tag data /** This struct is used to associate list box entries with smart tag data
...@@ -2288,22 +2279,21 @@ struct ImplSmartTagLBUserData ...@@ -2288,22 +2279,21 @@ struct ImplSmartTagLBUserData
mnSmartTagIdx( nSmartTagIdx ) {} mnSmartTagIdx( nSmartTagIdx ) {}
}; };
/** Clears m_pSmartTagTypesLB /** Clears m_xSmartTagTypesLB
*/ */
void OfaSmartTagOptionsTabPage::ClearListBox() void OfaSmartTagOptionsTabPage::ClearListBox()
{ {
const sal_uLong nCount = m_pSmartTagTypesLB->GetEntryCount(); const int nCount = m_xSmartTagTypesLB->n_children();
for ( sal_uLong i = 0; i < nCount; ++i ) for (int i = 0; i < nCount; ++i)
{ {
const SvTreeListEntry* pEntry = m_pSmartTagTypesLB->GetEntry(i); const ImplSmartTagLBUserData* pUserData = reinterpret_cast<ImplSmartTagLBUserData*>(m_xSmartTagTypesLB->get_id(i).toInt64());
const ImplSmartTagLBUserData* pUserData = static_cast< ImplSmartTagLBUserData* >(pEntry->GetUserData());
delete pUserData; delete pUserData;
} }
m_pSmartTagTypesLB->Clear(); m_xSmartTagTypesLB->clear();
} }
/** Inserts items into m_pSmartTagTypesLB /** Inserts items into m_xSmartTagTypesLB
*/ */
void OfaSmartTagOptionsTabPage::FillListBox( const SmartTagMgr& rSmartTagMgr ) void OfaSmartTagOptionsTabPage::FillListBox( const SmartTagMgr& rSmartTagMgr )
{ {
...@@ -2331,24 +2321,23 @@ void OfaSmartTagOptionsTabPage::FillListBox( const SmartTagMgr& rSmartTagMgr ) ...@@ -2331,24 +2321,23 @@ void OfaSmartTagOptionsTabPage::FillListBox( const SmartTagMgr& rSmartTagMgr )
const OUString aLBEntry = aSmartTagCaption + " (" + aName + ")"; const OUString aLBEntry = aSmartTagCaption + " (" + aName + ")";
SvTreeListEntry* pEntry = m_pSmartTagTypesLB->SvTreeListBox::InsertEntry( aLBEntry ); m_xSmartTagTypesLB->insert(nullptr, -1, nullptr, nullptr, nullptr,
if ( pEntry ) nullptr, nullptr, false);
{ const int nRow = m_xSmartTagTypesLB->n_children() - 1;
const bool bCheck = rSmartTagMgr.IsSmartTagTypeEnabled( aSmartTagType ); const bool bCheck = rSmartTagMgr.IsSmartTagTypeEnabled( aSmartTagType );
m_pSmartTagTypesLB->SetCheckButtonState( pEntry, bCheck ? SvButtonState::Checked : SvButtonState::Unchecked ); m_xSmartTagTypesLB->set_toggle(nRow, bCheck);
pEntry->SetUserData(static_cast<void*>(new ImplSmartTagLBUserData( aSmartTagType, xRec, j ) ) ); m_xSmartTagTypesLB->set_text(nRow, aLBEntry, 1);
} m_xSmartTagTypesLB->set_id(nRow, OUString::number(reinterpret_cast<sal_Int64>(new ImplSmartTagLBUserData(aSmartTagType, xRec, j))));
} }
} }
} }
/** Handler for the push button /** Handler for the push button
*/ */
IMPL_LINK_NOARG(OfaSmartTagOptionsTabPage, ClickHdl, Button*, void) IMPL_LINK_NOARG(OfaSmartTagOptionsTabPage, ClickHdl, weld::Button&, void)
{ {
const sal_uLong nPos = m_pSmartTagTypesLB->GetSelectedEntryPos(); const int nPos = m_xSmartTagTypesLB->get_selected_index();
const SvTreeListEntry* pEntry = m_pSmartTagTypesLB->GetEntry(nPos); const ImplSmartTagLBUserData* pUserData = reinterpret_cast<ImplSmartTagLBUserData*>(m_xSmartTagTypesLB->get_id(nPos).toInt64());
const ImplSmartTagLBUserData* pUserData = static_cast< ImplSmartTagLBUserData* >(pEntry->GetUserData());
uno::Reference< smarttags::XSmartTagRecognizer > xRec = pUserData->mxRec; uno::Reference< smarttags::XSmartTagRecognizer > xRec = pUserData->mxRec;
const sal_Int32 nSmartTagIdx = pUserData->mnSmartTagIdx; const sal_Int32 nSmartTagIdx = pUserData->mnSmartTagIdx;
...@@ -2359,39 +2348,36 @@ IMPL_LINK_NOARG(OfaSmartTagOptionsTabPage, ClickHdl, Button*, void) ...@@ -2359,39 +2348,36 @@ IMPL_LINK_NOARG(OfaSmartTagOptionsTabPage, ClickHdl, Button*, void)
/** Handler for the check box /** Handler for the check box
*/ */
IMPL_LINK_NOARG(OfaSmartTagOptionsTabPage, CheckHdl, CheckBox&, void) IMPL_LINK_NOARG(OfaSmartTagOptionsTabPage, CheckHdl, weld::ToggleButton&, void)
{ {
const bool bEnable = m_pMainCB->IsChecked(); const bool bEnable = m_xMainCB->get_active();
m_pSmartTagTypesLB->Enable( bEnable ); m_xSmartTagTypesLB->set_sensitive(bEnable);
m_pSmartTagTypesLB->Invalidate(); m_xPropertiesPB->set_sensitive(false);
m_pPropertiesPB->Enable( false );
// if the controls are currently enabled, we still have to check // if the controls are currently enabled, we still have to check
// if the properties button should be disabled because the currently // if the properties button should be disabled because the currently
// selected smart tag type does not have a properties dialog. // selected smart tag type does not have a properties dialog.
// We do this by calling SelectHdl: // We do this by calling SelectHdl:
if ( bEnable ) if (bEnable)
SelectHdl(m_pSmartTagTypesLB); SelectHdl(*m_xSmartTagTypesLB);
} }
/** Handler for the list box /** Handler for the list box
*/ */
IMPL_LINK_NOARG(OfaSmartTagOptionsTabPage, SelectHdl, SvTreeListBox*, void) IMPL_LINK_NOARG(OfaSmartTagOptionsTabPage, SelectHdl, weld::TreeView&, void)
{ {
if ( m_pSmartTagTypesLB->GetEntryCount() < 1 ) const int nPos = m_xSmartTagTypesLB->get_selected_index();
if (nPos == -1)
return; return;
const ImplSmartTagLBUserData* pUserData = reinterpret_cast<ImplSmartTagLBUserData*>(m_xSmartTagTypesLB->get_id(nPos).toInt64());
const sal_uLong nPos = m_pSmartTagTypesLB->GetSelectedEntryPos();
const SvTreeListEntry* pEntry = m_pSmartTagTypesLB->GetEntry(nPos);
const ImplSmartTagLBUserData* pUserData = static_cast< ImplSmartTagLBUserData* >(pEntry->GetUserData());
uno::Reference< smarttags::XSmartTagRecognizer > xRec = pUserData->mxRec; uno::Reference< smarttags::XSmartTagRecognizer > xRec = pUserData->mxRec;
const sal_Int32 nSmartTagIdx = pUserData->mnSmartTagIdx; const sal_Int32 nSmartTagIdx = pUserData->mnSmartTagIdx;
const lang::Locale aLocale( LanguageTag::convertToLocale( eLastDialogLanguage ) ); const lang::Locale aLocale( LanguageTag::convertToLocale( eLastDialogLanguage ) );
if ( xRec->hasPropertyPage( nSmartTagIdx, aLocale ) ) if ( xRec->hasPropertyPage( nSmartTagIdx, aLocale ) )
m_pPropertiesPB->Enable(); m_xPropertiesPB->set_sensitive(true);
else else
m_pPropertiesPB->Enable( false ); m_xPropertiesPB->set_sensitive(false);
} }
/** Propagates the current settings to the smart tag manager. /** Propagates the current settings to the smart tag manager.
...@@ -2409,13 +2395,12 @@ bool OfaSmartTagOptionsTabPage::FillItemSet( SfxItemSet* ) ...@@ -2409,13 +2395,12 @@ bool OfaSmartTagOptionsTabPage::FillItemSet( SfxItemSet* )
bool bModifiedSmartTagTypes = false; bool bModifiedSmartTagTypes = false;
std::vector< OUString > aDisabledSmartTagTypes; std::vector< OUString > aDisabledSmartTagTypes;
const sal_uLong nCount = m_pSmartTagTypesLB->GetEntryCount(); const int nCount = m_xSmartTagTypesLB->n_children();
for ( sal_uLong i = 0; i < nCount; ++i ) for (int i = 0; i < nCount; ++i)
{ {
const SvTreeListEntry* pEntry = m_pSmartTagTypesLB->GetEntry(i); const ImplSmartTagLBUserData* pUserData = reinterpret_cast<ImplSmartTagLBUserData*>(m_xSmartTagTypesLB->get_id(i).toInt64());
const ImplSmartTagLBUserData* pUserData = static_cast< ImplSmartTagLBUserData* >(pEntry->GetUserData()); const bool bChecked = m_xSmartTagTypesLB->get_toggle(i);
const bool bChecked = m_pSmartTagTypesLB->IsChecked(i);
const bool bIsCurrentlyEnabled = pSmartTagMgr->IsSmartTagTypeEnabled( pUserData->maSmartTagType ); const bool bIsCurrentlyEnabled = pSmartTagMgr->IsSmartTagTypeEnabled( pUserData->maSmartTagType );
bModifiedSmartTagTypes = bModifiedSmartTagTypes || ( !bChecked != !bIsCurrentlyEnabled ); bModifiedSmartTagTypes = bModifiedSmartTagTypes || ( !bChecked != !bIsCurrentlyEnabled );
...@@ -2426,10 +2411,10 @@ bool OfaSmartTagOptionsTabPage::FillItemSet( SfxItemSet* ) ...@@ -2426,10 +2411,10 @@ bool OfaSmartTagOptionsTabPage::FillItemSet( SfxItemSet* )
delete pUserData; delete pUserData;
} }
const bool bModifiedRecognize = ( !m_pMainCB->IsChecked() != !pSmartTagMgr->IsLabelTextWithSmartTags() ); const bool bModifiedRecognize = ( !m_xMainCB->get_active() != !pSmartTagMgr->IsLabelTextWithSmartTags() );
if ( bModifiedSmartTagTypes || bModifiedRecognize ) if ( bModifiedSmartTagTypes || bModifiedRecognize )
{ {
bool bLabelTextWithSmartTags = m_pMainCB->IsChecked(); bool bLabelTextWithSmartTags = m_xMainCB->get_active();
pSmartTagMgr->WriteConfiguration( bModifiedRecognize ? &bLabelTextWithSmartTags : nullptr, pSmartTagMgr->WriteConfiguration( bModifiedRecognize ? &bLabelTextWithSmartTags : nullptr,
bModifiedSmartTagTypes ? &aDisabledSmartTagTypes : nullptr ); bModifiedSmartTagTypes ? &aDisabledSmartTagTypes : nullptr );
} }
...@@ -2449,10 +2434,10 @@ void OfaSmartTagOptionsTabPage::Reset( const SfxItemSet* ) ...@@ -2449,10 +2434,10 @@ void OfaSmartTagOptionsTabPage::Reset( const SfxItemSet* )
if ( !pSmartTagMgr ) if ( !pSmartTagMgr )
return; return;
FillListBox( *pSmartTagMgr ); FillListBox(*pSmartTagMgr);
m_pSmartTagTypesLB->SelectEntryPos( 0 ); m_xSmartTagTypesLB->select(0);
m_pMainCB->Check( pSmartTagMgr->IsLabelTextWithSmartTags() ); m_xMainCB->set_active(pSmartTagMgr->IsLabelTextWithSmartTags());
CheckHdl(*m_pMainCB); CheckHdl(*m_xMainCB);
} }
void OfaSmartTagOptionsTabPage::ActivatePage( const SfxItemSet& ) void OfaSmartTagOptionsTabPage::ActivatePage( const SfxItemSet& )
......
...@@ -2,7 +2,16 @@ ...@@ -2,7 +2,16 @@
<!-- Generated with glade 3.16.1 --> <!-- Generated with glade 3.16.1 -->
<interface domain="cui"> <interface domain="cui">
<requires lib="gtk+" version="3.18"/> <requires lib="gtk+" version="3.18"/>
<requires lib="LibreOffice" version="1.0"/> <object class="GtkTreeStore" id="liststore2">
<columns>
<!-- column-name check1 -->
<column type="gboolean"/>
<!-- column-name text -->
<column type="gchararray"/>
<!-- column-name id -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkGrid" id="SmartTagOptionsPage"> <object class="GtkGrid" id="SmartTagOptionsPage">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
...@@ -73,13 +82,52 @@ ...@@ -73,13 +82,52 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="svxcorelo-SvxCheckListBox" id="list:border"> <object class="GtkScrolledWindow">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">True</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="vexpand">True</property> <property name="vexpand">True</property>
<child internal-child="selection"> <property name="shadow_type">in</property>
<object class="GtkTreeSelection" id="Check List Box-selection1"/> <child>
<object class="GtkTreeView" id="list">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="model">liststore2</property>
<property name="headers_visible">False</property>
<property name="search_column">0</property>
<property name="show_expanders">False</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="Macro Library List-selection2"/>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn4">
<property name="resizable">True</property>
<property name="spacing">6</property>
<property name="alignment">0.5</property>
<child>
<object class="GtkCellRendererToggle" id="cellrenderer5"/>
<attributes>
<attribute name="active">0</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn5">
<property name="resizable">True</property>
<property name="spacing">6</property>
<child>
<object class="GtkCellRendererText" id="cellrenderer4"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child> </child>
</object> </object>
<packing> <packing>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment