Commit 86381afb authored by Andrey Butirsky's avatar Andrey Butirsky
Browse files

feat: add option to disable OSD on keyboard layout change

Existing ability to disable OSD globally seems is not enough.
People see OSD on keyboard layout change especially annoying.
So provide the fine grained option.

Counterpart commit with the same title is in P-W

FEATURE: 426450
BUG: 376460
parent 422d8d3e
......@@ -105,6 +105,8 @@ ecm_qt_install_logging_categories(
DESTINATION "${KDE_INSTALL_LOGGINGCATEGORIESDIR}"
)
kconfig_add_kcfg_files(kcm_keyboard_PART_SRCS workspace_options.kcfgc)
ki18n_wrap_ui(kcm_keyboard_PART_SRCS kcm_keyboard.ui kcm_add_layout_dialog.ui kcmmiscwidget.ui)
add_library(kcm_keyboard MODULE ${kcm_keyboard_PART_SRCS})
......
......@@ -61,7 +61,7 @@ KCMKeyboard::KCMKeyboard(QWidget *parent, const QVariantList &args)
layout->setContentsMargins(0, 0, 0, 0);
// layout->setSpacing(KDialog::spacingHint());
widget = new KCMKeyboardWidget(rules, keyboardConfig, args, parent);
widget = new KCMKeyboardWidget(rules, keyboardConfig, m_workspaceOptions, args, parent);
layout->addWidget(widget);
connect(widget, SIGNAL(changed(bool)), this, SIGNAL(changed(bool)));
......@@ -78,14 +78,19 @@ KCMKeyboard::~KCMKeyboard()
void KCMKeyboard::defaults()
{
keyboardConfig->setDefaults();
m_workspaceOptions.osdKbdLayoutChangedEnabledItem()->setDefault();
widget->updateUI();
widget->getKcmMiscWidget()->defaults();
emit changed(true);
}
void KCMKeyboard::load()
{
keyboardConfig->load();
m_workspaceOptions.read();
widget->updateUI();
widget->getKcmMiscWidget()->load();
}
......@@ -94,6 +99,8 @@ void KCMKeyboard::load()
void KCMKeyboard::save()
{
keyboardConfig->save();
m_workspaceOptions.save();
widget->save();
widget->getKcmMiscWidget()->save();
......
......@@ -20,6 +20,7 @@
#define KCM_KEYBOARD_H_
#include <KCModule>
#include "workspace_options.h"
class KCMKeyboardWidget;
class KeyboardConfig;
......@@ -40,6 +41,7 @@ public:
private:
Rules *rules;
KeyboardConfig *keyboardConfig;
WorkspaceOptions m_workspaceOptions;
KCMKeyboardWidget *widget;
};
......
......@@ -103,34 +103,37 @@
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QCheckBox" name="showOSD_Chk"/>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="showIndicatorChk">
<property name="text">
<string>Show layout indicator</string>
</property>
</widget>
</item>
<item row="1" column="0">
<item row="2" column="0">
<widget class="QCheckBox" name="showSingleChk">
<property name="text">
<string>Show for single layout</string>
</property>
</widget>
</item>
<item row="2" column="0">
<item row="3" column="0">
<widget class="QRadioButton" name="showFlagRadioBtn">
<property name="text">
<string>Show flag</string>
</property>
</widget>
</item>
<item row="3" column="0">
<item row="4" column="0">
<widget class="QRadioButton" name="showLabelRadioBtn">
<property name="text">
<string>Show label</string>
</property>
</widget>
</item>
<item row="4" column="0">
<item row="5" column="0">
<widget class="QRadioButton" name="showLabelOnFlagRadioBtn">
<property name="text">
<string>Show label on flag</string>
......
......@@ -33,11 +33,13 @@
#include <QWidget>
#include <QX11Info>
#include "keyboard_config.h"
#include "workspace_options.h"
#include "bindings.h"
#include "flags.h"
#include "kcm_add_layout_dialog.h"
#include "kcm_view_models.h"
#include "keyboard_config.h"
#include "tastenbrett.h"
#include "x11_helper.h"
#include "xkb_rules.h"
......@@ -55,8 +57,11 @@ static const int TAB_ADVANCED = 2;
static const int MIN_LOOPING_COUNT = 2;
KCMKeyboardWidget::KCMKeyboardWidget(Rules *rules_, KeyboardConfig *keyboardConfig_, const QVariantList &args, QWidget * /*parent*/)
KCMKeyboardWidget::KCMKeyboardWidget(Rules *rules_, KeyboardConfig *keyboardConfig_, WorkspaceOptions &workspaceOptions,
const QVariantList &args, QWidget * /*parent*/)
: rules(rules_)
, m_workspaceOptions(workspaceOptions)
, actionCollection(nullptr)
, uiUpdating(false)
{
......@@ -152,6 +157,8 @@ void KCMKeyboardWidget::uiChanged()
if (uiUpdating)
return;
m_workspaceOptions.setOsdKbdLayoutChangedEnabled(uiWidget->showOSD_Chk->isChecked());
keyboardConfig->showIndicator = uiWidget->showIndicatorChk->isChecked();
keyboardConfig->showSingle = uiWidget->showSingleChk->isChecked();
......@@ -314,6 +321,9 @@ void KCMKeyboardWidget::initializeLayoutsUI()
uiWidget->kdeKeySequence->setModifierlessAllowed(false);
uiWidget->showOSD_Chk->setText(m_workspaceOptions.osdKbdLayoutChangedEnabledItem()->label());
uiWidget->showOSD_Chk->setToolTip(m_workspaceOptions.osdKbdLayoutChangedEnabledItem()->toolTip());
connect(uiWidget->addLayoutBtn, &QAbstractButton::clicked, this, &KCMKeyboardWidget::addLayout);
connect(uiWidget->removeLayoutBtn, &QAbstractButton::clicked, this, &KCMKeyboardWidget::removeLayout);
// connect(uiWidget->layoutsTable, SIGNAL(itemSelectionChanged()), this, SLOT(layoutSelectionChanged()));
......@@ -338,6 +348,7 @@ void KCMKeyboardWidget::initializeLayoutsUI()
// connect(uiWidget->configureLayoutsChk, SIGNAL(toggled(bool)), uiWidget->layoutsGroupBox, SLOT(setEnabled(bool)));
connect(uiWidget->layoutsGroupBox, &QGroupBox::toggled, this, &KCMKeyboardWidget::configureLayoutsChanged);
connect(uiWidget->showOSD_Chk, &QAbstractButton::clicked, this, &KCMKeyboardWidget::uiChanged);
connect(uiWidget->showIndicatorChk, &QAbstractButton::clicked, this, &KCMKeyboardWidget::uiChanged);
connect(uiWidget->showIndicatorChk, &QAbstractButton::toggled, uiWidget->showSingleChk, &QWidget::setEnabled);
connect(uiWidget->showFlagRadioBtn, &QAbstractButton::clicked, this, &KCMKeyboardWidget::uiChanged);
......@@ -632,6 +643,7 @@ void KCMKeyboardWidget::updateXkbOptionsUI()
void KCMKeyboardWidget::updateLayoutsUI()
{
uiWidget->layoutsGroupBox->setChecked(keyboardConfig->configureLayouts);
uiWidget->showOSD_Chk->setChecked(m_workspaceOptions.osdKbdLayoutChangedEnabled());
uiWidget->showIndicatorChk->setChecked(keyboardConfig->showIndicator);
uiWidget->showSingleChk->setChecked(keyboardConfig->showSingle);
uiWidget->showFlagRadioBtn->setChecked(keyboardConfig->indicatorType == KeyboardConfig::SHOW_FLAG);
......
......@@ -27,6 +27,7 @@
class QWidget;
class KeyboardConfig;
class WorkspaceOptions;
struct Rules;
class Flags;
class QString;
......@@ -40,7 +41,8 @@ class KCMKeyboardWidget : public QTabWidget
Q_OBJECT
public:
KCMKeyboardWidget(Rules *rules, KeyboardConfig *keyboardConfig, const QVariantList &args, QWidget *parent = nullptr);
KCMKeyboardWidget(Rules *rules, KeyboardConfig *keyboardConfig, WorkspaceOptions &workspaceOptions,
const QVariantList &args, QWidget *parent = nullptr);
~KCMKeyboardWidget() override;
void updateUI();
......@@ -76,6 +78,7 @@ private:
Flags *flags;
Ui::TabWidget *uiWidget;
KeyboardConfig *keyboardConfig;
WorkspaceOptions &m_workspaceOptions;
KeyboardLayoutActionCollection *actionCollection;
LayoutsTableModel *layoutsTableModel;
KCMiscKeyboardWidget *kcmMiscWidget;
......
File=../workspaceoptions/workspaceoptions_plasmasettings.kcfg
ClassName=WorkspaceOptions
Mutators=osdKbdLayoutChangedEnabled
DefaultValueGetters=osdKbdLayoutChangedEnabled
ItemAccessors=true
SetUserTexts=true
......@@ -13,6 +13,12 @@
<group name="OSD">
<entry name="osdEnabled" key="Enabled" type="Bool">
<label>Display visual feedback for status changes</label>
<tooltip>Show an on-screen display to indicate status changes such as brightness or volume</tooltip>
<default>true</default>
</entry>
<entry name="osdKbdLayoutChangedEnabled" key="kbdLayoutChangedEnabled" type="Bool">
<label>OSD on layout change</label>
<tooltip>Show a popup on layout changes</tooltip>
<default>true</default>
</entry>
</group>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment