Place database credentials widget in scroll area

* Fix #5440
This commit is contained in:
Jonathan White 2020-10-15 23:24:57 -04:00
parent 59b8b13146
commit 8b8cc2fa20
6 changed files with 67 additions and 22 deletions

View File

@ -38,6 +38,8 @@
#include "core/Resources.h"
#include "touchid/TouchID.h"
#include <QScrollArea>
class DatabaseSettingsDialog::ExtraPage
{
public:
@ -81,7 +83,16 @@ DatabaseSettingsDialog::DatabaseSettingsDialog(QWidget* parent)
m_ui->stackedWidget->addWidget(m_generalWidget);
m_ui->stackedWidget->addWidget(m_securityTabWidget);
m_securityTabWidget->addTab(m_databaseKeyWidget, tr("Database Credentials"));
auto* scrollArea = new QScrollArea(parent);
scrollArea->setFrameShape(QFrame::NoFrame);
scrollArea->setFrameShadow(QFrame::Plain);
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
scrollArea->setSizeAdjustPolicy(QScrollArea::AdjustToContents);
scrollArea->setWidgetResizable(true);
scrollArea->setWidget(m_databaseKeyWidget);
m_securityTabWidget->addTab(scrollArea, tr("Database Credentials"));
m_securityTabWidget->addTab(m_encryptionWidget, tr("Encryption Settings"));
#if defined(WITH_XC_KEESHARE)

View File

@ -216,8 +216,6 @@ void DatabaseSettingsWidgetDatabaseKey::setAdditionalKeyOptionsVisible(bool show
{
m_additionalKeyOptionsToggle->setVisible(!show);
m_additionalKeyOptions->setVisible(show);
m_additionalKeyOptions->layout()->setSizeConstraint(QLayout::SetMinimumSize);
emit sizeChanged();
}
bool DatabaseSettingsWidgetDatabaseKey::addToCompositeKey(KeyComponentWidget* widget,

View File

@ -47,11 +47,7 @@ NewDatabaseWizardPage::~NewDatabaseWizardPage()
void NewDatabaseWizardPage::setPageWidget(DatabaseSettingsWidget* page)
{
m_pageWidget = page;
if (!m_ui->pageContentLayout->isEmpty()) {
delete m_ui->pageContentLayout->takeAt(0);
}
m_ui->pageContentLayout->addWidget(m_pageWidget);
m_ui->pageContentLayout->setSizeConstraint(QLayout::SetMinimumSize);
m_ui->pageContent->setWidget(m_pageWidget);
m_ui->advancedSettingsButton->setVisible(m_pageWidget->hasAdvancedMode());
}

View File

@ -2,6 +2,14 @@
<ui version="4.0">
<class>NewDatabaseWizardPage</class>
<widget class="QWizardPage" name="NewDatabaseWizardPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>578</width>
<height>410</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
@ -17,9 +25,52 @@
<property name="subTitle">
<string>Here you can adjust the database encryption settings. Don't worry, you can change them later in the database settings.</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,0,0">
<item>
<layout class="QVBoxLayout" name="pageContentLayout"/>
<widget class="QScrollArea" name="pageContent">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>560</width>
<height>300</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QScrollArea { background: transparent; }
QScrollArea &gt; QWidget &gt; QWidget { background: transparent; }
QScrollArea &gt; QWidget &gt; QScrollBar { background: 1; }</string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustToContents</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="content">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>560</width>
<height>349</height>
</rect>
</property>
</widget>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
@ -29,7 +80,7 @@
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>15</height>
<height>6</height>
</size>
</property>
</spacer>

View File

@ -26,16 +26,8 @@ NewDatabaseWizardPageDatabaseKey::NewDatabaseWizardPageDatabaseKey(QWidget* pare
setTitle(tr("Database Credentials"));
setSubTitle(tr("A set of credentials known only to you that protects your database."));
connect(pageWidget(), SIGNAL(sizeChanged()), SLOT(updateWindowSize()));
}
NewDatabaseWizardPageDatabaseKey::~NewDatabaseWizardPageDatabaseKey()
{
}
void NewDatabaseWizardPageDatabaseKey::updateWindowSize()
{
// ugly workaround for QWizard not managing to react to size changes automatically
window()->adjustSize();
}

View File

@ -28,9 +28,6 @@ public:
explicit NewDatabaseWizardPageDatabaseKey(QWidget* parent = nullptr);
Q_DISABLE_COPY(NewDatabaseWizardPageDatabaseKey);
~NewDatabaseWizardPageDatabaseKey() override;
private slots:
void updateWindowSize();
};
#endif // KEEPASSXC_NEWDATABASEWIZARDPAGEDATABASEKEY_H