diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-04-01 21:32:15 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-04-02 12:36:29 +0200 |
commit | ff1bafa9755a1099f12cdf7c89dd62ec328dd223 (patch) | |
tree | 29261d3166a017332f073c9f882dd5ed53529146 /svx/source | |
parent | b8485778b3acbca8db44d4cb1576de4ecee02de2 (diff) |
weld CrashReportDialog
Change-Id: Ifc4b606596db1469af03748da2d04659b8fa443a
Reviewed-on: https://gerrit.libreoffice.org/70124
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svx/source')
-rw-r--r-- | svx/source/dialog/crashreportdlg.cxx | 97 | ||||
-rw-r--r-- | svx/source/dialog/crashreportdlg.hxx | 34 | ||||
-rw-r--r-- | svx/source/dialog/crashreportui.cxx | 4 |
3 files changed, 58 insertions, 77 deletions
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 <com/sun/star/task/OfficeRestartManager.hpp> #include <com/sun/star/task/XInteractionHandler.hpp> -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 <vcl/dialog.hxx> -#include <vcl/button.hxx> -#include <vcl/fixed.hxx> -#include <vcl/edit.hxx> -#include <vcl/vclmedit.hxx> +#include <vcl/weld.hxx> -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<Button> mpBtnSend; - VclPtr<Button> mpBtnCancel; - VclPtr<Button> mpBtnClose; - VclPtr<FixedText> mpEditPreUpload; - VclPtr<VclMultiLineEdit> mpEditPostUpload; - VclPtr<VclMultiLineEdit> mpFtBugReport; - VclPtr<CheckBox> mpCBSafeMode; + std::unique_ptr<weld::Button> mxBtnSend; + std::unique_ptr<weld::Button> mxBtnCancel; + std::unique_ptr<weld::Button> mxBtnClose; + std::unique_ptr<weld::Label> mxEditPreUpload; + std::unique_ptr<weld::TextView> mxEditPostUpload; + std::unique_ptr<weld::TextView> mxFtBugReport; + std::unique_ptr<weld::CheckButton> mxCBSafeMode; OUString maSuccessMsg; - DECL_LINK(BtnHdl, Button*, void); + DECL_LINK(BtnHdl, weld::Button&, void); }; #endif diff --git a/svx/source/dialog/crashreportui.cxx b/svx/source/dialog/crashreportui.cxx index fe12a1de28a1..535124d96c50 100644 --- a/svx/source/dialog/crashreportui.cxx +++ b/svx/source/dialog/crashreportui.cxx @@ -63,8 +63,8 @@ css::uno::Any SAL_CALL CrashReportUI::dispatchWithReturnValue(const css::util::U { SolarMutexGuard aGuard; css::uno::Any aRet; - ScopedVclPtrInstance<CrashReportDialog> xDialog(nullptr); - xDialog->Execute(); + CrashReportDialog aDialog(nullptr); + aDialog.run(); return aRet; } |