diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-04-11 12:53:18 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-04-11 15:37:27 +0200 |
commit | a87569e9ea8db9a0d869570613603eebf7c145e8 (patch) | |
tree | 804a8673c5c763bbffef835e5fba65d7e46ececf | |
parent | 5afe093d8994c37d239001e8e272ab86eea62dcb (diff) |
weld RestartDialog
Change-Id: Iae97806a11b6c950931a342d06b3eeea168c7559
Reviewed-on: https://gerrit.libreoffice.org/52721
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | cui/source/options/treeopt.cxx | 2 | ||||
-rw-r--r-- | desktop/source/deployment/gui/dp_gui_dialog2.cxx | 3 | ||||
-rw-r--r-- | include/svtools/restartdialog.hxx | 4 | ||||
-rw-r--r-- | svtools/source/dialogs/restartdialog.cxx | 73 | ||||
-rw-r--r-- | svtools/uiconfig/ui/restartdialog.ui | 8 |
5 files changed, 44 insertions, 46 deletions
diff --git a/cui/source/options/treeopt.cxx b/cui/source/options/treeopt.cxx index 993aaaf7ec86..3c44cd6089af 100644 --- a/cui/source/options/treeopt.cxx +++ b/cui/source/options/treeopt.cxx @@ -712,7 +712,7 @@ IMPL_LINK_NOARG(OfaTreeOptionsDialog, OKHdl_Impl, Button*, void) { SolarMutexGuard aGuard; ::svtools::executeRestartDialog(comphelper::getProcessComponentContext(), - static_cast<vcl::Window*>(m_pParent), eRestartReason); + m_pParent->GetFrameWeld(), eRestartReason); } } diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx b/desktop/source/deployment/gui/dp_gui_dialog2.cxx index 13f34f66f5f8..38072271b33c 100644 --- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx @@ -1023,7 +1023,8 @@ IMPL_STATIC_LINK(ExtMgrDialog, Restart, void*, pParent, void) { SolarMutexGuard aGuard; ::svtools::executeRestartDialog(comphelper::getProcessComponentContext(), - static_cast<vcl::Window*>(pParent), svtools::RESTART_REASON_EXTENSION_INSTALL); + pParent ? static_cast<vcl::Window*>(pParent)->GetFrameWeld() : nullptr, + svtools::RESTART_REASON_EXTENSION_INSTALL); } bool ExtMgrDialog::Close() diff --git a/include/svtools/restartdialog.hxx b/include/svtools/restartdialog.hxx index 996bdc010085..750542a37459 100644 --- a/include/svtools/restartdialog.hxx +++ b/include/svtools/restartdialog.hxx @@ -15,7 +15,7 @@ #include <com/sun/star/uno/Reference.hxx> #include <svtools/svtdllapi.h> -namespace vcl { class Window; } +namespace weld { class Window; } namespace com { namespace sun { namespace star { namespace uno { class XComponentContext; } } } } @@ -61,7 +61,7 @@ enum RestartReason { // Must be called with the solar mutex locked: SVT_DLLPUBLIC void executeRestartDialog( css::uno::Reference< css::uno::XComponentContext > const & context, - vcl::Window * parent, RestartReason reason); + weld::Window* parent, RestartReason reason); } diff --git a/svtools/source/dialogs/restartdialog.cxx b/svtools/source/dialogs/restartdialog.cxx index fc8e6e30bcf6..122f314eccd8 100644 --- a/svtools/source/dialogs/restartdialog.cxx +++ b/svtools/source/dialogs/restartdialog.cxx @@ -17,94 +17,85 @@ #include <com/sun/star/uno/XComponentContext.hpp> #include <svtools/restartdialog.hxx> #include <tools/link.hxx> -#include <vcl/button.hxx> -#include <vcl/dialog.hxx> -#include <vcl/window.hxx> +#include <vcl/weld.hxx> namespace { -class RestartDialog: public ModalDialog { +class RestartDialog : public weld::GenericDialogController{ public: - RestartDialog(vcl::Window * parent, svtools::RestartReason reason): - ModalDialog(parent, "RestartDialog", "svt/ui/restartdialog.ui") + RestartDialog(weld::Window* parent, svtools::RestartReason reason) + : GenericDialogController(parent, "svt/ui/restartdialog.ui", "RestartDialog") + , btnYes_(m_xBuilder->weld_button("yes")) + , btnNo_(m_xBuilder->weld_button("no")) { - get(btnYes_, "yes"); - get(btnNo_, "no"); switch (reason) { case svtools::RESTART_REASON_JAVA: - get(reason_, "reason_java"); + reason_.reset(m_xBuilder->weld_widget("reason_java")); break; case svtools::RESTART_REASON_PDF_AS_STANDARD_JOB_FORMAT: - get(reason_, "reason_pdf"); + reason_.reset(m_xBuilder->weld_widget("reason_pdf")); break; case svtools::RESTART_REASON_BIBLIOGRAPHY_INSTALL: - get(reason_, "reason_bibliography_install"); + reason_.reset(m_xBuilder->weld_widget("reason_bibliography_install")); break; case svtools::RESTART_REASON_MAILMERGE_INSTALL: - get(reason_, "reason_mailmerge_install"); + reason_.reset(m_xBuilder->weld_widget("reason_mailmerge_install")); break; case svtools::RESTART_REASON_LANGUAGE_CHANGE: - get(reason_, "reason_language_change"); + reason_.reset(m_xBuilder->weld_widget("reason_language_change")); break; case svtools::RESTART_REASON_ADDING_PATH: - get(reason_, "reason_adding_path"); + reason_.reset(m_xBuilder->weld_widget("reason_adding_path")); break; case svtools::RESTART_REASON_ASSIGNING_JAVAPARAMETERS: - get(reason_, "reason_assigning_javaparameters"); + reason_.reset(m_xBuilder->weld_widget("reason_assigning_javaparameters")); break; case svtools::RESTART_REASON_ASSIGNING_FOLDERS: - get(reason_, "reason_assigning_folders"); + reason_.reset(m_xBuilder->weld_widget("reason_assigning_folders")); break; case svtools::RESTART_REASON_EXP_FEATURES: - get(reason_,"reason_exp_features"); + reason_.reset(m_xBuilder->weld_widget("reason_exp_features")); break; case svtools::RESTART_REASON_EXTENSION_INSTALL: - get(reason_, "reason_extension_install"); + reason_.reset(m_xBuilder->weld_widget("reason_extension_install")); break; case svtools::RESTART_REASON_OPENGL: - get(reason_, "reason_opengl"); + reason_.reset(m_xBuilder->weld_widget("reason_opengl")); break; default: assert(false); // this cannot happen } - reason_->Show(); - btnYes_->SetClickHdl(LINK(this, RestartDialog, hdlYes)); - btnNo_->SetClickHdl(LINK(this, RestartDialog, hdlNo)); - } - virtual ~RestartDialog() override { disposeOnce(); } - virtual void dispose() override - { - reason_.clear(); - btnYes_.clear(); - btnNo_.clear(); - ModalDialog::dispose(); + reason_->show(); + btnYes_->connect_clicked(LINK(this, RestartDialog, hdlYes)); + btnNo_->connect_clicked(LINK(this, RestartDialog, hdlNo)); } private: - DECL_LINK(hdlYes, Button*, void); - DECL_LINK(hdlNo, Button*, void); + DECL_LINK(hdlYes, weld::Button&, void); + DECL_LINK(hdlNo, weld::Button&, void); - VclPtr<vcl::Window> reason_; - VclPtr<PushButton> btnYes_; - VclPtr<PushButton> btnNo_; + std::unique_ptr<weld::Widget> reason_; + std::unique_ptr<weld::Button> btnYes_; + std::unique_ptr<weld::Button> btnNo_; }; -IMPL_LINK_NOARG(RestartDialog, hdlYes, Button*, void) +IMPL_LINK_NOARG(RestartDialog, hdlYes, weld::Button&, void) { - EndDialog(RET_OK); + m_xDialog->response(RET_OK); } -IMPL_LINK_NOARG(RestartDialog, hdlNo, Button*, void) +IMPL_LINK_NOARG(RestartDialog, hdlNo, weld::Button&, void) { - EndDialog(); + m_xDialog->response(RET_CANCEL); } } void svtools::executeRestartDialog( css::uno::Reference< css::uno::XComponentContext > const & context, - vcl::Window * parent, RestartReason reason) + weld::Window* parent, RestartReason reason) { - if (ScopedVclPtrInstance<RestartDialog>(parent, reason)->Execute()) { + RestartDialog aDlg(parent, reason); + if (aDlg.run()) { css::task::OfficeRestartManager::get(context)->requestRestart( css::uno::Reference< css::task::XInteractionHandler >()); } diff --git a/svtools/uiconfig/ui/restartdialog.ui b/svtools/uiconfig/ui/restartdialog.ui index 0f59355e0ae0..f9c4ebc95b28 100644 --- a/svtools/uiconfig/ui/restartdialog.ui +++ b/svtools/uiconfig/ui/restartdialog.ui @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.20.0 --> +<!-- Generated with glade 3.20.4 --> <interface domain="svt"> <requires lib="gtk+" version="3.18"/> <object class="GtkDialog" id="RestartDialog"> @@ -7,6 +7,9 @@ <property name="border_width">6</property> <property name="title" translatable="yes" context="restartdialog|RestartDialog">Restart %PRODUCTNAME</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 internal-child="vbox"> <object class="GtkBox" id="dialog-vbox1"> @@ -252,5 +255,8 @@ <action-widget response="-8">yes</action-widget> <action-widget response="-9">no</action-widget> </action-widgets> + <child> + <placeholder/> + </child> </object> </interface> |