mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-27 14:57:09 -05:00
Fix sidebar resize behaviour (#10641)
* Fix database view splitters resize behaviour * Set default ratio sizes for first-run based on the size of the database widget itself * Fix setting splitter sizes before database widget has had a chance to render for the first time * Disallow collapsing the entry view (source of several bug reports) Fixes: #10613 --------- Co-authored-by: Jonathan White <support@dmapps.us>
This commit is contained in:
parent
1d008dbd72
commit
40f4428e36
@ -121,8 +121,9 @@ DatabaseWidget::DatabaseWidget(QSharedPointer<Database> db, QWidget* parent)
|
|||||||
m_groupSplitter->setChildrenCollapsible(true);
|
m_groupSplitter->setChildrenCollapsible(true);
|
||||||
m_groupSplitter->addWidget(m_groupView);
|
m_groupSplitter->addWidget(m_groupView);
|
||||||
m_groupSplitter->addWidget(tagsWidget);
|
m_groupSplitter->addWidget(tagsWidget);
|
||||||
m_groupSplitter->setStretchFactor(0, 70);
|
m_groupSplitter->setStretchFactor(0, 100);
|
||||||
m_groupSplitter->setStretchFactor(1, 30);
|
m_groupSplitter->setStretchFactor(1, 0);
|
||||||
|
m_groupSplitter->setSizes({1, 1});
|
||||||
|
|
||||||
auto rightHandSideWidget = new QWidget(m_mainSplitter);
|
auto rightHandSideWidget = new QWidget(m_mainSplitter);
|
||||||
auto rightHandSideVBox = new QVBoxLayout();
|
auto rightHandSideVBox = new QVBoxLayout();
|
||||||
@ -138,8 +139,10 @@ DatabaseWidget::DatabaseWidget(QSharedPointer<Database> db, QWidget* parent)
|
|||||||
m_mainSplitter->setChildrenCollapsible(true);
|
m_mainSplitter->setChildrenCollapsible(true);
|
||||||
m_mainSplitter->addWidget(m_groupSplitter);
|
m_mainSplitter->addWidget(m_groupSplitter);
|
||||||
m_mainSplitter->addWidget(rightHandSideWidget);
|
m_mainSplitter->addWidget(rightHandSideWidget);
|
||||||
m_mainSplitter->setStretchFactor(0, 30);
|
m_mainSplitter->setStretchFactor(0, 0);
|
||||||
m_mainSplitter->setStretchFactor(1, 70);
|
m_mainSplitter->setStretchFactor(1, 100);
|
||||||
|
m_mainSplitter->setCollapsible(1, false);
|
||||||
|
m_mainSplitter->setSizes({1, 1});
|
||||||
|
|
||||||
m_previewSplitter->setOrientation(Qt::Vertical);
|
m_previewSplitter->setOrientation(Qt::Vertical);
|
||||||
m_previewSplitter->setChildrenCollapsible(true);
|
m_previewSplitter->setChildrenCollapsible(true);
|
||||||
@ -361,20 +364,27 @@ QHash<Config::ConfigKey, QList<int>> DatabaseWidget::splitterSizes() const
|
|||||||
|
|
||||||
void DatabaseWidget::setSplitterSizes(const QHash<Config::ConfigKey, QList<int>>& sizes)
|
void DatabaseWidget::setSplitterSizes(const QHash<Config::ConfigKey, QList<int>>& sizes)
|
||||||
{
|
{
|
||||||
|
// Set the splitter sizes, if the size is invalid set a default ratio based on this widget size
|
||||||
for (auto itr = sizes.constBegin(); itr != sizes.constEnd(); ++itr) {
|
for (auto itr = sizes.constBegin(); itr != sizes.constEnd(); ++itr) {
|
||||||
// Less than two sizes indicates an invalid value
|
auto value = itr.value();
|
||||||
if (itr.value().size() < 2) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
switch (itr.key()) {
|
switch (itr.key()) {
|
||||||
case Config::GUI_SplitterState:
|
case Config::GUI_SplitterState:
|
||||||
m_mainSplitter->setSizes(itr.value());
|
if (value.size() < 2) {
|
||||||
|
value = QList({static_cast<int>(width() * 0.25), static_cast<int>(width() * 0.75)});
|
||||||
|
}
|
||||||
|
m_mainSplitter->setSizes(value);
|
||||||
break;
|
break;
|
||||||
case Config::GUI_PreviewSplitterState:
|
case Config::GUI_PreviewSplitterState:
|
||||||
m_previewSplitter->setSizes(itr.value());
|
if (value.size() < 2) {
|
||||||
|
value = QList({static_cast<int>(height() * 0.8), static_cast<int>(height() * 0.2)});
|
||||||
|
}
|
||||||
|
m_previewSplitter->setSizes(value);
|
||||||
break;
|
break;
|
||||||
case Config::GUI_GroupSplitterState:
|
case Config::GUI_GroupSplitterState:
|
||||||
m_groupSplitter->setSizes(itr.value());
|
if (value.size() < 2) {
|
||||||
|
value = QList({static_cast<int>(height() * 0.6), static_cast<int>(height() * 0.4)});
|
||||||
|
}
|
||||||
|
m_groupSplitter->setSizes(value);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -62,17 +62,24 @@ void DatabaseWidgetStateSync::setActive(DatabaseWidget* dbWidget)
|
|||||||
m_activeDbWidget = dbWidget;
|
m_activeDbWidget = dbWidget;
|
||||||
|
|
||||||
if (m_activeDbWidget) {
|
if (m_activeDbWidget) {
|
||||||
m_blockUpdates = true;
|
// Give the database widget a chance to render itself before restoring the state
|
||||||
|
QTimer::singleShot(0, this, [this] {
|
||||||
|
if (!m_activeDbWidget) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_activeDbWidget->setSplitterSizes(m_splitterSizes);
|
m_blockUpdates = true;
|
||||||
|
|
||||||
if (m_activeDbWidget->isSearchActive()) {
|
m_activeDbWidget->setSplitterSizes(m_splitterSizes);
|
||||||
restoreSearchView();
|
|
||||||
} else {
|
|
||||||
restoreListView();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_blockUpdates = false;
|
if (m_activeDbWidget->isSearchActive()) {
|
||||||
|
restoreSearchView();
|
||||||
|
} else {
|
||||||
|
restoreListView();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_blockUpdates = false;
|
||||||
|
});
|
||||||
|
|
||||||
connect(m_activeDbWidget, SIGNAL(splitterSizesChanged()), SLOT(updateSplitterSizes()));
|
connect(m_activeDbWidget, SIGNAL(splitterSizesChanged()), SLOT(updateSplitterSizes()));
|
||||||
connect(m_activeDbWidget, SIGNAL(entryViewStateChanged()), SLOT(updateViewState()));
|
connect(m_activeDbWidget, SIGNAL(entryViewStateChanged()), SLOT(updateViewState()));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user