Fix layout and alignment of Entry and Group edit views

* Fixes #5321 - Text alignment in the general tab of the entry and group edit views is fixed
* Fixes #5300 - Errant scrollbar in the general tab is fixed
* Fixes #4852 - Tabbing into notes field works as expected. To tab out, currently only Shift+Tab works.
This commit is contained in:
Jonathan White 2020-09-13 10:31:18 -04:00
parent 3c5bd0ff6b
commit 55e4889053
8 changed files with 562 additions and 490 deletions

View File

@ -59,12 +59,18 @@ void EditWidget::addPage(const QString& labelText, const QIcon& icon, QWidget* w
* from automatic resizing and it now should be able to fit into a user's monitor even if the monitor is only 768 * from automatic resizing and it now should be able to fit into a user's monitor even if the monitor is only 768
* pixels high. * pixels high.
*/ */
if (widget->inherits("QScrollArea")) {
m_ui->stackedWidget->addWidget(widget);
} else {
auto* scrollArea = new QScrollArea(m_ui->stackedWidget); auto* scrollArea = new QScrollArea(m_ui->stackedWidget);
scrollArea->setFrameShape(QFrame::NoFrame); scrollArea->setFrameShape(QFrame::NoFrame);
scrollArea->setFrameShadow(QFrame::Plain);
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
scrollArea->setWidget(widget); scrollArea->setSizeAdjustPolicy(QScrollArea::AdjustToContents);
scrollArea->setWidgetResizable(true); scrollArea->setWidgetResizable(true);
scrollArea->setWidget(widget);
m_ui->stackedWidget->addWidget(scrollArea); m_ui->stackedWidget->addWidget(scrollArea);
}
m_ui->categoryList->addCategory(labelText, icon); m_ui->categoryList->addCategory(labelText, icon);
} }

View File

@ -76,7 +76,7 @@ EditEntryWidget::EditEntryWidget(QWidget* parent)
, m_historyUi(new Ui::EditEntryWidgetHistory()) , m_historyUi(new Ui::EditEntryWidgetHistory())
, m_browserUi(new Ui::EditEntryWidgetBrowser()) , m_browserUi(new Ui::EditEntryWidgetBrowser())
, m_customData(new CustomData()) , m_customData(new CustomData())
, m_mainWidget(new QWidget()) , m_mainWidget(new QScrollArea())
, m_advancedWidget(new QWidget()) , m_advancedWidget(new QWidget())
, m_iconsWidget(new EditWidgetIcons()) , m_iconsWidget(new EditWidgetIcons())
, m_autoTypeWidget(new QWidget()) , m_autoTypeWidget(new QWidget())
@ -178,6 +178,9 @@ void EditEntryWidget::setupMain()
m_mainUi->expirePresets->setMenu(createPresetsMenu()); m_mainUi->expirePresets->setMenu(createPresetsMenu());
connect(m_mainUi->expirePresets->menu(), SIGNAL(triggered(QAction*)), this, SLOT(useExpiryPreset(QAction*))); connect(m_mainUi->expirePresets->menu(), SIGNAL(triggered(QAction*)), this, SLOT(useExpiryPreset(QAction*)));
// HACK: Align username text with other line edits. Qt does not let you do this with an application stylesheet.
m_mainUi->usernameComboBox->lineEdit()->setStyleSheet("padding-left: 8px;");
} }
void EditEntryWidget::setupAdvanced() void EditEntryWidget::setupAdvanced()

View File

@ -24,6 +24,7 @@
#include <QModelIndex> #include <QModelIndex>
#include <QPointer> #include <QPointer>
#include <QScopedPointer> #include <QScopedPointer>
#include <QScrollArea>
#include <QTimer> #include <QTimer>
#include "config-keepassx.h" #include "config-keepassx.h"
@ -174,7 +175,7 @@ private:
const QScopedPointer<Ui::EditEntryWidgetBrowser> m_browserUi; const QScopedPointer<Ui::EditEntryWidgetBrowser> m_browserUi;
const QScopedPointer<CustomData> m_customData; const QScopedPointer<CustomData> m_customData;
QWidget* const m_mainWidget; QScrollArea* const m_mainWidget;
QWidget* const m_advancedWidget; QWidget* const m_advancedWidget;
EditWidgetIcons* const m_iconsWidget; EditWidgetIcons* const m_iconsWidget;
QWidget* const m_autoTypeWidget; QWidget* const m_autoTypeWidget;

View File

@ -1,13 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>EditEntryWidgetMain</class> <class>EditEntryWidgetMain</class>
<widget class="QWidget" name="EditEntryWidgetMain"> <widget class="QScrollArea" name="EditEntryWidgetMain">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>496</width> <width>539</width>
<height>420</height> <height>523</height>
</rect>
</property>
<property name="windowTitle">
<string>Edit Entry</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="container">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>539</width>
<height>523</height>
</rect> </rect>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
@ -247,6 +274,7 @@
</item> </item>
</layout> </layout>
</widget> </widget>
</widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>
<class>PasswordEdit</class> <class>PasswordEdit</class>

View File

@ -62,7 +62,7 @@ private:
EditGroupWidget::EditGroupWidget(QWidget* parent) EditGroupWidget::EditGroupWidget(QWidget* parent)
: EditWidget(parent) : EditWidget(parent)
, m_mainUi(new Ui::EditGroupWidgetMain()) , m_mainUi(new Ui::EditGroupWidgetMain())
, m_editGroupWidgetMain(new QWidget()) , m_editGroupWidgetMain(new QScrollArea())
, m_editGroupWidgetIcons(new EditWidgetIcons()) , m_editGroupWidgetIcons(new EditWidgetIcons())
, m_editWidgetProperties(new EditWidgetProperties()) , m_editWidgetProperties(new EditWidgetProperties())
, m_group(nullptr) , m_group(nullptr)

View File

@ -20,6 +20,7 @@
#include <QComboBox> #include <QComboBox>
#include <QScopedPointer> #include <QScopedPointer>
#include <QScrollArea>
#include "core/Group.h" #include "core/Group.h"
#include "gui/EditWidget.h" #include "gui/EditWidget.h"
@ -78,7 +79,7 @@ private:
const QScopedPointer<Ui::EditGroupWidgetMain> m_mainUi; const QScopedPointer<Ui::EditGroupWidgetMain> m_mainUi;
QPointer<QWidget> m_editGroupWidgetMain; QPointer<QScrollArea> m_editGroupWidgetMain;
QPointer<EditWidgetIcons> m_editGroupWidgetIcons; QPointer<EditWidgetIcons> m_editGroupWidgetIcons;
QPointer<EditWidgetProperties> m_editWidgetProperties; QPointer<EditWidgetProperties> m_editWidgetProperties;

View File

@ -1,13 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>EditGroupWidgetMain</class> <class>EditGroupWidgetMain</class>
<widget class="QWidget" name="EditGroupWidgetMain"> <widget class="QScrollArea" name="EditGroupWidgetMain">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>410</width> <width>539</width>
<height>430</height> <height>523</height>
</rect>
</property>
<property name="windowTitle">
<string>Edit Group</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="container">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>539</width>
<height>523</height>
</rect> </rect>
</property> </property>
<layout class="QGridLayout" name="gridLayout" rowstretch="0,0,0,0,0,0,0,0,0,1" rowminimumheight="0,0,0,0,0,0,0,0,0,1"> <layout class="QGridLayout" name="gridLayout" rowstretch="0,0,0,0,0,0,0,0,0,1" rowminimumheight="0,0,0,0,0,0,0,0,0,1">
@ -211,6 +238,7 @@
</item> </item>
</layout> </layout>
</widget> </widget>
</widget>
<tabstops> <tabstops>
<tabstop>editName</tabstop> <tabstop>editName</tabstop>
<tabstop>editNotes</tabstop> <tabstop>editNotes</tabstop>

View File

@ -64,3 +64,8 @@ DatabaseWidget #SearchBanner, DatabaseWidget #KeeShareBanner {
border: 1px solid palette(dark); border: 1px solid palette(dark);
padding: 2px; padding: 2px;
} }
QPlainTextEdit, QTextEdit {
background-color: palette(base);
padding-left: 4px;
}