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(
short nDialogResult = RET_OK;
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
}
else
......
......@@ -191,80 +191,62 @@ void UpdateInstallDialog::Thread::execute()
}
UpdateInstallDialog::UpdateInstallDialog(
vcl::Window * parent,
weld::Window* pParent,
std::vector<dp_gui::UpdateData> & aVecUpdateData,
cssu::Reference< cssu::XComponentContext > const & xCtx):
ModalDialog(
parent,
"UpdateInstallDialog","desktop/ui/updateinstalldialog.ui"),
m_thread(new Thread(xCtx, *this, aVecUpdateData)),
m_bError(false),
m_bNoEntry(true),
m_sInstalling(DpResId(RID_DLG_UPDATE_INSTALL_INSTALLING)),
m_sFinished(DpResId(RID_DLG_UPDATE_INSTALL_FINISHED)),
m_sNoErrors(DpResId(RID_DLG_UPDATE_INSTALL_NO_ERRORS)),
m_sErrorDownload(DpResId(RID_DLG_UPDATE_INSTALL_ERROR_DOWNLOAD)),
m_sErrorInstallation(DpResId(RID_DLG_UPDATE_INSTALL_ERROR_INSTALLATION)),
m_sErrorLicenseDeclined(DpResId(RID_DLG_UPDATE_INSTALL_ERROR_LIC_DECLINED)),
m_sNoInstall(DpResId(RID_DLG_UPDATE_INSTALL_EXTENSION_NOINSTALL)),
m_sThisErrorOccurred(DpResId(RID_DLG_UPDATE_INSTALL_THIS_ERROR_OCCURRED))
cssu::Reference< cssu::XComponentContext > const & xCtx)
: GenericDialogController(pParent, "desktop/ui/updateinstalldialog.ui",
"UpdateInstallDialog")
, m_thread(new Thread(xCtx, *this, aVecUpdateData))
, m_bError(false)
, m_bNoEntry(true)
, m_sInstalling(DpResId(RID_DLG_UPDATE_INSTALL_INSTALLING))
, m_sFinished(DpResId(RID_DLG_UPDATE_INSTALL_FINISHED))
, m_sNoErrors(DpResId(RID_DLG_UPDATE_INSTALL_NO_ERRORS))
, m_sErrorDownload(DpResId(RID_DLG_UPDATE_INSTALL_ERROR_DOWNLOAD))
, m_sErrorInstallation(DpResId(RID_DLG_UPDATE_INSTALL_ERROR_INSTALLATION))
, m_sErrorLicenseDeclined(DpResId(RID_DLG_UPDATE_INSTALL_ERROR_LIC_DECLINED))
, m_sNoInstall(DpResId(RID_DLG_UPDATE_INSTALL_EXTENSION_NOINSTALL))
, m_sThisErrorOccurred(DpResId(RID_DLG_UPDATE_INSTALL_THIS_ERROR_OCCURRED))
, m_xFt_action(m_xBuilder->weld_label("DOWNLOADING"))
, 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");
get(m_pStatusbar, "STATUSBAR");
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_xMle_info->set_size_request(m_xMle_info->get_approximate_digit_width() * 52,
m_xMle_info->get_height_rows(5));
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())
m_pHelp->Disable();
m_xHelp->set_sensitive(false);
}
UpdateInstallDialog::~UpdateInstallDialog()
{
disposeOnce();
}
void UpdateInstallDialog::dispose()
{
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()
short UpdateInstallDialog::run()
{
m_thread->launch();
return ModalDialog::Execute();
short nRet = GenericDialogController::run();
m_thread->stop();
return nRet;
}
// make sure the solar mutex is locked before calling
void UpdateInstallDialog::updateDone()
{
if (!m_bError)
m_pMle_info->SetText(m_pMle_info->GetText() + m_sNoErrors);
m_pOk->Enable();
m_pOk->GrabFocus();
m_pCancel->Disable();
m_xMle_info->set_text(m_xMle_info->get_text() + m_sNoErrors);
m_xOk->set_sensitive(true);
m_xOk->grab_focus();
m_xCancel->set_sensitive(false);
}
// make sure the solar mutex is locked before calling
//sets an error message in the text area
void UpdateInstallDialog::setError(INSTALL_ERROR err, OUString const & sExtension,
......@@ -289,7 +271,7 @@ void UpdateInstallDialog::setError(INSTALL_ERROR err, OUString const & sExtensio
OSL_ASSERT(false);
}
OUString sMsg(m_pMle_info->GetText());
OUString sMsg(m_xMle_info->get_text());
sError = sError.replaceFirst("%NAME", sExtension);
//We want to have an empty line between the error messages. However,
//there shall be no empty line after the last entry.
......@@ -304,19 +286,18 @@ void UpdateInstallDialog::setError(INSTALL_ERROR err, OUString const & sExtensio
sMsg += m_sNoInstall + "\n";
m_pMle_info->SetText(sMsg);
m_xMle_info->set_text(sMsg);
}
void UpdateInstallDialog::setError(OUString const & exceptionMessage)
{
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();
EndDialog();
m_xDialog->response(RET_CANCEL);
}
void UpdateInstallDialog::Thread::downloadExtensions()
......@@ -365,10 +346,10 @@ void UpdateInstallDialog::Thread::downloadExtensions()
if (m_stop) {
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::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);
//remember occurring exceptions in case we need to print out error information
......@@ -439,8 +420,8 @@ void UpdateInstallDialog::Thread::installExtensions()
if (m_stop) {
return;
}
m_dialog.m_pFt_action->SetText(m_dialog.m_sInstalling);
m_dialog.m_pStatusbar->SetValue(0);
m_dialog.m_xFt_action->set_label(m_dialog.m_sInstalling);
m_dialog.m_xStatusbar->set_percentage(0);
}
sal_uInt16 count = 0;
......@@ -454,11 +435,11 @@ void UpdateInstallDialog::Thread::installExtensions()
}
//we only show progress after an extension has been installed.
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>(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 bLicenseDeclined = false;
......@@ -548,9 +529,9 @@ void UpdateInstallDialog::Thread::installExtensions()
if (m_stop) {
return;
}
m_dialog.m_pStatusbar->SetValue(100);
m_dialog.m_pFt_extension_name->SetText(OUString());
m_dialog.m_pFt_action->SetText(m_dialog.m_sFinished);
m_dialog.m_xStatusbar->set_percentage(100);
m_dialog.m_xFt_extension_name->set_label(OUString());
m_dialog.m_xFt_action->set_label(m_dialog.m_sFinished);
}
}
......
......@@ -26,6 +26,7 @@
#include <vcl/dialog.hxx>
#include <vcl/prgsbar.hxx>
#include <vcl/vclmedit.hxx>
#include <vcl/weld.hxx>
#include <rtl/ref.hxx>
#include <vector>
......@@ -48,7 +49,8 @@ namespace dp_gui {
/**
The modal &ldquo;Download and Installation&rdquo; dialog.
*/
class UpdateInstallDialog: public ModalDialog {
class UpdateInstallDialog : public weld::GenericDialogController
{
public:
/**
Create an instance.
......@@ -56,14 +58,12 @@ public:
@param parent
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);
virtual ~UpdateInstallDialog() override;
virtual void dispose() override;
bool Close() override;
virtual short Execute() override;
virtual short run() override;
private:
UpdateInstallDialog(UpdateInstallDialog const &) = delete;
......@@ -73,7 +73,7 @@ private:
friend class Thread;
friend class UpdateCommandEnv;
DECL_LINK(cancelHandler, Button*, void);
DECL_LINK(cancelHandler, weld::Button&, void);
//signals in the dialog that we have finished.
void updateDone();
......@@ -104,13 +104,13 @@ private:
OUString m_sNoInstall;
OUString m_sThisErrorOccurred;
VclPtr<FixedText> m_pFt_action;
VclPtr<ProgressBar> m_pStatusbar;
VclPtr<FixedText> m_pFt_extension_name;
VclPtr<VclMultiLineEdit> m_pMle_info;
VclPtr<HelpButton> m_pHelp;
VclPtr<OKButton> m_pOk;
VclPtr<CancelButton> m_pCancel;
std::unique_ptr<weld::Label> m_xFt_action;
std::unique_ptr<weld::ProgressBar> m_xStatusbar;
std::unique_ptr<weld::Label> m_xFt_extension_name;
std::unique_ptr<weld::TextView> m_xMle_info;
std::unique_ptr<weld::Button> m_xHelp;
std::unique_ptr<weld::Button> m_xOk;
std::unique_ptr<weld::Button> m_xCancel;
};
}
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<!-- Generated with glade 3.22.1 -->
<interface domain="dkt">
<requires lib="gtk+" version="3.18"/>
<object class="GtkDialog" id="UpdateInstallDialog">
<property name="can_focus">False</property>
<property name="border_width">6</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>
<child>
<placeholder/>
</child>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property>
......@@ -130,13 +136,22 @@
</packing>
</child>
<child>
<object class="GtkTextView" id="INFO">
<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="editable">False</property>
<property name="cursor_visible">False</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTextView" id="INFO">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="editable">False</property>
<property name="cursor_visible">False</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</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