summaryrefslogtreecommitdiff
path: root/cui/source/options/webconninfo.cxx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-02-05 15:35:35 +0000
committerCaolán McNamara <caolanm@redhat.com>2019-02-05 22:43:05 +0100
commit29a66fe8cde3e18bf4d1c3d7a1f2077ea54548be (patch)
treeefa032d617b6771bac09a5d5867634a0e605ab6e /cui/source/options/webconninfo.cxx
parent2877657777926dbc66f4844cc94e37e74fd546cd (diff)
weld WebConnectionInfoDialog
Change-Id: Idff8a0589075c8b7c774f187f5082fd954251d77 Reviewed-on: https://gerrit.libreoffice.org/67420 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'cui/source/options/webconninfo.cxx')
-rw-r--r--cui/source/options/webconninfo.cxx189
1 files changed, 54 insertions, 135 deletions
diff --git a/cui/source/options/webconninfo.cxx b/cui/source/options/webconninfo.cxx
index 18a2cd7fbca9..5bb56294cfc3 100644
--- a/cui/source/options/webconninfo.cxx
+++ b/cui/source/options/webconninfo.cxx
@@ -35,125 +35,49 @@ using namespace ::com::sun::star;
namespace svx
{
-
-// class PasswordTable ---------------------------------------------------
-
-PasswordTable::PasswordTable(SvSimpleTableContainer& rParent, WinBits nBits)
- : SvSimpleTable(rParent, nBits | WB_NOINITIALSELECTION)
-{
-}
-
-void PasswordTable::InsertHeaderItem(sal_uInt16 nColumn, const OUString& rText, HeaderBarItemBits nBits)
-{
- GetTheHeaderBar().InsertItem( nColumn, rText, 0, nBits );
-}
-
-void PasswordTable::Resort( bool bForced )
-{
- sal_uInt16 nColumn = GetSelectedCol();
- if ( 0 == nColumn || bForced ) // only the first column is sorted
- {
- HeaderBarItemBits nBits = GetTheHeaderBar().GetItemBits(1);
- bool bUp = ( ( nBits & HeaderBarItemBits::UPARROW ) == HeaderBarItemBits::UPARROW );
- SvSortMode eMode = SortAscending;
-
- if ( bUp )
- {
- nBits &= ~HeaderBarItemBits::UPARROW;
- nBits |= HeaderBarItemBits::DOWNARROW;
- eMode = SortDescending;
- }
- else
- {
- nBits &= ~HeaderBarItemBits::DOWNARROW;
- nBits |= HeaderBarItemBits::UPARROW;
- }
- GetTheHeaderBar().SetItemBits( 1, nBits );
- SvTreeList* pListModel = GetModel();
- pListModel->SetSortMode( eMode );
- pListModel->Resort();
- }
-}
-
-void PasswordTable::Resize()
-{
- SvSimpleTable::Resize();
- if (isInitialLayout(this))
- setColWidths();
-}
-
-void PasswordTable::setColWidths()
-{
- HeaderBar &rBar = GetTheHeaderBar();
- if (rBar.GetItemCount() < 2)
- return;
- long nUserNameWidth = 12 +
- std::max(rBar.GetTextWidth(rBar.GetItemText(2)),
- GetTextWidth("XXXXXXXXXXXX"));
- long nWebSiteWidth = std::max(
- 12 + rBar.GetTextWidth(rBar.GetItemText(1)),
- GetSizePixel().Width() - nUserNameWidth);
- long aStaticTabs[]= { 0, nWebSiteWidth };
- SvSimpleTable::SetTabs(SAL_N_ELEMENTS(aStaticTabs), aStaticTabs, MapUnit::MapPixel);
-}
-
// class WebConnectionInfoDialog -----------------------------------------
-
-WebConnectionInfoDialog::WebConnectionInfoDialog(vcl::Window* pParent)
- : ModalDialog(pParent, "StoredWebConnectionDialog", "cui/ui/storedwebconnectiondialog.ui")
+WebConnectionInfoDialog::WebConnectionInfoDialog(weld::Window* pParent)
+ : GenericDialogController(pParent, "cui/ui/storedwebconnectiondialog.ui", "StoredWebConnectionDialog")
, m_nPos( -1 )
+ , m_xRemoveBtn(m_xBuilder->weld_button("remove"))
+ , m_xRemoveAllBtn(m_xBuilder->weld_button("removeall"))
+ , m_xChangeBtn(m_xBuilder->weld_button("change"))
+ , m_xPasswordsLB(m_xBuilder->weld_tree_view("logins"))
{
- get(m_pRemoveBtn, "remove");
- get(m_pRemoveAllBtn, "removeall");
- get(m_pChangeBtn, "change");
-
- SvSimpleTableContainer *pPasswordsLBContainer = get<SvSimpleTableContainer>("logins");
- m_pPasswordsLB = VclPtr<PasswordTable>::Create(*pPasswordsLBContainer, 0);
-
- long const aStaticTabs[]= { 0, 0 };
- m_pPasswordsLB->SetTabs( SAL_N_ELEMENTS(aStaticTabs), aStaticTabs );
- m_pPasswordsLB->InsertHeaderItem( 1, get<FixedText>("website")->GetText(),
- HeaderBarItemBits::LEFT | HeaderBarItemBits::FIXEDPOS | HeaderBarItemBits::CLICKABLE | HeaderBarItemBits::UPARROW );
- m_pPasswordsLB->InsertHeaderItem( 2, get<FixedText>("username")->GetText(),
- HeaderBarItemBits::LEFT | HeaderBarItemBits::FIXEDPOS );
- pPasswordsLBContainer->set_height_request(m_pPasswordsLB->GetTextHeight()*8);
+ std::vector<int> aWidths;
+ aWidths.push_back(m_xPasswordsLB->get_approximate_digit_width() * 50);
+ m_xPasswordsLB->set_column_fixed_widths(aWidths);
+ m_xPasswordsLB->set_size_request(m_xPasswordsLB->get_approximate_digit_width() * 70,
+ m_xPasswordsLB->get_height_rows(8));
- m_pPasswordsLB->SetHeaderBarClickHdl( LINK( this, WebConnectionInfoDialog, HeaderBarClickedHdl ) );
+ m_xPasswordsLB->connect_column_clicked(LINK(this, WebConnectionInfoDialog, HeaderBarClickedHdl));
FillPasswordList();
- m_pRemoveBtn->SetClickHdl( LINK( this, WebConnectionInfoDialog, RemovePasswordHdl ) );
- m_pRemoveAllBtn->SetClickHdl( LINK( this, WebConnectionInfoDialog, RemoveAllPasswordsHdl ) );
- m_pChangeBtn->SetClickHdl( LINK( this, WebConnectionInfoDialog, ChangePasswordHdl ) );
- m_pPasswordsLB->SetSelectHdl( LINK( this, WebConnectionInfoDialog, EntrySelectedHdl ) );
+ m_xRemoveBtn->connect_clicked( LINK( this, WebConnectionInfoDialog, RemovePasswordHdl ) );
+ m_xRemoveAllBtn->connect_clicked( LINK( this, WebConnectionInfoDialog, RemoveAllPasswordsHdl ) );
+ m_xChangeBtn->connect_clicked( LINK( this, WebConnectionInfoDialog, ChangePasswordHdl ) );
+ m_xPasswordsLB->connect_changed( LINK( this, WebConnectionInfoDialog, EntrySelectedHdl ) );
- m_pRemoveBtn->Enable( false );
- m_pChangeBtn->Enable( false );
+ m_xRemoveBtn->set_sensitive( false );
+ m_xChangeBtn->set_sensitive( false );
- HeaderBarClickedHdl( nullptr );
+ m_xPasswordsLB->make_sorted();
}
WebConnectionInfoDialog::~WebConnectionInfoDialog()
{
- disposeOnce();
}
-void WebConnectionInfoDialog::dispose()
+IMPL_LINK(WebConnectionInfoDialog, HeaderBarClickedHdl, int, nColumn, void)
{
- m_pPasswordsLB.disposeAndClear();
- m_pRemoveBtn.clear();
- m_pRemoveAllBtn.clear();
- m_pChangeBtn.clear();
- ModalDialog::dispose();
-}
-
-IMPL_LINK( WebConnectionInfoDialog, HeaderBarClickedHdl, SvSimpleTable*, pTable, void )
-{
- m_pPasswordsLB->Resort( nullptr == pTable );
+ if (nColumn == 0) // only the first column is sorted
+ {
+ m_xPasswordsLB->set_sort_order(!m_xPasswordsLB->get_sort_order());
+ }
}
-
void WebConnectionInfoDialog::FillPasswordList()
{
try
@@ -173,10 +97,9 @@ void WebConnectionInfoDialog::FillPasswordList()
{
for ( sal_Int32 nUserInd = 0; nUserInd < aURLEntries[nURLInd].UserList.getLength(); nUserInd++ )
{
- SvTreeListEntry* pEntry = m_pPasswordsLB->InsertEntry(
- aURLEntries[nURLInd].Url + "\t" +
- aURLEntries[nURLInd].UserList[nUserInd].UserName);
- pEntry->SetUserData( reinterpret_cast<void*>(nCount++) );
+ m_xPasswordsLB->append(OUString::number(nCount), aURLEntries[nURLInd].Url);
+ m_xPasswordsLB->set_text(nCount, aURLEntries[nURLInd].UserList[nUserInd].UserName, 1);
+ ++nCount;
}
}
@@ -188,9 +111,9 @@ void WebConnectionInfoDialog::FillPasswordList()
for ( sal_Int32 nURLIdx = 0; nURLIdx < aUrls.getLength(); nURLIdx++ )
{
- SvTreeListEntry* pEntry = m_pPasswordsLB->InsertEntry(
- aUrls[nURLIdx] + "\t*");
- pEntry->SetUserData( reinterpret_cast<void*>(nCount++) );
+ m_xPasswordsLB->append(OUString::number(nCount), aUrls[nURLIdx]);
+ m_xPasswordsLB->set_text(nCount, "*");
+ ++nCount;
}
}
}
@@ -199,20 +122,20 @@ void WebConnectionInfoDialog::FillPasswordList()
}
-IMPL_LINK_NOARG(WebConnectionInfoDialog, RemovePasswordHdl, Button*, void)
+IMPL_LINK_NOARG(WebConnectionInfoDialog, RemovePasswordHdl, weld::Button&, void)
{
try
{
- SvTreeListEntry* pEntry = m_pPasswordsLB->GetCurEntry();
- if ( pEntry )
+ int nEntry = m_xPasswordsLB->get_selected_index();
+ if (nEntry != -1)
{
- OUString aURL = SvTabListBox::GetEntryText( pEntry, 0 );
- OUString aUserName = SvTabListBox::GetEntryText( pEntry, 1 );
+ OUString aURL = m_xPasswordsLB->get_text(nEntry, 0);
+ OUString aUserName = m_xPasswordsLB->get_text(nEntry, 1);
uno::Reference< task::XPasswordContainer2 > xPasswdContainer(
task::PasswordContainer::create(comphelper::getProcessComponentContext()));
- sal_Int32 nPos = static_cast<sal_Int32>(reinterpret_cast<sal_IntPtr>(pEntry->GetUserData()));
+ int nPos = m_xPasswordsLB->get_id(nEntry).toInt32();
if ( nPos < m_nPos )
{
xPasswdContainer->removePersistent( aURL, aUserName );
@@ -221,15 +144,15 @@ IMPL_LINK_NOARG(WebConnectionInfoDialog, RemovePasswordHdl, Button*, void)
{
xPasswdContainer->removeUrl( aURL );
}
- m_pPasswordsLB->RemoveEntry( pEntry );
+
+ m_xPasswordsLB->remove(nEntry);
}
}
catch( uno::Exception& )
{}
}
-
-IMPL_LINK_NOARG(WebConnectionInfoDialog, RemoveAllPasswordsHdl, Button*, void)
+IMPL_LINK_NOARG(WebConnectionInfoDialog, RemoveAllPasswordsHdl, weld::Button&, void)
{
try
{
@@ -244,30 +167,28 @@ IMPL_LINK_NOARG(WebConnectionInfoDialog, RemoveAllPasswordsHdl, Button*, void)
for ( sal_Int32 nURLIdx = 0; nURLIdx < aUrls.getLength(); nURLIdx++ )
xPasswdContainer->removeUrl( aUrls[ nURLIdx ] );
- m_pPasswordsLB->Clear();
+ m_xPasswordsLB->clear();
}
catch( uno::Exception& )
{}
}
-
-IMPL_LINK_NOARG(WebConnectionInfoDialog, ChangePasswordHdl, Button*, void)
+IMPL_LINK_NOARG(WebConnectionInfoDialog, ChangePasswordHdl, weld::Button&, void)
{
try
{
- SvTreeListEntry* pEntry = m_pPasswordsLB->GetCurEntry();
- if ( pEntry )
+ int nEntry = m_xPasswordsLB->get_selected_index();
+ if (nEntry != -1)
{
- OUString aURL = SvTabListBox::GetEntryText( pEntry, 0 );
- OUString aUserName = SvTabListBox::GetEntryText( pEntry, 1 );
+ OUString aURL = m_xPasswordsLB->get_text(nEntry, 0);
+ OUString aUserName = m_xPasswordsLB->get_text(nEntry, 1);
::comphelper::SimplePasswordRequest* pPasswordRequest
= new ::comphelper::SimplePasswordRequest;
uno::Reference< task::XInteractionRequest > rRequest( pPasswordRequest );
- auto xWindow = VCLUnoHelper::GetInterface(this);
uno::Reference< task::XInteractionHandler > xInteractionHandler(
- task::InteractionHandler::createWithParent(comphelper::getProcessComponentContext(), xWindow),
+ task::InteractionHandler::createWithParent(comphelper::getProcessComponentContext(), m_xDialog->GetXWindow()),
uno::UNO_QUERY );
xInteractionHandler->handle( rRequest );
@@ -288,27 +209,25 @@ IMPL_LINK_NOARG(WebConnectionInfoDialog, ChangePasswordHdl, Button*, void)
}
-IMPL_LINK_NOARG(WebConnectionInfoDialog, EntrySelectedHdl, SvTreeListBox*, void)
+IMPL_LINK_NOARG(WebConnectionInfoDialog, EntrySelectedHdl, weld::TreeView&, void)
{
- SvTreeListEntry* pEntry = m_pPasswordsLB->GetCurEntry();
- if ( !pEntry )
+ int nEntry = m_xPasswordsLB->get_selected_index();
+ if (nEntry == -1)
{
- m_pRemoveBtn->Enable( false );
- m_pChangeBtn->Enable( false );
+ m_xRemoveBtn->set_sensitive(false);
+ m_xChangeBtn->set_sensitive(false);
}
else
{
- m_pRemoveBtn->Enable();
+ m_xRemoveBtn->set_sensitive(true);
// url container entries (-> use system credentials) have
// no password
- sal_Int32 nPos = static_cast<sal_Int32>(reinterpret_cast<sal_IntPtr>(pEntry->GetUserData()));
- m_pChangeBtn->Enable( nPos < m_nPos );
+ int nPos = m_xPasswordsLB->get_id(nEntry).toInt32();
+ m_xChangeBtn->set_sensitive(nPos < m_nPos);
}
}
-
}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */