Commit 26b39137 authored by Corbin Schwimmbeck's avatar Corbin Schwimmbeck Committed by Nate Graham
Browse files

Add a splitter to the information sidebar

In Gwenview, the information page of the sidebar consists of two halves: an upper section displaying varying amounts of image details,
and a lower section displaying a rating, tags, and description.
Due to the expanding nature of the description's plain text edit, it takes up half of the sidebar by default, and is usually completely empty.
This additional space could be better used to show more image details, as requested in this bug report:

BUG: 459478

So, I have added a splitter, allowing you to move the previously-static central divider, 
and made sure that Gwenview remembers its position between sessions.

By default, the appearance of the sidebar looks identical to how it did before this patch.

Below are two screenshots, one of the splitter moved to its highest, and another at its lowest position.

![split_high](/uploads/1996ac1cd5be7d22cee2dacd6ca8ce7c/split_high.png)

![split_low](/uploads/a040f1d115efab6d7bc6a2f3b1489dc6/split_low.png)
parent 3f5e63b9
Pipeline #252722 passed with stage
in 2 minutes and 4 seconds
......@@ -632,15 +632,40 @@ struct MainWindow::Private {
page = new SideBarPage(QIcon::fromTheme(QStringLiteral("documentinfo")), i18n("Information"));
page->setObjectName(QStringLiteral("information"));
page->addWidget(infoItem->widget());
#ifndef GWENVIEW_SEMANTICINFO_BACKEND_NONE
// If we have semantic info, we want to share the sidebar using a splitter,
// so the user can dynamically resize the two widgets.
if (semanticInfoItem) {
auto splitter = new QSplitter;
splitter->setObjectName(QStringLiteral("information_splitter")); // This name is used to find it when loading previous sizes.
splitter->setOrientation(Qt::Vertical);
splitter->setHandleWidth(5);
splitter->addWidget(infoItem->widget());
splitter->setCollapsible(0, false);
// Cram the semantic info widget and a separator into a separate widget,
// so that they can be added to the splitter together (layouts can't be added directly).
// This will give the splitter a visible separator between the two widgets.
auto separator = new QFrame;
separator->setFrameShape(QFrame::HLine);
separator->setLineWidth(1);
page->addWidget(separator);
page->addWidget(semanticInfoItem->widget());
auto container = new QWidget;
auto containerLayout = new QVBoxLayout(container);
containerLayout->setContentsMargins(0, 0, 0, 0);
containerLayout->addWidget(separator);
containerLayout->addWidget(semanticInfoItem->widget());
splitter->addWidget(container);
splitter->setCollapsible(1, false);
page->addWidget(splitter);
} else {
page->addWidget(infoItem->widget());
}
#else
page->addWidget(infoItem->widget());
#endif
mSideBar->addPage(page);
......@@ -863,6 +888,30 @@ struct MainWindow::Private {
}
}
void loadInformationSplitterConfig()
{
const QList<int> sizes = GwenviewConfig::informationSplitterSizes();
if (!sizes.isEmpty()) {
// Find the splitter inside the sidebar by objectName.
auto informationSidebar = mSideBar->findChild<QSplitter *>(QStringLiteral("information_splitter"), Qt::FindChildrenRecursively);
if (informationSidebar) {
informationSidebar->setSizes(sizes);
} else {
qCWarning(GWENVIEW_APP_LOG) << "Could not find information splitter in sidebar when loading old position.";
}
}
}
void saveInformationSplitterConfig()
{
auto informationSidebar = mSideBar->findChild<QSplitter *>(QStringLiteral("information_splitter"), Qt::FindChildrenRecursively);
if (informationSidebar) {
GwenviewConfig::setInformationSplitterSizes(informationSidebar->sizes());
} else {
qCWarning(GWENVIEW_APP_LOG) << "Could not find information splitter in sidebar when saving new position.";
}
}
void setScreenSaverEnabled(bool enabled)
{
// Always delete mNotificationRestrictions, it does not hurt
......@@ -1791,6 +1840,7 @@ void MainWindow::loadConfig()
d->mContextManager->loadConfig();
d->mSideBar->loadConfig();
d->loadSplitterConfig();
d->loadInformationSplitterConfig();
}
void MainWindow::saveConfig()
......@@ -1800,6 +1850,7 @@ void MainWindow::saveConfig()
d->mBrowseMainPage->saveConfig();
d->mContextManager->saveConfig();
d->saveSplitterConfig();
d->saveInformationSplitterConfig();
GwenviewConfig::setFullScreenModeActive(isFullScreen());
// Save the last used version when Gwenview closes so we know which settings/features the user
// is aware of which is needed for migration. The version format is: two digits each for
......
......@@ -30,6 +30,9 @@
<entry name="SideBarSplitterSizes" type="IntList">
</entry>
<entry name="InformationSplitterSizes" type="IntList">
</entry>
</group>
<group name="General">
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment