Skip to content

Commit

Permalink
Place database credentials widget in scroll area
Browse files Browse the repository at this point in the history
  • Loading branch information
droidmonkey committed Oct 20, 2020
1 parent 59b8b13 commit 8b8cc2f
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 22 deletions.
13 changes: 12 additions & 1 deletion src/gui/dbsettings/DatabaseSettingsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
#include "core/Resources.h"
#include "touchid/TouchID.h"

#include <QScrollArea>

class DatabaseSettingsDialog::ExtraPage
{
public:
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions src/gui/dbsettings/DatabaseSettingsWidgetDatabaseKey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 1 addition & 5 deletions src/gui/wizard/NewDatabaseWizardPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down
57 changes: 54 additions & 3 deletions src/gui/wizard/NewDatabaseWizardPage.ui
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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">
Expand All @@ -29,7 +80,7 @@
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>15</height>
<height>6</height>
</size>
</property>
</spacer>
Expand Down
8 changes: 0 additions & 8 deletions src/gui/wizard/NewDatabaseWizardPageDatabaseKey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
3 changes: 0 additions & 3 deletions src/gui/wizard/NewDatabaseWizardPageDatabaseKey.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ class NewDatabaseWizardPageDatabaseKey : public NewDatabaseWizardPage
explicit NewDatabaseWizardPageDatabaseKey(QWidget* parent = nullptr);
Q_DISABLE_COPY(NewDatabaseWizardPageDatabaseKey);
~NewDatabaseWizardPageDatabaseKey() override;

private slots:
void updateWindowSize();
};

#endif // KEEPASSXC_NEWDATABASEWIZARDPAGEDATABASEKEY_H

0 comments on commit 8b8cc2f

Please sign in to comment.