mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-27 00:09:53 -05:00
parent
405d3ee1ca
commit
1dbec40be9
@ -19,9 +19,10 @@
|
|||||||
#include "EntryPreviewWidget.h"
|
#include "EntryPreviewWidget.h"
|
||||||
#include "ui_EntryPreviewWidget.h"
|
#include "ui_EntryPreviewWidget.h"
|
||||||
|
|
||||||
#include "Clipboard.h"
|
#include "gui/Clipboard.h"
|
||||||
#include "Font.h"
|
#include "gui/Font.h"
|
||||||
#include "gui/Icons.h"
|
#include "gui/Icons.h"
|
||||||
|
#include "totp/totp.h"
|
||||||
#if defined(WITH_XC_KEESHARE)
|
#if defined(WITH_XC_KEESHARE)
|
||||||
#include "keeshare/KeeShare.h"
|
#include "keeshare/KeeShare.h"
|
||||||
#include "keeshare/KeeShareSettings.h"
|
#include "keeshare/KeeShareSettings.h"
|
||||||
@ -65,6 +66,7 @@ EntryPreviewWidget::EntryPreviewWidget(QWidget* parent)
|
|||||||
connect(m_ui->entryUrlLabel, SIGNAL(linkActivated(QString)), SLOT(openEntryUrl()));
|
connect(m_ui->entryUrlLabel, SIGNAL(linkActivated(QString)), SLOT(openEntryUrl()));
|
||||||
|
|
||||||
connect(m_ui->entryTotpButton, SIGNAL(toggled(bool)), m_ui->entryTotpLabel, SLOT(setVisible(bool)));
|
connect(m_ui->entryTotpButton, SIGNAL(toggled(bool)), m_ui->entryTotpLabel, SLOT(setVisible(bool)));
|
||||||
|
connect(m_ui->entryTotpButton, SIGNAL(toggled(bool)), m_ui->entryTotpProgress, SLOT(setVisible(bool)));
|
||||||
connect(m_ui->entryCloseButton, SIGNAL(clicked()), SLOT(hide()));
|
connect(m_ui->entryCloseButton, SIGNAL(clicked()), SLOT(hide()));
|
||||||
connect(m_ui->togglePasswordButton, SIGNAL(clicked(bool)), SLOT(setPasswordVisible(bool)));
|
connect(m_ui->togglePasswordButton, SIGNAL(clicked(bool)), SLOT(setPasswordVisible(bool)));
|
||||||
connect(m_ui->toggleEntryNotesButton, SIGNAL(clicked(bool)), SLOT(setEntryNotesVisible(bool)));
|
connect(m_ui->toggleEntryNotesButton, SIGNAL(clicked(bool)), SLOT(setEntryNotesVisible(bool)));
|
||||||
@ -180,10 +182,12 @@ void EntryPreviewWidget::updateEntryTotp()
|
|||||||
const bool hasTotp = m_currentEntry->hasTotp();
|
const bool hasTotp = m_currentEntry->hasTotp();
|
||||||
m_ui->entryTotpButton->setVisible(hasTotp);
|
m_ui->entryTotpButton->setVisible(hasTotp);
|
||||||
m_ui->entryTotpLabel->hide();
|
m_ui->entryTotpLabel->hide();
|
||||||
|
m_ui->entryTotpProgress->hide();
|
||||||
m_ui->entryTotpButton->setChecked(false);
|
m_ui->entryTotpButton->setChecked(false);
|
||||||
|
|
||||||
if (hasTotp) {
|
if (hasTotp) {
|
||||||
m_totpTimer.start(1000);
|
m_totpTimer.start(1000);
|
||||||
|
m_ui->entryTotpProgress->setMaximum(m_currentEntry->totpSettings()->step);
|
||||||
updateTotpLabel();
|
updateTotpLabel();
|
||||||
} else {
|
} else {
|
||||||
m_ui->entryTotpLabel->clear();
|
m_ui->entryTotpLabel->clear();
|
||||||
@ -420,10 +424,14 @@ void EntryPreviewWidget::updateGroupSharingTab()
|
|||||||
void EntryPreviewWidget::updateTotpLabel()
|
void EntryPreviewWidget::updateTotpLabel()
|
||||||
{
|
{
|
||||||
if (!m_locked && m_currentEntry && m_currentEntry->hasTotp()) {
|
if (!m_locked && m_currentEntry && m_currentEntry->hasTotp()) {
|
||||||
const QString totpCode = m_currentEntry->totp();
|
auto totpCode = m_currentEntry->totp();
|
||||||
const QString firstHalf = totpCode.left(totpCode.size() / 2);
|
totpCode.insert(totpCode.size() / 2, " ");
|
||||||
const QString secondHalf = totpCode.mid(totpCode.size() / 2);
|
m_ui->entryTotpLabel->setText(totpCode);
|
||||||
m_ui->entryTotpLabel->setText(firstHalf + " " + secondHalf);
|
|
||||||
|
auto step = m_currentEntry->totpSettings()->step;
|
||||||
|
auto timeleft = step - (Clock::currentSecondsSinceEpoch() % step);
|
||||||
|
m_ui->entryTotpProgress->setValue(timeleft);
|
||||||
|
m_ui->entryTotpProgress->update();
|
||||||
} else {
|
} else {
|
||||||
m_ui->entryTotpLabel->clear();
|
m_ui->entryTotpLabel->clear();
|
||||||
m_totpTimer.stop();
|
m_totpTimer.stop();
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="entryHorizontalLayout" stretch="0,0,0,0">
|
<layout class="QHBoxLayout" name="entryHorizontalLayout" stretch="1,0,0,0">
|
||||||
<property name="sizeConstraint">
|
<property name="sizeConstraint">
|
||||||
<enum>QLayout::SetDefaultConstraint</enum>
|
<enum>QLayout::SetDefaultConstraint</enum>
|
||||||
</property>
|
</property>
|
||||||
@ -104,18 +104,44 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="entryTotpLabel">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<property name="font">
|
<property name="spacing">
|
||||||
<font>
|
<number>0</number>
|
||||||
<pointsize>10</pointsize>
|
|
||||||
<weight>75</weight>
|
|
||||||
<bold>true</bold>
|
|
||||||
</font>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<item>
|
||||||
<string notr="true">1234567</string>
|
<widget class="QLabel" name="entryTotpLabel">
|
||||||
</property>
|
<property name="font">
|
||||||
</widget>
|
<font>
|
||||||
|
<pointsize>10</pointsize>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">1234567</string>
|
||||||
|
</property>
|
||||||
|
<property name="textInteractionFlags">
|
||||||
|
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QProgressBar" name="entryTotpProgress">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>57</width>
|
||||||
|
<height>4</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>50</number>
|
||||||
|
</property>
|
||||||
|
<property name="textVisible">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QToolButton" name="entryTotpButton">
|
<widget class="QToolButton" name="entryTotpButton">
|
||||||
|
Loading…
Reference in New Issue
Block a user