Layout issues: Remove auto layout management from mainwindow.cpp

While this worked for a bit, it was very error prone as it relied in
layout having specific names, and layouts in the .ui files are treated as
substandard items. Every time a 'break layout' command is issues (and it's
issued quite a lot when trying to reorganize the items on the widget) all
layout items are removed and new ones are added later, without any of the
names.

Since the new layout can be different the old names are not usefull
anymore - and a clean compilation won't trigger a single warning either:
the name resolution is done at runtime and not at compile time, so it
would just fail silently.

Instead of brute-forcing each layout to have 0,0 or 5,5 margins, we should
put the correct values on the .ui files.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2015-05-25 13:58:48 -03:00 committed by Dirk Hohndel
parent 0fdb87b011
commit 7d1df992fa

View file

@ -163,36 +163,7 @@ MainWindow::MainWindow() : QMainWindow(),
memset(&copyPasteDive, 0, sizeof(copyPasteDive));
memset(&what, 0, sizeof(what));
// and now for some layout hackery
// this gets us consistent margins everywhere and a much more balanced look
QMargins margins(5, 5, 5, 5);
QMargins zeroMargins(0, 0, 0, 0);
QList<QString> noMarginList;
noMarginList << "notesAndSocialNetworksLayout" <<
"coordinatesDiveTypeLayout" <<
"mainTabOuterLayout" <<
"ratingVisibilityWidgets" <<
"temperatureLabels" <<
"airWaterTempLayout" <<
"fullWindowLayout" <<
"profileOuterLayout";
Q_FOREACH (QLayout *layout, findChildren<QLayout *>()) {
// 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 (noMarginList.contains(layout->objectName()))
layout->setContentsMargins(zeroMargins);
else
layout->setContentsMargins(margins);
}
toolBar->setContentsMargins(zeroMargins);
updateManager = new UpdateManager(this);
undoStack = new QUndoStack(this);
QAction *undoAction = undoStack->createUndoAction(this, tr("&Undo"));
QAction *redoAction = undoStack->createRedoAction(this, tr("&Redo"));