summaryrefslogtreecommitdiffstats
path: root/kdecore/generate_keys.sh
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitce4a32fe52ef09d8f5ff1dd22c001110902b60a2 (patch)
tree5ac38a06f3dde268dc7927dc155896926aaf7012 /kdecore/generate_keys.sh
downloadtdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.tar.gz
tdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kdecore/generate_keys.sh')
-rwxr-xr-xkdecore/generate_keys.sh63
1 files changed, 63 insertions, 0 deletions
diff --git a/kdecore/generate_keys.sh b/kdecore/generate_keys.sh
new file mode 100755
index 000000000..d0fea1cdd
--- /dev/null
+++ b/kdecore/generate_keys.sh
@@ -0,0 +1,63 @@
+#!/bin/sh
+
+## This script extracts the key names from the QT header
+##
+## Copyright (c) 1999 Nicolas HADACEK (hadacek@kde.org)
+## Distributed under the GNU General Public License
+
+# remove files
+rm -f kckey.h kckey.cpp kckey_a
+
+# extract key names and code from QT header
+sed -n '/enum Key/!d
+ :1
+ N
+ /}/!b1
+ p' $1 \
+| sed -n '/=/p' \
+| sed -n 's/\s*Key_/{ "/
+ s/,.*$/ },/
+ s/ =/",/
+ s/Key_/Qt::Key_/
+ $s/.*/& }/
+ p' \
+> kckey_a
+list=`grep '{ "' kckey_a | sed -e 's#.*{ "\([^"]*\)".*#\1#'`
+for i in $list; do
+ if grep -q "i18n(\"QAccel\", \"$i\");" ../common_texts.cpp; then
+ sed -e "s#^\(.*\"$i\",.*\$\)#\1 // translated#" kckey_a > kckey_a.new && mv kckey_a.new kckey_a
+ fi
+done
+
+# write header file
+begin_line="// This file has been automatically generated by \"generate_keys.sh\""
+echo -e $begin_line \
+ "\n// Distributed under the GNU Library General Public License" \
+ "\n#ifndef KCKEY_H" \
+ "\n#define KCKEY_H" \
+ "\n\ntypedef struct {" \
+ "\n\tconst char *name;" \
+ "\n\tint code;" \
+ "\n} KKeys;" \
+ "\n\n#define MAX_KEY_LENGTH 15 // should be calculated (gawk ?)" \
+ "\n#define MAX_KEY_MODIFIER_LENGTH 21 // \"SHIFT + CRTL + ALT + \" : " \
+ "\n#define MAX_FCTN_LENGTH 50 // arbitrary limit" \
+ "\n#define NB_KEYS " `cat kckey_a | wc -l` \
+ "\nextern const KKeys kde_KKEYS[NB_KEYS];" \
+ "\n\n#endif" \
+> kckey.h
+
+# write source file
+echo -e $begin_line \
+ "\n// Distributed under the GNU Library General Public License" \
+ "\n\n#include <qnamespace.h>" \
+ "\n#include \"kckey.h\"" \
+ "\n\nconst KKeys kde_KKEYS[NB_KEYS] = {" \
+> kckey.cpp
+
+cat kckey_a >> kckey.cpp
+
+echo -e "};" >> kckey.cpp
+
+# cleaning
+rm -f kckey_a