KXkb: add keyboard layout notification

Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
pull/438/head
Mavridis Philippe 4 months ago
parent 9647d4c7ff
commit 7c724a4921
No known key found for this signature in database
GPG Key ID: 93F66F98F906147D

@ -27,3 +27,9 @@ tde_l10n_create_template(
SOURCES *.desktop
DESTINATION "${CMAKE_SOURCE_DIR}/translations"
)
tde_l10n_create_template(
CATALOG "desktop_files/kxkb-eventsrc/"
SOURCES eventsrc
DESTINATION "${CMAKE_SOURCE_DIR}/translations"
)

@ -33,6 +33,12 @@ tde_create_translated_desktop(
PO_DIR kxkb-desktops
)
tde_create_translated_desktop(
SOURCE eventsrc
DESTINATION ${DATA_INSTALL_DIR}/kxkb
PO_DIR kxkb-eventsrc
)
install( FILES kxkb_groups DESTINATION ${CONFIG_INSTALL_DIR} )
tde_create_translated_desktop(

@ -0,0 +1,8 @@
[!Global!]
IconName=kxkb
Comment=TDE Keyboard Tool
[LayoutChange]
Name=Keyboard layout switch
Comment=The keyboard layout was switched
default_presentation=16

@ -150,6 +150,9 @@ LayoutConfig::LayoutConfig(TQWidget *parent, const char *name)
connect( widget->chkEnableSticky, TQT_SIGNAL(toggled(bool)), TQT_TQOBJECT(this), TQT_SLOT(changed()));
connect( widget->spinStickyDepth, TQT_SIGNAL(valueChanged(int)), TQT_TQOBJECT(this), TQT_SLOT(changed()));
connect(widget->chkEnableNotify, SIGNAL(toggled(bool)), SLOT(changed()));
connect(widget->chkNotifyUseKMilo, SIGNAL(toggled(bool)), SLOT(changed()));
widget->listLayoutsSrc->setColumnText(LAYOUT_COLUMN_FLAG, "");
widget->listLayoutsDst->setColumnText(LAYOUT_COLUMN_FLAG, "");
// widget->listLayoutsDst->setColumnText(LAYOUT_COLUMN_DISPLAY_NAME, "");
@ -288,6 +291,9 @@ void LayoutConfig::initUI() {
widget->spinStickyDepth->setEnabled(m_kxkbConfig.m_stickySwitching);
widget->spinStickyDepth->setValue( m_kxkbConfig.m_stickySwitchingDepth);
widget->chkEnableNotify->setChecked(m_kxkbConfig.m_enableNotify);
widget->chkNotifyUseKMilo->setChecked(m_kxkbConfig.m_notifyUseKMilo);
updateStickyLimit();
widget->chkEnable->setChecked( m_kxkbConfig.m_useKxkb );
@ -397,6 +403,9 @@ void LayoutConfig::save()
m_kxkbConfig.m_stickySwitching = widget->chkEnableSticky->isChecked();
m_kxkbConfig.m_stickySwitchingDepth = widget->spinStickyDepth->value();
m_kxkbConfig.m_enableNotify = widget->chkEnableNotify->isChecked();
m_kxkbConfig.m_notifyUseKMilo = widget->chkNotifyUseKMilo->isChecked();
m_kxkbConfig.save();
// We might need to unset previous hotkey options

@ -611,6 +611,41 @@
</widget>
</grid>
</widget>
<widget class="TQGroupBox">
<property name="name">
<cstring>grpBoxNotifications</cstring>
</property>
<property name="title">
<string>Notifications</string>
</property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="TQCheckBox">
<property name="name">
<cstring>chkEnableNotify</cstring>
</property>
<property name="text">
<string>Enable keyboard layout notification</string>
</property>
<property name="whatsThis" stdset="0">
<string>If this option is enabled, a little notification will pop up on the screen displaying the name of the currently selected layout whenever it changes.</string>
</property>
</widget>
<widget class="TQCheckBox">
<property name="name">
<cstring>chkNotifyUseKMilo</cstring>
</property>
<property name="text">
<string>Use KMilo for notifications, if available</string>
</property>
<property name="whatsThis" stdset="0">
<string>If this option is enabled and KMilo is available, it will be used to display the notifications instead of the standard notification system. If KMilo is not available, notifications will be showed via the standard TDE notification system.</string>
</property>
</widget>
</vbox>
</widget>
</vbox>
</widget>
<spacer>
@ -1193,6 +1228,12 @@
<receiver>labelBgColor</receiver>
<slot>setDisabled(bool)</slot>
</connection>
<connection>
<sender>chkEnableNotify</sender>
<signal>toggled(bool)</signal>
<receiver>chkNotifyUseKMilo</receiver>
<slot>setEnabled(bool)</slot>
</connection>
</connections>
<includes>
<include location="local" impldecl="in implementation">kiconloader.h</include>

@ -47,6 +47,9 @@ DESCRIPTION
#include <tdepopupmenu.h>
#include <kdebug.h>
#include <tdeconfig.h>
#include <knotifyclient.h>
#include <dcopclient.h>
#include <dcopref.h>
#include "x11helper.h"
#include "kxkb.h"
@ -205,9 +208,10 @@ bool KXKBApp::setLayout(const LayoutUnit& layoutUnit)
bool res = m_extension->setGroup(group);
if (res) {
m_currentLayout = layoutUnit;
maybeShowLayoutNotification();
}
if (m_tray) {
if (m_tray) {
if (res) {
m_tray->setCurrentLayout(layoutUnit);
} else {
@ -281,6 +285,44 @@ void KXKBApp::slotGroupChanged(uint group)
}
m_currentLayout = kxkbConfig.m_layouts[group];
m_tray->setCurrentLayout(m_currentLayout);
maybeShowLayoutNotification();
}
void KXKBApp::maybeShowLayoutNotification() {
if (!kxkbConfig.m_enableNotify) return;
TQString layoutName(m_rules->getLayoutName(m_currentLayout));
bool useKMilo = kxkbConfig.m_notifyUseKMilo;
bool notificationSent = false;
// Query KDED whether KMiloD is loaded
if (useKMilo) {
QCStringList modules;
TQCString replyType;
TQByteArray replyData;
if (kapp->dcopClient()->call("kded", "kded", "loadedModules()",
TQByteArray(), replyType, replyData))
{
if (replyType == "QCStringList") {
TQDataStream reply(replyData, IO_ReadOnly);
reply >> modules;
if (!modules.contains("kmilod")) {
useKMilo = false;
}
}
}
}
if (useKMilo) {
DCOPRef kmilo("kded", "kmilod");
if (kmilo.send("displayText(TQString,TQPixmap)", layoutName, kapp->miniIcon()))
notificationSent = true;
}
if (!notificationSent) {
KNotifyClient::event(m_tray->winId(), "LayoutChange", layoutName);
}
}
// TODO: we also have to handle deleted windows

@ -76,6 +76,7 @@ protected slots:
void slotGroupChanged(uint group);
void slotSettingsChanged(int category);
void maybeShowLayoutNotification();
protected:
// Read settings, and apply them.

@ -129,6 +129,10 @@ bool KxkbConfig::load(int loadMode)
}
}
config->setGroup("Notifications");
m_enableNotify = config->readBoolEntry("Enable", false);
m_notifyUseKMilo = config->readBoolEntry("UseKMilo", true);
delete config;
return true;
@ -196,6 +200,10 @@ void KxkbConfig::save()
config->deleteEntry("Additional");
config->deleteEntry("Layout");
config->setGroup("Notifications");
config->writeEntry("Enable", m_enableNotify);
config->writeEntry("UseKMilo", m_notifyUseKMilo);
config->sync();
delete config;

@ -56,6 +56,8 @@ public:
SwitchingPolicy m_switchingPolicy;
bool m_stickySwitching;
int m_stickySwitchingDepth;
bool m_enableNotify;
bool m_notifyUseKMilo;
bool m_useThemeColors;
TQColor m_colorBackground;

@ -43,6 +43,8 @@ public:
void setError(const TQString& layoutInfo="");
void setShowFlag(bool showFlag) { m_showFlag = showFlag; }
void show() { label->show(); }
WId winId() { return label->winId(); }
// signals:
//

@ -0,0 +1,32 @@
# SOME DESCRIPTIVE TITLE.
# This file is put in the public domain.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-12-25 17:45+0900\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#. Comment
#: eventsrc:3
msgid "TDE Keyboard Tool"
msgstr ""
#. Name
#: eventsrc:6
msgid "Keyboard layout switch"
msgstr ""
#. Comment
#: eventsrc:7
msgid "The keyboard layout was switched"
msgstr ""
Loading…
Cancel
Save