LibreOffice Module svtools (master) 1
restartdialog.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9
10#include <sal/config.h>
11
12#include <cassert>
13
14#include <com/sun/star/task/OfficeRestartManager.hpp>
15#include <com/sun/star/task/XInteractionHandler.hpp>
16#include <com/sun/star/uno/Reference.hxx>
17#include <com/sun/star/uno/XComponentContext.hpp>
19#include <tools/link.hxx>
20#include <vcl/weld.hxx>
21
22namespace {
23
24class RestartDialog : public weld::GenericDialogController{
25public:
26 RestartDialog(weld::Window* parent, svtools::RestartReason reason)
27 : GenericDialogController(parent, "svt/ui/restartdialog.ui", "RestartDialog")
28 , btnYes_(m_xBuilder->weld_button("yes"))
29 , btnNo_(m_xBuilder->weld_button("no"))
30 {
31 switch (reason) {
33 reason_ = m_xBuilder->weld_widget("reason_java");
34 break;
36 reason_ = m_xBuilder->weld_widget("reason_bibliography_install");
37 break;
39 reason_ = m_xBuilder->weld_widget("reason_mailmerge_install");
40 break;
42 reason_ = m_xBuilder->weld_widget("reason_language_change");
43 break;
45 reason_ = m_xBuilder->weld_widget("reason_adding_path");
46 break;
48 reason_ = m_xBuilder->weld_widget("reason_assigning_javaparameters");
49 break;
51 reason_ = m_xBuilder->weld_widget("reason_assigning_folders");
52 break;
54 reason_ = m_xBuilder->weld_widget("reason_exp_features");
55 break;
57 reason_ = m_xBuilder->weld_widget("reason_extension_install");
58 break;
60 reason_ = m_xBuilder->weld_widget("reason_skia");
61 break;
63 reason_ = m_xBuilder->weld_widget("reason_opencl");
64 break;
66 reason_ = m_xBuilder->weld_widget("reason_threading");
67 break;
69 reason_ = m_xBuilder->weld_widget("reason_mscompatible_formsmenu");
70 break;
72 reason_ = m_xBuilder->weld_widget("reason_uichange");
73 break;
74 default:
75 assert(false); // this cannot happen
76 }
77 reason_->show();
78 btnYes_->connect_clicked(LINK(this, RestartDialog, hdlYes));
79 btnNo_->connect_clicked(LINK(this, RestartDialog, hdlNo));
80 }
81private:
82 DECL_LINK(hdlYes, weld::Button&, void);
83 DECL_LINK(hdlNo, weld::Button&, void);
84
85 std::unique_ptr<weld::Widget> reason_;
86 std::unique_ptr<weld::Button> btnYes_;
87 std::unique_ptr<weld::Button> btnNo_;
88};
89
90IMPL_LINK_NOARG(RestartDialog, hdlYes, weld::Button&, void)
91{
92 m_xDialog->response(RET_OK);
93}
94
95IMPL_LINK_NOARG(RestartDialog, hdlNo, weld::Button&, void)
96{
97 m_xDialog->response(RET_CANCEL);
98}
99
100}
101
103 css::uno::Reference< css::uno::XComponentContext > const & context,
104 weld::Window* parent, RestartReason reason)
105{
106 auto xRestartManager = css::task::OfficeRestartManager::get(context);
107 if (xRestartManager->isRestartRequested(false))
108 return true; // don't try to show another dialog when restart is already in progress
109 RestartDialog aDlg(parent, reason);
110 if (aDlg.run()) {
111 xRestartManager->requestRestart(
112 css::uno::Reference< css::task::XInteractionHandler >());
113 return true;
114 }
115 return false;
116}
117
118/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< XExecutableDialog > m_xDialog
IMPL_LINK_NOARG(BrowserDataWin, RepeatedMouseMove, Timer *, void)
Definition: datwin.cxx:471
DECL_LINK(CheckNameHdl, SvxNameDialog &, bool)
@ RESTART_REASON_UI_CHANGE
@ RESTART_REASON_JAVA
@ RESTART_REASON_MSCOMPATIBLE_FORMS_MENU
@ RESTART_REASON_LANGUAGE_CHANGE
@ RESTART_REASON_OPENCL
@ RESTART_REASON_ADDING_PATH
@ RESTART_REASON_MAILMERGE_INSTALL
@ RESTART_REASON_THREADING
@ RESTART_REASON_ASSIGNING_JAVAPARAMETERS
@ RESTART_REASON_SKIA
@ RESTART_REASON_EXP_FEATURES
@ RESTART_REASON_EXTENSION_INSTALL
@ RESTART_REASON_BIBLIOGRAPHY_INSTALL
@ RESTART_REASON_ASSIGNING_FOLDERS
SVT_DLLPUBLIC bool executeRestartDialog(css::uno::Reference< css::uno::XComponentContext > const &context, weld::Window *parent, RestartReason reason)