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 | |
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>
-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 | ||||
-rw-r--r-- | svx/uiconfig/ui/crashreportdlg.ui | 38 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 19 |
5 files changed, 99 insertions, 93 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; } diff --git a/svx/uiconfig/ui/crashreportdlg.ui b/svx/uiconfig/ui/crashreportdlg.ui index 28547f66602b..a31f50aa3bcf 100644 --- a/svx/uiconfig/ui/crashreportdlg.ui +++ b/svx/uiconfig/ui/crashreportdlg.ui @@ -16,8 +16,13 @@ Thank you for your help in improving %PRODUCTNAME.</property> <property name="can_focus">False</property> <property name="border_width">6</property> <property name="title" translatable="yes" context="crashreportdlg|CrashReportDialog">Crash Report</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> @@ -32,6 +37,7 @@ Thank you for your help in improving %PRODUCTNAME.</property> <property name="label" translatable="yes" context="crashreportdlg|btn_send">_Send Crash Report</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_underline">True</property> @@ -95,9 +101,9 @@ You can help us to fix this issue by sending an anonymous crash report to the %P <property name="can_focus">False</property> <property name="valign">center</property> <property name="editable">False</property> - <property name="wrap_mode">word</property> <property name="cursor_visible">False</property> <property name="buffer">textbuffer1</property> + <property name="accepts_tab">False</property> </object> <packing> <property name="expand">False</property> @@ -106,27 +112,27 @@ You can help us to fix this issue by sending an anonymous crash report to the %P </packing> </child> <child> - <object class="GtkCheckButton" id="check_safemode"> - <property name="label" translatable="yes" context="crashreportdlg|check_safemode">Restart %PRODUCTNAME to enter safe mode</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="xalign">0</property> - <property name="draw_indicator">True</property> + <object class="GtkTextView" id="ed_bugreport"> + <property name="can_focus">False</property> + <property name="editable">False</property> + <property name="cursor_visible">False</property> + <property name="buffer">textbuffer2</property> + <property name="accepts_tab">False</property> </object> <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">3</property> + <property name="position">2</property> </packing> </child> <child> - <object class="GtkTextView" id="ed_bugreport"> - <property name="can_focus">False</property> - <property name="editable">False</property> - <property name="wrap_mode">word</property> - <property name="cursor_visible">False</property> - <property name="buffer">textbuffer2</property> + <object class="GtkCheckButton" id="check_safemode"> + <property name="label" translatable="yes" context="crashreportdlg|check_safemode">Restart %PRODUCTNAME to enter safe mode</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> </object> <packing> <property name="expand">False</property> diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 1a1713568e9b..3a3864398f48 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -8927,6 +8927,25 @@ private: if (gtk_label_get_use_underline(pLabel)) m_aMnemonicLabels.push_back(pLabel); } + else if (GTK_IS_TEXT_VIEW(pWidget)) + { + GtkTextView* pTextView = GTK_TEXT_VIEW(pWidget); + if (m_pStringReplace != nullptr) + { + GtkTextBuffer* pBuffer = gtk_text_view_get_buffer(pTextView); + GtkTextIter start, end; + gtk_text_buffer_get_bounds(pBuffer, &start, &end); + char* pTextStr = gtk_text_buffer_get_text(pBuffer, &start, &end, true); + int nTextLen = pTextStr ? strlen(pTextStr) : 0; + if (nTextLen) + { + OUString sOldText = OUString(pTextStr, nTextLen, RTL_TEXTENCODING_UTF8); + OString sText(OUStringToOString((*m_pStringReplace)(sOldText), RTL_TEXTENCODING_UTF8)); + gtk_text_buffer_set_text(pBuffer, sText.getStr(), sText.getLength()); + } + g_free(pTextStr); + } + } else if (GTK_IS_WINDOW(pWidget)) { if (m_pStringReplace != nullptr) { |