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:
sniperbeamer
2008-10-07 14:46:07 +00:00
parent ef92de215c
commit f88ca3f4c0
14 changed files with 1870 additions and 1373 deletions

View File

@@ -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>";
}

View File

@@ -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();

View File

@@ -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;
};