summaryrefslogtreecommitdiff
path: root/cui/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-02-05 12:38:02 +0000
committerCaolán McNamara <caolanm@redhat.com>2019-02-05 17:43:46 +0100
commitdb9e1ef04d13ecc1b8f8f156b059173143ea03ea (patch)
tree731b7d5dc796c027f288bfca423e5b22a1e1f830 /cui/source
parentb030e83fccbff8d82a4c84462075baa8442cde54 (diff)
weld CertPathDialog
Change-Id: I73c5aa3694d2580b707c2ce769e3e9ffbc076ec8 Reviewed-on: https://gerrit.libreoffice.org/67406 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'cui/source')
-rw-r--r--cui/source/options/certpath.cxx161
-rw-r--r--cui/source/options/certpath.hxx37
-rw-r--r--cui/source/options/optinet2.cxx7
-rw-r--r--cui/source/options/optinet2.hxx2
4 files changed, 91 insertions, 116 deletions
diff --git a/cui/source/options/certpath.cxx b/cui/source/options/certpath.cxx
index e06981b3867f..4a83dad29b94 100644
--- a/cui/source/options/certpath.cxx
+++ b/cui/source/options/certpath.cxx
@@ -23,32 +23,32 @@
using namespace ::com::sun::star;
-CertPathDialog::CertPathDialog(vcl::Window* pParent)
- : ModalDialog(pParent, "CertDialog", "cui/ui/certdialog.ui")
+CertPathDialog::CertPathDialog(weld::Window* pParent)
+ : GenericDialogController(pParent, "cui/ui/certdialog.ui", "CertDialog")
+ , m_xAddBtn(m_xBuilder->weld_button("add"))
+ , m_xOKBtn(m_xBuilder->weld_button("ok"))
+ , m_xCertPathList(m_xBuilder->weld_tree_view("paths"))
+ , m_xAddDialogLabel(m_xBuilder->weld_label("certdir"))
+ , m_xManualLabel(m_xBuilder->weld_label("manual"))
{
- get(m_pOKBtn, "ok");
- get(m_pAddBtn, "add");
- get(m_pCertPathListContainer, "paths");
- Size aSize(LogicToPixel(Size(210, 60), MapMode(MapUnit::MapAppFont)));
- m_pCertPathListContainer->set_width_request(aSize.Width());
- m_pCertPathListContainer->set_height_request(aSize.Height());
- m_pCertPathList =
- VclPtr<svx::SvxRadioButtonListBox>::Create(*m_pCertPathListContainer, 0);
- m_sAddDialogText = get<FixedText>("certdir")->GetText();
- m_sManual = get<FixedText>("manual")->GetText();
-
- static long aStaticTabs[] = { 0, 15, 75 };
- m_pCertPathList->SvSimpleTable::SetTabs( SAL_N_ELEMENTS(aStaticTabs), aStaticTabs );
-
- OUString sProfile(get<FixedText>("profile")->GetText());
- OUString sDirectory(get<FixedText>("dir")->GetText());
- OUString sHeader = "\t" + sProfile + "\t" + sDirectory;
-
- m_pCertPathList->InsertHeaderEntry( sHeader, HEADERBAR_APPEND, HeaderBarItemBits::LEFT );
- m_pCertPathList->SetCheckButtonHdl( LINK( this, CertPathDialog, CheckHdl_Impl ) );
-
- m_pAddBtn->SetClickHdl( LINK( this, CertPathDialog, AddHdl_Impl ) );
- m_pOKBtn->SetClickHdl( LINK( this, CertPathDialog, OKHdl_Impl ) );
+ m_sAddDialogText = m_xAddDialogLabel->get_label();
+ m_sManual = m_xManualLabel->get_label();
+
+ m_xCertPathList->set_size_request(m_xCertPathList->get_approximate_digit_width() * 70,
+ m_xCertPathList->get_height_rows(6));
+
+ std::vector<int> aWidths;
+ aWidths.push_back(m_xCertPathList->get_approximate_digit_width() * 3 + 6);
+ aWidths.push_back(m_xCertPathList->get_approximate_digit_width() * 20);
+ m_xCertPathList->set_column_fixed_widths(aWidths);
+
+ std::vector<int> aRadioColumns;
+ aRadioColumns.push_back(0);
+ m_xCertPathList->set_toggle_columns_as_radio(aRadioColumns);
+
+ m_xCertPathList->connect_toggled(LINK(this, CertPathDialog, CheckHdl_Impl));
+ m_xAddBtn->connect_clicked( LINK( this, CertPathDialog, AddHdl_Impl ) );
+ m_xOKBtn->connect_clicked( LINK( this, CertPathDialog, OKHdl_Impl ) );
try
{
@@ -69,12 +69,15 @@ CertPathDialog::CertPathDialog(vcl::Window* pParent)
if (!profile.isEmpty())
{
+ m_xCertPathList->insert(nullptr, -1, nullptr, nullptr, nullptr,
+ nullptr, nullptr, false);
+ const int nRow = m_xCertPathList->n_children() - 1;
+ m_xCertPathList->set_toggle(nRow, false, 0);
+ OUString sEntry = OUString::createFromAscii(productNames[i]) + ":" + profile;
+ m_xCertPathList->set_text(nRow, sEntry, 1);
OUString sProfilePath = xMozillaBootstrap->getProfilePath( productTypes[i], profile );
- OUString sEntry = "\t" + OUString::createFromAscii(productNames[i]) + ":" + profile
- + "\t" + sProfilePath;
- SvTreeListEntry *pEntry = m_pCertPathList->InsertEntry(sEntry);
- OUString* pCertPath = new OUString(sProfilePath);
- pEntry->SetUserData(pCertPath);
+ m_xCertPathList->set_text(nRow, sProfilePath, 2);
+ m_xCertPathList->set_id(nRow, sProfilePath);
}
}
}
@@ -82,13 +85,6 @@ CertPathDialog::CertPathDialog(vcl::Window* pParent)
{
}
- SvTreeListEntry *pEntry = m_pCertPathList->GetEntry(0);
- if (pEntry)
- {
- m_pCertPathList->SetCheckButtonState(pEntry, SvButtonState::Checked);
- HandleCheckEntry(pEntry);
- }
-
try
{
OUString sUserSetCertPath =
@@ -105,9 +101,15 @@ CertPathDialog::CertPathDialog(vcl::Window* pParent)
const char* pEnv = getenv("MOZILLA_CERTIFICATE_FOLDER");
if (pEnv)
AddCertPath("$MOZILLA_CERTIFICATE_FOLDER", OUString(pEnv, strlen(pEnv), osl_getThreadTextEncoding()));
+
+ if (m_xCertPathList->n_children())
+ {
+ m_xCertPathList->set_toggle(0, true, 0);
+ HandleEntryChecked(0);
+ }
}
-IMPL_LINK_NOARG(CertPathDialog, OKHdl_Impl, Button*, void)
+IMPL_LINK_NOARG(CertPathDialog, OKHdl_Impl, weld::Button&, void)
{
try
{
@@ -122,90 +124,67 @@ IMPL_LINK_NOARG(CertPathDialog, OKHdl_Impl, Button*, void)
SAL_WARN("cui.options", "CertPathDialog::OKHdl_Impl(): " << e);
}
- EndDialog(RET_OK);
+ m_xDialog->response(RET_OK);
}
OUString CertPathDialog::getDirectory() const
{
- SvTreeListEntry* pEntry = m_pCertPathList->FirstSelected();
- void* pCertPath = pEntry ? pEntry->GetUserData() : nullptr;
- return pCertPath ? *static_cast<OUString*>(pCertPath) : OUString();
+ int nEntry = m_xCertPathList->get_selected_index();
+ if (nEntry == -1)
+ return OUString();
+ return m_xCertPathList->get_id(nEntry);
}
CertPathDialog::~CertPathDialog()
{
- disposeOnce();
-}
-
-void CertPathDialog::dispose()
-{
- SvTreeListEntry* pEntry = m_pCertPathList->First();
- while (pEntry)
- {
- OUString* pCertPath = static_cast<OUString*>(pEntry->GetUserData());
- delete pCertPath;
- pEntry = m_pCertPathList->Next( pEntry );
- }
- m_pCertPathList.disposeAndClear();
- m_pCertPathListContainer.clear();
- m_pAddBtn.clear();
- m_pOKBtn.clear();
- ModalDialog::dispose();
}
-IMPL_LINK( CertPathDialog, CheckHdl_Impl, SvTreeListBox*, pList, void )
+IMPL_LINK(CertPathDialog, CheckHdl_Impl, const row_col&, rRowCol, void)
{
- SvTreeListEntry* pEntry = pList ? m_pCertPathList->GetEntry(m_pCertPathList->GetCurMousePoint())
- : m_pCertPathList->FirstSelected();
- if (pEntry)
- m_pCertPathList->HandleEntryChecked(pEntry);
+ HandleEntryChecked(rRowCol.first);
}
-void CertPathDialog::HandleCheckEntry( SvTreeListEntry* _pEntry )
+void CertPathDialog::HandleEntryChecked(int nRow)
{
- m_pCertPathList->Select( _pEntry );
- SvButtonState eState = m_pCertPathList->GetCheckButtonState( _pEntry );
-
- if (SvButtonState::Checked == eState)
+ m_xCertPathList->select(nRow);
+ bool bChecked = m_xCertPathList->get_toggle(nRow, 0);
+ if (bChecked)
{
- // uncheck the other entries
- SvTreeListEntry* pEntry = m_pCertPathList->First();
- while (pEntry)
+ // we have radio button behavior -> so uncheck the other entries
+ int nCount = m_xCertPathList->n_children();
+ for (int i = 0; i < nCount; ++i)
{
- if (pEntry != _pEntry)
- m_pCertPathList->SetCheckButtonState(pEntry, SvButtonState::Unchecked);
- pEntry = m_pCertPathList->Next(pEntry);
+ if (i != nRow)
+ m_xCertPathList->set_toggle(i, false, 0);
}
}
- else
- m_pCertPathList->SetCheckButtonState(_pEntry, SvButtonState::Checked);
}
void CertPathDialog::AddCertPath(const OUString &rProfile, const OUString &rPath)
{
- SvTreeListEntry* pEntry = m_pCertPathList->First();
- while (pEntry)
+ for (int i = 0, nCount = m_xCertPathList->n_children(); i < nCount; ++i)
{
- OUString* pCertPath = static_cast<OUString*>(pEntry->GetUserData());
+ OUString sCertPath = m_xCertPathList->get_id(i);
//already exists, just select the original one
- if (*pCertPath == rPath)
+ if (sCertPath == rPath)
{
- m_pCertPathList->SetCheckButtonState(pEntry, SvButtonState::Checked);
- HandleCheckEntry(pEntry);
+ m_xCertPathList->set_toggle(i, true, 0);
+ HandleEntryChecked(i);
return;
}
- pEntry = m_pCertPathList->Next(pEntry);
}
- OUString sEntry( "\t" + rProfile + "\t" + rPath );
- pEntry = m_pCertPathList->InsertEntry(sEntry);
- OUString* pCertPath = new OUString(rPath);
- pEntry->SetUserData(pCertPath);
- m_pCertPathList->SetCheckButtonState(pEntry, SvButtonState::Checked);
- HandleCheckEntry(pEntry);
+ m_xCertPathList->insert(nullptr, -1, nullptr, nullptr, nullptr,
+ nullptr, nullptr, false);
+ const int nRow = m_xCertPathList->n_children() - 1;
+ m_xCertPathList->set_toggle(nRow, true, 0);
+ m_xCertPathList->set_text(nRow, rProfile, 1);
+ m_xCertPathList->set_text(nRow, rPath, 2);
+ m_xCertPathList->set_id(nRow, rPath);
+ HandleEntryChecked(nRow);
}
-IMPL_LINK_NOARG(CertPathDialog, AddHdl_Impl, Button*, void)
+IMPL_LINK_NOARG(CertPathDialog, AddHdl_Impl, weld::Button&, void)
{
try
{
diff --git a/cui/source/options/certpath.hxx b/cui/source/options/certpath.hxx
index ff373df5a996..c55f0c9000ab 100644
--- a/cui/source/options/certpath.hxx
+++ b/cui/source/options/certpath.hxx
@@ -10,32 +10,29 @@
#ifndef INCLUDED_CUI_SOURCE_OPTIONS_CERTPATH_HXX
#define INCLUDED_CUI_SOURCE_OPTIONS_CERTPATH_HXX
-#include <sfx2/basedlgs.hxx>
-#include <svtools/simptabl.hxx>
-#include <vcl/button.hxx>
-#include <vcl/fixed.hxx>
-#include <radiobtnbox.hxx>
+#include <vcl/weld.hxx>
-class CertPathDialog : public ModalDialog
+class CertPathDialog : public weld::GenericDialogController
{
private:
- VclPtr<SvSimpleTableContainer> m_pCertPathListContainer;
- VclPtr<svx::SvxRadioButtonListBox> m_pCertPathList;
- VclPtr<PushButton> m_pAddBtn;
- VclPtr<OKButton> m_pOKBtn;
- OUString m_sAddDialogText;
- OUString m_sManual;
-
- DECL_LINK(CheckHdl_Impl, SvTreeListBox*, void);
- DECL_LINK(AddHdl_Impl, Button*, void);
- DECL_LINK(OKHdl_Impl, Button*, void);
-
- void HandleCheckEntry(SvTreeListEntry* _pEntry);
+ std::unique_ptr<weld::Button> m_xAddBtn;
+ std::unique_ptr<weld::Button> m_xOKBtn;
+ std::unique_ptr<weld::TreeView> m_xCertPathList;
+ std::unique_ptr<weld::Label> m_xAddDialogLabel;
+ std::unique_ptr<weld::Label> m_xManualLabel;
+ OUString m_sAddDialogText;
+ OUString m_sManual;
+
+ typedef std::pair<int, int> row_col;
+ DECL_LINK(CheckHdl_Impl, const row_col&, void);
+ DECL_LINK(AddHdl_Impl, weld::Button&, void);
+ DECL_LINK(OKHdl_Impl, weld::Button&, void);
+
+ void HandleEntryChecked(int nRow);
void AddCertPath(const OUString &rProfile, const OUString &rPath);
public:
- explicit CertPathDialog(vcl::Window* pParent);
+ explicit CertPathDialog(weld::Window* pParent);
virtual ~CertPathDialog() override;
- virtual void dispose() override;
OUString getDirectory() const;
};
diff --git a/cui/source/options/optinet2.cxx b/cui/source/options/optinet2.cxx
index f4fa1ffb3594..c269d87fdda5 100644
--- a/cui/source/options/optinet2.cxx
+++ b/cui/source/options/optinet2.cxx
@@ -575,7 +575,6 @@ IMPL_STATIC_LINK( SvxProxyTabPage, LoseFocusHdl_Impl, Control&, rControl, void )
SvxSecurityTabPage::SvxSecurityTabPage(vcl::Window* pParent, const SfxItemSet& rSet)
: SfxTabPage(pParent, "OptSecurityPage", "cui/ui/optsecuritypage.ui", &rSet)
, mpSecOptions(new SvtSecurityOptions)
- , mpCertPathDlg(nullptr)
{
get(m_pSecurityOptionsPB, "options");
get(m_pSavePasswordsCB, "savepassword");
@@ -624,7 +623,7 @@ SvxSecurityTabPage::~SvxSecurityTabPage()
void SvxSecurityTabPage::dispose()
{
mpSecOptions.reset();
- mpCertPathDlg.disposeAndClear();
+ mpCertPathDlg.reset();
m_xSecOptDlg.reset();
m_pSecurityOptionsPB.clear();
m_pSavePasswordsCB.clear();
@@ -796,10 +795,10 @@ IMPL_LINK_NOARG(SvxSecurityTabPage, ShowPasswordsHdl, Button*, void)
IMPL_LINK_NOARG(SvxSecurityTabPage, CertPathPBHdl, Button*, void)
{
if (!mpCertPathDlg)
- mpCertPathDlg = VclPtr<CertPathDialog>::Create(this);
+ mpCertPathDlg.reset(new CertPathDialog(GetDialogFrameWeld()));
OUString sOrig = mpCertPathDlg->getDirectory();
- short nRet = mpCertPathDlg->Execute();
+ short nRet = mpCertPathDlg->run();
if (nRet == RET_OK && sOrig != mpCertPathDlg->getDirectory())
{
diff --git a/cui/source/options/optinet2.hxx b/cui/source/options/optinet2.hxx
index 546560f29c50..a5334c157052 100644
--- a/cui/source/options/optinet2.hxx
+++ b/cui/source/options/optinet2.hxx
@@ -129,7 +129,7 @@ private:
std::unique_ptr<SvtSecurityOptions> mpSecOptions;
std::unique_ptr<svx::SecurityOptionsDialog> m_xSecOptDlg;
- VclPtr<CertPathDialog> mpCertPathDlg;
+ std::unique_ptr<CertPathDialog> mpCertPathDlg;
OUString m_sPasswordStoringDeactivateStr;