fix group parent, add details update by keyboard

This commit is contained in:
thez3ro 2017-08-31 00:52:05 +02:00
parent 1a87e30b95
commit 0e6fedc056
No known key found for this signature in database
GPG Key ID: F628F9E41DD7C073
5 changed files with 43 additions and 63 deletions

View File

@ -439,10 +439,14 @@ QStringList Group::hierarchy()
{
QStringList hierarchy;
Group* group = this;
while (group->parentGroup()) {
hierarchy << group->name();
Group* parent = m_parent;
hierarchy << group->name();
while (parent) {
group = group->parentGroup();
parent = group->parentGroup();
hierarchy << group->name();
}
return hierarchy;
}

View File

@ -193,9 +193,9 @@ DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent)
connect(this, SIGNAL(currentChanged(int)), this, SLOT(emitCurrentModeChanged()));
connect(m_groupView, SIGNAL(groupPressed(Group*)), SLOT(emitPressedGroup(Group*)));
//connect(m_groupView, SIGNAL(groupChanged(Group*)), SLOT(emitPressedGroup(Group*)));
connect(m_groupView, SIGNAL(groupChanged(Group*)), SLOT(emitPressedGroup(Group*)));
connect(m_entryView, SIGNAL(entryPressed(Entry*)), SLOT(emitPressedEntry(Entry*)));
//connect(m_entryView, SIGNAL(entrySelectionChanged()), SLOT(emitPressedEntry()));
connect(m_entryView, SIGNAL(entrySelectionChanged()), SLOT(emitPressedEntry()));
connect(m_editEntryWidget, SIGNAL(editFinished(bool)), SLOT(emitPressedEntry()));
m_databaseModified = false;

View File

@ -24,6 +24,7 @@
#include "core/Config.h"
#include "core/FilePath.h"
#include "core/TimeInfo.h"
#include "gui/Clipboard.h"
DetailsWidget::DetailsWidget(QWidget* parent)
: QWidget(parent)
@ -38,11 +39,9 @@ DetailsWidget::DetailsWidget(QWidget* parent)
m_ui->totpButton->setIcon(filePath()->icon("actions", "chronometer"));
m_ui->closeButton->setIcon(filePath()->icon("actions", "dialog-close"));
m_ui->togglePasswordButton->setIcon(filePath()->onOffIcon("actions", "password-show"));
connect(m_ui->totpButton, SIGNAL(toggled(bool)), SLOT(showTotp(bool)));
connect(m_ui->closeButton, SIGNAL(toggled(bool)), SLOT(hideDetails()));
connect(m_ui->togglePasswordButton, SIGNAL(toggled(bool)), SLOT(togglePasswordShown(bool)));
this->hide();
}
@ -67,25 +66,31 @@ void DetailsWidget::getSelectedEntry(Entry* selectedEntry)
m_ui->entryIcon->setPixmap(m_currentEntry->iconPixmap());
QStringList hierarchy = m_currentEntry->group()->hierarchy();
QString title = " / ";
for (QString parent : hierarchy) {
title.append(parent);
title.append(" / ");
Group* entry_group = m_currentEntry->group();
if (entry_group) {
QStringList hierarchy = entry_group->hierarchy();
for (QString parent : hierarchy) {
title.append(parent);
title.append(" / ");
}
}
title.append(m_currentEntry->title());
title.append(m_currentEntry->resolveMultiplePlaceholders(m_currentEntry->title()));
m_ui->titleLabel->setText(title);
m_ui->usernameLabel->setText(m_currentEntry->username());
m_ui->groupLabel->setText(m_currentEntry->group()->name());
m_ui->notesEdit->setText(m_currentEntry->notes());
m_ui->usernameLabel->setText(m_currentEntry->resolveMultiplePlaceholders(m_currentEntry->username()));
if (entry_group) {
m_ui->groupLabel->setText(entry_group->name());
}
m_ui->notesEdit->setText(m_currentEntry->resolveMultiplePlaceholders(m_currentEntry->notes()));
if (!config()->get("security/hidepassworddetails").toBool()) {
m_ui->passwordEdit->setText(m_currentEntry->password());
m_ui->togglePasswordButton->show();
m_ui->passwordLabel->setText(shortPassword(m_currentEntry->resolveMultiplePlaceholders(m_currentEntry->password())));
m_ui->passwordLabel->setToolTip(m_currentEntry->resolveMultiplePlaceholders(m_currentEntry->password()));
} else {
m_ui->passwordEdit->setText("****");
m_ui->togglePasswordButton->hide();
m_ui->passwordLabel->setText("****");
}
QString url = m_currentEntry->webUrl();
@ -199,15 +204,18 @@ QString DetailsWidget::shortUrl(QString url)
return url;
}
QString DetailsWidget::shortPassword(QString password)
{
QString newpassword = "";
if (password.length() > 60) {
newpassword.append(password.left(50));
newpassword.append("...");
return newpassword;
}
return password;
}
void DetailsWidget::hideDetails()
{
this->hide();
}
void DetailsWidget::togglePasswordShown(bool showing)
{
m_ui->passwordEdit->setShowPassword(showing);
bool blockSignals = m_ui->togglePasswordButton->blockSignals(true);
m_ui->togglePasswordButton->setChecked(showing);
m_ui->togglePasswordButton->blockSignals(blockSignals);
}

View File

@ -46,7 +46,6 @@ private slots:
void showTotp(bool visible);
void updateTotp();
void hideDetails();
void togglePasswordShown(bool showing);
private:
const QScopedPointer<Ui::DetailsWidget> m_ui;
@ -55,6 +54,7 @@ private:
quint8 m_step;
QTimer* m_timer;
QString shortUrl(QString url);
QString shortPassword(QString password);
};
#endif // KEEPASSX_DETAILSWIDGET_H

View File

@ -235,33 +235,6 @@
<item row="1" column="1">
<widget class="QLabel" name="usernameLabel"/>
</item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="PasswordEdit" name="passwordEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maxLength">
<number>999</number>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="togglePasswordButton">
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="1">
<widget class="QLabel" name="urlLabel">
<property name="sizePolicy">
@ -275,6 +248,9 @@
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="passwordLabel"/>
</item>
</layout>
</item>
</layout>
@ -539,14 +515,6 @@
</property>
</action>
</widget>
<customwidgets>
<customwidget>
<class>PasswordEdit</class>
<extends>QLineEdit</extends>
<header>gui/PasswordEdit.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>