You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tdebase/kxkb/rules.cpp

76 lines
1.5 KiB

#include <tqwindowdefs.h>
#include <tqfile.h>
#include <tqtextstream.h>
#include <tqregexp.h>
#include <tqstringlist.h>
#include <tqdir.h>
#include <kstandarddirs.h>
#include <tdeglobal.h>
#include <tdelocale.h>
#include <kdebug.h>
#include <config.h>
#include "x11helper.h"
#include "rules.h"
XkbRules::XkbRules(bool layoutsOnly):
m_layouts(90)
{
X11_DIR = X11Helper::findX11Dir();
if( X11_DIR == NULL ) {
kdError() << "Cannot find X11 directory!" << endl;
// throw Exception();
return;
}
TQString rulesFile = X11Helper::findXkbRulesFile(X11_DIR, tqt_xdisplay());
if( rulesFile.isEmpty() ) {
kdError() << "Cannot find rules file in " << X11_DIR << endl;
// throw Exception();
return;
}
loadRules(rulesFile, layoutsOnly);
}
void XkbRules::loadRules(TQString file, bool layoutsOnly)
{
RulesInfo* rules = X11Helper::loadRules(file, layoutsOnly);
if (rules == NULL) {
kdDebug() << "Unable to load rules" << endl;
return;
}
m_layouts= rules->layouts;
if( layoutsOnly == false ) {
m_models = rules->models;
m_options = rules->options;
}
// fixLayouts();
}
TQStringList
XkbRules::getAvailableVariants(const TQString& layout)
{
if( layout.isEmpty() || !layouts().find(layout) )
return TQStringList();
TQStringList* result1 = m_varLists[layout];
if( result1 )
return *result1;
Kxkb: Improve layout switching 1) New layout switching approach The new approach is based on the "grp" options group of Xkb and so enables us to use predefined X11 layout (group) switching hotkeys like "Caps Lock" or "Shift+Alt" (you can see the full list in the Options tab). The added bonus to this is that we conform to the Xkb setting. The code lets Xkb handle the keyboard layout switching hotkey(s) and is similar to the one that is used in kkbswitch, monitoring for an Xkb group (layout) change event. This solution required me to remove some hacky and obsolete code which was there to support really old pre-XFree-4.2 era systems and included the "include groups" hack. This means that the "Enable latin layout" checkbox is now gone and setxkbmap is only called when the keyboard layouts and/or options are modified, and not for every layout change. 2) Common layout switching hotkeys combobox A combobox was added to the first page of the Keyboard Layouts KCM module. It provides to the users a quick way to set a layout switching key combination. It also controls the "grp" group in the Xkb tab. A special note about this combobox is that, even if Append Mode was selected in the Xkb Options tab, this hotkey will overwrite previous hotkey options. This means that all grp: options will be forced removed before applying the option from the combobox (in contrast to specifying options via the Xkb Options tab, which, in Append Mode, will not get overwritten until next login). Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
2 years ago
TQStringList* result = X11Helper::getVariants(layout, X11_DIR);
m_varLists.insert(layout, result);
return *result;
}