Fix double password edit field

This commit is contained in:
Janek Bevendorff 2019-04-02 22:32:48 +02:00
parent f49a8a7f70
commit e025444c86
2 changed files with 9 additions and 12 deletions

View File

@ -168,25 +168,20 @@ void KeyComponentWidget::cancelEdit()
void KeyComponentWidget::showEvent(QShowEvent* event)
{
QWidget::showEvent(event);
resetComponentEditWidget();
QWidget::showEvent(event);
}
void KeyComponentWidget::resetComponentEditWidget()
{
if (m_ui->componentWidgetLayout->isEmpty() || static_cast<Page>(m_ui->stackedWidget->currentIndex()) == Page::Edit) {
if (!m_ui->componentWidgetLayout->isEmpty()) {
auto* item = m_ui->componentWidgetLayout->takeAt(0);
if (item->widget()) {
delete item->widget();
}
delete item;
if (!m_componentWidget || static_cast<Page>(m_ui->stackedWidget->currentIndex()) == Page::Edit) {
if (m_componentWidget) {
delete m_componentWidget;
}
QWidget* widget = componentEditWidget();
m_ui->componentWidgetLayout->addWidget(widget);
initComponentEditWidget(widget);
m_componentWidget = componentEditWidget();
m_ui->componentWidgetLayout->addWidget(m_componentWidget);
initComponentEditWidget(m_componentWidget);
}
QTimer::singleShot(0, this, SLOT(updateSize()));

View File

@ -20,6 +20,7 @@
#include <QScopedPointer>
#include <QWidget>
#include <QPointer>
namespace Ui
{
@ -128,6 +129,7 @@ private:
Page m_previousPage = Page::AddNew;
QString m_componentName;
QString m_componentDescription;
QPointer<QWidget> m_componentWidget;
const QScopedPointer<Ui::KeyComponentWidget> m_ui;
};