summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-04-06 16:06:49 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-09-09 15:01:06 +0200
commit854d8c418904bbb9370ca6ee0aad6bde5deb426e (patch)
tree5031d234c155d3b8d67056b30d1b1af994a3c75b /sfx2
parentf2ea65c92330ef0e36725a351f7b39027023f4bf (diff)
weld SfxNewStyleDlg
set some parents and replace VclComboBoxText with an entry and a treeview Change-Id: Ied75176355f23c986eac4d5de8654472a15dbbbf Reviewed-on: https://gerrit.libreoffice.org/52517 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/dialog/newstyle.cxx67
-rw-r--r--sfx2/source/dialog/templdlg.cxx6
-rw-r--r--sfx2/uiconfig/ui/newstyle.ui89
3 files changed, 109 insertions, 53 deletions
diff --git a/sfx2/source/dialog/newstyle.cxx b/sfx2/source/dialog/newstyle.cxx
index f4feb1f3f959..38cd472c4d65 100644
--- a/sfx2/source/dialog/newstyle.cxx
+++ b/sfx2/source/dialog/newstyle.cxx
@@ -27,71 +27,62 @@
// Private methods ------------------------------------------------------
-IMPL_LINK_NOARG( SfxNewStyleDlg, OKClickHdl, Button*, void )
+IMPL_LINK_NOARG(SfxNewStyleDlg, OKClickHdl, weld::Button&, void)
{
- OKHdl(*m_pColBox);
-}
-IMPL_LINK_NOARG( SfxNewStyleDlg, OKHdl, ComboBox&, void )
-{
- const OUString aName( m_pColBox->GetText() );
- SfxStyleSheetBase* pStyle = rPool.Find( aName, rPool.GetSearchFamily() );
+ const OUString aName(m_xColBox->get_text());
+ SfxStyleSheetBase* pStyle = m_rPool.Find(aName, m_rPool.GetSearchFamily());
if ( pStyle )
{
if ( !pStyle->IsUserDefined() )
{
- std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(),
+ std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(),
VclMessageType::Info, VclButtonsType::Ok,
SfxResId(STR_POOL_STYLE_NAME)));
xBox->run();
return;
}
- if (RET_YES == xQueryOverwriteBox->run())
- EndDialog( RET_OK );
+ if (RET_YES == m_xQueryOverwriteBox->run())
+ m_xDialog->response(RET_OK);
}
else
- EndDialog( RET_OK );
+ m_xDialog->response(RET_OK);
+}
+
+IMPL_LINK_NOARG(SfxNewStyleDlg, OKHdl, weld::TreeView&, void)
+{
+ OKClickHdl(*m_xOKBtn);
}
-IMPL_LINK( SfxNewStyleDlg, ModifyHdl, Edit&, rBox, void )
+IMPL_LINK(SfxNewStyleDlg, ModifyHdl, weld::Entry&, rBox, void)
{
- m_pOKBtn->Enable( !rBox.GetText().replaceAll(" ", "").isEmpty() );
+ m_xOKBtn->set_sensitive(!rBox.get_text().replaceAll(" ", "").isEmpty());
}
-SfxNewStyleDlg::SfxNewStyleDlg( vcl::Window* pParent, SfxStyleSheetBasePool& rInPool )
- : ModalDialog(pParent, "CreateStyleDialog", "sfx/ui/newstyle.ui")
- , xQueryOverwriteBox(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Question, VclButtonsType::YesNo,
- SfxResId(STR_QUERY_OVERWRITE)))
- , rPool(rInPool)
+SfxNewStyleDlg::SfxNewStyleDlg(weld::Window* pParent, SfxStyleSheetBasePool& rInPool)
+ : GenericDialogController(pParent, "sfx/ui/newstyle.ui", "CreateStyleDialog")
+ , m_rPool(rInPool)
+ , m_xColBox(m_xBuilder->weld_entry_tree_view("stylename", "styles"))
+ , m_xOKBtn(m_xBuilder->weld_button("ok"))
+ , m_xQueryOverwriteBox(Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Question, VclButtonsType::YesNo,
+ SfxResId(STR_QUERY_OVERWRITE)))
{
- get(m_pColBox, "stylename");
- m_pColBox->set_width_request(m_pColBox->approximate_char_width() * 25);
- m_pColBox->set_height_request(m_pColBox->GetTextHeight() * 10);
- get(m_pOKBtn, "ok");
+ m_xColBox->set_size_request_by_digits_rows(20, 8);
- m_pOKBtn->SetClickHdl(LINK(this, SfxNewStyleDlg, OKClickHdl));
- m_pColBox->SetModifyHdl(LINK(this, SfxNewStyleDlg, ModifyHdl));
- m_pColBox->SetDoubleClickHdl(LINK(this, SfxNewStyleDlg, OKHdl));
+ m_xOKBtn->connect_clicked(LINK(this, SfxNewStyleDlg, OKClickHdl));
+ m_xColBox->connect_changed(LINK(this, SfxNewStyleDlg, ModifyHdl));
+ m_xColBox->connect_row_activated(LINK(this, SfxNewStyleDlg, OKHdl));
- SfxStyleSheetBase *pStyle = rPool.First();
- while ( pStyle )
+ SfxStyleSheetBase *pStyle = m_rPool.First();
+ while (pStyle)
{
- m_pColBox->InsertEntry(pStyle->GetName());
- pStyle = rPool.Next();
+ m_xColBox->append_text(pStyle->GetName());
+ pStyle = m_rPool.Next();
}
}
SfxNewStyleDlg::~SfxNewStyleDlg()
{
- disposeOnce();
-}
-
-void SfxNewStyleDlg::dispose()
-{
- xQueryOverwriteBox.reset();
- m_pColBox.clear();
- m_pOKBtn.clear();
- ModalDialog::dispose();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index e72d920bd8c0..3bec0c87479b 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -1696,12 +1696,12 @@ void SfxCommonTemplateDialog_Impl::ActionSelect(sal_uInt16 nEntry)
nFilter=pStyleSheetPool->GetSearchMask();
pStyleSheetPool->SetSearchMask( eFam, SfxStyleSearchBits::UserDefined );
- ScopedVclPtrInstance< SfxNewStyleDlg > pDlg(pWindow, *pStyleSheetPool);
// why? : FloatingWindow must not be parent of a modal dialog
- if(RET_OK == pDlg->Execute())
+ SfxNewStyleDlg aDlg(pWindow ? pWindow->GetFrameWeld() : nullptr, *pStyleSheetPool);
+ if (aDlg.run() == RET_OK)
{
pStyleSheetPool->SetSearchMask(eFam, nFilter);
- const OUString aTemplName(pDlg->GetName());
+ const OUString aTemplName(aDlg.GetName());
Execute_Impl(SID_STYLE_NEW_BY_EXAMPLE,
aTemplName, "",
static_cast<sal_uInt16>(GetFamilyItem_Impl()->GetFamily()),
diff --git a/sfx2/uiconfig/ui/newstyle.ui b/sfx2/uiconfig/ui/newstyle.ui
index e9fa34ca4909..86ad1f114d92 100644
--- a/sfx2/uiconfig/ui/newstyle.ui
+++ b/sfx2/uiconfig/ui/newstyle.ui
@@ -1,13 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.22.1 -->
<interface domain="sfx">
<requires lib="gtk+" version="3.18"/>
- <requires lib="LibreOffice" version="1.0"/>
+ <object class="GtkListStore" id="liststore1">
+ <columns>
+ <!-- column-name text -->
+ <column type="gchararray"/>
+ <!-- column-name id -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
+ <object class="GtkEntryCompletion" id="entrycompletion1">
+ <property name="model">liststore1</property>
+ <property name="text_column">0</property>
+ <property name="inline_completion">True</property>
+ <property name="popup_completion">False</property>
+ <property name="popup_set_width">False</property>
+ <property name="popup_single_match">False</property>
+ </object>
<object class="GtkDialog" id="CreateStyleDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes" context="newstyle|CreateStyleDialog">Create Style</property>
+ <property name="modal">True</property>
+ <property name="default_width">0</property>
+ <property name="default_height">0</property>
<property name="type_hint">dialog</property>
+ <child>
+ <placeholder/>
+ </child>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox3">
<property name="can_focus">False</property>
@@ -90,23 +111,67 @@
<property name="top_padding">6</property>
<property name="left_padding">12</property>
<child>
- <object class="VclComboBoxText" id="stylename">
+ <object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
- <property name="has_entry">True</property>
- <property name="dropdown">False</property>
- <property name="max_width_chars">60</property>
- <child internal-child="entry">
- <object class="GtkEntry" id="comboboxtext-entry">
- <property name="can_focus">False</property>
+ <property name="row_spacing">3</property>
+ <child>
+ <object class="GtkScrolledWindow">
+ <property name="visible">True</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="styles">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="model">liststore1</property>
+ <property name="headers_visible">False</property>
+ <property name="headers_clickable">False</property>
+ <property name="search_column">0</property>
+ <property name="show_expanders">False</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection" id="treeview-selection1"/>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn1">
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderertext1"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ </packing>
</child>
- <child internal-child="accessible">
- <object class="AtkObject" id="stylename-atkobject">
- <property name="AtkObject::accessible-name" translatable="yes" context="newstyle|stylename-atkobject">Style Name</property>
+ <child>
+ <object class="GtkEntry" id="stylename">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="activates_default">True</property>
+ <property name="completion">entrycompletion1</property>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="stylename-atkobject">
+ <property name="AtkObject::accessible-name" translatable="yes" context="newstyle|stylename-atkobject">Style Name</property>
+ </object>
+ </child>
</object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
</child>
</object>
</child>