From ff1bafa9755a1099f12cdf7c89dd62ec328dd223 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 1 Apr 2019 21:32:15 +0100 Subject: weld CrashReportDialog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ifc4b606596db1469af03748da2d04659b8fa443a Reviewed-on: https://gerrit.libreoffice.org/70124 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- svx/source/dialog/crashreportdlg.cxx | 97 ++++++++++++++++-------------------- svx/source/dialog/crashreportdlg.hxx | 34 +++++-------- svx/source/dialog/crashreportui.cxx | 4 +- 3 files changed, 58 insertions(+), 77 deletions(-) (limited to 'svx/source') diff --git a/svx/source/dialog/crashreportdlg.cxx b/svx/source/dialog/crashreportdlg.cxx index 70799f969bba..652bc4565ba0 100644 --- a/svx/source/dialog/crashreportdlg.cxx +++ b/svx/source/dialog/crashreportdlg.cxx @@ -22,60 +22,50 @@ #include #include -CrashReportDialog::CrashReportDialog(vcl::Window* pParent): - Dialog(pParent, "CrashReportDialog", - "svx/ui/crashreportdlg.ui") +CrashReportDialog::CrashReportDialog(weld::Window* pParent) + : GenericDialogController(pParent, "svx/ui/crashreportdlg.ui", + "CrashReportDialog") + , mxBtnSend(m_xBuilder->weld_button("btn_send")) + , mxBtnCancel(m_xBuilder->weld_button("btn_cancel")) + , mxBtnClose(m_xBuilder->weld_button("btn_close")) + , mxEditPreUpload(m_xBuilder->weld_label("ed_pre")) + , mxEditPostUpload(m_xBuilder->weld_text_view("ed_post")) + , mxFtBugReport(m_xBuilder->weld_text_view("ed_bugreport")) + , mxCBSafeMode(m_xBuilder->weld_check_button("check_safemode")) { - get(mpBtnSend, "btn_send"); - get(mpBtnCancel, "btn_cancel"); - get(mpBtnClose, "btn_close"); - get(mpEditPreUpload, "ed_pre"); - get(mpEditPostUpload, "ed_post"); - get(mpFtBugReport, "ed_bugreport"); - get(mpCBSafeMode, "check_safemode"); - - maSuccessMsg = mpEditPostUpload->GetText(); - - mpBtnSend->SetClickHdl(LINK(this, CrashReportDialog, BtnHdl)); - mpBtnCancel->SetClickHdl(LINK(this, CrashReportDialog, BtnHdl)); - mpBtnClose->SetClickHdl(LINK(this, CrashReportDialog, BtnHdl)); - mpEditPostUpload->SetReadOnly(); + maSuccessMsg = mxEditPostUpload->get_text(); + + auto nWidth = mxEditPreUpload->get_preferred_size().Width(); + nWidth = std::max(nWidth, mxCBSafeMode->get_size_request().Width()); + mxEditPreUpload->set_size_request(nWidth, -1); + mxCBSafeMode->set_size_request(nWidth, -1); + + mxBtnSend->connect_clicked(LINK(this, CrashReportDialog, BtnHdl)); + mxBtnCancel->connect_clicked(LINK(this, CrashReportDialog, BtnHdl)); + mxBtnClose->connect_clicked(LINK(this, CrashReportDialog, BtnHdl)); } CrashReportDialog::~CrashReportDialog() { - disposeOnce(); } -void CrashReportDialog::dispose() +short CrashReportDialog::run() { - mpBtnSend.clear(); - mpBtnCancel.clear(); - mpBtnClose.clear(); - mpEditPreUpload.clear(); - mpEditPostUpload.clear(); - mpFtBugReport.clear(); - mpCBSafeMode.clear(); - - Dialog::dispose(); -} + short nRet = GenericDialogController::run(); -bool CrashReportDialog::Close() -{ // Check whether to go to safe mode - if (mpCBSafeMode->IsChecked()) + if (mxCBSafeMode->get_active()) { sfx2::SafeMode::putFlag(); css::task::OfficeRestartManager::get(comphelper::getProcessComponentContext())->requestRestart( css::uno::Reference< css::task::XInteractionHandler >()); } - - return Dialog::Close(); + return nRet; } -IMPL_LINK(CrashReportDialog, BtnHdl, Button*, pBtn, void) +IMPL_LINK(CrashReportDialog, BtnHdl, weld::Button&, rBtn, void) { - if (pBtn == mpBtnSend.get()) + if (&rBtn == mxBtnSend.get()) { std::string ini_path = CrashReporter::getIniFileName(); @@ -89,32 +79,33 @@ IMPL_LINK(CrashReportDialog, BtnHdl, Button*, pBtn, void) OUString aProcessedMessage = maSuccessMsg.replaceAll("%CRASHID", aCrashID.replaceAll("Crash-ID=","")); // vclbuilder seems to replace _ with ~ even in text - mpEditPostUpload->SetText(aProcessedMessage.replaceAll("~", "_")); + mxEditPostUpload->set_text(aProcessedMessage.replaceAll("~", "_")); } else { - mpEditPostUpload->SetText(aCrashID); + mxEditPostUpload->set_text(aCrashID); } - mpBtnClose->Show(); - mpFtBugReport->Show(); - mpEditPreUpload->Hide(); - mpEditPostUpload->Show(); - mpBtnSend->Hide(); - mpBtnSend->Disable(); - mpBtnCancel->Hide(); - mpBtnCancel->Disable(); - mpBtnClose->GrabFocus(); - - setOptimalLayoutSize(); + mxBtnClose->show(); + mxFtBugReport->show(); + mxEditPostUpload->show(); + mxBtnSend->set_sensitive(false); + mxBtnCancel->set_sensitive(false); + mxBtnClose->grab_focus(); + + mxEditPreUpload->hide(); + mxBtnSend->hide(); + mxBtnCancel->hide(); + + m_xDialog->resize_to_request(); } - else if (pBtn == mpBtnCancel.get()) + else if (&rBtn == mxBtnCancel.get()) { - Close(); + m_xDialog->response(RET_CLOSE); } - else if (pBtn == mpBtnClose.get()) + else if (&rBtn == mxBtnClose.get()) { - Close(); + m_xDialog->response(RET_CLOSE); } } diff --git a/svx/source/dialog/crashreportdlg.hxx b/svx/source/dialog/crashreportdlg.hxx index b0014364bd06..f913cabac43f 100644 --- a/svx/source/dialog/crashreportdlg.hxx +++ b/svx/source/dialog/crashreportdlg.hxx @@ -10,37 +10,27 @@ #ifndef INCLUDED_SVX_SOURCE_DIALOG_CRASHREPORTDLG_HXX #define INCLUDED_SVX_SOURCE_DIALOG_CRASHREPORTDLG_HXX -#include -#include -#include -#include -#include +#include -class CrashReportDialog : public Dialog +class CrashReportDialog : public weld::GenericDialogController { public: - - explicit CrashReportDialog(vcl::Window* pParent); - + explicit CrashReportDialog(weld::Window* pParent); + virtual short run() override; virtual ~CrashReportDialog() override; - virtual void dispose() override; - - virtual bool Close() override; - private: - - VclPtr