diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-07-30 09:15:46 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-07-30 11:39:33 +0200 |
commit | f67188df868d40aa81b58616c3702b9f81904119 (patch) | |
tree | 4284068e6af92919e2df02fa7761231af47c0296 /cui/source/options/optinet2.cxx | |
parent | 5ba84c3c7080d55d86b8b39db077b6da36cb700a (diff) |
weld SvxProxyTabPage
Change-Id: I34651fc7c56da5205b349a83276d5efa536c4301
Reviewed-on: https://gerrit.libreoffice.org/76582
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/optinet2.cxx')
-rw-r--r-- | cui/source/options/optinet2.cxx | 282 |
1 files changed, 121 insertions, 161 deletions
diff --git a/cui/source/options/optinet2.cxx b/cui/source/options/optinet2.cxx index af3c497d44e8..a6476b60b950 100644 --- a/cui/source/options/optinet2.cxx +++ b/cui/source/options/optinet2.cxx @@ -122,53 +122,17 @@ bool isValidPort(OUString const & value) { } -VCL_BUILDER_FACTORY_ARGS(SvxNoSpaceEdit, WB_LEFT|WB_VCENTER|WB_BORDER|WB_3DLOOK) - -void SvxNoSpaceEdit::KeyInput( const KeyEvent& rKEvent ) -{ - bool bValid = rKEvent.GetKeyCode().GetCode() != KEY_SPACE; - if (bValid && bOnlyNumeric) - { - const vcl::KeyCode& rKeyCode = rKEvent.GetKeyCode(); - sal_uInt16 nGroup = rKeyCode.GetGroup(); - sal_uInt16 nKey = rKeyCode.GetCode(); - bValid = ( KEYGROUP_NUM == nGroup || KEYGROUP_CURSOR == nGroup || - ( KEYGROUP_MISC == nGroup && ( nKey < KEY_ADD || nKey > KEY_EQUAL ) ) ); - if ( !bValid && ( rKeyCode.IsMod1() && ( - KEY_A == nKey || KEY_C == nKey || KEY_V == nKey || KEY_X == nKey || KEY_Z == nKey ) ) ) - // Erase, Copy, Paste, Select All and Undo should work - bValid = true; - } - if (bValid) - Edit::KeyInput(rKEvent); -} - -void SvxNoSpaceEdit::Modify() +IMPL_LINK(SvxProxyTabPage, PortChangedHdl, weld::Entry&, rEdit, void) { - Edit::Modify(); - - if ( bOnlyNumeric ) + if (!isValidPort(rEdit.get_text())) { - if ( !isValidPort(GetText()) ) - { - std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(GetFrameWeld(), - VclMessageType::Warning, VclButtonsType::Ok, - CuiResId( RID_SVXSTR_OPT_PROXYPORTS))); - xErrorBox->run(); - } + std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(GetDialogFrameWeld(), + VclMessageType::Warning, VclButtonsType::Ok, + CuiResId( RID_SVXSTR_OPT_PROXYPORTS))); + xErrorBox->run(); } } -bool SvxNoSpaceEdit::set_property(const OString &rKey, const OUString &rValue) -{ - if (rKey == "only-numeric") - bOnlyNumeric = toBool(rValue); - else - return Edit::set_property(rKey, rValue); - return true; -} - - static const char g_aProxyModePN[] = "ooInetProxyType"; static const char g_aHttpProxyPN[] = "ooInetHTTPProxyName"; static const char g_aHttpPortPN[] = "ooInetHTTPProxyPort"; @@ -178,42 +142,64 @@ static const char g_aFtpProxyPN[] = "ooInetFTPProxyName"; static const char g_aFtpPortPN[] = "ooInetFTPProxyPort"; static const char g_aNoProxyDescPN[] = "ooInetNoProxy"; +IMPL_STATIC_LINK(SvxProxyTabPage, NumberOnlyTextFilterHdl, OUString&, rTest, bool) +{ + OUStringBuffer sAllowed; + for (sal_Int32 i = 0, nLen = rTest.getLength(); i < nLen; ++i) + { + if (rTest[i] >= '0' && rTest[i] <= '9') + sAllowed.append(rTest[i]); + } + rTest = sAllowed.makeStringAndClear(); + return true; +} + +IMPL_STATIC_LINK(SvxProxyTabPage, NoSpaceTextFilterHdl, OUString&, rTest, bool) +{ + rTest = rTest.replaceAll(" ", ""); + return true; +} + /********************************************************************/ /* */ /* SvxProxyTabPage */ /* */ /********************************************************************/ - -SvxProxyTabPage::SvxProxyTabPage(vcl::Window* pParent, const SfxItemSet& rSet) - : SfxTabPage(pParent, "OptProxyPage","cui/ui/optproxypage.ui", &rSet) +SvxProxyTabPage::SvxProxyTabPage(TabPageParent pParent, const SfxItemSet& rSet) + : SfxTabPage(pParent, "cui/ui/optproxypage.ui", "OptProxyPage", &rSet) + , m_xProxyModeLB(m_xBuilder->weld_combo_box("proxymode")) + , m_xHttpProxyFT(m_xBuilder->weld_label("httpft")) + , m_xHttpProxyED(m_xBuilder->weld_entry("http")) + , m_xHttpPortFT(m_xBuilder->weld_label("httpportft")) + , m_xHttpPortED(m_xBuilder->weld_entry("httpport")) + , m_xHttpsProxyFT(m_xBuilder->weld_label("httpsft")) + , m_xHttpsProxyED(m_xBuilder->weld_entry("https")) + , m_xHttpsPortFT(m_xBuilder->weld_label("httpsportft")) + , m_xHttpsPortED(m_xBuilder->weld_entry("httpsport")) + , m_xFtpProxyFT(m_xBuilder->weld_label("ftpft")) + , m_xFtpProxyED(m_xBuilder->weld_entry("ftp")) + , m_xFtpPortFT(m_xBuilder->weld_label("ftpportft")) + , m_xFtpPortED(m_xBuilder->weld_entry("ftpport")) + , m_xNoProxyForFT(m_xBuilder->weld_label("noproxyft")) + , m_xNoProxyForED(m_xBuilder->weld_entry("noproxy")) + , m_xNoProxyDescFT(m_xBuilder->weld_label("noproxydesc")) { - get(m_pProxyModeLB, "proxymode"); - - get(m_pHttpProxyFT, "httpft"); - get(m_pHttpProxyED, "http"); - get(m_pHttpPortFT, "httpportft"); - get(m_pHttpPortED, "httpport"); - - get(m_pHttpsProxyFT, "httpsft"); - get(m_pHttpsProxyED, "https"); - get(m_pHttpsPortFT, "httpsportft"); - get(m_pHttpsPortED, "httpsport"); - - get(m_pFtpProxyFT, "ftpft"); - get(m_pFtpProxyED, "ftp"); - get(m_pFtpPortFT, "ftpportft"); - get(m_pFtpPortED, "ftpport"); - - get(m_pNoProxyForFT, "noproxyft"); - get(m_pNoProxyForED, "noproxy"); - get(m_pNoProxyDescFT, "noproxydesc"); - - Link<Control&,void> aLink = LINK( this, SvxProxyTabPage, LoseFocusHdl_Impl ); - m_pHttpPortED->SetLoseFocusHdl( aLink ); - m_pHttpsPortED->SetLoseFocusHdl( aLink ); - m_pFtpPortED->SetLoseFocusHdl( aLink ); - - m_pProxyModeLB->SetSelectHdl(LINK( this, SvxProxyTabPage, ProxyHdl_Impl )); + m_xHttpProxyED->connect_insert_text(LINK(this, SvxProxyTabPage, NoSpaceTextFilterHdl)); + m_xHttpPortED->connect_insert_text(LINK(this, SvxProxyTabPage, NumberOnlyTextFilterHdl)); + m_xHttpPortED->connect_changed(LINK(this, SvxProxyTabPage, PortChangedHdl)); + m_xHttpsProxyED->connect_insert_text(LINK(this, SvxProxyTabPage, NoSpaceTextFilterHdl)); + m_xHttpsPortED->connect_insert_text(LINK(this, SvxProxyTabPage, NumberOnlyTextFilterHdl)); + m_xHttpsPortED->connect_changed(LINK(this, SvxProxyTabPage, PortChangedHdl)); + m_xFtpProxyED->connect_insert_text(LINK(this, SvxProxyTabPage, NoSpaceTextFilterHdl)); + m_xFtpPortED->connect_insert_text(LINK(this, SvxProxyTabPage, NumberOnlyTextFilterHdl)); + m_xFtpPortED->connect_changed(LINK(this, SvxProxyTabPage, PortChangedHdl)); + + Link<weld::Widget&,void> aLink = LINK( this, SvxProxyTabPage, LoseFocusHdl_Impl ); + m_xHttpPortED->connect_focus_out( aLink ); + m_xHttpsPortED->connect_focus_out( aLink ); + m_xFtpPortED->connect_focus_out( aLink ); + + m_xProxyModeLB->connect_changed(LINK( this, SvxProxyTabPage, ProxyHdl_Impl )); Reference< css::lang::XMultiServiceFactory > xConfigurationProvider( @@ -234,33 +220,11 @@ SvxProxyTabPage::SvxProxyTabPage(vcl::Window* pParent, const SfxItemSet& rSet) SvxProxyTabPage::~SvxProxyTabPage() { - disposeOnce(); -} - -void SvxProxyTabPage::dispose() -{ - m_pProxyModeLB.clear(); - m_pHttpProxyFT.clear(); - m_pHttpProxyED.clear(); - m_pHttpPortFT.clear(); - m_pHttpPortED.clear(); - m_pHttpsProxyFT.clear(); - m_pHttpsProxyED.clear(); - m_pHttpsPortFT.clear(); - m_pHttpsPortED.clear(); - m_pFtpProxyFT.clear(); - m_pFtpProxyED.clear(); - m_pFtpPortFT.clear(); - m_pFtpPortED.clear(); - m_pNoProxyForFT.clear(); - m_pNoProxyForED.clear(); - m_pNoProxyDescFT.clear(); - SfxTabPage::dispose(); } VclPtr<SfxTabPage> SvxProxyTabPage::Create(TabPageParent pParent, const SfxItemSet* rAttrSet ) { - return VclPtr<SvxProxyTabPage>::Create(pParent.pParent, *rAttrSet); + return VclPtr<SvxProxyTabPage>::Create(pParent, *rAttrSet); } void SvxProxyTabPage::ReadConfigData_Impl() @@ -273,42 +237,42 @@ void SvxProxyTabPage::ReadConfigData_Impl() if( xNameAccess->getByName(g_aProxyModePN) >>= nIntValue ) { - m_pProxyModeLB->SelectEntryPos( nIntValue ); + m_xProxyModeLB->set_active(nIntValue); } if( xNameAccess->getByName(g_aHttpProxyPN) >>= aStringValue ) { - m_pHttpProxyED->SetText( aStringValue ); + m_xHttpProxyED->set_text( aStringValue ); } if( xNameAccess->getByName(g_aHttpPortPN) >>= nIntValue ) { - m_pHttpPortED->SetText( OUString::number( nIntValue )); + m_xHttpPortED->set_text( OUString::number( nIntValue )); } if( xNameAccess->getByName(g_aHttpsProxyPN) >>= aStringValue ) { - m_pHttpsProxyED->SetText( aStringValue ); + m_xHttpsProxyED->set_text( aStringValue ); } if( xNameAccess->getByName(g_aHttpsPortPN) >>= nIntValue ) { - m_pHttpsPortED->SetText( OUString::number( nIntValue )); + m_xHttpsPortED->set_text( OUString::number( nIntValue )); } if( xNameAccess->getByName(g_aFtpProxyPN) >>= aStringValue ) { - m_pFtpProxyED->SetText( aStringValue ); + m_xFtpProxyED->set_text( aStringValue ); } if( xNameAccess->getByName(g_aFtpPortPN) >>= nIntValue ) { - m_pFtpPortED->SetText( OUString::number( nIntValue )); + m_xFtpPortED->set_text( OUString::number( nIntValue )); } if( xNameAccess->getByName(g_aNoProxyDescPN) >>= aStringValue ) { - m_pNoProxyForED->SetText( aStringValue ); + m_xNoProxyForED->set_text( aStringValue ); } } catch (const container::NoSuchElementException&) { @@ -333,37 +297,37 @@ void SvxProxyTabPage::ReadConfigDefaults_Impl() if( xPropertyState->getPropertyDefault(g_aHttpProxyPN) >>= aStringValue ) { - m_pHttpProxyED->SetText( aStringValue ); + m_xHttpProxyED->set_text( aStringValue ); } if( xPropertyState->getPropertyDefault(g_aHttpPortPN) >>= nIntValue ) { - m_pHttpPortED->SetText( OUString::number( nIntValue )); + m_xHttpPortED->set_text( OUString::number( nIntValue )); } if( xPropertyState->getPropertyDefault(g_aHttpsProxyPN) >>= aStringValue ) { - m_pHttpsProxyED->SetText( aStringValue ); + m_xHttpsProxyED->set_text( aStringValue ); } if( xPropertyState->getPropertyDefault(g_aHttpsPortPN) >>= nIntValue ) { - m_pHttpsPortED->SetText( OUString::number( nIntValue )); + m_xHttpsPortED->set_text( OUString::number( nIntValue )); } if( xPropertyState->getPropertyDefault(g_aFtpProxyPN) >>= aStringValue ) { - m_pFtpProxyED->SetText( aStringValue ); + m_xFtpProxyED->set_text( aStringValue ); } if( xPropertyState->getPropertyDefault(g_aFtpPortPN) >>= nIntValue ) { - m_pFtpPortED->SetText( OUString::number( nIntValue )); + m_xFtpPortED->set_text( OUString::number( nIntValue )); } if( xPropertyState->getPropertyDefault(g_aNoProxyDescPN) >>= aStringValue ) { - m_pNoProxyForED->SetText( aStringValue ); + m_xNoProxyForED->set_text( aStringValue ); } } catch (const beans::UnknownPropertyException &) @@ -414,14 +378,14 @@ void SvxProxyTabPage::Reset(const SfxItemSet*) { ReadConfigData_Impl(); - m_pProxyModeLB->SaveValue(); - m_pHttpProxyED->SaveValue(); - m_pHttpPortED->SaveValue(); - m_pHttpsProxyED->SaveValue(); - m_pHttpsPortED->SaveValue(); - m_pFtpProxyED->SaveValue(); - m_pFtpPortED->SaveValue(); - m_pNoProxyForED->SaveValue(); + m_xProxyModeLB->save_value(); + m_xHttpProxyED->save_value(); + m_xHttpPortED->save_value(); + m_xHttpsProxyED->save_value(); + m_xHttpsPortED->save_value(); + m_xFtpProxyED->save_value(); + m_xFtpPortED->save_value(); + m_xNoProxyForED->save_value(); EnableControls_Impl(); } @@ -433,8 +397,8 @@ bool SvxProxyTabPage::FillItemSet(SfxItemSet* ) try { Reference< beans::XPropertySet > xPropertySet(m_xConfigurationUpdateAccess, UNO_QUERY_THROW ); - sal_Int32 nSelPos = m_pProxyModeLB->GetSelectedEntryPos(); - if(m_pProxyModeLB->IsValueChangedFromSaved()) + sal_Int32 nSelPos = m_xProxyModeLB->get_active(); + if(m_xProxyModeLB->get_value_changed_from_saved()) { if( nSelPos == 1 ) { @@ -446,45 +410,45 @@ bool SvxProxyTabPage::FillItemSet(SfxItemSet* ) bModified = true; } - if(m_pHttpProxyED->IsValueChangedFromSaved()) + if(m_xHttpProxyED->get_value_changed_from_saved()) { - xPropertySet->setPropertyValue( g_aHttpProxyPN, Any(m_pHttpProxyED->GetText())); + xPropertySet->setPropertyValue( g_aHttpProxyPN, Any(m_xHttpProxyED->get_text())); bModified = true; } - if ( m_pHttpPortED->IsValueChangedFromSaved()) + if ( m_xHttpPortED->get_value_changed_from_saved()) { - xPropertySet->setPropertyValue( g_aHttpPortPN, Any(m_pHttpPortED->GetText().toInt32())); + xPropertySet->setPropertyValue( g_aHttpPortPN, Any(m_xHttpPortED->get_text().toInt32())); bModified = true; } - if( m_pHttpsProxyED->IsValueChangedFromSaved() ) + if( m_xHttpsProxyED->get_value_changed_from_saved() ) { - xPropertySet->setPropertyValue( g_aHttpsProxyPN, Any(m_pHttpsProxyED->GetText()) ); + xPropertySet->setPropertyValue( g_aHttpsProxyPN, Any(m_xHttpsProxyED->get_text()) ); bModified = true; } - if ( m_pHttpsPortED->IsValueChangedFromSaved() ) + if ( m_xHttpsPortED->get_value_changed_from_saved() ) { - xPropertySet->setPropertyValue( g_aHttpsPortPN, Any(m_pHttpsPortED->GetText().toInt32()) ); + xPropertySet->setPropertyValue( g_aHttpsPortPN, Any(m_xHttpsPortED->get_text().toInt32()) ); bModified = true; } - if( m_pFtpProxyED->IsValueChangedFromSaved()) + if( m_xFtpProxyED->get_value_changed_from_saved()) { - xPropertySet->setPropertyValue( g_aFtpProxyPN, Any(m_pFtpProxyED->GetText()) ); + xPropertySet->setPropertyValue( g_aFtpProxyPN, Any(m_xFtpProxyED->get_text()) ); bModified = true; } - if ( m_pFtpPortED->IsValueChangedFromSaved() ) + if ( m_xFtpPortED->get_value_changed_from_saved() ) { - xPropertySet->setPropertyValue( g_aFtpPortPN, Any(m_pFtpPortED->GetText().toInt32())); + xPropertySet->setPropertyValue( g_aFtpPortPN, Any(m_xFtpPortED->get_text().toInt32())); bModified = true; } - if ( m_pNoProxyForED->IsValueChangedFromSaved() ) + if ( m_xNoProxyForED->get_value_changed_from_saved() ) { - xPropertySet->setPropertyValue( g_aNoProxyDescPN, Any( m_pNoProxyForED->GetText())); + xPropertySet->setPropertyValue( g_aNoProxyDescPN, Any( m_xNoProxyForED->get_text())); bModified = true; } @@ -512,41 +476,40 @@ bool SvxProxyTabPage::FillItemSet(SfxItemSet* ) void SvxProxyTabPage::EnableControls_Impl() { - m_pProxyModeLB->Enable(!officecfg::Inet::Settings::ooInetNoProxy::isReadOnly()); + m_xProxyModeLB->set_sensitive(!officecfg::Inet::Settings::ooInetNoProxy::isReadOnly()); - const bool bManualConfig = m_pProxyModeLB->GetSelectedEntryPos() == 2; + const bool bManualConfig = m_xProxyModeLB->get_active() == 2; const bool bHTTPProxyNameEnabled = bManualConfig && !officecfg::Inet::Settings::ooInetHTTPProxyName::isReadOnly(); const bool bHTTPProxyPortEnabled = bManualConfig && !officecfg::Inet::Settings::ooInetHTTPProxyPort::isReadOnly(); - m_pHttpProxyFT->Enable(bHTTPProxyNameEnabled); - m_pHttpProxyED->Enable(bHTTPProxyNameEnabled); - m_pHttpPortFT->Enable(bHTTPProxyPortEnabled); - m_pHttpPortED->Enable(bHTTPProxyPortEnabled); + m_xHttpProxyFT->set_sensitive(bHTTPProxyNameEnabled); + m_xHttpProxyED->set_sensitive(bHTTPProxyNameEnabled); + m_xHttpPortFT->set_sensitive(bHTTPProxyPortEnabled); + m_xHttpPortED->set_sensitive(bHTTPProxyPortEnabled); const bool bHTTPSProxyNameEnabled = bManualConfig && !officecfg::Inet::Settings::ooInetHTTPSProxyName::isReadOnly(); const bool bHTTPSProxyPortEnabled = bManualConfig && !officecfg::Inet::Settings::ooInetHTTPSProxyPort::isReadOnly(); - m_pHttpsProxyFT->Enable(bHTTPSProxyNameEnabled); - m_pHttpsProxyED->Enable(bHTTPSProxyNameEnabled); - m_pHttpsPortFT->Enable(bHTTPSProxyPortEnabled); - m_pHttpsPortED->Enable(bHTTPSProxyPortEnabled); + m_xHttpsProxyFT->set_sensitive(bHTTPSProxyNameEnabled); + m_xHttpsProxyED->set_sensitive(bHTTPSProxyNameEnabled); + m_xHttpsPortFT->set_sensitive(bHTTPSProxyPortEnabled); + m_xHttpsPortED->set_sensitive(bHTTPSProxyPortEnabled); const bool bFTPProxyNameEnabled = bManualConfig && !officecfg::Inet::Settings::ooInetFTPProxyName::isReadOnly(); const bool bFTPProxyPortEnabled = bManualConfig && !officecfg::Inet::Settings::ooInetFTPProxyPort::isReadOnly(); - m_pFtpProxyFT->Enable(bFTPProxyNameEnabled); - m_pFtpProxyED->Enable(bFTPProxyNameEnabled); - m_pFtpPortFT->Enable(bFTPProxyPortEnabled); - m_pFtpPortED->Enable(bFTPProxyPortEnabled); + m_xFtpProxyFT->set_sensitive(bFTPProxyNameEnabled); + m_xFtpProxyED->set_sensitive(bFTPProxyNameEnabled); + m_xFtpPortFT->set_sensitive(bFTPProxyPortEnabled); + m_xFtpPortED->set_sensitive(bFTPProxyPortEnabled); const bool bInetNoProxyEnabled = bManualConfig && !officecfg::Inet::Settings::ooInetNoProxy::isReadOnly(); - m_pNoProxyForFT->Enable(bInetNoProxyEnabled); - m_pNoProxyForED->Enable(bInetNoProxyEnabled); - m_pNoProxyDescFT->Enable(bInetNoProxyEnabled); + m_xNoProxyForFT->set_sensitive(bInetNoProxyEnabled); + m_xNoProxyForED->set_sensitive(bInetNoProxyEnabled); + m_xNoProxyDescFT->set_sensitive(bInetNoProxyEnabled); } - -IMPL_LINK( SvxProxyTabPage, ProxyHdl_Impl, ListBox&, rBox, void ) +IMPL_LINK(SvxProxyTabPage, ProxyHdl_Impl, weld::ComboBox&, rBox, void) { - sal_Int32 nPos = rBox.GetSelectedEntryPos(); + sal_Int32 nPos = rBox.get_active(); // Restore original system values if( nPos == 1 ) @@ -557,16 +520,13 @@ IMPL_LINK( SvxProxyTabPage, ProxyHdl_Impl, ListBox&, rBox, void ) EnableControls_Impl(); } - -IMPL_STATIC_LINK( SvxProxyTabPage, LoseFocusHdl_Impl, Control&, rControl, void ) +IMPL_STATIC_LINK(SvxProxyTabPage, LoseFocusHdl_Impl, weld::Widget&, rControl, void) { - Edit* pEdit = static_cast<Edit*>(&rControl); - if ( !isValidPort(pEdit->GetText()) ) - pEdit->SetText( OUString('0') ); + weld::Entry* pEdit = dynamic_cast<weld::Entry*>(&rControl); + if (pEdit && !isValidPort(pEdit->get_text())) + pEdit->set_text(OUString('0')); } - - /********************************************************************/ /* */ /* SvxSecurityTabPage */ |