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

make PlaceEditDialog a bit more ordinary

the various part of PlaceEditDialog are unusual in binding multiple things to a
set of shared widgets with a bunch of multiple LINKS to the same things and
using the most recent one shown to displace the previous handlers

End up with multiple notifications in the gtk3 case, rework this to have
a single owner of the widgets so it can do what it wants to do.

Change-Id: I65826a69ce2f1d4279f6e8091a518777fcfeca07
Reviewed-on: https://gerrit.libreoffice.org/54496Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst e0d85694
......@@ -39,6 +39,7 @@ private:
bool m_bLabelChanged;
bool m_bShowPassword;
public:
std::unique_ptr<weld::Entry> m_xEDServerName;
std::unique_ptr<weld::ComboBoxText> m_xLBServerType;
std::unique_ptr<weld::Entry> m_xEDUsername;
......@@ -52,21 +53,39 @@ private:
std::unique_ptr<weld::Label> m_xFTPasswordLabel;
std::unique_ptr<weld::Widget> m_xTypeGrid;
std::unique_ptr<weld::Widget> m_xRepositoryBox;
std::unique_ptr<weld::Label> m_xFTRepository;
std::unique_ptr<weld::ComboBoxText> m_xLBRepository;
std::unique_ptr<weld::Entry> m_xEDShare;
std::unique_ptr<weld::Label> m_xFTShare;
std::unique_ptr<weld::Widget> m_xDetailsGrid;
std::unique_ptr<weld::Widget> m_xHostBox;
std::unique_ptr<weld::Entry> m_xEDHost;
std::unique_ptr<weld::Label> m_xFTHost;
std::unique_ptr<weld::SpinButton> m_xEDPort;
std::unique_ptr<weld::Label> m_xFTPort;
std::unique_ptr<weld::Entry> m_xEDRoot;
std::unique_ptr<weld::Label> m_xFTRoot;
std::unique_ptr<weld::CheckButton> m_xCBDavs;
public:
PlaceEditDialog(weld::Window* pParent);
PlaceEditDialog(weld::Window* pParent, const std::shared_ptr<Place> &rPlace );
virtual ~PlaceEditDialog() override;
PlaceEditDialog(weld::Window* pParent);
PlaceEditDialog(weld::Window* pParent, const std::shared_ptr<Place> &rPlace );
virtual ~PlaceEditDialog() override;
// Returns a place instance with given information
std::shared_ptr<Place> GetPlace();
// Returns a place instance with given information
std::shared_ptr<Place> GetPlace();
OUString GetServerName() { return m_xEDServerName->get_text(); }
OUString GetServerUrl();
OUString GetPassword() { return m_xEDPassword->get_text(); };
OUString GetUser() { return m_xEDUsername->get_text(); };
bool IsRememberChecked() { return m_xCBPassword->get_active(); }
OUString GetServerName() { return m_xEDServerName->get_text(); }
OUString GetServerUrl();
OUString GetPassword() { return m_xEDPassword->get_text(); };
OUString GetUser() { return m_xEDUsername->get_text(); };
bool IsRememberChecked() { return m_xCBPassword->get_active(); }
void ShowPasswordControl() { m_bShowPassword = true; }
void ShowPasswordControl() { m_bShowPassword = true; }
private:
......
......@@ -16,30 +16,18 @@
#include <com/sun/star/task/XPasswordContainer2.hpp>
#include <tools/urlobj.hxx>
#include <vcl/builder.hxx>
#include <vcl/button.hxx>
#include <vcl/dialog.hxx>
#include <vcl/edit.hxx>
#include <vcl/field.hxx>
#include <vcl/fixed.hxx>
#include <vcl/layout.hxx>
#include <vcl/weld.hxx>
class PlaceEditDialog;
class DetailsContainer
{
protected:
PlaceEditDialog* m_pDialog;
Link<DetailsContainer*,void> m_aChangeHdl;
std::unique_ptr<weld::Widget> m_xDetailsGrid;
std::unique_ptr<weld::Widget> m_xHostBox;
std::unique_ptr<weld::Entry> m_xEDHost;
std::unique_ptr<weld::Label> m_xFTHost;
std::unique_ptr<weld::SpinButton> m_xEDPort;
std::unique_ptr<weld::Label> m_xFTPort;
std::unique_ptr<weld::Entry> m_xEDRoot;
std::unique_ptr<weld::Label> m_xFTRoot;
public:
DetailsContainer( weld::Builder* pBuilder );
DetailsContainer(PlaceEditDialog* pDialog);
virtual ~DetailsContainer( );
void setChangeHdl( const Link<DetailsContainer*,void>& rLink ) { m_aChangeHdl = rLink; }
......@@ -73,7 +61,7 @@ class HostDetailsContainer : public DetailsContainer
OUString m_sHost;
public:
HostDetailsContainer( weld::Builder* pBuilder, sal_uInt16 nPort, const OUString& sScheme );
HostDetailsContainer(PlaceEditDialog* pDialog, sal_uInt16 nPort, const OUString& sScheme);
virtual void show( bool bShow = true ) override;
virtual INetURLObject getUrl( ) override;
......@@ -90,11 +78,8 @@ class HostDetailsContainer : public DetailsContainer
class DavDetailsContainer : public HostDetailsContainer
{
private:
std::unique_ptr<weld::CheckButton> m_xCBDavs;
public:
DavDetailsContainer(weld::Builder* pBuilder);
DavDetailsContainer(PlaceEditDialog* pDialog);
virtual void show( bool bShow = true ) override;
virtual bool enableUserCredentials( ) override { return false; };
......@@ -108,12 +93,8 @@ class DavDetailsContainer : public HostDetailsContainer
class SmbDetailsContainer : public DetailsContainer
{
private:
std::unique_ptr<weld::Entry> m_xEDShare;
std::unique_ptr<weld::Label> m_xFTShare;
public:
SmbDetailsContainer(weld::Builder* pBuilder);
SmbDetailsContainer(PlaceEditDialog* pDialog);
virtual INetURLObject getUrl( ) override;
virtual bool setUrl( const INetURLObject& rUrl ) override;
......@@ -131,13 +112,8 @@ class CmisDetailsContainer : public DetailsContainer
OUString m_sBinding;
css::uno::Reference< css::awt::XWindow > m_xParentDialog;
std::unique_ptr<weld::Widget> m_xRepositoryBox;
std::unique_ptr<weld::Label> m_xFTRepository;
std::unique_ptr<weld::ComboBoxText> m_xLBRepository;
std::unique_ptr<weld::Button> m_xBTRepoRefresh;
public:
CmisDetailsContainer(weld::Builder* pBuilder, weld::Dialog* pParentDialog, OUString const & sBinding);
CmisDetailsContainer(PlaceEditDialog* pDialog, OUString const & sBinding);
virtual void show( bool bShow = true ) override;
virtual INetURLObject getUrl( ) override;
......
......@@ -352,7 +352,7 @@ protected:
public:
virtual void set_label(const OUString& rText) = 0;
virtual OUString get_label() const = 0;
virtual void clicked() = 0;
void clicked() { signal_clicked(); }
void connect_clicked(const Link<Button&, void>& rLink) { m_aClickHdl = rLink; }
};
......
......@@ -35,6 +35,24 @@ PlaceEditDialog::PlaceEditDialog(weld::Window* pParent)
, m_xEDPassword(m_xBuilder->weld_entry("password"))
, m_xFTPasswordLabel(m_xBuilder->weld_label("passwordLabel"))
, m_xTypeGrid(m_xBuilder->weld_widget("TypeGrid"))
, m_xRepositoryBox(m_xBuilder->weld_widget("RepositoryDetails"))
, m_xFTRepository(m_xBuilder->weld_label("repositoryLabel"))
, m_xLBRepository(m_xBuilder->weld_combo_box_text("repositories"))
, m_xEDShare(m_xBuilder->weld_entry("share"))
, m_xFTShare(m_xBuilder->weld_label("shareLabel"))
, m_xDetailsGrid(m_xBuilder->weld_widget("Details"))
, m_xHostBox(m_xBuilder->weld_widget("HostDetails"))
, m_xEDHost(m_xBuilder->weld_entry("host"))
, m_xFTHost(m_xBuilder->weld_label("hostLabel"))
, m_xEDPort(m_xBuilder->weld_spin_button("port"))
, m_xFTPort(m_xBuilder->weld_label("portLabel"))
, m_xEDRoot(m_xBuilder->weld_entry("path"))
, m_xFTRoot(m_xBuilder->weld_label("pathLabel"))
, m_xCBDavs(m_xBuilder->weld_check_button("webdavs"))
{
m_xBTOk->connect_clicked( LINK( this, PlaceEditDialog, OKHdl) );
m_xBTOk->set_sensitive( false );
......@@ -167,7 +185,7 @@ void PlaceEditDialog::InitDetails( )
m_xLBServerType->insert_text(nPos, aTypesNamesList[i].replaceFirst("Other CMIS", SvtResId(STR_SVT_OTHER_CMIS)));
std::shared_ptr<DetailsContainer> xCmisDetails(std::make_shared<CmisDetailsContainer>(m_xBuilder.get(), m_xDialog.get(), sUrl));
std::shared_ptr<DetailsContainer> xCmisDetails(std::make_shared<CmisDetailsContainer>(this, sUrl));
xCmisDetails->setChangeHdl( LINK( this, PlaceEditDialog, EditHdl ) );
m_aDetailsContainers.push_back(xCmisDetails);
......@@ -175,20 +193,20 @@ void PlaceEditDialog::InitDetails( )
}
// Create WebDAV / FTP / SSH details control
std::shared_ptr<DetailsContainer> xDavDetails(std::make_shared<DavDetailsContainer>(m_xBuilder.get()));
std::shared_ptr<DetailsContainer> xDavDetails(std::make_shared<DavDetailsContainer>(this));
xDavDetails->setChangeHdl( LINK( this, PlaceEditDialog, EditHdl ) );
m_aDetailsContainers.push_back(xDavDetails);
std::shared_ptr<DetailsContainer> xFtpDetails(std::make_shared<HostDetailsContainer>(m_xBuilder.get(), 21, "ftp"));
std::shared_ptr<DetailsContainer> xFtpDetails(std::make_shared<HostDetailsContainer>(this, 21, "ftp"));
xFtpDetails->setChangeHdl( LINK( this, PlaceEditDialog, EditHdl ) );
m_aDetailsContainers.push_back(xFtpDetails);
std::shared_ptr<DetailsContainer> xSshDetails(std::make_shared<HostDetailsContainer>(m_xBuilder.get(), 22, "ssh"));
std::shared_ptr<DetailsContainer> xSshDetails(std::make_shared<HostDetailsContainer>(this, 22, "ssh"));
xSshDetails->setChangeHdl( LINK( this, PlaceEditDialog, EditHdl ) );
m_aDetailsContainers.push_back(xSshDetails);
// Create Windows Share control
std::shared_ptr<DetailsContainer> xSmbDetails(std::make_shared<SmbDetailsContainer>(m_xBuilder.get()));
std::shared_ptr<DetailsContainer> xSmbDetails(std::make_shared<SmbDetailsContainer>(this));
xSmbDetails->setChangeHdl( LINK( this, PlaceEditDialog, EditHdl ) );
m_aDetailsContainers.push_back(xSmbDetails);
......
......@@ -879,11 +879,6 @@ public:
return m_xButton->GetText();
}
virtual void clicked() override
{
m_xButton->Click();
}
virtual ~SalInstanceButton() override
{
m_xButton->SetClickHdl(Link<::Button*,void>());
......
......@@ -2517,11 +2517,6 @@ public:
return ::get_label(m_pButton);
}
virtual void clicked() override
{
gtk_button_clicked(m_pButton);
}
// allow us to block buttons with click handlers making dialogs return a response
bool has_click_handler() const
{
......
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