From 7de7e8ecb5d53d219e47dccf9b1b767852b215e2 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 1 Apr 2019 14:57:37 +0100 Subject: weld ScSolverProgressDialog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I5ee081b1c9e542a2b717b4eb27ee0aba7331d57d Reviewed-on: https://gerrit.libreoffice.org/70071 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- sc/source/ui/inc/optsolver.hxx | 7 +++---- sc/source/ui/miscdlgs/optsolver.cxx | 37 +++++++++++++++---------------------- 2 files changed, 18 insertions(+), 26 deletions(-) diff --git a/sc/source/ui/inc/optsolver.hxx b/sc/source/ui/inc/optsolver.hxx index eae17564ada3..21b2b5c3ba6e 100644 --- a/sc/source/ui/inc/optsolver.hxx +++ b/sc/source/ui/inc/optsolver.hxx @@ -199,14 +199,13 @@ private: DECL_LINK( SelectHdl, ListBox&, void ); }; -class ScSolverProgressDialog : public ModelessDialog +class ScSolverProgressDialog : public weld::GenericDialogController { - VclPtr m_pFtTime; + std::unique_ptr m_xFtTime; public: - ScSolverProgressDialog( vcl::Window* pParent ); + ScSolverProgressDialog(weld::Window* pParent); virtual ~ScSolverProgressDialog() override; - virtual void dispose() override; void HideTimeLimit(); void SetTimeLimit( sal_Int32 nSeconds ); diff --git a/sc/source/ui/miscdlgs/optsolver.cxx b/sc/source/ui/miscdlgs/optsolver.cxx index 239591ac28ba..4fd377d87b47 100644 --- a/sc/source/ui/miscdlgs/optsolver.cxx +++ b/sc/source/ui/miscdlgs/optsolver.cxx @@ -45,35 +45,27 @@ using namespace com::sun::star; -ScSolverProgressDialog::ScSolverProgressDialog(vcl::Window* pParent) - : ModelessDialog(pParent, "SolverProgressDialog", - "modules/scalc/ui/solverprogressdialog.ui") +ScSolverProgressDialog::ScSolverProgressDialog(weld::Window* pParent) + : GenericDialogController(pParent, "modules/scalc/ui/solverprogressdialog.ui", + "SolverProgressDialog") + , m_xFtTime(m_xBuilder->weld_label("progress")) { - get(m_pFtTime, "progress"); } ScSolverProgressDialog::~ScSolverProgressDialog() { - disposeOnce(); -} - -void ScSolverProgressDialog::dispose() -{ - m_pFtTime.clear(); - ModelessDialog::dispose(); } - void ScSolverProgressDialog::HideTimeLimit() { - m_pFtTime->Hide(); + m_xFtTime->hide(); } void ScSolverProgressDialog::SetTimeLimit( sal_Int32 nSeconds ) { - OUString aOld = m_pFtTime->GetText(); + OUString aOld = m_xFtTime->get_label(); OUString aNew = aOld.replaceFirst("#", OUString::number(nSeconds)); - m_pFtTime->SetText( aNew ); + m_xFtTime->set_label(aNew); } ScSolverNoSolutionDialog::ScSolverNoSolutionDialog(weld::Window* pParent, const OUString& rErrorText) @@ -811,15 +803,15 @@ bool ScOptSolverDlg::CallSolver() // return true -> close dialog after cal { // show progress dialog - ScopedVclPtrInstance< ScSolverProgressDialog > aProgress( this ); + std::shared_ptr xProgress(new ScSolverProgressDialog(GetFrameWeld())); sal_Int32 nTimeout = 0; if ( FindTimeout( nTimeout ) ) - aProgress->SetTimeLimit( nTimeout ); + xProgress->SetTimeLimit( nTimeout ); else - aProgress->HideTimeLimit(); - aProgress->Show(); - aProgress->Update(); - aProgress->Flush(); + xProgress->HideTimeLimit(); + + weld::DialogController::runAsync(xProgress, [](sal_Int32 /*nResult*/){}); + // try to make sure the progress dialog is painted before continuing Application::Reschedule(true); @@ -1009,7 +1001,8 @@ bool ScOptSolverDlg::CallSolver() // return true -> close dialog after cal xSolver->solve(); bool bSuccess = xSolver->getSuccess(); - aProgress->Hide(); + xProgress->response(RET_CLOSE); + bool bClose = false; bool bRestore = true; // restore old values unless a solution is accepted if ( bSuccess ) -- cgit