Commit c275bf35 authored by Tomaz  Canabrava's avatar Tomaz Canabrava Committed by Nate Graham
Browse files

Port the accessibility KCM to QML

This rewrites the Accessibility KCM to use QML and the new Managed
Config classes.
parent ca08ebb3
......@@ -3,25 +3,44 @@ add_definitions(-DTRANSLATION_DOMAIN=\"kcmaccess\")
set(kcm_access_PART_SRCS kcmaccess.cpp )
ki18n_wrap_ui(kcm_access_PART_SRCS
accessibility.ui
)
# needed for krdb
qt5_add_dbus_interface(kcm_access_PART_SRCS ${KINIT_DBUS_INTERFACES_DIR}/kf5_org.kde.KLauncher.xml klauncher_iface)
kconfig_add_kcfg_files(kcm_access_PART_SRCS
kcmaccessibilitybell.kcfgc
kcmaccessibilitykeyboard.kcfgc
kcmaccessibilitymouse.kcfgc
kcmaccessibilityscreenreader.kcfgc
GENERATE_MOC)
add_library(kcm_access MODULE ${kcm_access_PART_SRCS})
target_link_libraries(kcm_access
Qt5::X11Extras
Qt5::DBus
KF5::KCMUtils
KF5::CoreAddons
KF5::Declarative
KF5::GuiAddons
KF5::I18n
KF5::KIOCore
KF5::KIOWidgets
KF5::NotifyConfig
KF5::NewStuff
KF5::QuickAddons
KF5::WindowSystem
KF5::NotifyConfig
Qt5::X11Extras
${X11_LIBRARIES}
)
install(TARGETS kcm_access DESTINATION ${KDE_INSTALL_PLUGINDIR})
kcoreaddons_desktop_to_json(kcm_access "kcm_access.desktop")
########### install files ###############
install(FILES kcm_access.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR})
install(TARGETS kcm_access DESTINATION ${KDE_INSTALL_PLUGINDIR}/kcms)
install(
FILES
kcmaccessibilitybell.kcfg
kcmaccessibilitykeyboard.kcfg
kcmaccessibilitymouse.kcfg
kcmaccessibilityscreenreader.kcfg
DESTINATION
${KDE_INSTALL_KCFGDIR}
)
install( FILES kcmaccess.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR} )
kpackage_install_package(package kcmaccess kcms)
This diff is collapsed.
This diff is collapsed.
......@@ -22,36 +22,52 @@
#ifndef __kcmaccess_h__
#define __kcmaccess_h__
#include <KQuickAddons/ManagedConfigModule>
#include <QString>
#include <QColor>
#include <KCModule>
#include "ui_accessibility.h"
class MouseSettings;
class BellSettings;
class KeyboardSettings;
class ScreenReaderSettings;
class KAccessConfig : public KCModule
class KAccessConfig : public KQuickAddons::ManagedConfigModule
{
Q_OBJECT
Q_PROPERTY(MouseSettings *mouseSettings MEMBER m_mouseSettings CONSTANT)
Q_PROPERTY(BellSettings *bellSettings MEMBER m_bellSettings CONSTANT)
Q_PROPERTY(KeyboardSettings *keyboardSettings MEMBER m_keyboardSettings CONSTANT)
Q_PROPERTY(ScreenReaderSettings *screenReaderSettings MEMBER m_screenReaderSettings CONSTANT)
Q_PROPERTY(QString orcaLaunchFeedback READ orcaLaunchFeedback WRITE setOrcaLaunchFeedback NOTIFY orcaLaunchFeedbackChanged)
Q_PROPERTY(QString desktopShortcutInfo MEMBER m_desktopShortcutInfo CONSTANT)
Q_PROPERTY(bool screenReaderInstalled MEMBER m_screenReaderInstalled CONSTANT)
public:
KAccessConfig(QWidget *parent, const QVariantList&);
KAccessConfig(QObject *parent, const QVariantList&);
~KAccessConfig() override;
void load() override;
void save() override;
void defaults() override;
protected Q_SLOTS:
Q_INVOKABLE void configureKNotify(QQuickItem *parent);
Q_INVOKABLE void launchOrcaConfiguration();
Q_INVOKABLE bool orcaInstalled();
void configChanged();
void checkAccess();
void invertClicked();
void flashClicked();
void selectSound();
void changeFlashScreenColor();
void configureKNotify();
void launchOrcaConfiguration();
QString orcaLaunchFeedback() const;
Q_SIGNALS:
void orcaLaunchFeedbackChanged();
private:
Ui::access ui;
void setOrcaLaunchFeedback(const QString& value);
MouseSettings *m_mouseSettings;
BellSettings *m_bellSettings;
KeyboardSettings *m_keyboardSettings;
ScreenReaderSettings *m_screenReaderSettings;
QString m_orcaLaunchFeedback;
QString m_desktopShortcutInfo;
bool m_screenReaderInstalled;
};
......
<?xml version="1.0" encoding="UTF-8"?>
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile name="kaccessrc" />
<group name="Bell">
<entry name="SystemBell" key="SystemBell" type="Bool">
<label>Use System Bell</label>
<default>true</default>
</entry>
<entry name="CustomBell" key="ArtsBell" type="Bool">
<label>Customize system bell</label>
<default>false</default>
</entry>
<entry name="CustomBellFile" key="ArtsBellFile" type="String">
<label>Sound file for the Bell</label>
</entry>
<entry name="VisibleBell" key="VisibleBell" type="Bool">
<label>Use a visual bell instead of a sound</label>
<default>false</default>
</entry>
<entry name="InvertScreen" key="VisibleBellInvert" type="Bool">
<label>Invert the system colors on the bell</label>
<default>true</default>
</entry>
<entry name="VisibleBellColor" key="VisibleBellColor" type="Color">
<label>Color of the Systme bell</label>
<default></default>
</entry>
<entry name="VisibleBellPause" key="VisibleBellPause" type="Int">
<label>Duration of the Visible Bell</label>
<default>500</default>
</entry>
</group>
</kcfg>
File=kcmaccessibilitybell.kcfg
ClassName=BellSettings
Mutators=true
DefaultValueGetters=true
GenerateProperties=true
ParentInConstructor=true
<?xml version="1.0" encoding="UTF-8"?>
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile name="kaccessrc" />
<group name="Keyboard">
<entry name="StickyKeys" key="StickyKeys" type="Bool">
<label>Use sticky Keys</label>
<default>false</default>
</entry>
<entry name="StickyKeysLatch" key="StickyKeysLatch" type="Bool">
<label>Lock the sticky keys</label>
<default>true</default>
</entry>
<entry name="StickyKeysAutoOff" key="StickyKeysAutoOff" type="Bool">
<label>Automatically turn off the sticky keys after an interval</label>
<default>false</default>
</entry>
<entry name="StickyKeysBeep" key="StickyKeysBeep" type="Bool">
<label>Beep on a sticky key press</label>
<default>true</default>
</entry>
<entry name="ToggleKeysBeep" key="ToggleKeysBeep" type="Bool">
<label>Toggle keys beep</label>
<default>false</default>
</entry>
<entry name="KeyboardNotifyModifiers" key="kNotifyModifiers" type="Bool">
<label>Notify when a keyboard modifier is pressed</label>
<default>false</default>
</entry>
<entry name="SlowKeys" key="SlowKeys" type="Bool">
<label>Use slow keypresses</label>
<default>false</default>
</entry>
<entry name="SlowKeysDelay" key="SlowKeysDelay" type="Int">
<label>Delay for the key press</label>
<default>500</default>
</entry>
<entry name="SlowKeysPressBeep" key="SlowKeysPressBeep" type="Bool">
<label>Beep on a slow keypress</label>
<default>true</default>
</entry>
<entry name="SlowKeysAcceptBeep" key="SlowKeysAcceptBeep" type="Bool">
<label>Beep on an accepted keypress</label>
<default>true</default>
</entry>
<entry name="SlowKeysRejectBeep" key="SlowKeysRejectBeep" type="Bool">
<label>Beep on a rejected keypress</label>
<default>true</default>
</entry>
<entry name="BounceKeys" key="BounceKeys" type="Bool">
<label>Bounce Keys</label>
<default>false</default>
</entry>
<entry name="BounceKeysDelay" key="BounceKeysDelay" type="Int">
<label>Use a delay for bouncing</label>
<default>500</default>
</entry>
<entry name="BounceKeysRejectBeep" key="BounceKeysRejectBeep" type="Bool">
<label>Beep if a bounce key event is rejected</label>
<default>false</default>
</entry>
<entry name="Gestures" key="Gestures" type="Bool">
<label>Use Gestures</label>
<default>false</default>
</entry>
<entry name="AccessXTimeout" key="AccessXTimeout" type="Int">
<label>Use a timeout delay</label>
<default>30</default>
</entry>
<entry name="AccessXTimeoutDelay" key="AccessXTimeoutDelay" type="Bool">
<label>Invert the system colors on the bell</label>
<default>false</default>
</entry>
<entry name="AccessXBeep" key="AccessBeep" type="Bool">
<label>Use a beep for access</label>
<default>false</default>
</entry>
<entry name="GestureConfirmation" key="GestureConfirmation" type="Bool">
<label>Ask for Confirmation for a gesture</label>
<default>false</default>
</entry>
<entry name="KeyboardNotifyAccess" key="kNotifyAccess" type="Bool">
<label>Confirm access to the Keyboard</label>
<default>false</default>
</entry>
</group>
</kcfg>
File=kcmaccessibilitykeyboard.kcfg
ClassName=KeyboardSettings
Mutators=true
DefaultValueGetters=true
GenerateProperties=true
ParentInConstructor=true
<?xml version="1.0" encoding="UTF-8"?>
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile name="kaccessrc" />
<group name="Mouse">
<entry name="MouseKeys" key="MouseKeys" type="Bool">
<label>Use keys to control the mouse</label>
<default>false</default>
</entry>
<entry name="AccelerationDelay" key="MKDelay" type="Int">
<label>Delay for the mouse movement</label>
<default>1</default>
</entry>
<entry name="RepetitionInterval" key="MKInterval" type="Int">
<label>Repetition interval for the mouse movement</label>
<default>1</default>
</entry>
<entry name="MK_TimeToMax" key="MK_TimeToMax" type="Int">
<label>Time to hit maximum velocity</label>
<default>5000</default>
</entry>
<entry name="AccelerationTime" key="MKTimeToMax" type="Int">
<label>Time to hit maximum velocity</label>
</entry>
<entry name="MK_MaxSpeed" key="MK_MaxSpeed" type="Int">
<label>Maximum velocity</label>
<default>1000</default>
</entry>
<entry name="MaxSpeed" key="MKMaxSpeed" type="Int">
<label>Maximum Velocity</label>
</entry>
<entry name="ProfileCurve" key="MKCurve" type="Int">
<label>Mouse Key Curve</label>
<default>0</default>
</entry>
</group>
</kcfg>
File=kcmaccessibilitymouse.kcfg
ClassName=MouseSettings
Mutators=true
DefaultValueGetters=true
GenerateProperties=true
ParentInConstructor=true
<?xml version="1.0" encoding="UTF-8"?>
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile name="kaccessrc" />
<group name="ScreenReader">
<entry name="Enabled" key="Enabled" type="Bool">
<label>Enable Screen Reader</label>
<default>true</default>
</entry>
</group>
</kcfg>
File=kcmaccessibilityscreenreader.kcfg
ClassName=ScreenReaderSettings
Mutators=true
DefaultValueGetters=true
GenerateProperties=true
ParentInConstructor=true
/*
* Copyright 2018 Tomaz Canabrava <tcanabrava@kde.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.6
import QtQuick.Layouts 1.1
import QtQuick.Controls 2.12 as QQC2
import QtQuick.Dialogs 1.3 as Dialogs
import org.kde.kcm 1.1 as KCM
import org.kde.kquickcontrols 2.0 as KQuickAddons
import org.kde.kirigami 2.3 as Kirigami
Kirigami.FormLayout {
Dialogs.FileDialog {
id: fileDialog
title: i18n("Please choose an audio file")
folder: shortcuts.home
nameFilters: [i18n("Audio Files (*.mp3 *.ogg *.wav)")]
onAccepted: {
kcm.bellSettings.customBellFile = fileDialog.fileUrls[0]
}
}
QQC2.CheckBox {
id: systemBell
Kirigami.FormData.label: i18n("Audible bell:")
text: i18nc("Enable the system bell", "Enable")
enabled: !kcm.bellSettings.isImmutable("SystemBell")
checked: kcm.bellSettings.systemBell
onToggled: kcm.bellSettings.systemBell = checked
}
QQC2.CheckBox {
text: i18n("Ring when toggling accessibility features with gestures")
enabled: !kcm.keyboardSettings.isImmutable("Gestures") && systemBell.checked
checked: kcm.keyboardSettings.gestures
onToggled: kcm.keyboardSettings.gestures = checked
}
RowLayout {
Kirigami.FormData.label: i18nc("Defines if the system will use a sound system bell", "Custom sound:")
spacing: 0
QQC2.CheckBox {
id: customBell
Layout.alignment: Qt.AlignVCenter
enabled: !kcm.bellSettings.isImmutable("CustomBell") && kcm.bellSettings.systemBell
checked: kcm.bellSettings.customBell
onToggled: kcm.bellSettings.customBell= checked
}
QQC2.TextField {
id: textEdit
text: kcm.bellSettings.customBellFile
enabled: !kcm.bellSettings.isImmutable("CustomBellFile") && kcm.bellSettings.customBell
onEditingFinished: kcm.bellSettings.customBellFile = textEdit.text
}
QQC2.Button {
icon.name: "folder"
QQC2.ToolTip.visible: down
QQC2.ToolTip.text: i18n("Search audio file for the system bell")
Accessible.name: i18n("Button search audio file")
enabled: !kcm.bellSettings.isImmutable("CustomBellFile") && kcm.bellSettings.customBell
onClicked: fileDialog.open()
}
}
Item {
Kirigami.FormData.isSection: true
}
QQC2.CheckBox {
id: visibleBell
Kirigami.FormData.label: i18n("Visual bell:")
text: i18nc("Enable visual bell", "Enable")
enabled: !kcm.bellSettings.isImmutable("VisibleBell")
checked: kcm.bellSettings.visibleBell
onToggled: kcm.bellSettings.visibleBell = checked
}
QQC2.RadioButton {
id: invertScreen
text: i18nc("Invert screen on a system bell", "Invert Screen")
enabled: !kcm.bellSettings.isImmutable("InvertScreen") && kcm.bellSettings.visibleBell
checked: kcm.bellSettings.invertScreen
onToggled: kcm.bellSettings.invertScreen = checked
}
RowLayout {
enabled: kcm.bellSettings.visibleBell
QQC2.RadioButton {
id: flashScreen
text: i18nc("Flash screen on a system bell", "Flash")
enabled: !kcm.bellSettings.isImmutable("InvertScreen")
checked: !kcm.bellSettings.invertScreen
onToggled: kcm.bellSettings.invertScreen = !checked
}
KQuickAddons.ColorButton {
text: i18nc("Color of the system bell","Color")
enabled: !kcm.bellSettings.isImmutable("VisibleBellColor")
color: kcm.bellSettings.visibleBellColor
onAccepted: kcm.bellSettings.visibleBellColor = color
}
}
QQC2.SpinBox {
Kirigami.FormData.label: i18nc("Duration of the system bell", "Duration:")
enabled: !kcm.bellSettings.isImmutable("VisibleBellPause") && kcm.bellSettings.visibleBell
value: kcm.bellSettings.visibleBellPause
onValueModified: kcm.bellSettings.visibleBellPause = value
}
}
/*
* Copyright 2018 Tomaz Canabrava <tcanabrava@kde.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.6
import QtQuick.Layouts 1.1
import QtQuick.Controls 2.12 as QQC2
import org.kde.kcm 1.1 as KCM
import org.kde.kirigami 2.3 as Kirigami
Kirigami.FormLayout {
QQC2.CheckBox {
id: slowKeys
Kirigami.FormData.label: i18n("Slow keys:")
text: i18nc("Enable slow keys", "Enable")
enabled: !kcm.keyboardSettings.isImmutable("SlowKeys")
checked: kcm.keyboardSettings.slowKeys
onToggled: kcm.keyboardSettings.slowKeys = checked
}
QQC2.SpinBox {
id: slowKayDelay
Kirigami.FormData.label: i18nc("Slow keys Delay", "Delay:")
enabled: !kcm.keyboardSettings.isImmutable("SlowKeysDelay") && kcm.keyboardSettings.slowKeys
onValueChanged: kcm.keyboardSettings.slowKeysDelay = value
}
Item {
Kirigami.FormData.isSection: true
}
QQC2.CheckBox {
id: slowKeysPressBeep
Kirigami.FormData.label: i18n("Ring system bell:")
text: i18nc("Use system bell when a key is pressed", "&when any key is pressed")
enabled: !kcm.keyboardSettings.isImmutable("SlowKeysPressBeep") && kcm.keyboardSettings.slowKeys
checked: kcm.keyboardSettings.slowKeysPressBeep
onToggled: kcm.keyboardSettings.slowKeysPressBeep = checked
}
QQC2.CheckBox{
id: slowKeysAcceptBeep
text: i18nc("Use system bell when a key is accepted", "&when any key is accepted")
enabled: !kcm.keyboardSettings.isImmutable("SlowKeysAcceptBeep") && kcm.keyboardSettings.slowKeys
checked: kcm.keyboardSettings.slowKeysAcceptBeep
onToggled: kcm.keyboardSettings.slowKeysAcceptBeep = checked
}
QQC2.CheckBox{
id: slowKeysRejectBeep
text: i18nc("Use system bell when a key is rejected", "&when any key is rejected")
enabled: !kcm.keyboardSettings.isImmutable("SlowKeysRejectBeep") && kcm.keyboardSettings.slowKeys
checked: kcm.keyboardSettings.slowKeysRejectBeep
onToggled: kcm.keyboardSettings.slowKeysRejectBeep = checked
}
Item {
Kirigami.FormData.isSection: true
}
QQC2.CheckBox {
id: bounceKeys
Kirigami.FormData.label: i18n("Bounce keys:")
text: i18nc("Bounce keys enable", "Enable");
enabled: !kcm.keyboardSettings.isImmutable("BounceKeys")
checked: kcm.keyboardSettings.bounceKeys
onToggled: kcm.keyboardSettings.bounceKeys = checked
}
QQC2.SpinBox {
id: bounceKeysDelay