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 /svtools/source/dialogs | |
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>
Diffstat (limited to 'svtools/source/dialogs')
-rw-r--r-- | svtools/source/dialogs/restartdialog.cxx | 73 |
1 files changed, 32 insertions, 41 deletions
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 >()); } |