summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-03-30 21:24:28 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-03-31 20:49:32 +0200
commit1595604169f7643cf134f71e218ea512887ed8a3 (patch)
treebef728dc91af919b58f94d4561bd5f815930c4ea /cui
parentc8af8aebd1336e919e9531e39f84296085d91ea7 (diff)
weld SvxNewDictionaryDialog
Change-Id: Idf9a4a74615b3216918dde50563e9d081c61cd52 Reviewed-on: https://gerrit.libreoffice.org/52174 Tested-by: Jenkins <ci@libreoffice.org> 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/factory/dlgfact.cxx13
-rw-r--r--cui/source/factory/dlgfact.hxx14
-rw-r--r--cui/source/inc/optdict.hxx25
-rw-r--r--cui/source/options/optdict.cxx75
-rw-r--r--cui/source/options/optlingu.cxx2
-rw-r--r--cui/uiconfig/ui/optnewdictionarydialog.ui42
6 files changed, 83 insertions, 88 deletions
diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx
index 6dc1f279693d..a3b1ced56c74 100644
--- a/cui/source/factory/dlgfact.cxx
+++ b/cui/source/factory/dlgfact.cxx
@@ -119,7 +119,11 @@ IMPL_ABSTDLG_BASE(AbstractSvxTransformTabDialog_Impl);
IMPL_ABSTDLG_BASE(AbstractSvxCaptionDialog_Impl);
IMPL_ABSTDLG_BASE(AbstractSvxJSearchOptionsDialog_Impl);
IMPL_ABSTDLG_BASE(AbstractFmInputRecordNoDialog_Impl);
-IMPL_ABSTDLG_BASE(AbstractSvxNewDictionaryDialog_Impl);
+
+short AbstractSvxNewDictionaryDialog_Impl::Execute()
+{
+ return m_xDlg->run();
+}
short AbstractSvxNameDialog_Impl::Execute()
{
@@ -586,7 +590,7 @@ long AbstractFmInputRecordNoDialog_Impl::GetValue() const
::Reference< css::linguistic2::XDictionary > AbstractSvxNewDictionaryDialog_Impl::GetNewDictionary()
{
- return pDlg->GetNewDictionary();
+ return m_xDlg->GetNewDictionary();
}
void AbstractSvxNameDialog_Impl::GetName(OUString& rName)
@@ -1116,10 +1120,9 @@ VclPtr<AbstractFmInputRecordNoDialog> AbstractDialogFactory_Impl::CreateFmInputR
return VclPtr<AbstractFmInputRecordNoDialog_Impl>::Create( pDlg );
}
-VclPtr<AbstractSvxNewDictionaryDialog> AbstractDialogFactory_Impl::CreateSvxNewDictionaryDialog( vcl::Window* pParent )
+VclPtr<AbstractSvxNewDictionaryDialog> AbstractDialogFactory_Impl::CreateSvxNewDictionaryDialog(weld::Window* pParent)
{
- VclPtrInstance<SvxNewDictionaryDialog> pDlg( pParent );
- return VclPtr<AbstractSvxNewDictionaryDialog_Impl>::Create( pDlg );
+ return VclPtr<AbstractSvxNewDictionaryDialog_Impl>::Create(new SvxNewDictionaryDialog(pParent));
}
VclPtr<VclAbstractDialog> AbstractDialogFactory_Impl::CreateSvxEditDictionaryDialog( vcl::Window* pParent,
diff --git a/cui/source/factory/dlgfact.hxx b/cui/source/factory/dlgfact.hxx
index 25573f60a19e..2b36adee6204 100644
--- a/cui/source/factory/dlgfact.hxx
+++ b/cui/source/factory/dlgfact.hxx
@@ -300,7 +300,14 @@ class AbstractFmInputRecordNoDialog_Impl :public AbstractFmInputRecordNoDialog
class SvxNewDictionaryDialog;
class AbstractSvxNewDictionaryDialog_Impl :public AbstractSvxNewDictionaryDialog
{
- DECL_ABSTDLG_BASE(AbstractSvxNewDictionaryDialog_Impl,SvxNewDictionaryDialog)
+protected:
+ std::unique_ptr<SvxNewDictionaryDialog> m_xDlg;
+public:
+ explicit AbstractSvxNewDictionaryDialog_Impl(SvxNewDictionaryDialog* p)
+ : m_xDlg(p)
+ {
+ }
+ virtual short Execute() override;
virtual css::uno::Reference< css::linguistic2::XDictionary > GetNewDictionary() override;
};
@@ -599,9 +606,8 @@ public:
const SfxItemSet& rOptionsSet,
TransliterationFlags nInitialFlags) override;
virtual VclPtr<AbstractFmInputRecordNoDialog> CreateFmInputRecordNoDialog() override;
- virtual VclPtr<AbstractSvxNewDictionaryDialog> CreateSvxNewDictionaryDialog( vcl::Window* pParent ) override;
- virtual VclPtr<VclAbstractDialog> CreateSvxEditDictionaryDialog( vcl::Window* pParent,
- const OUString& rName) override;
+ virtual VclPtr<AbstractSvxNewDictionaryDialog> CreateSvxNewDictionaryDialog(weld::Window* pParent) override;
+ virtual VclPtr<VclAbstractDialog> CreateSvxEditDictionaryDialog(vcl::Window* pParent, const OUString& rName) override;
virtual VclPtr<AbstractSvxNameDialog> CreateSvxNameDialog(weld::Window* pParent,
const OUString& rName, const OUString& rDesc) override;
// #i68101#
diff --git a/cui/source/inc/optdict.hxx b/cui/source/inc/optdict.hxx
index e2dc53bf9e6e..e50accd43276 100644
--- a/cui/source/inc/optdict.hxx
+++ b/cui/source/inc/optdict.hxx
@@ -47,27 +47,22 @@ namespace linguistic2{
// class SvxNewDictionaryDialog ------------------------------------------
-class SvxNewDictionaryDialog : public ModalDialog
+class SvxNewDictionaryDialog : public weld::GenericDialogController
{
private:
- VclPtr<Edit> pNameEdit;
- VclPtr<SvxLanguageBox> pLanguageLB;
- VclPtr<CheckBox> pExceptBtn;
- VclPtr<OKButton> pOKBtn;
- css::uno::Reference<
- css::linguistic2::XDictionary > xNewDic;
+ std::unique_ptr<weld::Entry> m_xNameEdit;
+ std::unique_ptr<LanguageBox> m_xLanguageLB;
+ std::unique_ptr<weld::CheckButton> m_xExceptBtn;
+ std::unique_ptr<weld::Button> m_xOKBtn;
+ css::uno::Reference<css::linguistic2::XDictionary> m_xNewDic;
- DECL_LINK(OKHdl_Impl, Button*, void);
- DECL_LINK(ModifyHdl_Impl, Edit&, void);
+ DECL_LINK(OKHdl_Impl, weld::Button&, void);
+ DECL_LINK(ModifyHdl_Impl, weld::Entry&, void);
public:
- SvxNewDictionaryDialog( vcl::Window* pParent );
- virtual ~SvxNewDictionaryDialog() override;
- virtual void dispose() override;
+ SvxNewDictionaryDialog(weld::Window* pParent);
- const css::uno::Reference<
- css::linguistic2::XDictionary >&
- GetNewDictionary() { return xNewDic; }
+ const css::uno::Reference<css::linguistic2::XDictionary>& GetNewDictionary() { return m_xNewDic; }
};
// class SvxDictEdit ----------------------------------------------------
diff --git a/cui/source/options/optdict.cxx b/cui/source/options/optdict.cxx
index 425583b4d2c1..c28f06399572 100644
--- a/cui/source/options/optdict.cxx
+++ b/cui/source/options/optdict.cxx
@@ -96,43 +96,27 @@ static CDE_RESULT cmpDicEntry_Impl( const OUString &rText1, const OUString &rTex
// class SvxNewDictionaryDialog -------------------------------------------
-SvxNewDictionaryDialog::SvxNewDictionaryDialog( vcl::Window* pParent ) :
- ModalDialog( pParent, "OptNewDictionaryDialog" , "cui/ui/optnewdictionarydialog.ui" )
+SvxNewDictionaryDialog::SvxNewDictionaryDialog(weld::Window* pParent)
+ : GenericDialogController(pParent, "cui/ui/optnewdictionarydialog.ui", "OptNewDictionaryDialog")
+ , m_xNameEdit(m_xBuilder->weld_entry("nameedit"))
+ , m_xLanguageLB(new LanguageBox(m_xBuilder->weld_combo_box_text("language")))
+ , m_xExceptBtn(m_xBuilder->weld_check_button("except"))
+ , m_xOKBtn(m_xBuilder->weld_button("ok"))
{
- get(pNameEdit,"nameedit");
- get(pLanguageLB,"language");
- get(pExceptBtn,"except");
- get(pOKBtn,"ok");
// install handler
- pNameEdit->SetModifyHdl(
- LINK( this, SvxNewDictionaryDialog, ModifyHdl_Impl ) );
- pOKBtn->SetClickHdl( LINK( this, SvxNewDictionaryDialog, OKHdl_Impl ) );
+ m_xNameEdit->connect_changed(LINK(this, SvxNewDictionaryDialog, ModifyHdl_Impl));
+ m_xOKBtn->connect_clicked(LINK(this, SvxNewDictionaryDialog, OKHdl_Impl));
// display languages
- pLanguageLB->SetLanguageList( SvxLanguageListFlags::ALL, true, true );
- pLanguageLB->SelectEntryPos(0);
+ m_xLanguageLB->SetLanguageList(SvxLanguageListFlags::ALL, true, true);
+ m_xLanguageLB->SelectEntryPos(0);
}
-SvxNewDictionaryDialog::~SvxNewDictionaryDialog()
-{
- disposeOnce();
-}
-
-void SvxNewDictionaryDialog::dispose()
-{
- pNameEdit.clear();
- pLanguageLB.clear();
- pExceptBtn.clear();
- pOKBtn.clear();
- ModalDialog::dispose();
-}
-
-
-IMPL_LINK_NOARG(SvxNewDictionaryDialog, OKHdl_Impl, Button*, void)
+IMPL_LINK_NOARG(SvxNewDictionaryDialog, OKHdl_Impl, weld::Button&, void)
{
// add extension for personal dictionaries
- OUString sDict = comphelper::string::stripEnd(pNameEdit->GetText(), ' ') + ".dic";
+ OUString sDict = comphelper::string::stripEnd(m_xNameEdit->get_text(), ' ') + ".dic";
Reference< XSearchableDictionaryList > xDicList( LinguMgr::GetDictionaryList() );
@@ -151,61 +135,56 @@ IMPL_LINK_NOARG(SvxNewDictionaryDialog, OKHdl_Impl, Button*, void)
if ( bFound )
{
// duplicate names?
- std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(),
+ std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(m_xDialog.get(),
VclMessageType::Info, VclButtonsType::Ok,
CuiResId(RID_SVXSTR_OPT_DOUBLE_DICTS)));
xInfoBox->run();
- pNameEdit->GrabFocus();
+ m_xNameEdit->grab_focus();
return;
}
// create and add
- LanguageType nLang = pLanguageLB->GetSelectedLanguage();
+ LanguageType nLang = m_xLanguageLB->GetSelectedLanguage();
try
{
// create new dictionary
- DictionaryType eType = pExceptBtn->IsChecked() ?
+ DictionaryType eType = m_xExceptBtn->get_active() ?
DictionaryType_NEGATIVE : DictionaryType_POSITIVE;
if (xDicList.is())
{
lang::Locale aLocale( LanguageTag::convertToLocale(nLang) );
OUString aURL( linguistic::GetWritableDictionaryURL( sDict ) );
- xNewDic.set( xDicList->createDictionary( sDict, aLocale, eType, aURL ) , UNO_QUERY );
- xNewDic->setActive( true );
+ m_xNewDic.set(xDicList->createDictionary(sDict, aLocale, eType, aURL) , UNO_QUERY);
+ m_xNewDic->setActive(true);
}
- DBG_ASSERT(xNewDic.is(), "NULL pointer");
+ DBG_ASSERT(m_xNewDic.is(), "NULL pointer");
}
catch(...)
{
- xNewDic = nullptr;
+ m_xNewDic = nullptr;
// error: couldn't create new dictionary
SfxErrorContext aContext( ERRCTX_SVX_LINGU_DICTIONARY, OUString(),
- GetFrameWeld(), RID_SVXERRCTX, SvxResLocale() );
+ m_xDialog.get(), RID_SVXERRCTX, SvxResLocale() );
ErrorHandler::HandleError( *new StringErrorInfo(
ERRCODE_SVX_LINGU_DICT_NOTWRITEABLE, sDict ) );
- EndDialog();
+ m_xDialog->response(RET_CANCEL);
}
- if (xDicList.is() && xNewDic.is())
+ if (xDicList.is() && m_xNewDic.is())
{
- xDicList->addDictionary( Reference< XDictionary > ( xNewDic, UNO_QUERY ) );
+ xDicList->addDictionary(Reference<XDictionary>(m_xNewDic, UNO_QUERY));
// refresh list of dictionaries
//! dictionaries may have been added/removed elsewhere too.
aDics = xDicList->getDictionaries();
}
-
- EndDialog( RET_OK );
+ m_xDialog->response(RET_OK);
}
-
-IMPL_LINK_NOARG(SvxNewDictionaryDialog, ModifyHdl_Impl, Edit&, void)
+IMPL_LINK_NOARG(SvxNewDictionaryDialog, ModifyHdl_Impl, weld::Entry&, void)
{
- if ( !pNameEdit->GetText().isEmpty() )
- pOKBtn->Enable();
- else
- pOKBtn->Disable();
+ m_xOKBtn->set_sensitive(!m_xNameEdit->get_text().isEmpty());
}
// class SvxEditDictionaryDialog -------------------------------------------
diff --git a/cui/source/options/optlingu.cxx b/cui/source/options/optlingu.cxx
index 6d04a6f4d435..239546732acf 100644
--- a/cui/source/options/optlingu.cxx
+++ b/cui/source/options/optlingu.cxx
@@ -1493,7 +1493,7 @@ IMPL_LINK( SvxLinguTabPage, ClickHdl_Impl, Button *, pBtn, void )
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
if(pFact)
{
- ScopedVclPtr<AbstractSvxNewDictionaryDialog> aDlg(pFact->CreateSvxNewDictionaryDialog( this ));
+ ScopedVclPtr<AbstractSvxNewDictionaryDialog> aDlg(pFact->CreateSvxNewDictionaryDialog(GetFrameWeld()));
DBG_ASSERT(aDlg, "Dialog creation failed!");
uno::Reference< XDictionary > xNewDic;
if ( aDlg->Execute() == RET_OK )
diff --git a/cui/uiconfig/ui/optnewdictionarydialog.ui b/cui/uiconfig/ui/optnewdictionarydialog.ui
index 06296da93006..1ba69e74af8d 100644
--- a/cui/uiconfig/ui/optnewdictionarydialog.ui
+++ b/cui/uiconfig/ui/optnewdictionarydialog.ui
@@ -1,12 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.20.4 -->
<interface domain="cui">
<requires lib="gtk+" version="3.18"/>
- <requires lib="LibreOffice" version="1.0"/>
<object class="GtkDialog" id="OptNewDictionaryDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes" context="optnewdictionarydialog|OptNewDictionaryDialog">New Dictionary</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 internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
@@ -95,7 +97,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="max_length">32</property>
- <property name="invisible_char">●</property>
+ <property name="activates_default">True</property>
<property name="width_chars">32</property>
</object>
<packing>
@@ -104,23 +106,13 @@
</packing>
</child>
<child>
- <object class="svxcorelo-SvxLanguageBox" id="language">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- <child>
<object class="GtkLabel" id="name_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="optnewdictionarydialog|name_label">_Name:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">nameedit</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -131,10 +123,10 @@
<object class="GtkLabel" id="language_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="optnewdictionarydialog|language_label">_Language:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">language</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -157,6 +149,23 @@
<property name="width">2</property>
</packing>
</child>
+ <child>
+ <object class="GtkComboBoxText" id="language">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="has_entry">True</property>
+ <child internal-child="entry">
+ <object class="GtkEntry">
+ <property name="can_focus">True</property>
+ <property name="activates_default">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
</object>
</child>
</object>
@@ -185,5 +194,8 @@
<action-widget response="-6">cancel</action-widget>
<action-widget response="-11">help</action-widget>
</action-widgets>
+ <child>
+ <placeholder/>
+ </child>
</object>
</interface>