diff --git a/src/dialogs/PasswordGenDlg.cpp b/src/dialogs/PasswordGenDlg.cpp index f1e7f9d..91d8831 100644 --- a/src/dialogs/PasswordGenDlg.cpp +++ b/src/dialogs/PasswordGenDlg.cpp @@ -33,13 +33,9 @@ CGenPwDialog::CGenPwDialog(QWidget* parent, bool StandAloneMode,Qt::WFlags fl) { setupUi(this); connect(ButtonGenerate, SIGNAL(clicked()), SLOT(OnGeneratePw())); - connect(Radio_1, SIGNAL(toggled(bool)), SLOT(OnRadio1StateChanged(bool))); - connect(Radio_2, SIGNAL(toggled(bool)), SLOT(OnRadio2StateChanged(bool))); connect(DialogButtons, SIGNAL(rejected()), SLOT(OnCancel())); connect(DialogButtons, SIGNAL(accepted()), SLOT(OnAccept())); connect(tabCategory, SIGNAL(currentChanged(int)), SLOT(estimateQuality())); - connect(Radio_1, SIGNAL(toggled(bool)), SLOT(estimateQuality())); - connect(Radio_2, SIGNAL(toggled(bool)), SLOT(estimateQuality())); connect(checkBox1, SIGNAL(toggled(bool)), SLOT(estimateQuality())); connect(checkBox2, SIGNAL(toggled(bool)), SLOT(estimateQuality())); connect(checkBox3, SIGNAL(toggled(bool)), SLOT(estimateQuality())); @@ -57,8 +53,6 @@ CGenPwDialog::CGenPwDialog(QWidget* parent, bool StandAloneMode,Qt::WFlags fl) connect(Check_CollectEntropy, SIGNAL(stateChanged(int)), SLOT(OnCollectEntropyChanged(int))); connect(ButtonChangeEchoMode, SIGNAL(clicked()), SLOT(SwapEchoMode())); connect(tabCategory, SIGNAL(currentChanged(int)), SLOT(setGenerateEnabled())); - connect(Radio_1, SIGNAL(toggled(bool)), SLOT(setGenerateEnabled())); - connect(Radio_2, SIGNAL(toggled(bool)), SLOT(setGenerateEnabled())); connect(checkBox1, SIGNAL(toggled(bool)), SLOT(setGenerateEnabled())); connect(checkBox2, SIGNAL(toggled(bool)), SLOT(setGenerateEnabled())); connect(checkBox3, SIGNAL(toggled(bool)), SLOT(setGenerateEnabled())); @@ -87,8 +81,8 @@ CGenPwDialog::CGenPwDialog(QWidget* parent, bool StandAloneMode,Qt::WFlags fl) tabCategory->setCurrentIndex(config->pwGenCategory()); QBitArray pwGenOptions=config->pwGenOptions(); - Radio_1->setChecked(pwGenOptions.at(0)); - Radio_2->setChecked(!pwGenOptions.at(0)); + //Radio_1->setChecked(pwGenOptions.at(0)); + //Radio_2->setChecked(!pwGenOptions.at(0)); checkBox1->setChecked(pwGenOptions.at(1)); checkBox2->setChecked(pwGenOptions.at(2)); checkBox3->setChecked(pwGenOptions.at(3)); @@ -98,8 +92,8 @@ CGenPwDialog::CGenPwDialog(QWidget* parent, bool StandAloneMode,Qt::WFlags fl) checkBox7->setChecked(pwGenOptions.at(7)); Check_CollectEntropy->setChecked(pwGenOptions.at(8)); Check_CollectOncePerSession->setChecked(pwGenOptions.at(9)); - OnRadio1StateChanged(pwGenOptions.at(0)); - OnRadio2StateChanged(!pwGenOptions.at(0)); + //OnRadio1StateChanged(pwGenOptions.at(0)); + //OnRadio2StateChanged(!pwGenOptions.at(0)); if (pwGenOptions.size()>=14){ checkBoxPU->setChecked(pwGenOptions.at(10)); checkBoxPL->setChecked(pwGenOptions.at(11)); @@ -129,7 +123,7 @@ CGenPwDialog::CGenPwDialog(QWidget* parent, bool StandAloneMode,Qt::WFlags fl) CGenPwDialog::~CGenPwDialog(){ config->setPwGenCategory(tabCategory->currentIndex()); QBitArray pwGenOptions(14); - pwGenOptions.setBit(0,Radio_1->isChecked()); + //pwGenOptions.setBit(0,Radio_1->isChecked()); pwGenOptions.setBit(1,checkBox1->isChecked()); pwGenOptions.setBit(2,checkBox2->isChecked()); pwGenOptions.setBit(3,checkBox3->isChecked()); @@ -157,34 +151,6 @@ void CGenPwDialog::paintEvent(QPaintEvent *event){ painter.drawPixmap(QPoint(0,0),BannerPixmap); } -void CGenPwDialog::OnRadio1StateChanged(bool state) -{ - if(state){ - checkBox1->setEnabled(true); - checkBox2->setEnabled(true); - checkBox3->setEnabled(true); - checkBox4->setEnabled(true); - checkBox5->setEnabled(true); - checkBox6->setEnabled(true); - checkBox7->setEnabled(true); - }else{ - checkBox1->setDisabled(true); - checkBox2->setDisabled(true); - checkBox3->setDisabled(true); - checkBox4->setDisabled(true); - checkBox5->setDisabled(true); - checkBox6->setDisabled(true); - checkBox7->setDisabled(true); - } -} - -void CGenPwDialog::OnRadio2StateChanged(bool state){ - if(state) - Edit_chars->setEnabled(true); - else - Edit_chars->setDisabled(true); -} - void CGenPwDialog::OnGeneratePw() { if(Check_CollectEntropy->isChecked()){ @@ -198,7 +164,7 @@ void CGenPwDialog::OnGeneratePw() int length = Spin_Num->value(); QString password; - if (tabCategory->currentIndex()==1) + if (tabCategory->currentIndex() == 1) { unsigned int mode = 0; if (checkBoxPU->isChecked()) @@ -225,40 +191,37 @@ void CGenPwDialog::OnGeneratePw() } void CGenPwDialog::estimateQuality(){ - int num=0; - if (tabCategory->currentIndex()==0){ - if(Radio_1->isChecked()){ - if(checkBox1->isChecked()) { - num+=26; - if (Check_ExcludeLookAlike->isChecked()) - num -= 2; - } - if(checkBox2->isChecked()) { - num+=26; - if (Check_ExcludeLookAlike->isChecked()) - num -= 1; - } - if(checkBox3->isChecked()) { - num+=10; - if (Check_ExcludeLookAlike->isChecked()) - num -= 2; - } - if(checkBox4->isChecked()) { - num+=32; - if (Check_ExcludeLookAlike->isChecked()) - num -= 1; - } - if(checkBox5->isChecked()) - num++; - if(checkBox6->isChecked()) - num++; - if(checkBox7->isChecked()) - num++; + int num = 0; + int index = tabCategory->currentIndex(); + if (index == 0) { + if (checkBox1->isChecked()) { + num+=26; + if (Check_ExcludeLookAlike->isChecked()) + num -= 2; } - else - num=Edit_chars->text().length(); + if (checkBox2->isChecked()) { + num+=26; + if (Check_ExcludeLookAlike->isChecked()) + num -= 1; + } + if (checkBox3->isChecked()) { + num+=10; + if (Check_ExcludeLookAlike->isChecked()) + num -= 2; + } + if (checkBox4->isChecked()) { + num+=32; + if (Check_ExcludeLookAlike->isChecked()) + num -= 1; + } + if (checkBox5->isChecked()) + num++; + if (checkBox6->isChecked()) + num++; + if (checkBox7->isChecked()) + num++; } - else{ + else if (index == 1) { if (checkBoxPU->isChecked()) num+=26; if (checkBoxPL->isChecked()) @@ -268,6 +231,9 @@ void CGenPwDialog::estimateQuality(){ if (checkBoxPS->isChecked()) num+=32; } + else { + num=Edit_chars->text().length(); + } float bits = 0; if (num) @@ -354,7 +320,7 @@ QString CGenPwDialog::generatePasswordInternal(int length){ bool ensureEveryGroup = false; QList groupTable; - if(Radio_1->isChecked()){ + if (tabCategory->currentIndex() == 0) { if (Check_EveryGroup->isChecked()){ if (checkBox1->isChecked()) groups++; if (checkBox2->isChecked()) groups++; @@ -407,7 +373,7 @@ QString CGenPwDialog::generatePasswordInternal(int length){ else AddToAssoctable(assoctable,95,95,num); } } - else{ + else { QString str=Edit_chars->text(); for(int i=0;icurrentIndex(); - if (tabCategory->currentIndex()==0){ - if (Radio_1->isChecked()){ - enable = checkBox1->isChecked() || checkBox2->isChecked() || checkBox3->isChecked() || - checkBox4->isChecked() || checkBox5->isChecked() || checkBox6->isChecked() || - checkBox7->isChecked(); - } - else{ - enable = !Edit_chars->text().isEmpty(); - } + if (index == 0) { + enable = checkBox1->isChecked() || checkBox2->isChecked() || checkBox3->isChecked() || + checkBox4->isChecked() || checkBox5->isChecked() || checkBox6->isChecked() || + checkBox7->isChecked(); } - else{ + else if (index == 1) { enable = checkBoxPU->isChecked() || checkBoxPL->isChecked() || checkBoxPN->isChecked() || checkBoxPS->isChecked(); } + else { + enable = !Edit_chars->text().isEmpty(); + } ButtonGenerate->setEnabled(enable); } diff --git a/src/dialogs/PasswordGenDlg.h b/src/dialogs/PasswordGenDlg.h index e3f78d7..7707b49 100644 --- a/src/dialogs/PasswordGenDlg.h +++ b/src/dialogs/PasswordGenDlg.h @@ -46,8 +46,6 @@ class CGenPwDialog : public QDialog, public Ui_GenPwDlg private slots: void OnGeneratePw(); - void OnRadio2StateChanged(bool); - void OnRadio1StateChanged(bool); void OnCancel(); void OnAccept(); void estimateQuality(); diff --git a/src/forms/EditEntryDlg.ui b/src/forms/EditEntryDlg.ui index 12930b9..8c4e6b8 100644 --- a/src/forms/EditEntryDlg.ui +++ b/src/forms/EditEntryDlg.ui @@ -1,88 +1,89 @@ - + + Tarek Saidi EditEntryDialog - - + + 0 0 494 - 491 + 490 - + Edit Entry - + true - + true - - + + 6 - - - + + + 6 - - - - + + + + 0 0 - + 0 23 - + 16777215 23 - + Ge&n. - - - + + + Serif - - - - + + + + 0 0 - + 0 23 - + 16777215 23 - + 16 16 @@ -90,9 +91,9 @@ - - - + + + Serif @@ -101,183 +102,183 @@ - - - - + + + + 0 0 - + Quality: - - - - + + + + 0 0 - + Attachment: - - - - + + + + 0 0 - + Title: - - - - + + + + 0 0 - + Username: - - - - + + + + 0 0 - + Comment: - - - - + + + + 0 0 - + URL: - - - - + + + + 0 0 - + Group: - - + + - - + + - - - - + + + + 0 0 - - Password Repet.: + + Repeat: - - - - + + + + 0 0 - + Password: - - - - + + + + 0 0 - + Expires: - - - + + + 0 40 - + true - + false - - - + + + QFrame::HLine - + QFrame::Sunken - + Qt::Horizontal - - - + + + 6 - - + + false - - + + 0 0 @@ -285,16 +286,16 @@ - - + + - + - + 16 16 @@ -303,16 +304,16 @@ - - + + - + - + 16 16 @@ -321,16 +322,16 @@ - - + + - + - + 16 16 @@ -339,101 +340,101 @@ - - - + + + 0 0 - + %1 - - - + + + 6 - + - - + + - + 16 16 - + QToolButton::MenuButtonPopup - - + + Never - - - + + + 6 - - + + 0 14 - + 16777215 14 - + false - + Qt::Horizontal - - + + %1 Bit - - + + - - - + + + 6 - - - + + + 0 0 @@ -442,13 +443,13 @@ - + Qt::Horizontal - + QSizePolicy::Fixed - + 100 20 @@ -457,18 +458,18 @@ - - + + Icon: - + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + 16 16 @@ -478,25 +479,25 @@ - - - + + + Qt::Horizontal - + QDialogButtonBox::Cancel|QDialogButtonBox::Ok - + - + Qt::Vertical - + QSizePolicy::Minimum - + 20 50 @@ -506,7 +507,7 @@ - + Edit_Title Edit_UserName diff --git a/src/forms/PasswordGenDlg.ui b/src/forms/PasswordGenDlg.ui index 818b779..255827e 100644 --- a/src/forms/PasswordGenDlg.ui +++ b/src/forms/PasswordGenDlg.ui @@ -1,30 +1,31 @@ - + + GenPwDlg - - + + 0 0 460 - 505 + 432 - + Password Generator - - + + 6 - + Qt::Vertical - + QSizePolicy::Fixed - + 442 50 @@ -33,44 +34,36 @@ - - + + 0 - - - - 0 - 0 - 438 - 243 - - - + + Random - + - - - Use follo&wing character groups: + + + Use following character groups: - - + + 6 - + Qt::Horizontal - + QSizePolicy::Fixed - + 30 20 @@ -79,64 +72,64 @@ - - + + 6 - - - + + + &Lower Letters - + true - - - + + + &Underline - - - + + + &Numbers - + true - - - + + + &White Spaces - - - + + + &Upper Letters - + true - - - + + + &Minus - - - + + + &Special Characters @@ -146,118 +139,68 @@ - - - Use &only following characters: - - - - - - - 6 - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 30 - 20 - - - - - - - - - Serif - - - - 255 - - - - - - - - + + Exclude look-alike characters - - + + Ensure that password contains characters from every group - - - - 0 - 0 - 438 - 243 - - - + + Pronounceable - + - - + + Qt::Vertical - + 20 - 60 + 1 - - + + 12 - - - + + + Lower Letters - - - + + + Upper Letters - - - + + + Numbers - - - + + + Special Characters @@ -265,14 +208,66 @@ - - + + + Qt::Vertical + + + + 20 + 1 + + + + + + + + + Custom + + + + + + Qt::Vertical + + + + 20 + 51 + + + + + + + + Use the following characters: + + + + + + + + Serif + + + + 255 + + + + + + Qt::Vertical - + 20 - 60 + 51 @@ -283,13 +278,13 @@ - + Qt::Vertical - + QSizePolicy::Fixed - + 20 5 @@ -298,48 +293,48 @@ - - + + Options - - + + 6 - - + + 6 - - + + Length: - - + + 1 - + 10000 - + 20 - + Qt::Horizontal - + QSizePolicy::Fixed - + 10 1 @@ -348,21 +343,21 @@ - - + + Quality: - - + + 128 - + 0 - + Qt::Horizontal @@ -370,29 +365,29 @@ - - + + 6 - - + + Enable entropy collection - + true - + Qt::Horizontal - + QSizePolicy::Fixed - + 10 20 @@ -401,18 +396,18 @@ - - + + Collect only once per session - + Qt::Horizontal - + 40 20 @@ -426,20 +421,20 @@ - - + + 6 - - + + New Password: - - + + Serif @@ -447,15 +442,15 @@ - - + + - - + + Generate @@ -463,34 +458,33 @@ - - + + QFrame::HLine - + QFrame::Sunken - + Qt::Horizontal - - + + Qt::Horizontal - + QDialogButtonBox::NoButton - + tabCategory - Radio_1 checkBox1 checkBox2 checkBox3 @@ -498,8 +492,6 @@ checkBox6 checkBox7 checkBox4 - Radio_2 - Edit_chars Check_ExcludeLookAlike Check_EveryGroup Spin_Num diff --git a/src/main.cpp b/src/main.cpp index 202a498..c825647 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -51,8 +51,6 @@ int main(int argc, char **argv) { setlocale(LC_CTYPE, ""); - QT_REQUIRE_VERSION(argc, argv, "4.3.0"); - #if defined(Q_WS_X11) && defined(AUTOTYPE) QApplication* app = new KeepassApplication(argc,argv); #else diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index b35c89c..b99691a 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -714,23 +714,27 @@ void KeepassMainWindow::updateDetailView(){ QString templ=DetailViewTemplate; IEntryHandle* entry=((EntryViewItem*)(EntryView->selectedItems()[0]))->EntryHandle; - templ.replace("%group%",entry->group()->title()); - templ.replace("%title%",entry->title()); - if(config->hideUsernames())templ.replace("%username%","****"); - else templ.replace("%username%",entry->username()); - if(!config->hidePasswords()){ + templ.replace("%group%", Qt::escape(entry->group()->title())); + templ.replace("%title%", Qt::escape(entry->title())); + if (config->hideUsernames()) + templ.replace("%username%","****"); + else + templ.replace("%username%", Qt::escape(entry->username())); + if (!config->hidePasswords()) { SecString password=entry->password(); password.unlock(); - templ.replace("%password%",password.string()); + templ.replace("%password%", Qt::escape(password.string())); + } + else { + templ.replace("%password%","****"); } - else templ.replace("%password%","****"); - templ.replace("%url%",entry->url()); - templ.replace("%creation%",entry->creation().toString(Qt::SystemLocaleDate)); - templ.replace("%lastmod%",entry->lastMod().toString(Qt::SystemLocaleDate)); - templ.replace("%lastaccess%",entry->lastAccess().toString(Qt::SystemLocaleDate)); - templ.replace("%expire%",entry->expire().toString(Qt::SystemLocaleDate)); - templ.replace("%comment%",entry->comment().replace("\n","
")); - templ.replace("%attachment%",entry->binaryDesc()); + templ.replace("%url%", Qt::escape(entry->url())); + templ.replace("%creation%", Qt::escape(entry->creation().toString(Qt::SystemLocaleDate))); + templ.replace("%lastmod%", Qt::escape(entry->lastMod().toString(Qt::SystemLocaleDate))); + templ.replace("%lastaccess%", Qt::escape(entry->lastAccess().toString(Qt::SystemLocaleDate))); + templ.replace("%expire%", Qt::escape(entry->expire().toString(Qt::SystemLocaleDate))); + templ.replace("%comment%", Qt::escape(entry->comment()).replace("\n","
")); + templ.replace("%attachment%", Qt::escape(entry->binaryDesc())); if(entry->expire()!=Date_Never){ int secs=QDateTime::currentDateTime().secsTo(entry->expire());