summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-02-17 16:59:43 +0000
committerCaolán McNamara <caolanm@redhat.com>2019-02-17 22:18:38 +0100
commit9712dd74bfb0c9b99cab37bd147fe267b48c6d7d (patch)
treeddec3dae09bf25a1504cbb6644e53b89667b4579 /cui
parent3bb5e0c6dc5f069b8af39cdb669913e286a294fd (diff)
weld HangulHanjaOptionsDialog
Change-Id: Ic155a1f393bfcc95e094ed194acba0d98fce248d Reviewed-on: https://gerrit.libreoffice.org/67945 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'cui')
-rw-r--r--cui/source/dialogs/hangulhanjadlg.cxx145
-rw-r--r--cui/source/inc/hangulhanjadlg.hxx35
-rw-r--r--cui/uiconfig/ui/hangulhanjaoptdialog.ui59
3 files changed, 132 insertions, 107 deletions
diff --git a/cui/source/dialogs/hangulhanjadlg.cxx b/cui/source/dialogs/hangulhanjadlg.cxx
index 46fa519c8f3f..74f46d3d3647 100644
--- a/cui/source/dialogs/hangulhanjadlg.cxx
+++ b/cui/source/dialogs/hangulhanjadlg.cxx
@@ -758,24 +758,21 @@ namespace svx
IMPL_LINK_NOARG( HangulHanjaConversionDialog, OnOption, Button*, void )
{
- ScopedVclPtrInstance< HangulHanjaOptionsDialog > aOptDlg(this);
- aOptDlg->Execute();
+ HangulHanjaOptionsDialog aOptDlg(GetFrameWeld());
+ aOptDlg.run();
m_aOptionsChangedLink.Call( nullptr );
}
-
OUString HangulHanjaConversionDialog::GetCurrentString( ) const
{
return m_pOriginalWord->GetText( );
}
-
void HangulHanjaConversionDialog::FocusSuggestion( )
{
m_pWordInput->GrabFocus();
}
-
namespace
{
void lcl_modifyWindowStyle( vcl::Window* _pWin, WinBits _nSet, WinBits _nReset )
@@ -938,7 +935,7 @@ namespace svx
}
m_aDictList.clear();
- m_pDictsLB->Clear();
+ m_xDictsLB->clear();
Reference< XNameContainer > xNameCont = m_xConversionDictionaryList->getDictionaryContainer();
if( xNameCont.is() )
@@ -965,7 +962,7 @@ namespace svx
}
}
- IMPL_LINK_NOARG(HangulHanjaOptionsDialog, OkHdl, Button*, void)
+ IMPL_LINK_NOARG(HangulHanjaOptionsDialog, OkHdl, weld::Button&, void)
{
sal_uInt32 nCnt = m_aDictList.size();
sal_uInt32 n = 0;
@@ -978,12 +975,10 @@ namespace svx
while( nCnt )
{
Reference< XConversionDictionary > xDict = m_aDictList[ n ];
- SvTreeListEntry* pEntry = m_pDictsLB->SvTreeListBox::GetEntry( n );
DBG_ASSERT( xDict.is(), "-HangulHanjaOptionsDialog::OkHdl(): someone is evaporated..." );
- DBG_ASSERT( pEntry, "-HangulHanjaOptionsDialog::OkHdl(): no one there in list?" );
- bool bActive = m_pDictsLB->GetCheckButtonState( pEntry ) == SvButtonState::Checked;
+ bool bActive = m_xDictsLB->get_toggle(n, 0);
xDict->setActive( bActive );
Reference< util::XFlushable > xFlush( xDict, uno::UNO_QUERY );
if( xFlush.is() )
@@ -1006,30 +1001,30 @@ namespace svx
aTmp <<= aActiveDics;
aLngCfg.SetProperty( UPH_ACTIVE_CONVERSION_DICTIONARIES, aTmp );
- aTmp <<= m_pIgnorepostCB->IsChecked();
+ aTmp <<= m_xIgnorepostCB->get_active();
aLngCfg.SetProperty( UPH_IS_IGNORE_POST_POSITIONAL_WORD, aTmp );
- aTmp <<= m_pShowrecentlyfirstCB->IsChecked();
+ aTmp <<= m_xShowrecentlyfirstCB->get_active();
aLngCfg.SetProperty( UPH_IS_SHOW_ENTRIES_RECENTLY_USED_FIRST, aTmp );
- aTmp <<= m_pAutoreplaceuniqueCB->IsChecked();
+ aTmp <<= m_xAutoreplaceuniqueCB->get_active();
aLngCfg.SetProperty( UPH_IS_AUTO_REPLACE_UNIQUE_ENTRIES, aTmp );
- EndDialog( RET_OK );
+ m_xDialog->response(RET_OK);
}
- IMPL_LINK_NOARG(HangulHanjaOptionsDialog, DictsLB_SelectHdl, SvTreeListBox*, void)
+ IMPL_LINK_NOARG(HangulHanjaOptionsDialog, DictsLB_SelectHdl, weld::TreeView&, void)
{
- bool bSel = m_pDictsLB->FirstSelected() != nullptr;
+ bool bSel = m_xDictsLB->get_selected_index() != -1;
- m_pEditPB->Enable(bSel);
- m_pDeletePB->Enable(bSel);
+ m_xEditPB->set_sensitive(bSel);
+ m_xDeletePB->set_sensitive(bSel);
}
- IMPL_LINK_NOARG(HangulHanjaOptionsDialog, NewDictHdl, Button*, void)
+ IMPL_LINK_NOARG(HangulHanjaOptionsDialog, NewDictHdl, weld::Button&, void)
{
OUString aName;
- HangulHanjaNewDictDialog aNewDlg(GetFrameWeld());
+ HangulHanjaNewDictDialog aNewDlg(m_xDialog.get());
aNewDlg.run();
if (aNewDlg.GetName(aName))
{
@@ -1057,21 +1052,21 @@ namespace svx
}
}
- IMPL_LINK_NOARG(HangulHanjaOptionsDialog, EditDictHdl, Button*, void)
+ IMPL_LINK_NOARG(HangulHanjaOptionsDialog, EditDictHdl, weld::Button&, void)
{
- SvTreeListEntry* pEntry = m_pDictsLB->FirstSelected();
- DBG_ASSERT( pEntry, "+HangulHanjaEditDictDialog::EditDictHdl(): call of edit should not be possible with no selection!" );
- if( pEntry )
+ int nEntry = m_xDictsLB->get_selected_index();
+ DBG_ASSERT(nEntry != -1, "+HangulHanjaEditDictDialog::EditDictHdl(): call of edit should not be possible with no selection!");
+ if (nEntry != -1)
{
- HangulHanjaEditDictDialog aEdDlg(GetFrameWeld(), m_aDictList, m_pDictsLB->GetSelectedEntryPos());
+ HangulHanjaEditDictDialog aEdDlg(m_xDialog.get(), m_aDictList, nEntry);
aEdDlg.run();
}
}
- IMPL_LINK_NOARG(HangulHanjaOptionsDialog, DeleteDictHdl, Button*, void)
+ IMPL_LINK_NOARG(HangulHanjaOptionsDialog, DeleteDictHdl, weld::Button&, void)
{
- sal_uLong nSelPos = m_pDictsLB->GetSelectedEntryPos();
- if( nSelPos != TREELIST_ENTRY_NOTFOUND )
+ int nSelPos = m_xDictsLB->get_selected_index();
+ if (nSelPos != -1)
{
Reference< XConversionDictionary > xDic( m_aDictList[ nSelPos ] );
if( m_xConversionDictionaryList.is() && xDic.is() )
@@ -1085,7 +1080,7 @@ namespace svx
//adapt local caches:
m_aDictList.erase(m_aDictList.begin()+nSelPos );
- m_pDictsLB->RemoveEntry(nSelPos);
+ m_xDictsLB->remove(nSelPos);
}
catch( const ElementExistException& )
{
@@ -1098,85 +1093,61 @@ namespace svx
}
}
- HangulHanjaOptionsDialog::HangulHanjaOptionsDialog(vcl::Window* _pParent)
- : ModalDialog( _pParent, "HangulHanjaOptDialog",
- "cui/ui/hangulhanjaoptdialog.ui" )
- {
- get(m_pDictsLB, "dicts");
- get(m_pIgnorepostCB, "ignorepost");
- get(m_pShowrecentlyfirstCB, "showrecentfirst");
- get(m_pAutoreplaceuniqueCB, "autoreplaceunique");
- get(m_pNewPB, "new");
- get(m_pEditPB, "edit");
- get(m_pDeletePB, "delete");
- get(m_pOkPB, "ok");
-
- m_pDictsLB->set_height_request(m_pDictsLB->GetTextHeight() * 5);
- m_pDictsLB->set_width_request(m_pDictsLB->approximate_char_width() * 32);
- m_pDictsLB->SetStyle( m_pDictsLB->GetStyle() | WB_CLIPCHILDREN | WB_HSCROLL );
- m_pDictsLB->SetForceMakeVisible(true);
- m_pDictsLB->SetSelectionMode( SelectionMode::Single );
- m_pDictsLB->SetHighlightRange();
- m_pDictsLB->SetSelectHdl( LINK( this, HangulHanjaOptionsDialog, DictsLB_SelectHdl ) );
- m_pDictsLB->SetDeselectHdl( LINK( this, HangulHanjaOptionsDialog, DictsLB_SelectHdl ) );
-
- m_pOkPB->SetClickHdl( LINK( this, HangulHanjaOptionsDialog, OkHdl ) );
- m_pNewPB->SetClickHdl( LINK( this, HangulHanjaOptionsDialog, NewDictHdl ) );
- m_pEditPB->SetClickHdl( LINK( this, HangulHanjaOptionsDialog, EditDictHdl ) );
- m_pDeletePB->SetClickHdl( LINK( this, HangulHanjaOptionsDialog, DeleteDictHdl ) );
+ HangulHanjaOptionsDialog::HangulHanjaOptionsDialog(weld::Window* pParent)
+ : GenericDialogController(pParent, "cui/ui/hangulhanjaoptdialog.ui", "HangulHanjaOptDialog")
+ , m_xDictsLB(m_xBuilder->weld_tree_view("dicts"))
+ , m_xIgnorepostCB(m_xBuilder->weld_check_button("ignorepost"))
+ , m_xShowrecentlyfirstCB(m_xBuilder->weld_check_button("showrecentfirst"))
+ , m_xAutoreplaceuniqueCB(m_xBuilder->weld_check_button("autoreplaceunique"))
+ , m_xNewPB(m_xBuilder->weld_button("new"))
+ , m_xEditPB(m_xBuilder->weld_button("edit"))
+ , m_xDeletePB(m_xBuilder->weld_button("delete"))
+ , m_xOkPB(m_xBuilder->weld_button("ok"))
+ {
+ m_xDictsLB->set_size_request(m_xDictsLB->get_approximate_digit_width() * 32,
+ m_xDictsLB->get_height_rows(5));
+
+ std::vector<int> aWidths;
+ aWidths.push_back(m_xDictsLB->get_checkbox_column_width());
+ m_xDictsLB->set_column_fixed_widths(aWidths);
+
+ m_xDictsLB->connect_changed( LINK( this, HangulHanjaOptionsDialog, DictsLB_SelectHdl ) );
+
+ m_xOkPB->connect_clicked( LINK( this, HangulHanjaOptionsDialog, OkHdl ) );
+ m_xNewPB->connect_clicked( LINK( this, HangulHanjaOptionsDialog, NewDictHdl ) );
+ m_xEditPB->connect_clicked( LINK( this, HangulHanjaOptionsDialog, EditDictHdl ) );
+ m_xDeletePB->connect_clicked( LINK( this, HangulHanjaOptionsDialog, DeleteDictHdl ) );
SvtLinguConfig aLngCfg;
Any aTmp;
bool bVal = bool();
aTmp = aLngCfg.GetProperty( UPH_IS_IGNORE_POST_POSITIONAL_WORD );
if( aTmp >>= bVal )
- m_pIgnorepostCB->Check( bVal );
+ m_xIgnorepostCB->set_active( bVal );
aTmp = aLngCfg.GetProperty( UPH_IS_SHOW_ENTRIES_RECENTLY_USED_FIRST );
if( aTmp >>= bVal )
- m_pShowrecentlyfirstCB->Check( bVal );
+ m_xShowrecentlyfirstCB->set_active( bVal );
aTmp = aLngCfg.GetProperty( UPH_IS_AUTO_REPLACE_UNIQUE_ENTRIES );
if( aTmp >>= bVal )
- m_pAutoreplaceuniqueCB->Check( bVal );
+ m_xAutoreplaceuniqueCB->set_active( bVal );
Init();
}
HangulHanjaOptionsDialog::~HangulHanjaOptionsDialog()
{
- disposeOnce();
- }
-
- void HangulHanjaOptionsDialog::dispose()
- {
- if (m_pDictsLB)
- {
- SvTreeListEntry* pEntry = m_pDictsLB->First();
- while( pEntry )
- {
- delete static_cast<OUString const *>(pEntry->GetUserData());
- pEntry->SetUserData( nullptr );
- pEntry = m_pDictsLB->Next( pEntry );
- }
- }
-
- m_pDictsLB.clear();
- m_pIgnorepostCB.clear();
- m_pShowrecentlyfirstCB.clear();
- m_pAutoreplaceuniqueCB.clear();
- m_pNewPB.clear();
- m_pEditPB.clear();
- m_pDeletePB.clear();
- m_pOkPB.clear();
- ModalDialog::dispose();
}
- void HangulHanjaOptionsDialog::AddDict( const OUString& _rName, bool _bChecked )
+ void HangulHanjaOptionsDialog::AddDict(const OUString& rName, bool bChecked)
{
- SvTreeListEntry* pEntry = m_pDictsLB->SvTreeListBox::InsertEntry( _rName );
- m_pDictsLB->SetCheckButtonState( pEntry, _bChecked? SvButtonState::Checked : SvButtonState::Unchecked );
- pEntry->SetUserData( new OUString( _rName ) );
+ m_xDictsLB->insert(nullptr, -1, nullptr, nullptr,
+ nullptr, nullptr, nullptr, false);
+ int nRow = m_xDictsLB->n_children() - 1;
+ m_xDictsLB->set_toggle(nRow, bChecked, 0);
+ m_xDictsLB->set_text(nRow, rName, 1);
+ m_xDictsLB->set_id(nRow, rName);
}
IMPL_LINK_NOARG(HangulHanjaNewDictDialog, OKHdl, weld::Button&, void)
diff --git a/cui/source/inc/hangulhanjadlg.hxx b/cui/source/inc/hangulhanjadlg.hxx
index 390e8663433e..2af5257cb17b 100644
--- a/cui/source/inc/hangulhanjadlg.hxx
+++ b/cui/source/inc/hangulhanjadlg.hxx
@@ -196,32 +196,31 @@ namespace svx
typedef std::vector< css::uno::Reference< css::linguistic2::XConversionDictionary > > HHDictList;
- class HangulHanjaOptionsDialog : public ModalDialog
+ class HangulHanjaOptionsDialog : public weld::GenericDialogController
{
private:
- VclPtr<SvxCheckListBox> m_pDictsLB;
- VclPtr<CheckBox> m_pIgnorepostCB;
- VclPtr<CheckBox> m_pShowrecentlyfirstCB;
- VclPtr<CheckBox> m_pAutoreplaceuniqueCB;
- VclPtr<PushButton> m_pNewPB;
- VclPtr<PushButton> m_pEditPB;
- VclPtr<PushButton> m_pDeletePB;
- VclPtr<OKButton> m_pOkPB;
-
HHDictList m_aDictList;
css::uno::Reference< css::linguistic2::XConversionDictionaryList > m_xConversionDictionaryList;
- DECL_LINK( OkHdl, Button*, void );
- DECL_LINK( DictsLB_SelectHdl, SvTreeListBox*, void );
- DECL_LINK( NewDictHdl, Button*, void );
- DECL_LINK( EditDictHdl, Button*, void );
- DECL_LINK( DeleteDictHdl, Button*, void );
+ std::unique_ptr<weld::TreeView> m_xDictsLB;
+ std::unique_ptr<weld::CheckButton> m_xIgnorepostCB;
+ std::unique_ptr<weld::CheckButton> m_xShowrecentlyfirstCB;
+ std::unique_ptr<weld::CheckButton> m_xAutoreplaceuniqueCB;
+ std::unique_ptr<weld::Button> m_xNewPB;
+ std::unique_ptr<weld::Button> m_xEditPB;
+ std::unique_ptr<weld::Button> m_xDeletePB;
+ std::unique_ptr<weld::Button> m_xOkPB;
+
+ DECL_LINK( OkHdl, weld::Button&, void );
+ DECL_LINK( DictsLB_SelectHdl, weld::TreeView&, void );
+ DECL_LINK( NewDictHdl, weld::Button&, void );
+ DECL_LINK( EditDictHdl, weld::Button&, void );
+ DECL_LINK( DeleteDictHdl, weld::Button&, void );
void Init(); ///< reads settings from core and init controls
public:
- HangulHanjaOptionsDialog( vcl::Window* _pParent );
- virtual ~HangulHanjaOptionsDialog() override;
- virtual void dispose() override;
+ HangulHanjaOptionsDialog(weld::Window* pParent);
+ virtual ~HangulHanjaOptionsDialog() override;
void AddDict( const OUString& _rName, bool _bChecked );
};
diff --git a/cui/uiconfig/ui/hangulhanjaoptdialog.ui b/cui/uiconfig/ui/hangulhanjaoptdialog.ui
index d44e9c692d08..0464ba462567 100644
--- a/cui/uiconfig/ui/hangulhanjaoptdialog.ui
+++ b/cui/uiconfig/ui/hangulhanjaoptdialog.ui
@@ -2,6 +2,18 @@
<!-- Generated with glade 3.18.3 -->
<interface domain="cui">
<requires lib="gtk+" version="3.18"/>
+ <object class="GtkTreeStore" id="liststore2">
+ <columns>
+ <!-- column-name check1 -->
+ <column type="gboolean"/>
+ <!-- column-name text -->
+ <column type="gchararray"/>
+ <!-- column-name id -->
+ <column type="gchararray"/>
+ <!-- column-name checkvis1 -->
+ <column type="gboolean"/>
+ </columns>
+ </object>
<object class="GtkDialog" id="HangulHanjaOptDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
@@ -150,11 +162,54 @@
</packing>
</child>
<child>
- <object class="svxcorelo-SvxCheckListBox" id="dicts:border">
+ <object class="GtkScrolledWindow">
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTreeView" id="dicts">
+ <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">1</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="visible">3</attribute>
+ <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">1</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
<packing>
<property name="left_attach">0</property>