tdf#158004 - UI: Part 20 - Unify lockdown behavior of Options dialog
for Connections Page.
Change-Id: I76510a893bb35e03e6401aeeb03971969cc42ad2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158989
Tested-by: Jenkins
Reviewed-by: Balazs Varga <balazs.varga.extern@allotropia.de>
diff --git a/cui/source/options/connpooloptions.cxx b/cui/source/options/connpooloptions.cxx
index 00101be..f6321f2 100644
--- a/cui/source/options/connpooloptions.cxx
+++ b/cui/source/options/connpooloptions.cxx
@@ -25,6 +25,8 @@
#include <svx/databaseregistrationui.hxx>
#include <strings.hrc>
#include <dialmgr.hxx>
#include <officecfg/Office/DataAccess.hxx>
#include <com/sun/star/beans/PropertyAttribute.hpp>
namespace offapp
{
@@ -49,13 +51,16 @@ namespace offapp
, m_sYes(CuiResId(RID_CUISTR_YES))
, m_sNo(CuiResId(RID_CUISTR_NO))
, m_xEnablePooling(m_xBuilder->weld_check_button("connectionpooling"))
, m_xEnablePoolingImg(m_xBuilder->weld_widget("lockconnectionpooling"))
, m_xDriversLabel(m_xBuilder->weld_label("driverslabel"))
, m_xDriverList(m_xBuilder->weld_tree_view("driverlist"))
, m_xDriverLabel(m_xBuilder->weld_label("driverlabel"))
, m_xDriver(m_xBuilder->weld_label("driver"))
, m_xDriverPoolingEnabled(m_xBuilder->weld_check_button("enablepooling"))
, m_xDriverPoolingEnabledImg(m_xBuilder->weld_widget("lockenablepooling"))
, m_xTimeoutLabel(m_xBuilder->weld_label("timeoutlabel"))
, m_xTimeout(m_xBuilder->weld_spin_button("timeout"))
, m_xTimeoutImg(m_xBuilder->weld_widget("locktimeout"))
{
m_xDriverList->set_size_request(m_xDriverList->get_approximate_digit_width() * 60,
m_xDriverList->get_height_rows(15));
@@ -68,6 +73,9 @@ namespace offapp
};
m_xDriverList->set_column_fixed_widths(aWidths);
css::uno::Reference < css::uno::XComponentContext > xContext(::comphelper::getProcessComponentContext());
m_xReadWriteAccess = css::configuration::ReadWriteAccess::create(xContext, "*");
m_xEnablePooling->connect_toggled( LINK(this, ConnectionPoolOptionsPage, OnEnabledDisabled) );
m_xDriverPoolingEnabled->connect_toggled( LINK(this, ConnectionPoolOptionsPage, OnEnabledDisabled) );
@@ -136,6 +144,8 @@ namespace offapp
const SfxBoolItem* pEnabled = _rSet.GetItem<SfxBoolItem>(SID_SB_POOLING_ENABLED);
OSL_ENSURE(pEnabled, "ConnectionPoolOptionsPage::implInitControls: missing the Enabled item!");
m_xEnablePooling->set_active(pEnabled == nullptr || pEnabled->GetValue());
m_xEnablePooling->set_sensitive(!officecfg::Office::DataAccess::ConnectionPool::EnablePooling::isReadOnly());
m_xEnablePoolingImg->set_visible(officecfg::Office::DataAccess::ConnectionPool::EnablePooling::isReadOnly());
m_xEnablePooling->save_state();
@@ -233,6 +243,20 @@ namespace offapp
m_xDriverPoolingEnabled->set_active(currentSetting.bEnabled);
m_xTimeout->set_value(currentSetting.nTimeoutSeconds);
OUString aConfigPath = officecfg::Office::DataAccess::ConnectionPool::DriverSettings::path() + "/" + currentSetting.sName;
css::beans::Property aProperty = m_xReadWriteAccess->getPropertyByHierarchicalName(aConfigPath + "/Enable");
bool bReadOnly = (aProperty.Attributes & css::beans::PropertyAttribute::READONLY) != 0;
m_xDriverPoolingEnabled->set_sensitive(!bReadOnly);
m_xDriverPoolingEnabledImg->set_visible(bReadOnly);
aProperty = m_xReadWriteAccess->getPropertyByHierarchicalName(aConfigPath + "/Timeout");
bReadOnly = (aProperty.Attributes & css::beans::PropertyAttribute::READONLY) != 0;
m_xTimeout->set_sensitive(!bReadOnly);
m_xTimeoutLabel->set_sensitive(!bReadOnly);
m_xTimeoutImg->set_visible(bReadOnly);
OnEnabledDisabled(*m_xDriverPoolingEnabled);
}
}
@@ -259,13 +283,13 @@ namespace offapp
m_xDriverList->select(-1);
m_xDriverLabel->set_sensitive(bGloballyEnabled);
m_xDriver->set_sensitive(bGloballyEnabled);
m_xDriverPoolingEnabled->set_sensitive(bGloballyEnabled);
m_xDriverPoolingEnabled->set_sensitive(bGloballyEnabled && !m_xDriverPoolingEnabledImg->get_visible());
}
else
OSL_ENSURE(bLocalDriverChanged, "ConnectionPoolOptionsPage::OnEnabledDisabled: where did this come from?");
m_xTimeoutLabel->set_sensitive(bGloballyEnabled && m_xDriverPoolingEnabled->get_active());
m_xTimeout->set_sensitive(bGloballyEnabled && m_xDriverPoolingEnabled->get_active());
m_xTimeoutLabel->set_sensitive(bGloballyEnabled && m_xDriverPoolingEnabled->get_active() && !m_xTimeoutImg->get_visible());
m_xTimeout->set_sensitive(bGloballyEnabled && m_xDriverPoolingEnabled->get_active() && !m_xTimeoutImg->get_visible());
if (bLocalDriverChanged)
{
diff --git a/cui/source/options/connpooloptions.hxx b/cui/source/options/connpooloptions.hxx
index e5ec2a6..2413f0d 100644
--- a/cui/source/options/connpooloptions.hxx
+++ b/cui/source/options/connpooloptions.hxx
@@ -20,6 +20,7 @@
#pragma once
#include <sfx2/tabdlg.hxx>
#include <com/sun/star/configuration/ReadWriteAccess.hpp>
#include "connpoolsettings.hxx"
@@ -32,14 +33,19 @@ namespace offapp
DriverPoolingSettings m_aSettings;
DriverPoolingSettings m_aSavedSettings;
css::uno::Reference< css::configuration::XReadWriteAccess> m_xReadWriteAccess;
std::unique_ptr<weld::CheckButton> m_xEnablePooling;
std::unique_ptr<weld::Widget> m_xEnablePoolingImg;
std::unique_ptr<weld::Label> m_xDriversLabel;
std::unique_ptr<weld::TreeView> m_xDriverList;
std::unique_ptr<weld::Label> m_xDriverLabel;
std::unique_ptr<weld::Label> m_xDriver;
std::unique_ptr<weld::CheckButton> m_xDriverPoolingEnabled;
std::unique_ptr<weld::Widget> m_xDriverPoolingEnabledImg;
std::unique_ptr<weld::Label> m_xTimeoutLabel;
std::unique_ptr<weld::SpinButton> m_xTimeout;
std::unique_ptr<weld::Widget> m_xTimeoutImg;
public:
ConnectionPoolOptionsPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& _rAttrSet);
diff --git a/cui/uiconfig/ui/connpooloptions.ui b/cui/uiconfig/ui/connpooloptions.ui
index 20440c5..f31d024 100644
--- a/cui/uiconfig/ui/connpooloptions.ui
+++ b/cui/uiconfig/ui/connpooloptions.ui
@@ -48,25 +48,6 @@
<property name="vexpand">True</property>
<property name="row-spacing">6</property>
<child>
<object class="GtkCheckButton" id="connectionpooling">
<property name="label" translatable="yes" context="connpooloptions|connectionpooling">Connection pooling enabled</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="use-underline">True</property>
<property name="draw-indicator">True</property>
<child internal-child="accessible">
<object class="AtkObject" id="connectionpooling-atkobject">
<property name="AtkObject::accessible-description" translatable="yes" context="extended_tip|connectionpooling">Specifies whether the chosen connections are pooled.</property>
</object>
</child>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<!-- n-columns=1 n-rows=5 -->
<object class="GtkGrid" id="grid2">
<property name="visible">True</property>
@@ -133,73 +114,6 @@
</packing>
</child>
<child>
<object class="GtkCheckButton" id="enablepooling">
<property name="label" translatable="yes" context="connpooloptions|enablepooling">Enable pooling for this driver</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="use-underline">True</property>
<property name="draw-indicator">True</property>
<child internal-child="accessible">
<object class="AtkObject" id="enablepooling-atkobject">
<property name="AtkObject::accessible-description" translatable="yes" context="extended_tip|enablepooling">Select a driver from the list and mark the Enable pooling for this driver checkbox in order to pool its connection.</property>
</object>
</child>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">3</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box4">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-start">12</property>
<property name="spacing">12</property>
<child>
<object class="GtkLabel" id="timeoutlabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes" context="connpooloptions|timeoutlabel">_Timeout (seconds):</property>
<property name="use-underline">True</property>
<property name="mnemonic-widget">timeout</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="timeout">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="activates-default">True</property>
<property name="text">60</property>
<property name="truncate-multiline">True</property>
<property name="adjustment">adjustment1</property>
<property name="value">60</property>
<child internal-child="accessible">
<object class="AtkObject" id="timeout-atkobject">
<property name="AtkObject::accessible-description" translatable="yes" context="extended_tip|timeout">Defines the time in seconds after which a pooled connection is freed.</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">4</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
@@ -280,12 +194,170 @@
<property name="top-attach">1</property>
</packing>
</child>
<child>
<!-- n-columns=2 n-rows=1 -->
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkBox" id="box4">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-start">12</property>
<property name="spacing">12</property>
<child>
<object class="GtkLabel" id="timeoutlabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes" context="connpooloptions|timeoutlabel">_Timeout (seconds):</property>
<property name="use-underline">True</property>
<property name="mnemonic-widget">timeout</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="timeout">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="activates-default">True</property>
<property name="text">60</property>
<property name="truncate-multiline">True</property>
<property name="adjustment">adjustment1</property>
<property name="value">60</property>
<child internal-child="accessible">
<object class="AtkObject" id="timeout-atkobject">
<property name="AtkObject::accessible-description" translatable="yes" context="extended_tip|timeout">Defines the time in seconds after which a pooled connection is freed.</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkImage" id="locktimeout">
<property name="can-focus">False</property>
<property name="no-show-all">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="icon-name">res/lock.png</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">4</property>
</packing>
</child>
<child>
<!-- n-columns=2 n-rows=1 -->
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkCheckButton" id="enablepooling">
<property name="label" translatable="yes" context="connpooloptions|enablepooling">Enable pooling for this driver</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="use-underline">True</property>
<property name="draw-indicator">True</property>
<child internal-child="accessible">
<object class="AtkObject" id="enablepooling-atkobject">
<property name="AtkObject::accessible-description" translatable="yes" context="extended_tip|enablepooling">Select a driver from the list and mark the Enable pooling for this driver checkbox in order to pool its connection.</property>
</object>
</child>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkImage" id="lockenablepooling">
<property name="can-focus">False</property>
<property name="no-show-all">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="icon-name">res/lock.png</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">3</property>
</packing>
</child>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<!-- n-columns=2 n-rows=1 -->
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkCheckButton" id="connectionpooling">
<property name="label" translatable="yes" context="connpooloptions|connectionpooling">Connection pooling enabled</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="use-underline">True</property>
<property name="draw-indicator">True</property>
<child internal-child="accessible">
<object class="AtkObject" id="connectionpooling-atkobject">
<property name="AtkObject::accessible-description" translatable="yes" context="extended_tip|connectionpooling">Specifies whether the chosen connections are pooled.</property>
</object>
</child>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkImage" id="lockconnectionpooling">
<property name="can-focus">False</property>
<property name="no-show-all">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="icon-name">res/lock.png</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
</object>
</child>
<child type="label">