Added ability to select language in SettingsDlg
Redesigned SettingsDlg git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@232 b624d157-de02-0410-bad0-e51aec6abb33
This commit is contained in:
@@ -60,7 +60,6 @@ public:
|
||||
bool hideUsernames(){return settings.value("UI/HideUsernames",true).toBool();}
|
||||
QByteArray hSplitterPos(){return settings.value("UI/HSplitterPos").toByteArray();}
|
||||
IntegrPluginType integrPlugin(){return stringToIntegrPluginType(settings.value("Options/IntegrPlugin").toString());}
|
||||
QString langFile(){return settings.value("Options/LangFile").toString();}
|
||||
QString lastFile(){return settings.value("Options/LastFile").toString();}
|
||||
QString lastKeyLocation(){return settings.value("Options/LastKeyLocation").toString();}
|
||||
tKeyType lastKeyType(){return stringToKeyType(settings.value("Options/LastKeyType").toString());}
|
||||
@@ -110,6 +109,7 @@ public:
|
||||
#endif
|
||||
//bool featureBookmarks(){return settings.value("Features/Bookmarks",true).toBool();}
|
||||
bool featureBookmarks(){return true;}
|
||||
QString language(){return settings.value("Options/Language","auto").toString();}
|
||||
|
||||
void setAlternatingRowColors(bool value){settings.setValue("Options/AlternatingRowColors",value);}
|
||||
void setBannerColor1(const QColor& value){settings.setValue("Options/BannerColor1",colorToString(value));}
|
||||
@@ -127,7 +127,6 @@ public:
|
||||
void setHideUsernames(bool value){settings.setValue("UI/HideUsernames",value);}
|
||||
void setHSplitterPos(const QByteArray& value){settings.setValue("UI/HSplitterPos",value);}
|
||||
void setIntegrPlugin(IntegrPluginType value){settings.setValue("Options/IntegrPlugin",integrPluginTypeToString(value));}
|
||||
void setLangFile(const QString& value){settings.setValue("Options/LangFile",value);}
|
||||
void setLastFile(const QString& value){settings.setValue("Options/LastFile",value);}
|
||||
void setLastKeyLocation(const QString& value){settings.setValue("Options/LastKeyLocation",value);}
|
||||
void setLastKeyType(tKeyType value){settings.setValue("Options/LastKeyType",keyTypeToString(value));}
|
||||
@@ -176,6 +175,7 @@ public:
|
||||
void setEntryTitlesMatch(bool value){settings.setValue("Options/EntryTitlesMatch",value);}
|
||||
#endif
|
||||
//void setFeatureBookmarks(bool value){settings.setValue("Features/Bookmarks",value);}
|
||||
void setLanguage(const QString& value){settings.setValue("Options/Language",value);}
|
||||
|
||||
unsigned fileDlgHistorySize();
|
||||
void clearFileDlgHistory(){settings.remove("FileDlgHistory");};
|
||||
|
||||
@@ -30,9 +30,9 @@ AboutDialog::AboutDialog(QWidget* parent):QDialog(parent)
|
||||
labelAppFunc->setText(QString(" - ").append(APP_LONG_FUNC));
|
||||
|
||||
QString AboutTr=QString("<b>%1: %2</b><br><br>").arg(tr("Current Translation")).arg(tr("None","Please replace 'None' with the language of your translation"));
|
||||
if(TrActive){
|
||||
AboutTr+=QString("<b>%1:</b> %2<br>").arg(tr("Author")).arg(tr("$TRANSLATION_AUTHOR"));
|
||||
QString mail=tr("$TRANSLATION_AUTHOR_EMAIL","Here you can enter your email or homepage if you want.");
|
||||
if(isTranslationActive()){
|
||||
AboutTr+=QString("<b>%1:</b> %2<br>").arg(tr("Author")).arg(QApplication::translate("Translation", "$TRANSLATION_AUTHOR"));
|
||||
QString mail=QApplication::translate("Translation", "$TRANSLATION_AUTHOR_EMAIL","Here you can enter your email or homepage if you want.");
|
||||
if(!mail.isEmpty()){
|
||||
AboutTr+=mail+"<br>";
|
||||
}
|
||||
|
||||
@@ -22,12 +22,14 @@
|
||||
#include "dialogs/SettingsDlg.h"
|
||||
#include "dialogs/CustomizeDetailViewDlg.h"
|
||||
|
||||
bool CSettingsDlg::PluginsModified=false;
|
||||
//bool CSettingsDlg::PluginsModified=false;
|
||||
|
||||
|
||||
CSettingsDlg::CSettingsDlg(QWidget* parent):QDialog(parent,Qt::Dialog)
|
||||
{
|
||||
setupUi(this);
|
||||
connect(listWidget, SIGNAL( currentRowChanged(int) ), stackedWidget, SLOT( setCurrentIndex(int) ) );
|
||||
|
||||
connect(DialogButtons, SIGNAL( accepted() ), this, SLOT( OnOK() ) );
|
||||
connect(DialogButtons, SIGNAL( rejected() ), this, SLOT( OnCancel() ) );
|
||||
connect(DialogButtons, SIGNAL( clicked(QAbstractButton*)), this, SLOT(OnOtherButton(QAbstractButton*)));
|
||||
@@ -38,6 +40,8 @@ CSettingsDlg::CSettingsDlg(QWidget* parent):QDialog(parent,Qt::Dialog)
|
||||
connect(CheckBox_OpenLast, SIGNAL( toggled(bool) ), CheckBox_StartMinimized, SLOT( setEnabled(bool) ) );
|
||||
connect(CheckBox_OpenLast, SIGNAL( toggled(bool) ), CheckBox_StartLocked, SLOT( setEnabled(bool) ) );
|
||||
|
||||
connect(listSelectLanguage, SIGNAL( currentRowChanged(int) ), SLOT( OnSelectLanguage(int) ) );
|
||||
|
||||
connect(Button_ClearFileDlgHistory, SIGNAL(clicked()), &fileDlgHistory, SLOT(clear()));
|
||||
connect(ButtonColor1, SIGNAL( clicked() ), this, SLOT( OnColor1() ) );
|
||||
connect(ButtonColor2, SIGNAL( clicked() ), this, SLOT( OnColor2() ) );
|
||||
@@ -45,9 +49,9 @@ CSettingsDlg::CSettingsDlg(QWidget* parent):QDialog(parent,Qt::Dialog)
|
||||
connect(Button_MountDirBrowse,SIGNAL(clicked()),this,SLOT(OnMountDirBrowse()));
|
||||
connect(Button_BrowserCmdBrowse,SIGNAL(clicked()),this,SLOT(OnBrowserCmdBrowse()));
|
||||
|
||||
connect(Radio_IntPlugin_None,SIGNAL(toggled(bool)),this,SLOT(OnIntPluginNone()));
|
||||
connect(Radio_IntPlugin_Gnome,SIGNAL(toggled(bool)),this,SLOT(OnIntPluginGnome()));
|
||||
connect(Radio_IntPlugin_Kde,SIGNAL(toggled(bool)),this,SLOT(OnIntPluginKde()));
|
||||
//connect(Radio_IntPlugin_None,SIGNAL(toggled(bool)),this,SLOT(OnIntPluginNone()));
|
||||
//connect(Radio_IntPlugin_Gnome,SIGNAL(toggled(bool)),this,SLOT(OnIntPluginGnome()));
|
||||
//connect(Radio_IntPlugin_Kde,SIGNAL(toggled(bool)),this,SLOT(OnIntPluginKde()));
|
||||
|
||||
connect(Button_CustomizeEntryDetails,SIGNAL(clicked()),this,SLOT(OnCustomizeEntryDetails()));
|
||||
connect(CheckBox_InactivityLock, SIGNAL(toggled(bool)), SLOT(OnInactivityLockChange(bool)));
|
||||
@@ -71,6 +75,8 @@ CSettingsDlg::CSettingsDlg(QWidget* parent):QDialog(parent,Qt::Dialog)
|
||||
pShortcut = AutoType::shortcut;
|
||||
connect(this,SIGNAL(rejected()),SLOT(resetGlobalShortcut()));
|
||||
#endif
|
||||
|
||||
listWidget->setCurrentRow(0);
|
||||
|
||||
//General (1)
|
||||
CheckBox_OpenLast->setChecked(config->openLastFile());
|
||||
@@ -121,8 +127,25 @@ CSettingsDlg::CSettingsDlg(QWidget* parent):QDialog(parent,Qt::Dialog)
|
||||
color2=config->bannerColor2();
|
||||
textcolor=config->bannerTextColor();
|
||||
CheckBox_AlternatingRowColors->setChecked(config->alternatingRowColors());
|
||||
|
||||
|
||||
|
||||
//Language
|
||||
translations = getAllTranslations();
|
||||
QString currentLang = config->language();
|
||||
bool foundCurrent = false;
|
||||
for (int i=0; i<translations.size(); i++){
|
||||
listSelectLanguage->addItem(translations[i].nameLong);
|
||||
if (translations[i].nameCode==currentLang){
|
||||
listSelectLanguage->setCurrentRow(i+2);
|
||||
foundCurrent = true;
|
||||
}
|
||||
}
|
||||
if (!foundCurrent){
|
||||
if (currentLang=="en_US")
|
||||
listSelectLanguage->setCurrentRow(1);
|
||||
else
|
||||
listSelectLanguage->setCurrentRow(0);
|
||||
}
|
||||
|
||||
//Security
|
||||
SpinBox_ClipboardTime->setValue(config->clipboardTimeOut());
|
||||
CheckBox_ShowPasswords->setChecked(config->showPasswords());
|
||||
@@ -132,12 +155,12 @@ CSettingsDlg::CSettingsDlg(QWidget* parent):QDialog(parent,Qt::Dialog)
|
||||
SpinBox_InacitivtyTime->setValue(config->lockAfterSec());
|
||||
|
||||
//Features
|
||||
tabWidgetSettings->removeTab(tabWidgetSettings->indexOf(tabFeatures));
|
||||
stackedWidget->removeWidget(pageFeatures);
|
||||
//CheckBox_FeatureBookmarks->setChecked(config->featureBookmarks());
|
||||
|
||||
|
||||
// TODO Desktop Integration
|
||||
tabWidgetSettings->removeTab(tabWidgetSettings->indexOf(tabIntegration));
|
||||
stackedWidget->removeWidget(pageDesktop);
|
||||
/*if(PluginLoadError==QString())
|
||||
Label_IntPlugin_Error->hide();
|
||||
else
|
||||
@@ -174,11 +197,10 @@ CSettingsDlg::CSettingsDlg(QWidget* parent):QDialog(parent,Qt::Dialog)
|
||||
#endif
|
||||
|
||||
adjustSize();
|
||||
resize( size() + QSize(50,20) );
|
||||
resize( size() + QSize(20,20) );
|
||||
}
|
||||
|
||||
CSettingsDlg::~CSettingsDlg()
|
||||
{
|
||||
CSettingsDlg::~CSettingsDlg(){
|
||||
}
|
||||
|
||||
void CSettingsDlg::paintEvent(QPaintEvent *event){
|
||||
@@ -238,6 +260,21 @@ void CSettingsDlg::apply(){
|
||||
config->setBannerTextColor(textcolor);
|
||||
config->setAlternatingRowColors(CheckBox_AlternatingRowColors->isChecked());
|
||||
|
||||
//Language
|
||||
int langIndex = listSelectLanguage->currentRow();
|
||||
QString oldLang = config->language();
|
||||
if (langIndex==0)
|
||||
config->setLanguage("auto");
|
||||
else if (langIndex==1)
|
||||
config->setLanguage("en_US");
|
||||
else
|
||||
config->setLanguage(translations[langIndex-2].nameCode);
|
||||
if (config->language() != oldLang){
|
||||
installTranslator();
|
||||
retranslateUi(this);
|
||||
OnSelectLanguage(langIndex);
|
||||
}
|
||||
|
||||
//Security
|
||||
config->setClipboardTimeOut(SpinBox_ClipboardTime->value());
|
||||
config->setShowPasswords(CheckBox_ShowPasswords->isChecked());
|
||||
@@ -327,7 +364,7 @@ void CSettingsDlg::OnBrowserCmdBrowse(){
|
||||
}
|
||||
}
|
||||
|
||||
void CSettingsDlg::OnIntPluginNone(){
|
||||
/*void CSettingsDlg::OnIntPluginNone(){
|
||||
Label_IntPlugin_Info->show();
|
||||
}
|
||||
|
||||
@@ -337,8 +374,7 @@ void CSettingsDlg::OnIntPluginGnome(){
|
||||
|
||||
void CSettingsDlg::OnIntPluginKde(){
|
||||
Label_IntPlugin_Info->show();
|
||||
}
|
||||
|
||||
}*/
|
||||
|
||||
void CSettingsDlg::OnCustomizeEntryDetails(){
|
||||
CustomizeDetailViewDialog dlg(this);
|
||||
@@ -361,6 +397,24 @@ void CSettingsDlg::OnBackupDeleteChange(){
|
||||
SpinBox_BackupDeleteAfter->setEnabled(CheckBox_Backup->isChecked() && CheckBox_BackupDelete->isChecked());
|
||||
}
|
||||
|
||||
void CSettingsDlg::OnSelectLanguage(int index){
|
||||
if (index==0){
|
||||
labelLang->clear();
|
||||
labelAuthor->clear();
|
||||
}
|
||||
else if (index==1){
|
||||
labelLang->setText("English (United States)");
|
||||
labelAuthor->setText("KeePassX Development Team");
|
||||
}
|
||||
else{
|
||||
if (translations[index-2].nameLong != translations[index-2].nameEnglish)
|
||||
labelLang->setText(QString("%1 / %2").arg(translations[index-2].nameLong).arg(translations[index-2].nameEnglish));
|
||||
else
|
||||
labelLang->setText(translations[index-2].nameEnglish);
|
||||
labelAuthor->setText(translations[index-2].author);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef GLOBAL_AUTOTYPE
|
||||
void CSettingsDlg::resetGlobalShortcut(){
|
||||
AutoType::unregisterGlobalShortcut();
|
||||
|
||||
@@ -30,7 +30,7 @@ class CSettingsDlg : public QDialog, private Ui_SettingsDialog
|
||||
public:
|
||||
CSettingsDlg(QWidget* parent);
|
||||
~CSettingsDlg();
|
||||
|
||||
|
||||
private slots:
|
||||
virtual void OnCancel();
|
||||
virtual void OnOK();
|
||||
@@ -38,9 +38,9 @@ class CSettingsDlg : public QDialog, private Ui_SettingsDialog
|
||||
virtual void OnColor2();
|
||||
virtual void OnColor1();
|
||||
void OnOtherButton(QAbstractButton*);
|
||||
void OnIntPluginNone();
|
||||
/*void OnIntPluginNone();
|
||||
void OnIntPluginGnome();
|
||||
void OnIntPluginKde();
|
||||
void OnIntPluginKde();*/
|
||||
void OnMountDirBrowse();
|
||||
void OnBrowserCmdBrowse();
|
||||
void OnCustomizeEntryDetails();
|
||||
@@ -48,6 +48,7 @@ class CSettingsDlg : public QDialog, private Ui_SettingsDialog
|
||||
void OnAutoSaveToggle(bool checked);
|
||||
void OnAutoSaveChangeToggle(bool checked);
|
||||
void OnBackupDeleteChange();
|
||||
void OnSelectLanguage(int index);
|
||||
|
||||
#ifdef GLOBAL_AUTOTYPE
|
||||
private slots:
|
||||
@@ -60,10 +61,11 @@ class CSettingsDlg : public QDialog, private Ui_SettingsDialog
|
||||
void apply();
|
||||
QColor color1,color2,textcolor;
|
||||
QPixmap BannerPixmap;
|
||||
QList<Translation> translations;
|
||||
#ifdef GLOBAL_AUTOTYPE
|
||||
Shortcut pShortcut;
|
||||
#endif
|
||||
static bool PluginsModified;
|
||||
//static bool PluginsModified;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -9,24 +9,6 @@
|
||||
<height>305</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize" >
|
||||
<size>
|
||||
<width>419</width>
|
||||
<height>305</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize" >
|
||||
<size>
|
||||
<width>419</width>
|
||||
<height>305</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string>About</string>
|
||||
</property>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -132,7 +132,8 @@ bool Import_PwManager::parseXmlContent(char* content){
|
||||
if(!groups.elementsByTagName("c"+QString::number(i)).item(0).isElement())return false;
|
||||
CurrGroup=groups.elementsByTagName("c"+QString::number(i)).item(0).toElement();
|
||||
if(!CurrGroup.hasAttribute("n"))return false;
|
||||
IGroupHandle* NewGroup=database->addGroup(&CGroup(),NULL);
|
||||
CGroup tmpGroup;
|
||||
IGroupHandle* NewGroup=database->addGroup(&tmpGroup,NULL);
|
||||
NewGroup->setTitle(CurrGroup.attribute("n"));
|
||||
int j=0;
|
||||
while(1){
|
||||
|
||||
@@ -17,8 +17,10 @@
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#include <QProcess>
|
||||
#include <QDesktopServices>
|
||||
#include <QLibraryInfo>
|
||||
#include <QProcess>
|
||||
#include <QTranslator>
|
||||
|
||||
#if defined(Q_WS_X11) || defined(Q_WS_MAC)
|
||||
#include <sys/mman.h>
|
||||
@@ -234,3 +236,131 @@ bool unlockPage(void* addr, int len){
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
QTranslator* translator = new QTranslator();
|
||||
QTranslator* qtTranslator = new QTranslator();
|
||||
bool translatorActive = false;
|
||||
bool qtTranslatorActive = false;
|
||||
|
||||
bool loadTranslation(QTranslator* tr,const QString& prefix,const QString& loc,const QStringList& paths){
|
||||
for (int i=0;i<paths.size();i++){
|
||||
if(tr->load(prefix+loc+".qm",paths[i]))
|
||||
return true;
|
||||
}
|
||||
|
||||
for (int i=0;i<paths.size();i++){
|
||||
QDir dir(paths[i]);
|
||||
QStringList TrFiles=dir.entryList(QStringList()<<"*.qm",QDir::Files);
|
||||
for (int j=0;j<TrFiles.size();j++){
|
||||
if (TrFiles[j].left(prefix.length()+2)==prefix+loc.left(2)){
|
||||
if (tr->load(TrFiles[j],paths[i]))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void deactivateTranslators(bool qtOnly=false){
|
||||
if (translatorActive && !qtOnly){
|
||||
QApplication::removeTranslator(translator);
|
||||
translatorActive = false;
|
||||
}
|
||||
|
||||
if (qtTranslatorActive){
|
||||
QApplication::removeTranslator(qtTranslator);
|
||||
qtTranslatorActive = false;
|
||||
}
|
||||
}
|
||||
|
||||
void installTranslator(){
|
||||
QString language = config->language();
|
||||
if (language=="auto")
|
||||
language = QLocale::system().name();
|
||||
|
||||
if (language.isEmpty() || language=="en_US"){
|
||||
deactivateTranslators();
|
||||
return;
|
||||
}
|
||||
|
||||
if (loadTranslation(translator,"keepassx-",language,QStringList()
|
||||
<< DataDir+"/i18n/" << HomeDir))
|
||||
{
|
||||
if (!translatorActive){
|
||||
QApplication::installTranslator(translator);
|
||||
translatorActive = true;
|
||||
}
|
||||
}
|
||||
else{
|
||||
deactivateTranslators();
|
||||
return;
|
||||
}
|
||||
|
||||
if (loadTranslation(qtTranslator,"qt_",language,QStringList()
|
||||
<< QLibraryInfo::location(QLibraryInfo::TranslationsPath)
|
||||
<< DataDir+"/i18n/" << HomeDir))
|
||||
{
|
||||
if (!qtTranslatorActive){
|
||||
QApplication::installTranslator(qtTranslator);
|
||||
qtTranslatorActive = true;
|
||||
}
|
||||
}
|
||||
else{
|
||||
deactivateTranslators(true);
|
||||
}
|
||||
}
|
||||
|
||||
bool isTranslationActive(){
|
||||
return translatorActive;
|
||||
}
|
||||
|
||||
bool operator<(const Translation& t1, const Translation& t2){
|
||||
return t1.nameLong < t2.nameLong;
|
||||
}
|
||||
|
||||
QList<Translation> getAllTranslations(){
|
||||
QTranslator tmpTranslator;
|
||||
QList<Translation> translations;
|
||||
QSet<QString> names;
|
||||
|
||||
QStringList paths = QStringList() << DataDir+"/i18n/" << HomeDir;
|
||||
QRegExp filename("keepassx-([^_]{2}_[^\\.]{2}|[^\\.]{2})\\.qm");
|
||||
for (int i=0;i<paths.size();i++){
|
||||
QDir dir(paths[i]);
|
||||
QStringList TrFiles=dir.entryList(QStringList()<<"*.qm",QDir::Files);
|
||||
for (int j=0;j<TrFiles.size();j++){
|
||||
if (filename.exactMatch(TrFiles[j]) && tmpTranslator.load(TrFiles[j],paths[i]) &&
|
||||
!names.contains(filename.cap(1)))
|
||||
{
|
||||
Translation t;
|
||||
t.nameCode = filename.cap(1);
|
||||
t.nameLong = tmpTranslator.translate("Translation", "$LANGUAGE_NAME", "Insert your language name in the format: English (United States)");
|
||||
t.author = tmpTranslator.translate("Translation", "$TRANSLATION_AUTHOR");
|
||||
|
||||
QLocale l(t.nameCode);
|
||||
t.nameEnglish = QLocale::languageToString(l.language());
|
||||
if (t.nameCode.size()==5){
|
||||
QString country = QLocale::countryToString(l.country());
|
||||
int size = country.size();
|
||||
for (int k=1; k<size; k++){
|
||||
if (country[k].isUpper()){
|
||||
country.insert(k, " ");
|
||||
k += 2;
|
||||
size++;
|
||||
}
|
||||
}
|
||||
t.nameEnglish.append(" (").append(country).append(")");
|
||||
}
|
||||
|
||||
if (t.nameLong.isEmpty())
|
||||
t.nameLong = t.nameEnglish;
|
||||
|
||||
translations << t;
|
||||
names << t.nameCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
qSort(translations.begin(), translations.end());
|
||||
return translations;
|
||||
}
|
||||
|
||||
@@ -20,8 +20,18 @@
|
||||
#define TOOLS_H
|
||||
|
||||
#define CSTR(x)(x.toLocal8Bit().constData())
|
||||
|
||||
class IEntryHandle;
|
||||
|
||||
typedef enum tKeyType {PASSWORD=0,KEYFILE=1,BOTH=2};
|
||||
struct Translation {
|
||||
QString nameCode;
|
||||
QString nameLong;
|
||||
QString nameEnglish;
|
||||
QString author;
|
||||
};
|
||||
bool operator<(const Translation& t1, const Translation& t2);
|
||||
|
||||
const QIcon& getIcon(const QString& name);
|
||||
const QPixmap* getPixmap(const QString& name);
|
||||
void createBanner(QPixmap* Pixmap, const QPixmap* IconAlpha,const QString& Text,int Width);
|
||||
@@ -35,5 +45,8 @@ QString getImageFile(const QString& name);
|
||||
bool createKeyFile(const QString& filename,QString* err, int length=32, bool Hex=true);
|
||||
bool lockPage(void* addr, int len);
|
||||
bool unlockPage(void* addr, int len);
|
||||
void installTranslator();
|
||||
bool isTranslationActive();
|
||||
QList<Translation> getAllTranslations();
|
||||
|
||||
#endif //TOOLS_H
|
||||
|
||||
90
src/main.cpp
90
src/main.cpp
@@ -24,9 +24,7 @@
|
||||
#include "plugins/interfaces/IGnomeInit.h"
|
||||
|
||||
|
||||
#include <QTranslator>
|
||||
#include <QLibraryInfo>
|
||||
#include <QPluginLoader>
|
||||
//#include <QPluginLoader>
|
||||
#include "mainwindow.h"
|
||||
#include "main.h"
|
||||
#if defined(Q_WS_X11) && defined(GLOBAL_AUTOTYPE)
|
||||
@@ -40,7 +38,6 @@ QString AppDir;
|
||||
QString HomeDir;
|
||||
QString DataDir;
|
||||
QString PluginLoadError;
|
||||
bool TrActive;
|
||||
QString DetailViewTemplate;
|
||||
bool EventOccurred;
|
||||
bool EventOccurredBlock = false;
|
||||
@@ -118,7 +115,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
else{
|
||||
qWarning(CSTR(QString("Could not load desktop integration plugin: File '%1' not found.").arg(LibName)));
|
||||
PluginLoadError=QObject::tr("Could not locate library file.");
|
||||
PluginLoadError=QApplication::translate("Main", "Could not locate library file.");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -140,57 +137,14 @@ int main(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
//Internationalization
|
||||
QLocale loc;
|
||||
if(!args.language().size())
|
||||
loc=QLocale::system();
|
||||
else
|
||||
loc=QLocale(args.language());
|
||||
|
||||
QTranslator* translator = new QTranslator;
|
||||
QTranslator* qtTranslator = new QTranslator;
|
||||
|
||||
if(loadTranslation(translator,"keepassx-",loc.name(),QStringList()
|
||||
<< DataDir+"/i18n/"
|
||||
<< HomeDir))
|
||||
{
|
||||
QApplication::installTranslator(translator);
|
||||
TrActive=true;
|
||||
}
|
||||
else{
|
||||
if(loc.name()!="en_US")
|
||||
qWarning(CSTR(
|
||||
QString("Kpx: No Translation found for '%1 (%2)' using 'English (United States)'")
|
||||
.arg(QLocale::languageToString(loc.language()))
|
||||
.arg(QLocale::countryToString(loc.country()))
|
||||
));
|
||||
delete translator;
|
||||
TrActive=false;
|
||||
}
|
||||
|
||||
if(TrActive){
|
||||
if(loadTranslation(qtTranslator,"qt_",loc.name(),QStringList()
|
||||
<< QLibraryInfo::location(QLibraryInfo::TranslationsPath)
|
||||
<< DataDir+"/i18n/"
|
||||
<< HomeDir))
|
||||
QApplication::installTranslator(qtTranslator);
|
||||
else{
|
||||
if(loc.name()!="en_US")
|
||||
qWarning(CSTR(
|
||||
QString("Qt: No Translation found for '%1 (%2)' using 'English (United States)'")
|
||||
.arg(QLocale::languageToString(loc.language()))
|
||||
.arg(QLocale::countryToString(loc.country()))
|
||||
));
|
||||
delete qtTranslator;
|
||||
}
|
||||
}
|
||||
|
||||
DetailViewTemplate=config->detailViewTemplate();
|
||||
|
||||
loadImages();
|
||||
KpxBookmarks::load();
|
||||
initYarrow(); //init random number generator
|
||||
SecString::generateSessionKey();
|
||||
|
||||
installTranslator();
|
||||
|
||||
EventListener* eventListener = new EventListener();
|
||||
app->installEventFilter(eventListener);
|
||||
@@ -221,21 +175,7 @@ void loadImages(){
|
||||
}
|
||||
|
||||
|
||||
bool loadTranslation(QTranslator* tr,const QString& prefix,const QString& loc,const QStringList& paths){
|
||||
for(int i=0;i<paths.size();i++)
|
||||
if(tr->load(prefix+loc+".qm",paths[i])) return true;
|
||||
|
||||
for(int i=0;i<paths.size();i++){
|
||||
QDir dir(paths[i]);
|
||||
QStringList TrFiles=dir.entryList(QStringList()<<"*.qm",QDir::Files);
|
||||
for(int j=0;j<TrFiles.size();j++){
|
||||
if(TrFiles[j].left(prefix.length()+2)==prefix+loc.left(2)){
|
||||
if(tr->load(TrFiles[j],paths[i]))return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
CmdLineArgs::CmdLineArgs(){
|
||||
@@ -250,19 +190,6 @@ bool CmdLineArgs::parse(const QStringList& argv){
|
||||
Help=true;
|
||||
break; // break, because other arguments will be ignored anyway
|
||||
}
|
||||
if(argv[i]=="-lang"){
|
||||
if(argv.size()==i+1){
|
||||
Error="Missing argument for '-lang'.";
|
||||
return false;
|
||||
}
|
||||
if(argv[i+1].size() != 2 && argv[i+1].size() != 5 ){
|
||||
Error=QString("'%1' is not a valid language code.").arg(argv[i+1]);
|
||||
return false;
|
||||
}
|
||||
Language=argv[i+1];
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
if(argv[i]=="-cfg"){
|
||||
//already done in preparse() -> skip
|
||||
i++;
|
||||
@@ -308,16 +235,11 @@ bool CmdLineArgs::preparse(int argc,char** argv){
|
||||
|
||||
void CmdLineArgs::printHelp(){
|
||||
cerr << "KeePassX " << APP_VERSION << endl;
|
||||
cerr << "Usage: keepassx [Filename] [Options]" << endl;
|
||||
cerr << "Usage: keepassx [filename] [options]" << endl;
|
||||
cerr << " -help This Help" << endl;
|
||||
cerr << " -cfg <CONFIG> Use specified file for loading/saving the configuration." << endl;
|
||||
cerr << " -min Start minimized." << endl;
|
||||
cerr << " -lock Start locked." << endl;
|
||||
cerr << " -lang <LOCALE> Use specified language instead of systems default." << endl;
|
||||
cerr << " <LOCALE> is the ISO-639 language code with or without ISO-3166 country code" << endl;
|
||||
cerr << " Examples: de German" << endl;
|
||||
cerr << " de_CH German(Switzerland)" << endl;
|
||||
cerr << " pt_BR Portuguese(Brazil)" << endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
QString findPlugin(const QString& filename);
|
||||
void loadImages();
|
||||
bool loadTranslation(QTranslator* tr,const QString& prefix,const QString& LocaleCode,const QStringList& SearchPaths);
|
||||
void initAppPaths(int argc, char **argv);
|
||||
|
||||
class CmdLineArgs {
|
||||
|
||||
@@ -1070,8 +1070,14 @@ void KeepassMainWindow::showEvent(QShowEvent* event){
|
||||
}
|
||||
|
||||
void KeepassMainWindow::OnExtrasSettings(){
|
||||
QString oldLang = config->language();
|
||||
CSettingsDlg dlg(this);
|
||||
dlg.exec();
|
||||
if (config->language() != oldLang){
|
||||
retranslateUi(this);
|
||||
EntryView->updateColumns();
|
||||
|
||||
}
|
||||
|
||||
EntryView->setAlternatingRowColors(config->alternatingRowColors());
|
||||
SysTray->setVisible(config->showSysTrayIcon());
|
||||
|
||||
Reference in New Issue
Block a user