fixed error message when using en_US locale,
added new cmd line parameter '-lang', added some templates for Auto-Type (still incomplete) git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@77 b624d157-de02-0410-bad0-e51aec6abb33
This commit is contained in:
parent
b08e5e8fad
commit
931d8374a5
|
@ -21,7 +21,7 @@
|
||||||
#include "AutoType.h"
|
#include "AutoType.h"
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QChar>
|
#include <QChar>
|
||||||
/* { 0x05c7, 0x0627 }, Arabic_alef ا ARABIC LETTER ALEF */
|
|
||||||
|
|
||||||
QWidget* AutoType::MainWin=NULL;
|
QWidget* AutoType::MainWin=NULL;
|
||||||
|
|
||||||
|
@ -102,13 +102,13 @@ for(int i=0;i<str.size();i++){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MainWin->hide();
|
MainWin->hide();
|
||||||
Display* pDisplay = XOpenDisplay( NULL );
|
Display* pDisplay = XOpenDisplay( NULL );
|
||||||
for(int i=0;i<Keys.size();i++){
|
for(int i=0;i<Keys.size();i++){
|
||||||
int keycode=XKeysymToKeycode(pDisplay,Keys[i]);
|
int keycode=XKeysymToKeycode(pDisplay,Keys[i]);
|
||||||
int mods=getModifiers(pDisplay,Keys[i],keycode);
|
int mods=getModifiers(pDisplay,Keys[i],keycode);
|
||||||
pressModifiers(pDisplay,mods);
|
pressModifiers(pDisplay,mods);
|
||||||
|
qDebug("[%i]: Keysym=%i, KeyCode=%i, Mod=%i",i,(int)Keys[i],keycode,mods);
|
||||||
XTestFakeKeyEvent(pDisplay,keycode,True,0);
|
XTestFakeKeyEvent(pDisplay,keycode,True,0);
|
||||||
XTestFakeKeyEvent(pDisplay,keycode,False,1);
|
XTestFakeKeyEvent(pDisplay,keycode,False,1);
|
||||||
releaseModifiers(pDisplay,mods);
|
releaseModifiers(pDisplay,mods);
|
||||||
|
@ -169,6 +169,50 @@ if(!tmpl.compare("esc")){
|
||||||
if(!tmpl.compare("help")){
|
if(!tmpl.compare("help")){
|
||||||
keys << XK_Help;
|
keys << XK_Help;
|
||||||
return;}
|
return;}
|
||||||
|
|
||||||
|
if(!tmpl.compare("home")){
|
||||||
|
keys << XK_Home;
|
||||||
|
return;}
|
||||||
|
|
||||||
|
if(!tmpl.compare("ins")){
|
||||||
|
keys << XK_Insert;
|
||||||
|
return;}
|
||||||
|
|
||||||
|
if(!tmpl.compare("numlock")){
|
||||||
|
keys << XK_Num_Lock;
|
||||||
|
return;}
|
||||||
|
|
||||||
|
if(!tmpl.compare("scroll")){
|
||||||
|
keys << XK_Scroll_Lock;
|
||||||
|
return;}
|
||||||
|
|
||||||
|
if(!tmpl.compare("pgdn")){
|
||||||
|
keys << XK_Page_Down;
|
||||||
|
return;}
|
||||||
|
|
||||||
|
if(!tmpl.compare("pgup")){
|
||||||
|
keys << XK_Page_Up;
|
||||||
|
return;}
|
||||||
|
|
||||||
|
if(!tmpl.compare("prtsc")){
|
||||||
|
keys << XK_3270_PrintScreen;
|
||||||
|
return;}
|
||||||
|
|
||||||
|
if(!tmpl.compare("up")){
|
||||||
|
keys << XK_Up;
|
||||||
|
return;}
|
||||||
|
|
||||||
|
if(!tmpl.compare("down")){
|
||||||
|
keys << XK_Down;
|
||||||
|
return;}
|
||||||
|
|
||||||
|
if(!tmpl.compare("left")){
|
||||||
|
keys << XK_Left;
|
||||||
|
return;}
|
||||||
|
|
||||||
|
if(!tmpl.compare("right")){
|
||||||
|
keys << XK_Right;
|
||||||
|
return;}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoType::stringToKeysyms(const QString& string,QList<quint16>& KeySymList){
|
void AutoType::stringToKeysyms(const QString& string,QList<quint16>& KeySymList){
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#ifdef Q_WS_X11
|
#ifdef Q_WS_X11
|
||||||
#define XK_MISCELLANY
|
#define XK_MISCELLANY
|
||||||
#define XK_XKB_KEYS
|
#define XK_XKB_KEYS
|
||||||
|
#define XK_3270
|
||||||
#include <X11/extensions/XTest.h>
|
#include <X11/extensions/XTest.h>
|
||||||
#include <X11/keysymdef.h>
|
#include <X11/keysymdef.h>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
|
|
36
src/main.cpp
36
src/main.cpp
|
@ -75,15 +75,15 @@ QIcon *Icon_Help;
|
||||||
QIcon *Icon_AutoType;
|
QIcon *Icon_AutoType;
|
||||||
|
|
||||||
inline void loadImages();
|
inline void loadImages();
|
||||||
inline void parseCmdLineArgs(int argc, char** argv,QString &ArgFile,QString& ArgCfg);
|
inline void parseCmdLineArgs(int argc, char** argv,QString &ArgFile,QString& ArgCfg,QString& ArgLang);
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
|
||||||
QApplication* app=new QApplication(argc,argv);
|
QApplication* app=new QApplication(argc,argv);
|
||||||
QString ArgFile,ArgCfg,IniFilename;
|
QString ArgFile,ArgCfg,ArgLang,IniFilename;
|
||||||
parseCmdLineArgs(argc,argv,ArgFile,ArgCfg);
|
parseCmdLineArgs(argc,argv,ArgFile,ArgCfg,ArgLang);
|
||||||
AppDir=app->applicationDirPath();
|
AppDir=app->applicationDirPath();
|
||||||
//Load Config
|
//Load Config
|
||||||
if(ArgCfg==QString()){
|
if(ArgCfg==QString()){
|
||||||
|
@ -102,15 +102,23 @@ else{
|
||||||
|
|
||||||
|
|
||||||
//Internationalization
|
//Internationalization
|
||||||
QLocale loc=QLocale::system();
|
QLocale loc;
|
||||||
|
if(!ArgLang.size())
|
||||||
|
loc=QLocale::system();
|
||||||
|
else
|
||||||
|
loc=QLocale(ArgLang);
|
||||||
|
|
||||||
QTranslator* translator = NULL;
|
QTranslator* translator = NULL;
|
||||||
QTranslator* qtTranslator=NULL;
|
QTranslator* qtTranslator=NULL;
|
||||||
translator=new QTranslator;
|
translator=new QTranslator;
|
||||||
qtTranslator=new QTranslator;
|
qtTranslator=new QTranslator;
|
||||||
bool TrFound=true;
|
bool TrFound=true;
|
||||||
|
QString locname;
|
||||||
|
|
||||||
if(!translator->load("keepass-"+loc.name(),app->applicationDirPath()+"/../share/keepass/i18n/")){
|
if(!translator->load("keepass-"+loc.name(),app->applicationDirPath()+"/../share/keepass/i18n/")){
|
||||||
if(!translator->load("keepass-"+loc.name(),QDir::homeDirPath()+"/.keepass/")){
|
if(!translator->load("keepass-"+loc.name(),QDir::homeDirPath()+"/.keepass/")){
|
||||||
qWarning(QString("KeePassX: No Translation found for language '%1 (%2)'")
|
if(loc.name()!="en_US")
|
||||||
|
qWarning(QString("KeePassX: No Translation found language '%1 (%2)' using 'English (UnitedStates)'")
|
||||||
.arg(QLocale::languageToString(loc.language()))
|
.arg(QLocale::languageToString(loc.language()))
|
||||||
.arg(QLocale::countryToString(loc.country())));
|
.arg(QLocale::countryToString(loc.country())));
|
||||||
TrFound=false;
|
TrFound=false;
|
||||||
|
@ -124,7 +132,8 @@ else
|
||||||
|
|
||||||
|
|
||||||
if(!qtTranslator->load("qt_"+loc.name().left(2),QLibraryInfo::location(QLibraryInfo::TranslationsPath))){
|
if(!qtTranslator->load("qt_"+loc.name().left(2),QLibraryInfo::location(QLibraryInfo::TranslationsPath))){
|
||||||
qWarning(QString("Qt: No Translation found for '%1 (%2)'")
|
if(loc.name()!="en_US")
|
||||||
|
qWarning(QString("Qt: No Translation found for '%1 (%2)'using 'English (UnitedStates)'")
|
||||||
.arg(QLocale::languageToString(loc.language()))
|
.arg(QLocale::languageToString(loc.language()))
|
||||||
.arg(QLocale::countryToString(loc.country())));
|
.arg(QLocale::countryToString(loc.country())));
|
||||||
delete qtTranslator;
|
delete qtTranslator;
|
||||||
|
@ -287,7 +296,7 @@ _loadIcon(Icon_AutoType,"/apps/ktouch.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void parseCmdLineArgs(int argc, char** argv,QString &ArgFile,QString& ArgCfg){
|
void parseCmdLineArgs(int argc, char** argv,QString &ArgFile,QString& ArgCfg,QString& ArgLang){
|
||||||
if(argc>1){
|
if(argc>1){
|
||||||
int i=1;
|
int i=1;
|
||||||
if(argv[i][0]!='-'){
|
if(argv[i][0]!='-'){
|
||||||
|
@ -298,13 +307,22 @@ int i=1;
|
||||||
cout << "KeePassX" << KEEPASS_VERSION << endl;
|
cout << "KeePassX" << KEEPASS_VERSION << endl;
|
||||||
cout << "Usage: keepass [Filename] [Options]" << endl;
|
cout << "Usage: keepass [Filename] [Options]" << endl;
|
||||||
cout << " -h This Help" << endl;
|
cout << " -h This Help" << endl;
|
||||||
cout << " -cfg ConfigFile Use specified configuration" << endl;
|
cout << " -cfg <ConfigFile> Use specified configuration." << endl;
|
||||||
|
cout << " -lang <LOCALE> Use specified language instead of system default." << endl;
|
||||||
|
cout << " <LOCALE> is the ISO-639 language code with or without ISO-3166 country code" << endl;
|
||||||
|
cout << " Examples: de German" << endl;
|
||||||
|
cout << " de_CH German(Switzerland)"<<endl;
|
||||||
|
cout << " pt_BR Portuguese(Brazil)"<<endl;
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
else if(QString(argv[i])=="-cfg"){
|
else if(QString(argv[i])=="-cfg"){
|
||||||
if(i-1==argc) cout << "No configuration file specified." << endl;
|
if(i-1==argc){ cout << "Missing argument for -cfg" << endl; exit(1);}
|
||||||
else{ArgCfg=QString::fromUtf8(argv[i+1]); i++;}
|
else{ArgCfg=QString::fromUtf8(argv[i+1]); i++;}
|
||||||
}
|
}
|
||||||
|
else if(QString(argv[i])=="-lang"){
|
||||||
|
if(i-1==argc) cout << "Missing argument for -lang" << endl;
|
||||||
|
else{ArgLang=QString::fromUtf8(argv[i+1]); i++;}
|
||||||
|
}
|
||||||
else if(QString(argv[i])=="-test"){
|
else if(QString(argv[i])=="-test"){
|
||||||
if (testDatabase()) exit(0);
|
if (testDatabase()) exit(0);
|
||||||
else exit(1);
|
else exit(1);
|
||||||
|
|
Loading…
Reference in New Issue