From 7d1df992fae41241266dc068cefb1f2c2670c745 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Mon, 25 May 2015 13:58:48 -0300 Subject: 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 Signed-off-by: Dirk Hohndel --- qt-ui/mainwindow.cpp | 29 ----------------------------- 1 file changed, 29 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 1e3a89dbc..3ba79ef94 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -163,36 +163,7 @@ MainWindow::MainWindow() : QMainWindow(), memset(©PasteDive, 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 noMarginList; - noMarginList << "notesAndSocialNetworksLayout" << - "coordinatesDiveTypeLayout" << - "mainTabOuterLayout" << - "ratingVisibilityWidgets" << - "temperatureLabels" << - "airWaterTempLayout" << - "fullWindowLayout" << - "profileOuterLayout"; - 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 (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")); -- cgit v1.2.3-70-g09d2