Commit fc90aca6 authored by Janet Blackquill's avatar Janet Blackquill 🌈
Browse files

Revert "Move QMainWindow contentMargins setting to polish"

This reverts commit 6d3f235f. 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.
parent 6d3f235f
......@@ -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();
};
......
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