diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-02-07 21:19:37 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-02-08 10:59:15 +0100 |
commit | eb25b3c94053b4b614d7c8f983158d6519e530c1 (patch) | |
tree | b6961d95abaad7977bf1ebf6e37f5bb699ffec70 /svx | |
parent | 74ed61e793ff9641a2c67b83327b066cb9a1af3d (diff) |
weld AddConditionDialog
Change-Id: Ib685ea89b31c1f000bc2276e3362ba059f997422
Reviewed-on: https://gerrit.libreoffice.org/67521
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/form/datanavi.cxx | 82 | ||||
-rw-r--r-- | svx/source/form/xfm_addcondition.cxx | 4 | ||||
-rw-r--r-- | svx/source/inc/datanavi.hxx | 30 | ||||
-rw-r--r-- | svx/uiconfig/ui/addconditiondialog.ui | 169 | ||||
-rw-r--r-- | svx/uiconfig/ui/namespacedialog.ui | 1 |
5 files changed, 147 insertions, 139 deletions
diff --git a/svx/source/form/datanavi.cxx b/svx/source/form/datanavi.cxx index 6b241324b353..0f064627489c 100644 --- a/svx/source/form/datanavi.cxx +++ b/svx/source/form/datanavi.cxx @@ -2372,7 +2372,7 @@ namespace svxform sPropName = PN_READONLY_EXPR; else if (m_pCalculateBtn == pBtn) sPropName = PN_CALCULATE_EXPR; - ScopedVclPtrInstance< AddConditionDialog > aDlg(this, sPropName, m_xTempBinding); + AddConditionDialog aDlg(GetFrameWeld(), sPropName, m_xTempBinding); bool bIsDefBtn = ( m_pDefaultBtn == pBtn ); OUString sCondition; if ( bIsDefBtn ) @@ -2384,11 +2384,11 @@ namespace svxform sTemp = TRUE_VALUE; sCondition = sTemp; } - aDlg->SetCondition( sCondition ); + aDlg.SetCondition( sCondition ); - if ( aDlg->Execute() == RET_OK ) + if (aDlg.run() == RET_OK) { - OUString sNewCondition = aDlg->GetCondition(); + OUString sNewCondition = aDlg.GetCondition(); if ( bIsDefBtn ) m_pDefaultED->SetText( sNewCondition ); else @@ -2732,28 +2732,27 @@ namespace svxform m_pItemFrame->set_label(sText); } - AddConditionDialog::AddConditionDialog(vcl::Window* pParent, + AddConditionDialog::AddConditionDialog(weld::Window* pParent, const OUString& _rPropertyName, const Reference< XPropertySet >& _rPropSet) - : ModalDialog(pParent, "AddConditionDialog", "svx/ui/addconditiondialog.ui") + : GenericDialogController(pParent, "svx/ui/addconditiondialog.ui", "AddConditionDialog") , m_sPropertyName(_rPropertyName) , m_xBinding(_rPropSet) - + , m_xConditionED(m_xBuilder->weld_text_view("condition")) + , m_xResultWin(m_xBuilder->weld_text_view("result")) + , m_xEditNamespacesBtn(m_xBuilder->weld_button("edit")) + , m_xOKBtn(m_xBuilder->weld_button("ok")) { - get(m_pConditionED, "condition"); - get(m_pResultWin, "result"); - get(m_pEditNamespacesBtn, "edit"); - get(m_pOKBtn, "ok"); DBG_ASSERT( m_xBinding.is(), "AddConditionDialog::Ctor(): no Binding" ); - m_pConditionED->set_height_request(m_pConditionED->GetTextHeight() * 4); - m_pConditionED->set_width_request(m_pConditionED->approximate_char_width() * 62); - m_pResultWin->set_height_request(m_pResultWin->GetTextHeight() * 4); - m_pResultWin->set_width_request(m_pResultWin->approximate_char_width() * 62); + m_xConditionED->set_size_request(m_xConditionED->get_approximate_digit_width() * 52, + m_xConditionED->get_height_rows(4)); + m_xResultWin->set_size_request(m_xResultWin->get_approximate_digit_width() * 52, + m_xResultWin->get_height_rows(4)); - m_pConditionED->SetModifyHdl( LINK( this, AddConditionDialog, ModifyHdl ) ); - m_pEditNamespacesBtn->SetClickHdl( LINK( this, AddConditionDialog, EditHdl ) ); - m_pOKBtn->SetClickHdl( LINK( this, AddConditionDialog, OKHdl ) ); + m_xConditionED->connect_changed( LINK( this, AddConditionDialog, ModifyHdl ) ); + m_xEditNamespacesBtn->connect_clicked( LINK( this, AddConditionDialog, EditHdl ) ); + m_xOKBtn->connect_clicked( LINK( this, AddConditionDialog, OKHdl ) ); m_aResultIdle.SetPriority( TaskPriority::LOWEST ); m_aResultIdle.SetInvokeHandler( LINK( this, AddConditionDialog, ResultHdl ) ); @@ -2765,12 +2764,12 @@ namespace svxform if ( ( m_xBinding->getPropertyValue( m_sPropertyName ) >>= sTemp ) && !sTemp.isEmpty() ) { - m_pConditionED->SetText( sTemp ); + m_xConditionED->set_text( sTemp ); } else { //! m_xBinding->setPropertyValue( m_sPropertyName, makeAny( TRUE_VALUE ) ); - m_pConditionED->SetText( TRUE_VALUE ); + m_xConditionED->set_text( TRUE_VALUE ); } Reference< css::xforms::XModel > xModel; @@ -2789,19 +2788,9 @@ namespace svxform AddConditionDialog::~AddConditionDialog() { - disposeOnce(); - } - - void AddConditionDialog::dispose() - { - m_pConditionED.clear(); - m_pResultWin.clear(); - m_pEditNamespacesBtn.clear(); - m_pOKBtn.clear(); - ModalDialog::dispose(); } - IMPL_LINK_NOARG(AddConditionDialog, EditHdl, Button*, void) + IMPL_LINK_NOARG(AddConditionDialog, EditHdl, weld::Button&, void) { Reference< XNameContainer > xNameContnr; try @@ -2824,8 +2813,7 @@ namespace svxform } } - - IMPL_LINK_NOARG(AddConditionDialog, OKHdl, Button*, void) + IMPL_LINK_NOARG(AddConditionDialog, OKHdl, weld::Button&, void) { /*!!! try @@ -2838,19 +2826,17 @@ namespace svxform SAL_WARN( "svx.form", "AddConditionDialog, OKHdl: caught an exception!" ); } */ - EndDialog( RET_OK ); + m_xDialog->response(RET_OK); } - - IMPL_LINK_NOARG(AddConditionDialog, ModifyHdl, Edit&, void) + IMPL_LINK_NOARG(AddConditionDialog, ModifyHdl, weld::TextView&, void) { m_aResultIdle.Start(); } - IMPL_LINK_NOARG(AddConditionDialog, ResultHdl, Timer *, void) { - OUString sCondition = comphelper::string::strip(m_pConditionED->GetText(), ' '); + OUString sCondition = comphelper::string::strip(m_xConditionED->get_text(), ' '); OUString sResult; if ( !sCondition.isEmpty() ) { @@ -2863,11 +2849,11 @@ namespace svxform SAL_WARN( "svx.form", "AddConditionDialog::ResultHdl(): exception caught" ); } } - m_pResultWin->SetText( sResult ); + m_xResultWin->set_text(sResult); } NamespaceItemDialog::NamespaceItemDialog(AddConditionDialog* pCondDlg, Reference<XNameContainer>& rContainer) - : GenericDialogController(pCondDlg->GetFrameWeld(), "svx/ui/namespacedialog.ui", "NamespaceDialog") + : GenericDialogController(pCondDlg->getDialog(), "svx/ui/namespacedialog.ui", "NamespaceDialog") , m_pConditionDlg(pCondDlg) , m_rNamespaces(rContainer) , m_xNamespacesList(m_xBuilder->weld_tree_view("namespaces")) @@ -3009,9 +2995,9 @@ namespace svxform } } - ManageNamespaceDialog::ManageNamespaceDialog(weld::Window* pParent, AddConditionDialog* _pCondDlg, bool bIsEdit) + ManageNamespaceDialog::ManageNamespaceDialog(weld::Window* pParent, AddConditionDialog* pCondDlg, bool bIsEdit) : GenericDialogController(pParent, "svx/ui/addnamespacedialog.ui", "AddNamespaceDialog") - , m_xConditionDlg(_pCondDlg) + , m_pConditionDlg(pCondDlg) , m_xPrefixED(m_xBuilder->weld_entry("prefix")) , m_xUrlED(m_xBuilder->weld_entry("url")) , m_xOKBtn(m_xBuilder->weld_button("ok")) @@ -3033,7 +3019,7 @@ namespace svxform try { - if (!m_xConditionDlg->GetUIHelper()->isValidPrefixName(sPrefix)) + if (!m_pConditionDlg->GetUIHelper()->isValidPrefixName(sPrefix)) { std::unique_ptr<weld::MessageDialog> xErrBox(Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Warning, VclButtonsType::Ok, @@ -3096,16 +3082,14 @@ namespace svxform ModalDialog::dispose(); } - IMPL_LINK_NOARG(AddSubmissionDialog, RefHdl, Button*, void) { - ScopedVclPtrInstance< AddConditionDialog > aDlg(this, PN_BINDING_EXPR, m_xTempBinding ); - aDlg->SetCondition( m_pRefED->GetText() ); - if ( aDlg->Execute() == RET_OK ) - m_pRefED->SetText( aDlg->GetCondition() ); + AddConditionDialog aDlg(GetFrameWeld(), PN_BINDING_EXPR, m_xTempBinding ); + aDlg.SetCondition( m_pRefED->GetText() ); + if ( aDlg.run() == RET_OK ) + m_pRefED->SetText( aDlg.GetCondition() ); } - IMPL_LINK_NOARG(AddSubmissionDialog, OKHdl, Button*, void) { OUString sName(m_pNameED->GetText()); diff --git a/svx/source/form/xfm_addcondition.cxx b/svx/source/form/xfm_addcondition.cxx index 659327d00fee..a99ae039a363 100644 --- a/svx/source/form/xfm_addcondition.cxx +++ b/svx/source/form/xfm_addcondition.cxx @@ -144,14 +144,14 @@ namespace svxform if ( !m_xBinding.is() || m_sFacetName.isEmpty() ) throw RuntimeException( OUString(), *this ); - return svt::OGenericUnoDialog::Dialog(VclPtr<AddConditionDialog>::Create(VCLUnoHelper::GetWindow(rParent), m_sFacetName, m_xBinding)); + return svt::OGenericUnoDialog::Dialog(std::make_unique<AddConditionDialog>(Application::GetFrameWeld(rParent), m_sFacetName, m_xBinding)); } void OAddConditionDialog::executedDialog( sal_Int16 _nExecutionResult ) { OAddConditionDialogBase::executedDialog( _nExecutionResult ); if ( _nExecutionResult == RET_OK ) - m_sConditionValue = static_cast< AddConditionDialog* >( m_aDialog.m_xVclDialog.get() )->GetCondition(); + m_sConditionValue = static_cast< AddConditionDialog* >( m_aDialog.m_xWeldDialog.get() )->GetCondition(); } } diff --git a/svx/source/inc/datanavi.hxx b/svx/source/inc/datanavi.hxx index facd9fbefe2c..5bfc7e5d6feb 100644 --- a/svx/source/inc/datanavi.hxx +++ b/svx/source/inc/datanavi.hxx @@ -444,15 +444,9 @@ namespace svxform void InitText( DataItemType _eType ); }; - - class AddConditionDialog : public ModalDialog + class AddConditionDialog : public weld::GenericDialogController { private: - VclPtr<VclMultiLineEdit> m_pConditionED; - VclPtr<VclMultiLineEdit> m_pResultWin; - VclPtr<PushButton> m_pEditNamespacesBtn; - VclPtr<OKButton> m_pOKBtn; - Idle m_aResultIdle; OUString const m_sPropertyName; @@ -461,22 +455,26 @@ namespace svxform css::uno::Reference< css::beans::XPropertySet > m_xBinding; - DECL_LINK(ModifyHdl, Edit&, void); + std::unique_ptr<weld::TextView> m_xConditionED; + std::unique_ptr<weld::TextView> m_xResultWin; + std::unique_ptr<weld::Button> m_xEditNamespacesBtn; + std::unique_ptr<weld::Button> m_xOKBtn; + + DECL_LINK(ModifyHdl, weld::TextView&, void); DECL_LINK(ResultHdl, Timer *, void); - DECL_LINK(EditHdl, Button*, void); - DECL_LINK(OKHdl, Button*, void); + DECL_LINK(EditHdl, weld::Button&, void); + DECL_LINK(OKHdl, weld::Button&, void); public: - AddConditionDialog(vcl::Window* pParent, + AddConditionDialog(weld::Window* pParent, const OUString& _rPropertyName, const css::uno::Reference< css::beans::XPropertySet >& _rBinding); virtual ~AddConditionDialog() override; - virtual void dispose() override; const css::uno::Reference< css::xforms::XFormsUIHelper1 >& GetUIHelper() const { return m_xUIHelper; } - OUString GetCondition() const { return m_pConditionED->GetText(); } + OUString GetCondition() const { return m_xConditionED->get_text(); } void SetCondition(const OUString& _rCondition) { - m_pConditionED->SetText(_rCondition); + m_xConditionED->set_text(_rCondition); m_aResultIdle.Start(); } }; @@ -484,7 +482,7 @@ namespace svxform class NamespaceItemDialog : public weld::GenericDialogController { private: - VclPtr<AddConditionDialog> m_pConditionDlg; + AddConditionDialog* m_pConditionDlg; std::vector< OUString > m_aRemovedList; css::uno::Reference< css::container::XNameContainer >& @@ -510,7 +508,7 @@ namespace svxform class ManageNamespaceDialog : public weld::GenericDialogController { private: - VclPtr<AddConditionDialog> m_xConditionDlg; + AddConditionDialog* m_pConditionDlg; std::unique_ptr<weld::Entry> m_xPrefixED; std::unique_ptr<weld::Entry> m_xUrlED; diff --git a/svx/uiconfig/ui/addconditiondialog.ui b/svx/uiconfig/ui/addconditiondialog.ui index 6a2b47abfa15..ab60984fd425 100644 --- a/svx/uiconfig/ui/addconditiondialog.ui +++ b/svx/uiconfig/ui/addconditiondialog.ui @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.22.1 --> <interface domain="svx"> <requires lib="gtk+" version="3.18"/> <object class="GtkDialog" id="AddConditionDialog"> @@ -7,12 +7,75 @@ <property name="border_width">6</property> <property name="title" translatable="yes" context="addconditiondialog|AddConditionDialog">Add Condition</property> <property name="resizable">False</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-vbox1"> <property name="can_focus">False</property> <property name="orientation">vertical</property> <property name="spacing">12</property> + <child internal-child="action_area"> + <object class="GtkButtonBox" id="dialog-action_area1"> + <property name="can_focus">False</property> + <property name="layout_style">end</property> + <child> + <object class="GtkButton" id="ok"> + <property name="label">gtk-ok</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="can_default">True</property> + <property name="has_default">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="cancel"> + <property name="label">gtk-cancel</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkButton" id="help"> + <property name="label">gtk-help</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + <property name="secondary">True</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">end</property> + <property name="position">2</property> + </packing> + </child> <child> <object class="GtkGrid" id="grid1"> <property name="visible">True</property> @@ -24,10 +87,10 @@ <object class="GtkLabel" id="label1"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="addconditiondialog|label1">_Condition:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">condition:border</property> + <property name="mnemonic_widget">condition</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> @@ -35,12 +98,21 @@ </packing> </child> <child> - <object class="GtkTextView" id="condition:border"> + <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="wrap_mode">word</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkTextView" id="condition"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="wrap_mode">word</property> + </object> + </child> </object> <packing> <property name="left_attach">0</property> @@ -65,10 +137,10 @@ <object class="GtkLabel" id="label2"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="addconditiondialog|label2">_Result:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">result:border</property> + <property name="mnemonic_widget">result</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> @@ -76,20 +148,6 @@ </packing> </child> <child> - <object class="GtkTextView" id="result:border"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - <property name="vexpand">True</property> - <property name="editable">False</property> - <property name="wrap_mode">word</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> <object class="GtkButton" id="edit"> <property name="label" translatable="yes" context="addconditiondialog|edit">_Edit Namespaces...</property> <property name="visible">True</property> @@ -103,68 +161,35 @@ <property name="top_attach">2</property> </packing> </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - <child internal-child="action_area"> - <object class="GtkButtonBox" id="dialog-action_area1"> - <property name="can_focus">False</property> - <property name="layout_style">end</property> - <child> - <object class="GtkButton" id="ok"> - <property name="label">gtk-ok</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="has_default">True</property> - <property name="receives_default">True</property> - <property name="use_stock">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkButton" id="cancel"> - <property name="label">gtk-cancel</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="use_stock">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> <child> - <object class="GtkButton" id="help"> - <property name="label">gtk-help</property> + <object class="GtkScrolledWindow"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="use_stock">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkTextView" id="result"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="editable">False</property> + <property name="wrap_mode">word</property> + <property name="cursor_visible">False</property> + </object> + </child> </object> <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">2</property> - <property name="secondary">True</property> + <property name="left_attach">0</property> + <property name="top_attach">1</property> </packing> </child> </object> <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="pack_type">end</property> - <property name="position">2</property> + <property name="position">1</property> </packing> </child> </object> diff --git a/svx/uiconfig/ui/namespacedialog.ui b/svx/uiconfig/ui/namespacedialog.ui index 9542213eb9ae..7c5e445ac830 100644 --- a/svx/uiconfig/ui/namespacedialog.ui +++ b/svx/uiconfig/ui/namespacedialog.ui @@ -17,6 +17,7 @@ <property name="border_width">6</property> <property name="title" translatable="yes" context="namespacedialog|NamespaceDialog">Namespaces for Forms</property> <property name="resizable">False</property> + <property name="modal">True</property> <property name="type_hint">dialog</property> <child> <placeholder/> |