Kaydet (Commit) 7de7e8ec authored tarafından Caolán McNamara's avatar Caolán McNamara

weld ScSolverProgressDialog

Change-Id: I5ee081b1c9e542a2b717b4eb27ee0aba7331d57d
Reviewed-on: https://gerrit.libreoffice.org/70071
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 554bae3e
...@@ -199,14 +199,13 @@ private: ...@@ -199,14 +199,13 @@ private:
DECL_LINK( SelectHdl, ListBox&, void ); DECL_LINK( SelectHdl, ListBox&, void );
}; };
class ScSolverProgressDialog : public ModelessDialog class ScSolverProgressDialog : public weld::GenericDialogController
{ {
VclPtr<FixedText> m_pFtTime; std::unique_ptr<weld::Label> m_xFtTime;
public: public:
ScSolverProgressDialog( vcl::Window* pParent ); ScSolverProgressDialog(weld::Window* pParent);
virtual ~ScSolverProgressDialog() override; virtual ~ScSolverProgressDialog() override;
virtual void dispose() override;
void HideTimeLimit(); void HideTimeLimit();
void SetTimeLimit( sal_Int32 nSeconds ); void SetTimeLimit( sal_Int32 nSeconds );
......
...@@ -45,35 +45,27 @@ ...@@ -45,35 +45,27 @@
using namespace com::sun::star; using namespace com::sun::star;
ScSolverProgressDialog::ScSolverProgressDialog(vcl::Window* pParent) ScSolverProgressDialog::ScSolverProgressDialog(weld::Window* pParent)
: ModelessDialog(pParent, "SolverProgressDialog", : GenericDialogController(pParent, "modules/scalc/ui/solverprogressdialog.ui",
"modules/scalc/ui/solverprogressdialog.ui") "SolverProgressDialog")
, m_xFtTime(m_xBuilder->weld_label("progress"))
{ {
get(m_pFtTime, "progress");
} }
ScSolverProgressDialog::~ScSolverProgressDialog() ScSolverProgressDialog::~ScSolverProgressDialog()
{ {
disposeOnce();
}
void ScSolverProgressDialog::dispose()
{
m_pFtTime.clear();
ModelessDialog::dispose();
} }
void ScSolverProgressDialog::HideTimeLimit() void ScSolverProgressDialog::HideTimeLimit()
{ {
m_pFtTime->Hide(); m_xFtTime->hide();
} }
void ScSolverProgressDialog::SetTimeLimit( sal_Int32 nSeconds ) void ScSolverProgressDialog::SetTimeLimit( sal_Int32 nSeconds )
{ {
OUString aOld = m_pFtTime->GetText(); OUString aOld = m_xFtTime->get_label();
OUString aNew = aOld.replaceFirst("#", OUString::number(nSeconds)); OUString aNew = aOld.replaceFirst("#", OUString::number(nSeconds));
m_pFtTime->SetText( aNew ); m_xFtTime->set_label(aNew);
} }
ScSolverNoSolutionDialog::ScSolverNoSolutionDialog(weld::Window* pParent, const OUString& rErrorText) ScSolverNoSolutionDialog::ScSolverNoSolutionDialog(weld::Window* pParent, const OUString& rErrorText)
...@@ -811,15 +803,15 @@ bool ScOptSolverDlg::CallSolver() // return true -> close dialog after cal ...@@ -811,15 +803,15 @@ bool ScOptSolverDlg::CallSolver() // return true -> close dialog after cal
{ {
// show progress dialog // show progress dialog
ScopedVclPtrInstance< ScSolverProgressDialog > aProgress( this ); std::shared_ptr<ScSolverProgressDialog> xProgress(new ScSolverProgressDialog(GetFrameWeld()));
sal_Int32 nTimeout = 0; sal_Int32 nTimeout = 0;
if ( FindTimeout( nTimeout ) ) if ( FindTimeout( nTimeout ) )
aProgress->SetTimeLimit( nTimeout ); xProgress->SetTimeLimit( nTimeout );
else else
aProgress->HideTimeLimit(); xProgress->HideTimeLimit();
aProgress->Show();
aProgress->Update(); weld::DialogController::runAsync(xProgress, [](sal_Int32 /*nResult*/){});
aProgress->Flush();
// try to make sure the progress dialog is painted before continuing // try to make sure the progress dialog is painted before continuing
Application::Reschedule(true); Application::Reschedule(true);
...@@ -1009,7 +1001,8 @@ bool ScOptSolverDlg::CallSolver() // return true -> close dialog after cal ...@@ -1009,7 +1001,8 @@ bool ScOptSolverDlg::CallSolver() // return true -> close dialog after cal
xSolver->solve(); xSolver->solve();
bool bSuccess = xSolver->getSuccess(); bool bSuccess = xSolver->getSuccess();
aProgress->Hide(); xProgress->response(RET_CLOSE);
bool bClose = false; bool bClose = false;
bool bRestore = true; // restore old values unless a solution is accepted bool bRestore = true; // restore old values unless a solution is accepted
if ( bSuccess ) if ( bSuccess )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment