diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-01-23 10:52:14 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-01-23 15:06:39 +0100 |
commit | ac163b519fc56e3695617315579bbcafeb3a9fe1 (patch) | |
tree | 5184c1e2e1d40583c25e977d996c6eea8eb9ab32 /sw | |
parent | 2a4cba62438de7f3dc2ccc79cd2ee013a99bb990 (diff) |
Related: tdf#122889 weld SwMailConfigPage
and reweld SwMailConfigDlg
Change-Id: Icf7497db0cd2e9097752414eb11498c694723646
Reviewed-on: https://gerrit.libreoffice.org/66787
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/ui/config/mailconfigpage.cxx | 145 | ||||
-rw-r--r-- | sw/source/ui/dbui/mmresultdialogs.cxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/inc/mailconfigpage.hxx | 45 |
3 files changed, 89 insertions, 105 deletions
diff --git a/sw/source/ui/config/mailconfigpage.cxx b/sw/source/ui/config/mailconfigpage.cxx index 3d3090c61002..59d473bed798 100644 --- a/sw/source/ui/config/mailconfigpage.cxx +++ b/sw/source/ui/config/mailconfigpage.cxx @@ -105,26 +105,24 @@ public: SwAuthenticationSettingsDialog(weld::Window* pParent, SwMailMergeConfigItem& rItem); }; -SwMailConfigPage::SwMailConfigPage( vcl::Window* pParent, const SfxItemSet& rSet ) : - SfxTabPage(pParent, "MailConfigPage" , "modules/swriter/ui/mailconfigpage.ui", &rSet), - - m_pConfigItem( new SwMailMergeConfigItem ) +SwMailConfigPage::SwMailConfigPage(TabPageParent pParent, const SfxItemSet& rSet) + : SfxTabPage(pParent, "modules/swriter/ui/mailconfigpage.ui", "MailConfigPage", &rSet) + , m_pConfigItem(new SwMailMergeConfigItem) + , m_xDisplayNameED(m_xBuilder->weld_entry("displayname")) + , m_xAddressED(m_xBuilder->weld_entry("address")) + , m_xReplyToCB(m_xBuilder->weld_check_button("replytocb")) + , m_xReplyToFT(m_xBuilder->weld_label("replyto_label")) + , m_xReplyToED(m_xBuilder->weld_entry("replyto")) + , m_xServerED(m_xBuilder->weld_entry("server")) + , m_xPortNF(m_xBuilder->weld_spin_button("port")) + , m_xSecureCB(m_xBuilder->weld_check_button("secure")) + , m_xServerAuthenticationPB(m_xBuilder->weld_button("serverauthentication")) + , m_xTestPB(m_xBuilder->weld_button("test")) { - get(m_pDisplayNameED,"displayname"); - get(m_pAddressED,"address"); - get(m_pReplyToCB,"replytocb"); - get(m_pReplyToFT,"replyto_label"); - get(m_pReplyToED,"replyto"); - get(m_pServerED,"server"); - get(m_pPortNF,"port"); - get(m_pSecureCB,"secure"); - get(m_pServerAuthenticationPB,"serverauthentication"); - get(m_pTestPB,"test"); - - m_pReplyToCB->SetClickHdl(LINK(this, SwMailConfigPage, ReplyToHdl)); - m_pServerAuthenticationPB->SetClickHdl(LINK(this, SwMailConfigPage, AuthenticationHdl)); - m_pTestPB->SetClickHdl(LINK(this, SwMailConfigPage, TestHdl)); - m_pSecureCB->SetClickHdl(LINK(this, SwMailConfigPage, SecureHdl)); + m_xReplyToCB->connect_toggled(LINK(this, SwMailConfigPage, ReplyToHdl)); + m_xServerAuthenticationPB->connect_clicked(LINK(this, SwMailConfigPage, AuthenticationHdl)); + m_xTestPB->connect_clicked(LINK(this, SwMailConfigPage, TestHdl)); + m_xSecureCB->connect_toggled(LINK(this, SwMailConfigPage, SecureHdl)); } SwMailConfigPage::~SwMailConfigPage() @@ -135,39 +133,29 @@ SwMailConfigPage::~SwMailConfigPage() void SwMailConfigPage::dispose() { m_pConfigItem.reset(); - m_pDisplayNameED.clear(); - m_pAddressED.clear(); - m_pReplyToCB.clear(); - m_pReplyToFT.clear(); - m_pReplyToED.clear(); - m_pServerED.clear(); - m_pPortNF.clear(); - m_pSecureCB.clear(); - m_pServerAuthenticationPB.clear(); - m_pTestPB.clear(); SfxTabPage::dispose(); } -VclPtr<SfxTabPage> SwMailConfigPage::Create( TabPageParent pParent, const SfxItemSet* rAttrSet) +VclPtr<SfxTabPage> SwMailConfigPage::Create(TabPageParent pParent, const SfxItemSet* rAttrSet) { - return VclPtr<SwMailConfigPage>::Create(pParent.pParent, *rAttrSet); + return VclPtr<SwMailConfigPage>::Create(pParent, *rAttrSet); } bool SwMailConfigPage::FillItemSet( SfxItemSet* /*rSet*/ ) { - if(m_pDisplayNameED->IsValueChangedFromSaved()) - m_pConfigItem->SetMailDisplayName(m_pDisplayNameED->GetText()); - if(m_pAddressED->IsValueChangedFromSaved()) - m_pConfigItem->SetMailAddress(m_pAddressED->GetText()); - if( m_pReplyToCB->IsValueChangedFromSaved() ) - m_pConfigItem->SetMailReplyTo(m_pReplyToCB->IsChecked()); - if(m_pReplyToED->IsValueChangedFromSaved()) - m_pConfigItem->SetMailReplyTo(m_pReplyToED->GetText()); - if(m_pServerED->IsValueChangedFromSaved()) - m_pConfigItem->SetMailServer(m_pServerED->GetText()); - - m_pConfigItem->SetMailPort(static_cast<sal_Int16>(m_pPortNF->GetValue())); - m_pConfigItem->SetSecureConnection(m_pSecureCB->IsChecked()); + if (m_xDisplayNameED->get_value_changed_from_saved()) + m_pConfigItem->SetMailDisplayName(m_xDisplayNameED->get_text()); + if (m_xAddressED->get_value_changed_from_saved()) + m_pConfigItem->SetMailAddress(m_xAddressED->get_text()); + if (m_xReplyToCB->get_state_changed_from_saved() ) + m_pConfigItem->SetMailReplyTo(m_xReplyToCB->get_active()); + if (m_xReplyToED->get_value_changed_from_saved()) + m_pConfigItem->SetMailReplyTo(m_xReplyToED->get_text()); + if (m_xServerED->get_value_changed_from_saved()) + m_pConfigItem->SetMailServer(m_xServerED->get_text()); + + m_pConfigItem->SetMailPort(m_xPortNF->get_value()); + m_pConfigItem->SetSecureConnection(m_xSecureCB->get_active()); m_pConfigItem->Commit(); return true; @@ -175,58 +163,58 @@ bool SwMailConfigPage::FillItemSet( SfxItemSet* /*rSet*/ ) void SwMailConfigPage::Reset( const SfxItemSet* /*rSet*/ ) { - m_pDisplayNameED->SetText(m_pConfigItem->GetMailDisplayName()); - m_pAddressED->SetText(m_pConfigItem->GetMailAddress()); + m_xDisplayNameED->set_text(m_pConfigItem->GetMailDisplayName()); + m_xAddressED->set_text(m_pConfigItem->GetMailAddress()); - m_pReplyToED->SetText(m_pConfigItem->GetMailReplyTo()) ; - m_pReplyToCB->Check(m_pConfigItem->IsMailReplyTo()); - m_pReplyToCB->GetClickHdl().Call(m_pReplyToCB.get()); + m_xReplyToED->set_text(m_pConfigItem->GetMailReplyTo()) ; + m_xReplyToCB->set_active(m_pConfigItem->IsMailReplyTo()); + ReplyToHdl(*m_xReplyToCB); - m_pServerED->SetText(m_pConfigItem->GetMailServer()); - m_pPortNF->SetValue(m_pConfigItem->GetMailPort()); + m_xServerED->set_text(m_pConfigItem->GetMailServer()); + m_xPortNF->set_value(m_pConfigItem->GetMailPort()); - m_pSecureCB->Check(m_pConfigItem->IsSecureConnection()); + m_xSecureCB->set_active(m_pConfigItem->IsSecureConnection()); - m_pDisplayNameED->SaveValue(); - m_pAddressED ->SaveValue(); - m_pReplyToCB ->SaveValue(); - m_pReplyToED ->SaveValue(); - m_pServerED ->SaveValue(); - m_pPortNF ->SaveValue(); - m_pSecureCB ->SaveValue(); + m_xDisplayNameED->save_value(); + m_xAddressED->save_value(); + m_xReplyToCB->save_state(); + m_xReplyToED->save_value(); + m_xServerED->save_value(); + m_xPortNF->save_value(); + m_xSecureCB->save_state(); } -IMPL_LINK(SwMailConfigPage, ReplyToHdl, Button*, pBox, void) +IMPL_LINK(SwMailConfigPage, ReplyToHdl, weld::ToggleButton&, rBox, void) { - bool bEnable = static_cast<CheckBox*>(pBox)->IsChecked(); - m_pReplyToFT->Enable(bEnable); - m_pReplyToED->Enable(bEnable); + bool bEnable = rBox.get_active(); + m_xReplyToFT->set_sensitive(bEnable); + m_xReplyToED->set_sensitive(bEnable); } -IMPL_LINK_NOARG(SwMailConfigPage, AuthenticationHdl, Button*, void) +IMPL_LINK_NOARG(SwMailConfigPage, AuthenticationHdl, weld::Button&, void) { - m_pConfigItem->SetMailAddress(m_pAddressED->GetText()); + m_pConfigItem->SetMailAddress(m_xAddressED->get_text()); - SwAuthenticationSettingsDialog aDlg(GetFrameWeld(), *m_pConfigItem); + SwAuthenticationSettingsDialog aDlg(GetDialogFrameWeld(), *m_pConfigItem); aDlg.run(); } -IMPL_LINK_NOARG(SwMailConfigPage, TestHdl, Button*, void) +IMPL_LINK_NOARG(SwMailConfigPage, TestHdl, weld::Button&, void) { SwTestAccountSettingsDialog aDlg(this); aDlg.run(); } -IMPL_LINK(SwMailConfigPage, SecureHdl, Button*, pBox, void) +IMPL_LINK(SwMailConfigPage, SecureHdl, weld::ToggleButton&, rBox, void) { - bool bEnable = static_cast<CheckBox*>(pBox)->IsChecked(); + bool bEnable = rBox.get_active(); m_pConfigItem->SetSecureConnection(bEnable); - m_pConfigItem->SetMailPort(static_cast<sal_Int16>(m_pPortNF->GetValue())); - m_pPortNF->SetValue(m_pConfigItem->GetMailPort()); + m_pConfigItem->SetMailPort(m_xPortNF->get_value()); + m_xPortNF->set_value(m_pConfigItem->GetMailPort()); } SwTestAccountSettingsDialog::SwTestAccountSettingsDialog(SwMailConfigPage* pParent) - : SfxDialogController(pParent->GetFrameWeld(), "modules/swriter/ui/testmailsettings.ui", "TestMailSettings") + : SfxDialogController(pParent->GetDialogFrameWeld(), "modules/swriter/ui/testmailsettings.ui", "TestMailSettings") , m_bStop(false) , m_pParent(pParent) , m_xStopPB(m_xBuilder->weld_button("stop")) @@ -341,9 +329,9 @@ void SwTestAccountSettingsDialog::Test() //check connection uno::Reference< uno::XCurrentContext> xConnectionContext = new SwConnectionContext( - m_pParent->m_pServerED->GetText(), - sal::static_int_cast< sal_Int16, sal_Int64 >(m_pParent->m_pPortNF->GetValue()), - m_pParent->m_pSecureCB->IsChecked() ? OUString("Ssl") : OUString("Insecure")); + m_pParent->m_xServerED->get_text(), + m_pParent->m_xPortNF->get_value(), + m_pParent->m_xSecureCB->get_active() ? OUString("Ssl") : OUString("Insecure")); xMailService->connect(xConnectionContext, xAuthenticator); bIsLoggedIn = xMailService->isConnected(); if( xInMailService.is() ) @@ -373,11 +361,12 @@ void SwTestAccountSettingsDialog::Test() } } -SwMailConfigDlg::SwMailConfigDlg(vcl::Window* pParent, SfxItemSet& rSet) - : SfxSingleTabDialog(pParent, rSet) +SwMailConfigDlg::SwMailConfigDlg(weld::Window* pParent, SfxItemSet& rSet) + : SfxSingleTabDialogController(pParent, rSet) { + TabPageParent pPageParent(get_content_area(), this); // create TabPage - SetTabPage(SwMailConfigPage::Create(get_content_area(), &rSet)); + SetTabPage(SwMailConfigPage::Create(pPageParent, &rSet)); } SwAuthenticationSettingsDialog::SwAuthenticationSettingsDialog( diff --git a/sw/source/ui/dbui/mmresultdialogs.cxx b/sw/source/ui/dbui/mmresultdialogs.cxx index a103d4001023..dfde81645aa8 100644 --- a/sw/source/ui/dbui/mmresultdialogs.cxx +++ b/sw/source/ui/dbui/mmresultdialogs.cxx @@ -850,8 +850,8 @@ IMPL_LINK_NOARG(SwMMResultEmailDialog, SendDocumentsHdl_Impl, weld::Button&, voi { SwView* pConfigView = pTargetView ? pTargetView : pView; SfxAllItemSet aSet(pConfigView->GetPool()); - ScopedVclPtrInstance<SwMailConfigDlg> pDlg(nullptr, aSet); - nRet = pDlg->Execute(); + SwMailConfigDlg aDlg(m_xDialog.get(), aSet); + nRet = aDlg.run(); } if(nRet != RET_OK && nRet != RET_YES) diff --git a/sw/source/uibase/inc/mailconfigpage.hxx b/sw/source/uibase/inc/mailconfigpage.hxx index a02ca329699b..136717c80193 100644 --- a/sw/source/uibase/inc/mailconfigpage.hxx +++ b/sw/source/uibase/inc/mailconfigpage.hxx @@ -32,45 +32,40 @@ class SwMailConfigPage : public SfxTabPage { friend class SwTestAccountSettingsDialog; - VclPtr<Edit> m_pDisplayNameED; - VclPtr<Edit> m_pAddressED; - - VclPtr<CheckBox> m_pReplyToCB; - VclPtr<FixedText> m_pReplyToFT; - VclPtr<Edit> m_pReplyToED; - - VclPtr<Edit> m_pServerED; - VclPtr<NumericField> m_pPortNF; - - VclPtr<CheckBox> m_pSecureCB; - - VclPtr<PushButton> m_pServerAuthenticationPB; - VclPtr<PushButton> m_pTestPB; - std::unique_ptr<SwMailMergeConfigItem> m_pConfigItem; - DECL_LINK(ReplyToHdl, Button*, void); - DECL_LINK(AuthenticationHdl, Button*, void); - DECL_LINK(TestHdl, Button*, void); - DECL_LINK(SecureHdl, Button*, void); + std::unique_ptr<weld::Entry> m_xDisplayNameED; + std::unique_ptr<weld::Entry> m_xAddressED; + std::unique_ptr<weld::CheckButton> m_xReplyToCB; + std::unique_ptr<weld::Label> m_xReplyToFT; + std::unique_ptr<weld::Entry> m_xReplyToED; + std::unique_ptr<weld::Entry> m_xServerED; + std::unique_ptr<weld::SpinButton> m_xPortNF; + std::unique_ptr<weld::CheckButton> m_xSecureCB; + std::unique_ptr<weld::Button> m_xServerAuthenticationPB; + std::unique_ptr<weld::Button> m_xTestPB; + + DECL_LINK(ReplyToHdl, weld::ToggleButton&, void); + DECL_LINK(AuthenticationHdl, weld::Button&, void); + DECL_LINK(TestHdl, weld::Button&, void); + DECL_LINK(SecureHdl, weld::ToggleButton&, void); public: - SwMailConfigPage( vcl::Window* pParent, const SfxItemSet& rSet ); + SwMailConfigPage(TabPageParent pParent, const SfxItemSet& rSet); virtual ~SwMailConfigPage() override; virtual void dispose() override; - static VclPtr<SfxTabPage> Create( TabPageParent pParent, - const SfxItemSet* rAttrSet); + static VclPtr<SfxTabPage> Create(TabPageParent pParent, + const SfxItemSet* rAttrSet); virtual bool FillItemSet( SfxItemSet* rSet ) override; virtual void Reset( const SfxItemSet* rSet ) override; - }; -class SwMailConfigDlg : public SfxSingleTabDialog +class SwMailConfigDlg : public SfxSingleTabDialogController { public: - SwMailConfigDlg(vcl::Window* pParent, SfxItemSet& rSet); + SwMailConfigDlg(weld::Window* pParent, SfxItemSet& rSet); }; #endif |