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

weld SvxNewDictionaryDialog

Change-Id: Idf9a4a74615b3216918dde50563e9d081c61cd52
Reviewed-on: https://gerrit.libreoffice.org/52174Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst c8af8aeb
......@@ -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,
......
......@@ -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#
......
......@@ -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 ----------------------------------------------------
......
......@@ -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 -------------------------------------------
......
......@@ -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 )
......
<?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>
......@@ -103,24 +105,14 @@
<property name="top_attach">0</property>
</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>
......@@ -167,6 +167,7 @@ public:
void AddLanguages( const std::vector< LanguageType >& rLanguageTypes, SvxLanguageListFlags nLangList );
void SelectLanguage( const LanguageType eLangType );
LanguageType GetSelectedLanguage() const;
void SelectEntryPos(int nPos) { m_xControl->set_active(nPos); }
void connect_changed(const Link<weld::ComboBoxText&, void>& rLink) { m_aChangeHdl = rLink; }
};
......
......@@ -394,7 +394,7 @@ public:
const SfxItemSet& rOptionsSet,
TransliterationFlags nInitialFlags )=0;
virtual VclPtr<AbstractFmInputRecordNoDialog> CreateFmInputRecordNoDialog() = 0;
virtual VclPtr<AbstractSvxNewDictionaryDialog> CreateSvxNewDictionaryDialog( vcl::Window* pParent ) = 0;
virtual VclPtr<AbstractSvxNewDictionaryDialog> CreateSvxNewDictionaryDialog(weld::Window* pParent) = 0;
virtual VclPtr<VclAbstractDialog> CreateSvxEditDictionaryDialog( vcl::Window* pParent,
const OUString& rName) = 0;
virtual VclPtr<AbstractSvxNameDialog> CreateSvxNameDialog(weld::Window* pParent,
......
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