/* * Copyright (C) 2012 Shivam Makkar (amourphious1992@gmail.com) * * 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) any later version. * * 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, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "keyboardlayout.h" #include "keysymbols.h" #include #include #include #include #include #include #include #include #include #include #include //TODO: replace this with grammar parser (e.g. antlr) KeyboardLayout::KeyboardLayout() { } void KeyboardLayout::generateLayout(QString a,const QString& cname) { includeSymbol(a,cname); int i=a.indexOf("name[Group1]="); i+=13; QString n=a.mid(i); n=n.simplified(); i=n.indexOf("\"",1); layoutName=n.left(i); layoutName.remove("\""); layoutName.simplified(); i=n.indexOf("key"); n=n.mid(i); QList st; st=n.split("key"); KeySymbols dum; QString r,y; for(int k=0;ktobeinclude; tobeinclude=a.split("include"); QString r; for(int o=1;o incfile; incfile=incsym.split("("); for(int i=0;i symstrlist; symstrlist=content.split("xkb_symbols "); for(int u=1;u= 3 ) { // .../usr/lib/X11 -> /usr/share/X11/xkb vs .../usr/X11/lib -> /usr/X11/share/X11/xkb QString delta = base.endsWith("X11") ? "/../../share/X11" : "/../share/X11"; QDir baseDir(base + delta); if( baseDir.exists() ) { xkbParentDir = baseDir.absolutePath(); } else { QDir baseDir(base + "/X11"); // .../usr/X11/lib/X11/xkb (old XFree) if( baseDir.exists() ) { xkbParentDir = baseDir.absolutePath(); } } } if( xkbParentDir.isEmpty() ) { xkbParentDir = "/usr/share/X11"; } return QString("%1/xkb/symbols/").arg(xkbParentDir); }