Revert "Move QMainWindow contentMargins setting to polish"

This reverts commit 0deecb4d57. This commit
caused many regressions in regards to how the tools area handles changing
toolbars at runtime, and doesn't even properly handle most cases where there
are no changes after application initialisation, as you cannot assume the widget
tree is fully complete at ::polish time.
wilder-5.24
Jan Blackquill 5 years ago
parent 0deecb4d57
commit 27b4232257
  1. 6
      kstyle/breezestyle.cpp
  2. 13
      kstyle/breezetoolsareamanager.cpp
  3. 4
      kstyle/breezetoolsareamanager.h

@ -391,13 +391,7 @@ namespace Breeze
} else if ( qobject_cast<QMainWindow*> (widget) ) {
widget->setAttribute(Qt::WA_StyledBackground);
const QRect toolsAreaRect = _toolsAreaManager->toolsAreaRect(static_cast<QMainWindow*>(widget));
if (toolsAreaRect.height() == 0 && !(widget->property(PropertyNames::noSeparator).toBool())) {
const QMargins margins = widget->contentsMargins();
widget->setContentsMargins(margins.left(), qMax(margins.top(), 1), margins.right(), margins.bottom());
}
}
else if ( qobject_cast<QDialog*> (widget) ) {
widget->setAttribute(Qt::WA_StyledBackground);

@ -53,16 +53,25 @@ namespace Breeze {
configUpdated();
}
QRect ToolsAreaManager::toolsAreaRect(const QMainWindow *window) const
QRect ToolsAreaManager::toolsAreaRect(const QMainWindow *window)
{
Q_ASSERT(window);
int itemHeight = window->menuWidget() ? window->menuWidget()->height() : 0;
for (auto item : _windows[window]) {
for (auto item : _windows[const_cast<QMainWindow*>(window)]) {
if (!item.isNull() && item->isVisible() && window->toolBarArea(item) == Qt::TopToolBarArea) {
itemHeight = qMax(item->mapTo(window, item->rect().bottomLeft()).y(), itemHeight);
}
}
if (itemHeight == 0 && !(window->property(PropertyNames::noSeparator).toBool())) {
auto win = const_cast<QMainWindow*>(window);
win->setContentsMargins(0, 1, 0, 0);
} else {
auto win = const_cast<QMainWindow*>(window);
win->setContentsMargins(0, 0, 0, 0);
}
return QRect(0, 0, window->width(), itemHeight);
}

@ -31,7 +31,7 @@ namespace Breeze {
private:
Helper* _helper;
QHash<const QMainWindow*,QVector<QPointer<QToolBar>>> _windows;
QHash<QMainWindow*,QVector<QPointer<QToolBar>>> _windows;
KSharedConfigPtr _config;
KConfigWatcher::Ptr _watcher;
QPalette _palette = QPalette();
@ -57,7 +57,7 @@ namespace Breeze {
void registerWidget(QWidget *widget);
void unregisterWidget(QWidget *widget);
QRect toolsAreaRect(const QMainWindow *window) const;
QRect toolsAreaRect(const QMainWindow *window);
bool hasHeaderColors();
};

Loading…
Cancel
Save