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

weld UpdateInstallDialog

Change-Id: I56f1de2ac91076a35f1f3583d7500e5b2fa4ce54
Reviewed-on: https://gerrit.libreoffice.org/68315
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst ac40c9aa
...@@ -915,7 +915,8 @@ void ExtensionCmdQueue::Thread::_checkForUpdates( ...@@ -915,7 +915,8 @@ void ExtensionCmdQueue::Thread::_checkForUpdates(
short nDialogResult = RET_OK; short nDialogResult = RET_OK;
if ( !dataDownload.empty() ) if ( !dataDownload.empty() )
{ {
nDialogResult = ScopedVclPtrInstance<UpdateInstallDialog>( m_pDialogHelper? m_pDialogHelper->getWindow() : nullptr, dataDownload, m_xContext )->Execute(); UpdateInstallDialog aDlg(m_pDialogHelper? m_pDialogHelper->getFrameWeld() : nullptr, dataDownload, m_xContext);
nDialogResult = aDlg.run();
pUpdateDialog->notifyMenubar( false, true ); // Check, if there are still pending updates to be notified via menu bar icon pUpdateDialog->notifyMenubar( false, true ); // Check, if there are still pending updates to be notified via menu bar icon
} }
else else
......
...@@ -191,80 +191,62 @@ void UpdateInstallDialog::Thread::execute() ...@@ -191,80 +191,62 @@ void UpdateInstallDialog::Thread::execute()
} }
UpdateInstallDialog::UpdateInstallDialog( UpdateInstallDialog::UpdateInstallDialog(
vcl::Window * parent, weld::Window* pParent,
std::vector<dp_gui::UpdateData> & aVecUpdateData, std::vector<dp_gui::UpdateData> & aVecUpdateData,
cssu::Reference< cssu::XComponentContext > const & xCtx): cssu::Reference< cssu::XComponentContext > const & xCtx)
ModalDialog( : GenericDialogController(pParent, "desktop/ui/updateinstalldialog.ui",
parent, "UpdateInstallDialog")
"UpdateInstallDialog","desktop/ui/updateinstalldialog.ui"), , m_thread(new Thread(xCtx, *this, aVecUpdateData))
, m_bError(false)
m_thread(new Thread(xCtx, *this, aVecUpdateData)), , m_bNoEntry(true)
m_bError(false), , m_sInstalling(DpResId(RID_DLG_UPDATE_INSTALL_INSTALLING))
m_bNoEntry(true), , m_sFinished(DpResId(RID_DLG_UPDATE_INSTALL_FINISHED))
m_sInstalling(DpResId(RID_DLG_UPDATE_INSTALL_INSTALLING)), , m_sNoErrors(DpResId(RID_DLG_UPDATE_INSTALL_NO_ERRORS))
m_sFinished(DpResId(RID_DLG_UPDATE_INSTALL_FINISHED)), , m_sErrorDownload(DpResId(RID_DLG_UPDATE_INSTALL_ERROR_DOWNLOAD))
m_sNoErrors(DpResId(RID_DLG_UPDATE_INSTALL_NO_ERRORS)), , m_sErrorInstallation(DpResId(RID_DLG_UPDATE_INSTALL_ERROR_INSTALLATION))
m_sErrorDownload(DpResId(RID_DLG_UPDATE_INSTALL_ERROR_DOWNLOAD)), , m_sErrorLicenseDeclined(DpResId(RID_DLG_UPDATE_INSTALL_ERROR_LIC_DECLINED))
m_sErrorInstallation(DpResId(RID_DLG_UPDATE_INSTALL_ERROR_INSTALLATION)), , m_sNoInstall(DpResId(RID_DLG_UPDATE_INSTALL_EXTENSION_NOINSTALL))
m_sErrorLicenseDeclined(DpResId(RID_DLG_UPDATE_INSTALL_ERROR_LIC_DECLINED)), , m_sThisErrorOccurred(DpResId(RID_DLG_UPDATE_INSTALL_THIS_ERROR_OCCURRED))
m_sNoInstall(DpResId(RID_DLG_UPDATE_INSTALL_EXTENSION_NOINSTALL)), , m_xFt_action(m_xBuilder->weld_label("DOWNLOADING"))
m_sThisErrorOccurred(DpResId(RID_DLG_UPDATE_INSTALL_THIS_ERROR_OCCURRED)) , m_xStatusbar(m_xBuilder->weld_progress_bar("STATUSBAR"))
, m_xFt_extension_name(m_xBuilder->weld_label("EXTENSION_NAME"))
, m_xMle_info(m_xBuilder->weld_text_view("INFO"))
, m_xHelp(m_xBuilder->weld_button("help"))
, m_xOk(m_xBuilder->weld_button("ok"))
, m_xCancel(m_xBuilder->weld_button("cancel"))
{ {
get(m_pFt_action, "DOWNLOADING"); m_xMle_info->set_size_request(m_xMle_info->get_approximate_digit_width() * 52,
get(m_pStatusbar, "STATUSBAR"); m_xMle_info->get_height_rows(5));
get(m_pFt_extension_name, "EXTENSION_NAME");
get(m_pMle_info, "INFO");
m_pMle_info->set_height_request(m_pMle_info->GetTextHeight() * 5);
m_pMle_info->set_width_request(m_pMle_info->approximate_char_width() * 56);
get(m_pHelp, "help");
get(m_pOk, "ok");
get(m_pCancel, "cancel");
m_xExtensionManager = css::deployment::ExtensionManager::get( xCtx ); m_xExtensionManager = css::deployment::ExtensionManager::get( xCtx );
m_pCancel->SetClickHdl(LINK(this, UpdateInstallDialog, cancelHandler)); m_xCancel->connect_clicked(LINK(this, UpdateInstallDialog, cancelHandler));
if ( ! dp_misc::office_is_running()) if ( ! dp_misc::office_is_running())
m_pHelp->Disable(); m_xHelp->set_sensitive(false);
} }
UpdateInstallDialog::~UpdateInstallDialog() UpdateInstallDialog::~UpdateInstallDialog()
{ {
disposeOnce();
} }
void UpdateInstallDialog::dispose() short UpdateInstallDialog::run()
{
m_pFt_action.clear();
m_pStatusbar.clear();
m_pFt_extension_name.clear();
m_pMle_info.clear();
m_pHelp.clear();
m_pOk.clear();
m_pCancel.clear();
ModalDialog::dispose();
}
bool UpdateInstallDialog::Close()
{
m_thread->stop();
return ModalDialog::Close();
}
short UpdateInstallDialog::Execute()
{ {
m_thread->launch(); m_thread->launch();
return ModalDialog::Execute(); short nRet = GenericDialogController::run();
m_thread->stop();
return nRet;
} }
// make sure the solar mutex is locked before calling // make sure the solar mutex is locked before calling
void UpdateInstallDialog::updateDone() void UpdateInstallDialog::updateDone()
{ {
if (!m_bError) if (!m_bError)
m_pMle_info->SetText(m_pMle_info->GetText() + m_sNoErrors); m_xMle_info->set_text(m_xMle_info->get_text() + m_sNoErrors);
m_pOk->Enable(); m_xOk->set_sensitive(true);
m_pOk->GrabFocus(); m_xOk->grab_focus();
m_pCancel->Disable(); m_xCancel->set_sensitive(false);
} }
// make sure the solar mutex is locked before calling // make sure the solar mutex is locked before calling
//sets an error message in the text area //sets an error message in the text area
void UpdateInstallDialog::setError(INSTALL_ERROR err, OUString const & sExtension, void UpdateInstallDialog::setError(INSTALL_ERROR err, OUString const & sExtension,
...@@ -289,7 +271,7 @@ void UpdateInstallDialog::setError(INSTALL_ERROR err, OUString const & sExtensio ...@@ -289,7 +271,7 @@ void UpdateInstallDialog::setError(INSTALL_ERROR err, OUString const & sExtensio
OSL_ASSERT(false); OSL_ASSERT(false);
} }
OUString sMsg(m_pMle_info->GetText()); OUString sMsg(m_xMle_info->get_text());
sError = sError.replaceFirst("%NAME", sExtension); sError = sError.replaceFirst("%NAME", sExtension);
//We want to have an empty line between the error messages. However, //We want to have an empty line between the error messages. However,
//there shall be no empty line after the last entry. //there shall be no empty line after the last entry.
...@@ -304,19 +286,18 @@ void UpdateInstallDialog::setError(INSTALL_ERROR err, OUString const & sExtensio ...@@ -304,19 +286,18 @@ void UpdateInstallDialog::setError(INSTALL_ERROR err, OUString const & sExtensio
sMsg += m_sNoInstall + "\n"; sMsg += m_sNoInstall + "\n";
m_pMle_info->SetText(sMsg); m_xMle_info->set_text(sMsg);
} }
void UpdateInstallDialog::setError(OUString const & exceptionMessage) void UpdateInstallDialog::setError(OUString const & exceptionMessage)
{ {
m_bError = true; m_bError = true;
m_pMle_info->SetText(m_pMle_info->GetText() + exceptionMessage + "\n"); m_xMle_info->set_text(m_xMle_info->get_text() + exceptionMessage + "\n");
} }
IMPL_LINK_NOARG(UpdateInstallDialog, cancelHandler, Button*, void) IMPL_LINK_NOARG(UpdateInstallDialog, cancelHandler, weld::Button&, void)
{ {
m_thread->stop(); m_xDialog->response(RET_CANCEL);
EndDialog();
} }
void UpdateInstallDialog::Thread::downloadExtensions() void UpdateInstallDialog::Thread::downloadExtensions()
...@@ -365,10 +346,10 @@ void UpdateInstallDialog::Thread::downloadExtensions() ...@@ -365,10 +346,10 @@ void UpdateInstallDialog::Thread::downloadExtensions()
if (m_stop) { if (m_stop) {
return; return;
} }
m_dialog.m_pFt_extension_name->SetText(updateData.aInstalledPackage->getDisplayName()); m_dialog.m_xFt_extension_name->set_label(updateData.aInstalledPackage->getDisplayName());
sal_uInt16 prog = (sal::static_int_cast<sal_uInt16>(100) * ++count) / sal_uInt16 prog = (sal::static_int_cast<sal_uInt16>(100) * ++count) /
sal::static_int_cast<sal_uInt16>(m_aVecUpdateData.size()); sal::static_int_cast<sal_uInt16>(m_aVecUpdateData.size());
m_dialog.m_pStatusbar->SetValue(prog); m_dialog.m_xStatusbar->set_percentage(prog);
} }
dp_misc::DescriptionInfoset info(m_xComponentContext, updateData.aUpdateInfo); dp_misc::DescriptionInfoset info(m_xComponentContext, updateData.aUpdateInfo);
//remember occurring exceptions in case we need to print out error information //remember occurring exceptions in case we need to print out error information
...@@ -439,8 +420,8 @@ void UpdateInstallDialog::Thread::installExtensions() ...@@ -439,8 +420,8 @@ void UpdateInstallDialog::Thread::installExtensions()
if (m_stop) { if (m_stop) {
return; return;
} }
m_dialog.m_pFt_action->SetText(m_dialog.m_sInstalling); m_dialog.m_xFt_action->set_label(m_dialog.m_sInstalling);
m_dialog.m_pStatusbar->SetValue(0); m_dialog.m_xStatusbar->set_percentage(0);
} }
sal_uInt16 count = 0; sal_uInt16 count = 0;
...@@ -454,11 +435,11 @@ void UpdateInstallDialog::Thread::installExtensions() ...@@ -454,11 +435,11 @@ void UpdateInstallDialog::Thread::installExtensions()
} }
//we only show progress after an extension has been installed. //we only show progress after an extension has been installed.
if (count > 0) { if (count > 0) {
m_dialog.m_pStatusbar->SetValue( m_dialog.m_xStatusbar->set_percentage(
(sal::static_int_cast<sal_uInt16>(100) * count) / (sal::static_int_cast<sal_uInt16>(100) * count) /
sal::static_int_cast<sal_uInt16>(m_aVecUpdateData.size())); sal::static_int_cast<sal_uInt16>(m_aVecUpdateData.size()));
} }
m_dialog.m_pFt_extension_name->SetText(updateData.aInstalledPackage->getDisplayName()); m_dialog.m_xFt_extension_name->set_label(updateData.aInstalledPackage->getDisplayName());
} }
bool bError = false; bool bError = false;
bool bLicenseDeclined = false; bool bLicenseDeclined = false;
...@@ -548,9 +529,9 @@ void UpdateInstallDialog::Thread::installExtensions() ...@@ -548,9 +529,9 @@ void UpdateInstallDialog::Thread::installExtensions()
if (m_stop) { if (m_stop) {
return; return;
} }
m_dialog.m_pStatusbar->SetValue(100); m_dialog.m_xStatusbar->set_percentage(100);
m_dialog.m_pFt_extension_name->SetText(OUString()); m_dialog.m_xFt_extension_name->set_label(OUString());
m_dialog.m_pFt_action->SetText(m_dialog.m_sFinished); m_dialog.m_xFt_action->set_label(m_dialog.m_sFinished);
} }
} }
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <vcl/dialog.hxx> #include <vcl/dialog.hxx>
#include <vcl/prgsbar.hxx> #include <vcl/prgsbar.hxx>
#include <vcl/vclmedit.hxx> #include <vcl/vclmedit.hxx>
#include <vcl/weld.hxx>
#include <rtl/ref.hxx> #include <rtl/ref.hxx>
#include <vector> #include <vector>
...@@ -48,7 +49,8 @@ namespace dp_gui { ...@@ -48,7 +49,8 @@ namespace dp_gui {
/** /**
The modal &ldquo;Download and Installation&rdquo; dialog. The modal &ldquo;Download and Installation&rdquo; dialog.
*/ */
class UpdateInstallDialog: public ModalDialog { class UpdateInstallDialog : public weld::GenericDialogController
{
public: public:
/** /**
Create an instance. Create an instance.
...@@ -56,14 +58,12 @@ public: ...@@ -56,14 +58,12 @@ public:
@param parent @param parent
the parent window, may be null the parent window, may be null
*/ */
UpdateInstallDialog(vcl::Window * parent, std::vector<UpdateData> & aVecUpdateData, UpdateInstallDialog(weld::Window* parent, std::vector<UpdateData> & aVecUpdateData,
css::uno::Reference< css::uno::XComponentContext > const & xCtx); css::uno::Reference< css::uno::XComponentContext > const & xCtx);
virtual ~UpdateInstallDialog() override; virtual ~UpdateInstallDialog() override;
virtual void dispose() override;
bool Close() override; virtual short run() override;
virtual short Execute() override;
private: private:
UpdateInstallDialog(UpdateInstallDialog const &) = delete; UpdateInstallDialog(UpdateInstallDialog const &) = delete;
...@@ -73,7 +73,7 @@ private: ...@@ -73,7 +73,7 @@ private:
friend class Thread; friend class Thread;
friend class UpdateCommandEnv; friend class UpdateCommandEnv;
DECL_LINK(cancelHandler, Button*, void); DECL_LINK(cancelHandler, weld::Button&, void);
//signals in the dialog that we have finished. //signals in the dialog that we have finished.
void updateDone(); void updateDone();
...@@ -104,13 +104,13 @@ private: ...@@ -104,13 +104,13 @@ private:
OUString m_sNoInstall; OUString m_sNoInstall;
OUString m_sThisErrorOccurred; OUString m_sThisErrorOccurred;
VclPtr<FixedText> m_pFt_action; std::unique_ptr<weld::Label> m_xFt_action;
VclPtr<ProgressBar> m_pStatusbar; std::unique_ptr<weld::ProgressBar> m_xStatusbar;
VclPtr<FixedText> m_pFt_extension_name; std::unique_ptr<weld::Label> m_xFt_extension_name;
VclPtr<VclMultiLineEdit> m_pMle_info; std::unique_ptr<weld::TextView> m_xMle_info;
VclPtr<HelpButton> m_pHelp; std::unique_ptr<weld::Button> m_xHelp;
VclPtr<OKButton> m_pOk; std::unique_ptr<weld::Button> m_xOk;
VclPtr<CancelButton> m_pCancel; std::unique_ptr<weld::Button> m_xCancel;
}; };
} }
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 --> <!-- Generated with glade 3.22.1 -->
<interface domain="dkt"> <interface domain="dkt">
<requires lib="gtk+" version="3.18"/> <requires lib="gtk+" version="3.18"/>
<object class="GtkDialog" id="UpdateInstallDialog"> <object class="GtkDialog" id="UpdateInstallDialog">
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="border_width">6</property> <property name="border_width">6</property>
<property name="title" translatable="yes" context="updateinstalldialog|UpdateInstallDialog">Download and Installation</property> <property name="title" translatable="yes" context="updateinstalldialog|UpdateInstallDialog">Download and Installation</property>
<property name="modal">True</property>
<property name="default_width">0</property>
<property name="default_height">0</property>
<property name="type_hint">dialog</property> <property name="type_hint">dialog</property>
<child>
<placeholder/>
</child>
<child internal-child="vbox"> <child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1"> <object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property> <property name="can_focus">False</property>
...@@ -129,6 +135,13 @@ ...@@ -129,6 +135,13 @@
<property name="position">3</property> <property name="position">3</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="shadow_type">in</property>
<child> <child>
<object class="GtkTextView" id="INFO"> <object class="GtkTextView" id="INFO">
<property name="visible">True</property> <property name="visible">True</property>
...@@ -138,6 +151,8 @@ ...@@ -138,6 +151,8 @@
<property name="editable">False</property> <property name="editable">False</property>
<property name="cursor_visible">False</property> <property name="cursor_visible">False</property>
</object> </object>
</child>
</object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
......
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