Commit f2c5e10d authored by Harald Sitter's avatar Harald Sitter 🌹
Browse files

adjust smb kcm size to be sufficient vis a vis headers

Summary:
we use Stretch to get a somewhat uniform appearance between the two views
but Stretch is bit meh when it comes to actual sizing as it acts kind of
like QSizePolicy::Preferred in that it allows shrinking columns so small
that even the header gets cut off. this of course looks silly, so we
now set the largest required width as minimal section width. this prevents
the user from cutting off headers by resizing the window.

secondly, and entirely related to that, because KCMs are embedded into
a scrollview their sizehint kinda doesn't make any difference for
the window size which then combined with the aforementioned stretch problem
can lead to cut off headers by default as the window size is too small
making the stretch cut into header text.
to ensure the default size is reasonable let the view adjust to content
on first show, effectively making the window as large as needed
regardless of implicit hints.

BUG: 419786
FIXED-IN: 5.18.5

Test Plan:
- empty dialog
- dialog with only shares
- dialog with shares and mounts

Reviewers: ngraham

Reviewed By: ngraham

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D28678
parent a20ea703
......@@ -71,6 +71,25 @@ QTableView *SambaContainer::addTableView(const QString &localizedLabel, QAbstrac
auto view = new QTableView(this);
layout()->addWidget(view);
view->setModel(model);
// Stretching is a bit awkward because it allows resizing below the sizeHint of
// the header, effectively cutting off the text. This is made worse by kcmshell
// which rather unfortunately stacks scrollviews so size hinting is lost along
// the way allowing the actual window to be (even by default) smaller than
// what our preferred hint is. To mitigate this problem we manually make
// the sizeHint's width the minimal size. This is kind of like QSizePolicy::Minimum.
// https://bugs.kde.org/show_bug.cgi?id=419786
int maxSectionRequirement = 0;
for (auto i = 0; i < view->model()->columnCount(); ++i) {
const int hint = view->horizontalHeader()->sectionSizeHint(i);
maxSectionRequirement = qMax<int>(maxSectionRequirement, hint);
}
view->horizontalHeader()->setMinimumSectionSize(maxSectionRequirement);
// Combined with the minimum section size this makes sure the default size will
// be minimal sufficient regardless of parent sizing policies and model content
// i.e. an empty view will still have fine spacing for header text.
view->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContentsOnFirstShow);
view->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
view->horizontalHeader()->reset();
view->horizontalHeader()->setVisible(true);
......
Markdown is supported
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