diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-04-03 15:41:17 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-04-03 21:01:43 +0200 |
commit | 4329d9d8cf83f3642c068a1493c979a894328e26 (patch) | |
tree | 2149e82f6749afd2dff727f9c10ab4194d2b48b7 /sfx2/source | |
parent | 5672627a4d4adc613aecb3ccef721655d9dcd0b2 (diff) |
weld SfxViewVersionDialog_Impl
Change-Id: I5486df92b4e1d0ad5be18a35e72a7a6dbcc3b715
Reviewed-on: https://gerrit.libreoffice.org/52334
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 'sfx2/source')
-rw-r--r-- | sfx2/source/dialog/versdlg.cxx | 79 | ||||
-rw-r--r-- | sfx2/source/inc/versdlg.hxx | 23 |
2 files changed, 43 insertions, 59 deletions
diff --git a/sfx2/source/dialog/versdlg.cxx b/sfx2/source/dialog/versdlg.cxx index 9e29f167aade..79e59754ea9e 100644 --- a/sfx2/source/dialog/versdlg.cxx +++ b/sfx2/source/dialog/versdlg.cxx @@ -391,8 +391,8 @@ IMPL_LINK( SfxVersionDialog, ButtonHdl_Impl, Button*, pButton, void ) { SfxVersionInfo aInfo; aInfo.aAuthor = SvtUserOptions().GetFullName(); - VclPtrInstance< SfxViewVersionDialog_Impl > pDlg(this, aInfo, true); - short nRet = pDlg->Execute(); + SfxViewVersionDialog_Impl aDlg(GetFrameWeld(), aInfo, true); + short nRet = aDlg.run(); if ( nRet == RET_OK ) { SfxStringItem aComment( SID_DOCINFO_COMMENTS, aInfo.aComment ); @@ -423,8 +423,8 @@ IMPL_LINK( SfxVersionDialog, ButtonHdl_Impl, Button*, pButton, void ) else if (pButton == m_pViewButton && pEntry) { SfxVersionInfo* pInfo = static_cast<SfxVersionInfo*>(pEntry->GetUserData()); - VclPtrInstance<SfxViewVersionDialog_Impl> pDlg(this, *pInfo, false); - pDlg->Execute(); + SfxViewVersionDialog_Impl aDlg(GetFrameWeld(), *pInfo, false); + aDlg.run(); } else if (pEntry && pButton == m_pCompareButton) { @@ -451,65 +451,48 @@ IMPL_LINK( SfxVersionDialog, ButtonHdl_Impl, Button*, pButton, void ) } } -SfxViewVersionDialog_Impl::SfxViewVersionDialog_Impl(vcl::Window *pParent, SfxVersionInfo& rInfo, bool bEdit) - : SfxModalDialog(pParent, "VersionCommentDialog", "sfx/ui/versioncommentdialog.ui") +SfxViewVersionDialog_Impl::SfxViewVersionDialog_Impl(weld::Window *pParent, SfxVersionInfo& rInfo, bool bEdit) + : GenericDialogController(pParent, "sfx/ui/versioncommentdialog.ui", "VersionCommentDialog") , m_rInfo(rInfo) + , m_xDateTimeText(m_xBuilder->weld_label("timestamp")) + , m_xSavedByText(m_xBuilder->weld_label("author")) + , m_xEdit(m_xBuilder->weld_text_view("textview")) + , m_xOKButton(m_xBuilder->weld_button("ok")) + , m_xCancelButton(m_xBuilder->weld_button("cancel")) + , m_xCloseButton(m_xBuilder->weld_button("close")) { - get(m_pDateTimeText, "timestamp"); - get(m_pSavedByText, "author"); - get(m_pEdit, "textview"); - get(m_pOKButton, "ok"); - get(m_pCancelButton, "cancel"); - get(m_pCloseButton, "close"); - OUString sAuthor = rInfo.aAuthor.isEmpty() ? SfxResId(STR_NO_NAME_SET) : rInfo.aAuthor; const LocaleDataWrapper& rLocaleWrapper( Application::GetSettings().GetLocaleDataWrapper() ); - m_pDateTimeText->SetText(m_pDateTimeText->GetText() + formatTime(rInfo.aCreationDate, rLocaleWrapper)); - m_pSavedByText->SetText(m_pSavedByText->GetText() + sAuthor); - m_pEdit->SetText(rInfo.aComment); - m_pEdit->set_height_request(7 * m_pEdit->GetTextHeight()); - m_pEdit->set_width_request(40 * m_pEdit->approximate_char_width()); - m_pOKButton->SetClickHdl(LINK(this, SfxViewVersionDialog_Impl, ButtonHdl)); + m_xDateTimeText->set_label(m_xDateTimeText->get_label() + formatTime(rInfo.aCreationDate, rLocaleWrapper)); + m_xSavedByText->set_label(m_xSavedByText->get_label() + sAuthor); + m_xEdit->set_text(rInfo.aComment); + m_xEdit->set_size_request(40 * m_xEdit->get_approximate_digit_width(), + 7 * m_xEdit->get_text_height()); + m_xOKButton->connect_clicked(LINK(this, SfxViewVersionDialog_Impl, ButtonHdl)); if (!bEdit) { - m_pOKButton->Hide(); - m_pCancelButton->Hide(); - m_pEdit->SetReadOnly(); - SetText(SfxResId(STR_VIEWVERSIONCOMMENT)); - m_pCloseButton->GrabFocus(); + m_xOKButton->hide(); + m_xCancelButton->hide(); + m_xEdit->set_editable(false); + m_xDialog->set_title(SfxResId(STR_VIEWVERSIONCOMMENT)); + m_xCloseButton->grab_focus(); } else { - m_pDateTimeText->Hide(); - m_pCloseButton->Hide(); - m_pEdit->GrabFocus(); + m_xDateTimeText->hide(); + m_xCloseButton->hide(); + m_xEdit->grab_focus(); } } -SfxViewVersionDialog_Impl::~SfxViewVersionDialog_Impl() -{ - disposeOnce(); -} - -void SfxViewVersionDialog_Impl::dispose() -{ - m_pDateTimeText.clear(); - m_pSavedByText.clear(); - m_pEdit.clear(); - m_pOKButton.clear(); - m_pCancelButton.clear(); - m_pCloseButton.clear(); - SfxModalDialog::dispose(); -} - -IMPL_LINK(SfxViewVersionDialog_Impl, ButtonHdl, Button*, pButton, void) +IMPL_LINK(SfxViewVersionDialog_Impl, ButtonHdl, weld::Button&, rButton, void) { - assert(pButton == m_pOKButton); - (void)pButton; - m_rInfo.aComment = m_pEdit->GetText(); - EndDialog(RET_OK); + assert(&rButton == m_xOKButton.get()); + (void)rButton; + m_rInfo.aComment = m_xEdit->get_text(); + m_xDialog->response(RET_OK); } SfxCmisVersionsDialog::SfxCmisVersionsDialog ( SfxViewFrame* pVwFrame ) diff --git a/sfx2/source/inc/versdlg.hxx b/sfx2/source/inc/versdlg.hxx index 3fe32e8e065b..4d81c139a1e9 100644 --- a/sfx2/source/inc/versdlg.hxx +++ b/sfx2/source/inc/versdlg.hxx @@ -26,6 +26,7 @@ #include <svtools/svtabbx.hxx> #include <vcl/button.hxx> #include <vcl/fixed.hxx> +#include <vcl/weld.hxx> class SfxViewFrame; struct SfxVersionInfo; @@ -70,22 +71,22 @@ public: bool IsSaveVersionOnClose() const { return m_bIsSaveVersionOnClose; } }; -class SfxViewVersionDialog_Impl : public SfxModalDialog +class SfxViewVersionDialog_Impl : public weld::GenericDialogController { - VclPtr<FixedText> m_pDateTimeText; - VclPtr<FixedText> m_pSavedByText; - VclPtr<VclMultiLineEdit> m_pEdit; - VclPtr<OKButton> m_pOKButton; - VclPtr<CancelButton> m_pCancelButton; - VclPtr<CloseButton> m_pCloseButton; +private: SfxVersionInfo& m_rInfo; - DECL_LINK(ButtonHdl, Button*, void); + std::unique_ptr<weld::Label> m_xDateTimeText; + std::unique_ptr<weld::Label> m_xSavedByText; + std::unique_ptr<weld::TextView> m_xEdit; + std::unique_ptr<weld::Button> m_xOKButton; + std::unique_ptr<weld::Button> m_xCancelButton; + std::unique_ptr<weld::Button> m_xCloseButton; + + DECL_LINK(ButtonHdl, weld::Button&, void); public: - SfxViewVersionDialog_Impl(vcl::Window *pParent, SfxVersionInfo& rInfo, bool bEdit); - virtual ~SfxViewVersionDialog_Impl() override; - virtual void dispose() override; + SfxViewVersionDialog_Impl(weld::Window *pParent, SfxVersionInfo& rInfo, bool bEdit); }; class SfxCmisVersionsDialog : public SfxModalDialog |