tdf#151522 add Accessibility::HighContrast

0 Automatic, do what the system says
1 Disable
2 Enable

Forcing Disable/Enable won't have (much of) an effect on the widgetry, but will
affect how document content is rendered where typically content color
is mapped to fore/back ground color.

Change-Id: I71a2dcf8bc334080414a01691f942a5b7de7b84a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139753
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara
2022-10-15 20:10:04 +01:00
parent 75fd3093ea
commit 5bf38da091
5 changed files with 98 additions and 8 deletions

View File

@@ -29,6 +29,7 @@ SvxAccessibilityOptionsTabPage::SvxAccessibilityOptionsTabPage(weld::Container*
, m_xTextSelectionInReadonly(m_xBuilder->weld_check_button("textselinreadonly"))
, m_xAnimatedGraphics(m_xBuilder->weld_check_button("animatedgraphics"))
, m_xAnimatedTexts(m_xBuilder->weld_check_button("animatedtext"))
, m_xHighContrast(m_xBuilder->weld_combo_box("highcontrast"))
, m_xAutomaticFontColor(m_xBuilder->weld_check_button("autofontcolor"))
, m_xPagePreviews(m_xBuilder->weld_check_button("systempagepreviewcolor"))
{
@@ -60,6 +61,8 @@ bool SvxAccessibilityOptionsTabPage::FillItemSet( SfxItemSet* )
officecfg::Office::Common::Accessibility::IsAutomaticFontColor::set(m_xAutomaticFontColor->get_active(), batch);
if ( !officecfg::Office::Common::Accessibility::IsSelectionInReadonly::isReadOnly() )
officecfg::Office::Common::Accessibility::IsSelectionInReadonly::set(m_xTextSelectionInReadonly->get_active(), batch);
if ( !officecfg::Office::Common::Accessibility::HighContrast::isReadOnly() )
officecfg::Office::Common::Accessibility::HighContrast::set(m_xHighContrast->get_active(), batch);
batch->commit();
AllSettings aAllSettings = Application::GetSettings();
@@ -96,6 +99,10 @@ void SvxAccessibilityOptionsTabPage::Reset( const SfxItemSet* )
if( officecfg::Office::Common::Accessibility::IsSelectionInReadonly::isReadOnly() )
m_xTextSelectionInReadonly->set_sensitive(false);
m_xHighContrast->set_active( officecfg::Office::Common::Accessibility::HighContrast::get() );
if( officecfg::Office::Common::Accessibility::HighContrast::isReadOnly() )
m_xHighContrast->set_sensitive(false);
AllSettings aAllSettings = Application::GetSettings();
const MiscSettings& aMiscSettings = aAllSettings.GetMiscSettings();
m_xAccessibilityTool->set_active(aMiscSettings.GetEnableATToolSupport());

View File

@@ -26,6 +26,7 @@ class SvxAccessibilityOptionsTabPage : public SfxTabPage
std::unique_ptr<weld::CheckButton> m_xTextSelectionInReadonly;
std::unique_ptr<weld::CheckButton> m_xAnimatedGraphics;
std::unique_ptr<weld::CheckButton> m_xAnimatedTexts;
std::unique_ptr<weld::ComboBox> m_xHighContrast;
std::unique_ptr<weld::CheckButton> m_xAutomaticFontColor;
std::unique_ptr<weld::CheckButton> m_xPagePreviews;

View File

@@ -135,6 +135,56 @@
<property name="margin-top">6</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<!-- n-columns=2 n-rows=1 -->
<object class="GtkGrid" id="highcontrastbox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="hexpand">True</property>
<property name="column-spacing">6</property>
<child>
<object class="GtkLabel" id="label13">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes" context="optaccessibilitypage|label13">High Contrast:</property>
<property name="use-underline">True</property>
<property name="mnemonic-widget">highcontrast</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkComboBoxText" id="highcontrast">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="active">0</property>
<items>
<item translatable="yes" context="optaccessibilitypage|highcontrast">Automatic</item>
<item translatable="yes" context="optaccessibilitypage|highcontrast">Disable</item>
<item translatable="yes" context="optaccessibilitypage|highcontrast">Enable</item>
</items>
<child internal-child="accessible">
<object class="AtkObject" id="highcontrast-atkobject">
<property name="AtkObject::accessible-description" translatable="yes" context="extended_tip|highcontrast">Controls if high contrast mode is used. Select from "Automatic", "Disable" and "Enable". "Automatic" uses high contrast according to system settings.</property>
</object>
</child>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="autofontcolor">
<property name="label" translatable="yes" context="optaccessibilitypage|autofontcolor">Use automatic font _color for screen display</property>
@@ -152,7 +202,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
<property name="position">1</property>
</packing>
</child>
<child>
@@ -172,7 +222,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="position">2</property>
</packing>
</child>
</object>

View File

@@ -6188,6 +6188,31 @@
<info>
<desc>Specifies settings for the accessibility options.</desc>
</info>
<prop oor:name="HighContrast" oor:type="xs:short" oor:nillable="false">
<!-- UIHints: Tools Options - Accessibility Options -->
<info>
<desc>Indicates whether High Contrast accessibility mode should be active.</desc>
<label>High Contrast</label>
</info>
<constraints>
<enumeration oor:value="0">
<info>
<desc>Use the default setting for the current platform.</desc>
</info>
</enumeration>
<enumeration oor:value="1">
<info>
<desc>Disable</desc>
</info>
</enumeration>
<enumeration oor:value="2">
<info>
<desc>Enable</desc>
</info>
</enumeration>
</constraints>
<value>0</value>
</prop>
<prop oor:name="IsForPagePreviews" oor:type="xs:boolean" oor:nillable="false">
<info>
<desc>Enables the use of high contrast colors, instead of displaying

View File

@@ -25,6 +25,8 @@
#include <vcl/window.hxx>
#include <vcl/settings.hxx>
#include <officecfg/Office/Common.hxx>
#include <unotools/configmgr.hxx>
#include <unotools/confignode.hxx>
@@ -219,17 +221,22 @@ void Window::ImplUpdateGlobalSettings( AllSettings& rSettings, bool bCallHdl ) c
aFont.SetFontHeight( defFontheight );
aStyleSettings.SetGroupFont( aFont );
rSettings.SetStyleSettings( aStyleSettings );
static const char* pEnvHC = getenv( "SAL_FORCE_HC" );
const bool bForceHCMode = pEnvHC && *pEnvHC;
if( bForceHCMode )
{
aStyleSettings = rSettings.GetStyleSettings();
if (bForceHCMode)
aStyleSettings.SetHighContrastMode( true );
rSettings.SetStyleSettings( aStyleSettings );
else
{
short nHighContrastMode = officecfg::Office::Common::Accessibility::HighContrast::get();
if (nHighContrastMode != 0) // 0 Automatic, 1 Disable, 2 Enable
{
const bool bEnable = nHighContrastMode == 2;
aStyleSettings.SetHighContrastMode(bEnable);
}
}
rSettings.SetStyleSettings( aStyleSettings );
if ( bCallHdl )
GetpApp()->OverrideSystemSettings( rSettings );
}