As I'm sure many have noticed, when Tomaz implemented the new logic for
positioning different widgets on the screen, the vertical toolbar next to
the profile got lost.

So I thought to myself "how hard can it be to fix that?".

Apparently plenty hard.

I have something incredibly hackish that doesn't get the desired result
but gets "something" that allows you (with some fiddling) to get about the
right layout. But it definitely isn't what we want. For one thing, there
are two handles (one on either side of the toolbar) and moving them around
one can create useless empty space around the toolbar. Yuck.

I'm mostly posting this to provoke Tomaz or someone else with better Qt
skills to simply fix things :-)

/D


From 6fc18baf6dfdd8755fc953294092719ac973838a Mon Sep 17 00:00:00 2001
From: Dirk Hohndel <[email protected]>
Date: Sun, 15 Feb 2015 20:59:47 -0800
Subject: [PATCH] Non working fix to show the toolbar again

Having splitters on both sides of the toolbar and being able to create
emptry space around the toolbar is not workable...

Signed-off-by: Dirk Hohndel <[email protected]>
---
 qt-ui/mainwindow.cpp | 53 +++++++++++++++++++++++++---------------------------
 qt-ui/mainwindow.h   |  7 ++++---
 qt-ui/mainwindow.ui  |  4 ++++
 3 files changed, 33 insertions(+), 31 deletions(-)

diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index d7f520f18cc7..4b7e2b67a906 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -69,16 +69,6 @@ MainWindow::MainWindow() : QMainWindow(),
        PlannerDetails *plannerDetails = new PlannerDetails();
        LocationInformationWidget *locationInformation = new 
LocationInformationWidget();
 
-       registerApplicationState("Default", mainTab, profileWidget, 
diveListView, globeGps );
-       registerApplicationState("AddDive", mainTab, profileWidget, 
diveListView, globeGps );
-       registerApplicationState("EditDive", mainTab, profileWidget, 
diveListView, globeGps );
-       registerApplicationState("PlanDive", plannerWidget, profileWidget, 
plannerSettings, plannerDetails );
-       registerApplicationState("EditPlannedDive", plannerWidget, 
profileWidget, diveListView, globeGps );
-       registerApplicationState("EditDiveSite",locationInformation, 
profileWidget, diveListView, globeGps );
-
-       setApplicationState("Default");
-
-       ui.multiFilter->hide();
        // what is a sane order for those icons? we should have the ones the 
user is
        // most likely to want towards the top so they are always visible
        // and the ones that someone likely sets and then never touches again 
towards the bottom
@@ -91,6 +81,22 @@ MainWindow::MainWindow() : QMainWindow(),
                                 ui.profEad << ui.profSAC <<
                                 ui.profHR << // very few dive computers 
support this
                                 ui.profTissues; // maybe less frequently used
+       QToolBar *toolBar = new QToolBar();
+       Q_FOREACH (QAction *a, profileToolbarActions)
+               toolBar->addAction(a);
+       toolBar->setOrientation(Qt::Vertical);
+       toolBar->setIconSize(QSize(24,24));
+       registerApplicationState("Default", mainTab, profileWidget, 
diveListView, globeGps, toolBar );
+       registerApplicationState("AddDive", mainTab, profileWidget, 
diveListView, globeGps );
+       registerApplicationState("EditDive", mainTab, profileWidget, 
diveListView, globeGps );
+       registerApplicationState("PlanDive", plannerWidget, profileWidget, 
plannerSettings, plannerDetails );
+       registerApplicationState("EditPlannedDive", plannerWidget, 
profileWidget, diveListView, globeGps );
+       registerApplicationState("EditDiveSite",locationInformation, 
profileWidget, diveListView, globeGps );
+
+       setApplicationState("Default");
+
+       ui.multiFilter->hide();
+
        setWindowIcon(QIcon(":subsurface-icon"));
        if (!QIcon::hasThemeIcon("window-close")) {
                QIcon::setThemeName("subsurface");
@@ -144,22 +150,6 @@ MainWindow::MainWindow() : QMainWindow(),
        memset(&copyPasteDive, 0, sizeof(copyPasteDive));
        memset(&what, 0, sizeof(what));
 
-       QToolBar *toolBar = new QToolBar();
-       Q_FOREACH (QAction *a, profileToolbarActions)
-               toolBar->addAction(a);
-       toolBar->setOrientation(Qt::Vertical);
-       toolBar->setIconSize(QSize(24,24));
-       // since I'm adding the toolBar by hand, because designer
-       // has no concept of "toolbar" for a non-mainwindow widget (...)
-       // I need to take the current item that's in the toolbar Position
-       // and reposition it alongside the grid layout.
-       // TODO: FIX THIS
-       // QLayoutItem *p = ui.profileInnerLayout->takeAt(0);
-       // ui.profileInnerLayout->addWidget(toolBar, 0, 0);
-       // ui.profileInnerLayout->addItem(p, 0, 1);
-       // ui.profileInnerLayout->setContentsMargins(QMargins(0, 5, 5, 5));
-       // ui.profileInnerLayout->setSpacing(0);
-
        // and now for some layout hackery
        // this gets us consistent margins everywhere and a much more balanced 
look
        QMargins margins(5, 5, 5, 5);
@@ -743,8 +733,11 @@ void MainWindow::on_actionViewAll_triggered()
                
ui.bottomSplitter->restoreState(settings.value("bottomSplitter").toByteArray());
                if (ui.mainSplitter->sizes().first() == 0 || 
ui.mainSplitter->sizes().last() == 0)
                        ui.mainSplitter->setSizes(mainSizes);
+               qDebug() << ui.topSplitter->sizes();
                if (ui.topSplitter->sizes().first() == 0 || 
ui.topSplitter->sizes().last() == 0)
                        ui.topSplitter->setSizes(infoProfileSizes);
+               if (ui.topSplitter->sizes().at(2) != 24)
+                       ui.topSplitter->setSizes(QList<int>() << 1000 << 26 << 
1000);
                if (ui.bottomSplitter->sizes().first() == 0 || 
ui.bottomSplitter->sizes().last() == 0)
                        ui.bottomSplitter->setSizes(listGlobeSizes);
 
@@ -1525,12 +1518,15 @@ void MainWindow::on_actionFilterTags_triggered()
                ui.multiFilter->setVisible(true);
 }
 
-void MainWindow::registerApplicationState(const QByteArray& state, QWidget 
*topLeft, QWidget *topRight, QWidget *bottomLeft, QWidget *bottomRight)
+void MainWindow::registerApplicationState(const QByteArray& state, QWidget 
*topLeft, QWidget *topRight, QWidget *bottomLeft, QWidget *bottomRight, QWidget 
*toolBar)
 {
-       applicationState[state] = WidgetForQuadrant(topLeft, topRight, 
bottomLeft, bottomRight);
+       applicationState[state] = WidgetForQuadrant(topLeft, toolBar, topRight, 
bottomLeft, bottomRight);
        if (ui.topLeft->indexOf(topLeft) == -1 && topLeft) {
                ui.topLeft->addWidget(topLeft);
        }
+       if (ui.toolBar->indexOf(toolBar) == -1 && toolBar) {
+               ui.toolBar->addWidget(toolBar);
+       }
        if (ui.topRight->indexOf(topRight) == -1 && topRight) {
                ui.topRight->addWidget(topRight);
        }
@@ -1559,6 +1555,7 @@ void MainWindow::setApplicationState(const QByteArray& 
state) {
        }
 
        SET_CURRENT_INDEX( topLeft )
+       SET_CURRENT_INDEX( toolBar )
        SET_CURRENT_INDEX( topRight )
        SET_CURRENT_INDEX( bottomLeft )
        SET_CURRENT_INDEX( bottomRight )
diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h
index 85a63123bb32..bdfbcb9dff47 100644
--- a/qt-ui/mainwindow.h
+++ b/qt-ui/mainwindow.h
@@ -196,7 +196,7 @@ private:
        void saveSplitterSizes();
        QString lastUsedDir();
        void updateLastUsedDir(const QString &s);
-       void registerApplicationState(const QByteArray& state, QWidget 
*topLeft, QWidget *topRight, QWidget *bottomLeft, QWidget *bottomRight);
+       void registerApplicationState(const QByteArray& state, QWidget 
*topLeft, QWidget *topRight, QWidget *bottomLeft, QWidget *bottomRight, QWidget 
*toolBar = NULL);
        bool filesAsArguments;
        UpdateManager *updateManager;
 
@@ -208,9 +208,10 @@ private:
        QList<QAction *> profileToolbarActions;
 
        struct WidgetForQuadrant {
-               WidgetForQuadrant(QWidget *tl = 0, QWidget *tr = 0, QWidget *bl 
= 0, QWidget *br = 0) :
-                       topLeft(tl), topRight(tr), bottomLeft(bl), 
bottomRight(br) {}
+               WidgetForQuadrant(QWidget *tl = 0, QWidget *tc = 0, QWidget *tr 
= 0, QWidget *bl = 0, QWidget *br = 0) :
+                       topLeft(tl), toolBar(tc), topRight(tr), bottomLeft(bl), 
bottomRight(br) {}
                QWidget *topLeft;
+               QWidget *toolBar;
                QWidget *topRight;
                QWidget *bottomLeft;
                QWidget *bottomRight;
diff --git a/qt-ui/mainwindow.ui b/qt-ui/mainwindow.ui
index b6cd4a358e43..f85a08c9acdf 100644
--- a/qt-ui/mainwindow.ui
+++ b/qt-ui/mainwindow.ui
@@ -27,7 +27,11 @@
        <property name="orientation">
         <enum>Qt::Horizontal</enum>
        </property>
+       <property name="childrenCollapsible">
+        <bool>false</bool>
+       </property>
        <widget class="QStackedWidget" name="topLeft"/>
+       <widget class="QStackedWidget" name="toolBar"/>
        <widget class="QStackedWidget" name="topRight"/>
       </widget>
       <widget class="QSplitter" name="bottomSplitter">
-- 
1.8.0.rc0.18.gf84667d

_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to