From 66c2d3d9daab5d073dcc65d4a6279ea55ac6b6b0 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 2 Jan 2015 12:39:56 -0800 Subject: [PATCH] Set up consistent margins in the various layouts The hard coded margins were random and inconsistent and generally ended up with a rather unbalanced look. This was worse on Mac than on other platforms, as there the margins get exaggerated for some reason. This code is a bit of a hack and a bit brute force, but it seems to work to create a much more pleasing appearance. It may need some fine tuning (depending on OS or DE (under Linux)), but it definitely seems like a massive improvement. Signed-off-by: Dirk Hohndel --- qt-ui/mainwindow.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 8703fc38a..03f93a64d 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -135,6 +135,26 @@ MainWindow::MainWindow() : QMainWindow(), QLayoutItem *p = ui.gridLayout->takeAt(0); ui.gridLayout->addWidget(toolBar, 0, 0); ui.gridLayout->addItem(p, 0, 1); + + // and now for some layout hackery + // this gets us consistent margins everywhere and a much more balanced look + QMargins margins(5, 5, 5, 5); + QList dontChange; + dontChange << "notesAndSocialNetworksLayout" << ui.gridLayout->objectName(); + Q_FOREACH (QLayout *layout, findChildren()) { + // lots of internally used layouts by Qt have no names + // don't mess with those (or scroll bars look terrible, among other things + if (layout->objectName().isEmpty()) + continue; + // this allows us to exclude specific layouts where the one size fits all + // doesn't fit + if (dontChange.contains(layout->objectName())) + continue; + layout->setContentsMargins(margins); + } + margins = QMargins(0, 5, 5, 5); + ui.gridLayout->setContentsMargins(margins); + updateManager = new UpdateManager(this); }