Reduced height of password generator dialog (Bug #2831504)

Escape HTML chars in detail view (Bug #2836096)
Don't call QT_REQUIRE_VERSION as it produces a compiler warning/error (Bug #2815290)

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@329 b624d157-de02-0410-bad0-e51aec6abb33
master
sniperbeamer 16 years ago
parent 29ded0a62b
commit 0a2733a992
  1. 71
      src/dialogs/PasswordGenDlg.cpp
  2. 2
      src/dialogs/PasswordGenDlg.h
  3. 37
      src/forms/EditEntryDlg.ui
  4. 124
      src/forms/PasswordGenDlg.ui
  5. 2
      src/main.cpp
  6. 32
      src/mainwindow.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()){
@ -226,8 +192,8 @@ void CGenPwDialog::OnGeneratePw()
void CGenPwDialog::estimateQuality(){
int num = 0;
if (tabCategory->currentIndex()==0){
if(Radio_1->isChecked()){
int index = tabCategory->currentIndex();
if (index == 0) {
if (checkBox1->isChecked()) {
num+=26;
if (Check_ExcludeLookAlike->isChecked())
@ -255,10 +221,7 @@ void CGenPwDialog::estimateQuality(){
if (checkBox7->isChecked())
num++;
}
else
num=Edit_chars->text().length();
}
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<PwGroup> groupTable;
if(Radio_1->isChecked()){
if (tabCategory->currentIndex() == 0) {
if (Check_EveryGroup->isChecked()){
if (checkBox1->isChecked()) groups++;
if (checkBox2->isChecked()) groups++;
@ -446,21 +412,20 @@ QString CGenPwDialog::generatePasswordInternal(int length){
void CGenPwDialog::setGenerateEnabled(){
bool enable;
int index = tabCategory->currentIndex();
if (tabCategory->currentIndex()==0){
if (Radio_1->isChecked()){
if (index == 0) {
enable = checkBox1->isChecked() || checkBox2->isChecked() || checkBox3->isChecked() ||
checkBox4->isChecked() || checkBox5->isChecked() || checkBox6->isChecked() ||
checkBox7->isChecked();
}
else{
enable = !Edit_chars->text().isEmpty();
}
}
else{
else if (index == 1) {
enable = checkBoxPU->isChecked() || checkBoxPL->isChecked() ||
checkBoxPN->isChecked() || checkBoxPS->isChecked();
}
else {
enable = !Edit_chars->text().isEmpty();
}
ButtonGenerate->setEnabled(enable);
}

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

@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<author>Tarek Saidi</author>
<class>EditEntryDialog</class>
@ -7,7 +8,7 @@
<x>0</x>
<y>0</y>
<width>494</width>
<height>491</height>
<height>490</height>
</rect>
</property>
<property name="windowTitle">
@ -23,7 +24,7 @@
<property name="spacing">
<number>6</number>
</property>
<item rowspan="2" row="5" column="1" >
<item row="5" column="1" rowspan="2">
<layout class="QGridLayout">
<property name="spacing">
<number>6</number>
@ -31,7 +32,7 @@
<item row="1" column="1">
<widget class="QToolButton" name="ButtonGenPw">
<property name="sizePolicy">
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -65,7 +66,7 @@
<item row="0" column="1">
<widget class="QToolButton" name="ButtonEchoMode">
<property name="sizePolicy">
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -104,7 +105,7 @@
<item row="7" column="0">
<widget class="QLabel" name="textLabel9">
<property name="sizePolicy">
<sizepolicy vsizetype="Preferred" hsizetype="Maximum" >
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -117,7 +118,7 @@
<item row="10" column="0">
<widget class="QLabel" name="textLabel12">
<property name="sizePolicy">
<sizepolicy vsizetype="Preferred" hsizetype="Maximum" >
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -130,7 +131,7 @@
<item row="2" column="0">
<widget class="QLabel" name="textLabel4">
<property name="sizePolicy">
<sizepolicy vsizetype="Preferred" hsizetype="Maximum" >
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -143,7 +144,7 @@
<item row="3" column="0">
<widget class="QLabel" name="textLabel5">
<property name="sizePolicy">
<sizepolicy vsizetype="Preferred" hsizetype="Maximum" >
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -156,7 +157,7 @@
<item row="8" column="0">
<widget class="QLabel" name="textLabel10">
<property name="sizePolicy">
<sizepolicy vsizetype="Preferred" hsizetype="Maximum" >
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -169,7 +170,7 @@
<item row="4" column="0">
<widget class="QLabel" name="textLabel7">
<property name="sizePolicy">
<sizepolicy vsizetype="Preferred" hsizetype="Maximum" >
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -182,7 +183,7 @@
<item row="1" column="0">
<widget class="QLabel" name="textLabel3">
<property name="sizePolicy">
<sizepolicy vsizetype="Preferred" hsizetype="Maximum" >
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -201,20 +202,20 @@
<item row="6" column="0">
<widget class="QLabel" name="textLabel8">
<property name="sizePolicy">
<sizepolicy vsizetype="Preferred" hsizetype="Maximum" >
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Password Repet.:</string>
<string>Repeat:</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="textLabel6">
<property name="sizePolicy">
<sizepolicy vsizetype="Preferred" hsizetype="Maximum" >
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -227,7 +228,7 @@
<item row="9" column="0">
<widget class="QLabel" name="textLabel11">
<property name="sizePolicy">
<sizepolicy vsizetype="Preferred" hsizetype="Maximum" >
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -277,7 +278,7 @@
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -341,7 +342,7 @@
<item>
<widget class="QLabel" name="Label_AttachmentSize">
<property name="sizePolicy">
<sizepolicy vsizetype="Preferred" hsizetype="Maximum" >
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -433,7 +434,7 @@
<item>
<widget class="QComboBox" name="Combo_Group">
<property name="sizePolicy">
<sizepolicy vsizetype="Fixed" hsizetype="MinimumExpanding" >
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>

@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GenPwDlg</class>
<widget class="QDialog" name="GenPwDlg">
@ -6,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>460</width>
<height>505</height>
<height>432</height>
</rect>
</property>
<property name="windowTitle">
@ -38,22 +39,14 @@
<number>0</number>
</property>
<widget class="QWidget" name="tabRandom">
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>438</width>
<height>243</height>
</rect>
</property>
<attribute name="title">
<string>Random</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="Radio_1" >
<widget class="QLabel" name="label_2">
<property name="text">
<string>Use follo&amp;wing character groups:</string>
<string>Use following character groups:</string>
</property>
</widget>
</item>
@ -145,48 +138,6 @@
</item>
</layout>
</item>
<item>
<widget class="QRadioButton" name="Radio_2" >
<property name="text" >
<string>Use &amp;only following characters:</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="spacing" >
<number>6</number>
</property>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>30</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLineEdit" name="Edit_chars" >
<property name="font" >
<font>
<family>Serif</family>
</font>
</property>
<property name="maxLength" >
<number>255</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="Check_ExcludeLookAlike">
<property name="text">
@ -204,14 +155,6 @@
</layout>
</widget>
<widget class="QWidget" name="tabPronounceable">
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>438</width>
<height>243</height>
</rect>
</property>
<attribute name="title">
<string>Pronounceable</string>
</attribute>
@ -224,7 +167,7 @@
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>60</height>
<height>1</height>
</size>
</property>
</spacer>
@ -272,7 +215,59 @@
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>60</height>
<height>1</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabCustom">
<attribute name="title">
<string>Custom</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>51</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Use the following characters:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="Edit_chars">
<property name="font">
<font>
<family>Serif</family>
</font>
</property>
<property name="maxLength">
<number>255</number>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>51</height>
</size>
</property>
</spacer>
@ -490,7 +485,6 @@
<layoutdefault spacing="6" margin="11"/>
<tabstops>
<tabstop>tabCategory</tabstop>
<tabstop>Radio_1</tabstop>
<tabstop>checkBox1</tabstop>
<tabstop>checkBox2</tabstop>
<tabstop>checkBox3</tabstop>
@ -498,8 +492,6 @@
<tabstop>checkBox6</tabstop>
<tabstop>checkBox7</tabstop>
<tabstop>checkBox4</tabstop>
<tabstop>Radio_2</tabstop>
<tabstop>Edit_chars</tabstop>
<tabstop>Check_ExcludeLookAlike</tabstop>
<tabstop>Check_EveryGroup</tabstop>
<tabstop>Spin_Num</tabstop>

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

@ -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());
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());
}
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","<br/>"));
templ.replace("%attachment%",entry->binaryDesc());
templ.replace("%password%", Qt::escape(password.string()));
}
else {
templ.replace("%password%","****");
}
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","<br/>"));
templ.replace("%attachment%", Qt::escape(entry->binaryDesc()));
if(entry->expire()!=Date_Never){
int secs=QDateTime::currentDateTime().secsTo(entry->expire());