diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2013-06-12 15:54:55 -0300 |
---|---|---|
committer | Tomaz Canabrava <tcanabrava@kde.org> | 2013-06-12 15:54:55 -0300 |
commit | 7e9d6e28297432d4a15721a49a9dd0c0d067ce7e (patch) | |
tree | 40c5702060c1e5d5169d4473d5bb2911778d2f28 | |
parent | 9993d4996659b2d6c07f283895acb6409012ea9c (diff) | |
download | subsurface-7e9d6e28297432d4a15721a49a9dd0c0d067ce7e.tar.gz |
Fixed the show / hide dialog shortcuts to take the splitter into consideration
Fixed the show / hide dialog shortcuts to take the splitter into consideration,
So, here's the deal.
We have a few QSplitters that takes care of helping us with the
size of a few widgets, they are ok, and we should continue using them
to manage the visibility of them too. But the way that we did before was to
widget->hide(); something, and if you hided something using the splitter,
by holding it's handle and collapsing the widget, then you used the 'ctrl+number'
shortcut to show it, it whould only show a gray panel.
This patch makes everything behave using the splitters.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
-rw-r--r-- | qt-ui/mainwindow.cpp | 48 | ||||
-rw-r--r-- | qt-ui/mainwindow.h | 6 | ||||
-rw-r--r-- | qt-ui/mainwindow.ui | 18 |
3 files changed, 55 insertions, 17 deletions
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index ce9aadc62..eb7febed7 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -232,32 +232,54 @@ void MainWindow::on_actionYearlyStatistics_triggered() qDebug("actionYearlyStatistics"); } +/** + * So, here's the deal. + * We have a few QSplitters that takes care of helping us with the + * size of a few widgets, they are ok, and we should continue using them + * to manage the visibility of them too. But the way that we did before was to + * widget->hide(); something, and if you hided something using the splitter, + * by holding it's handle and collapsing the widget, then you used the 'ctrl+number' + * shortcut to show it, it whould only show a gray panel. + * + * This patch makes everything behave using the splitters. + */ + +#define BEHAVIOR QList<int>() void MainWindow::on_actionViewList_triggered() { - ui->InfoWidget->setVisible(false); - ui->ListWidget->setVisible(true); - ui->ProfileWidget->setVisible(false); + ui->listGlobeSplitter->setSizes( BEHAVIOR << EXPANDED << COLLAPSED); + ui->mainSplitter->setSizes( BEHAVIOR << COLLAPSED << EXPANDED); } void MainWindow::on_actionViewProfile_triggered() { - ui->InfoWidget->setVisible(false); - ui->ListWidget->setVisible(false); - ui->ProfileWidget->setVisible(true); + ui->infoProfileSplitter->setSizes(BEHAVIOR << COLLAPSED << EXPANDED); + ui->mainSplitter->setSizes( BEHAVIOR << EXPANDED << COLLAPSED); } void MainWindow::on_actionViewInfo_triggered() { - ui->InfoWidget->setVisible(true); - ui->ListWidget->setVisible(false); - ui->ProfileWidget->setVisible(false); + ui->infoProfileSplitter->setSizes(BEHAVIOR << EXPANDED << COLLAPSED); + ui->mainSplitter->setSizes( BEHAVIOR << EXPANDED << COLLAPSED); +} + +void MainWindow::on_actionViewGlobe_triggered() +{ + ui->infoProfileSplitter->setSizes(BEHAVIOR << COLLAPSED << EXPANDED); + ui->mainSplitter->setSizes( BEHAVIOR << COLLAPSED << EXPANDED); } +#undef BEHAVIOR void MainWindow::on_actionViewAll_triggered() { - ui->InfoWidget->setVisible(true); - ui->ListWidget->setVisible(true); - ui->ProfileWidget->setVisible(true); + // big number squash the info profile to it's minimum. + ui->infoProfileSplitter->setSizes(QList<int>() << 1 << 20000); + + // big number squash the globe view. + ui->listGlobeSplitter->setSizes(QList<int>() << 2000 << 1 ); + + // half and half? + ui->mainSplitter->setSizes( QList<int>() << 1 << 1); } void MainWindow::on_actionPreviousDC_triggered() @@ -397,6 +419,7 @@ void MainWindow::initialUiSetup() resize(sz); ui->mainSplitter->restoreState(settings.value("mainSplitter").toByteArray()); ui->infoProfileSplitter->restoreState(settings.value("infoProfileSplitter").toByteArray()); + ui->listGlobeSplitter->restoreState(settings.value("listGlobeSplitter").toByteArray()); settings.endGroup(); settings.beginGroup("ListWidget"); @@ -488,6 +511,7 @@ void MainWindow::writeSettings() settings.setValue("size",size()); settings.setValue("mainSplitter", ui->mainSplitter->saveState()); settings.setValue("infoProfileSplitter", ui->infoProfileSplitter->saveState()); + settings.setValue("listGlobeSplitter", ui->listGlobeSplitter->saveState()); settings.endGroup(); settings.beginGroup("ListWidget"); diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h index f3024ef8d..0b3812469 100644 --- a/qt-ui/mainwindow.h +++ b/qt-ui/mainwindow.h @@ -8,13 +8,13 @@ #define MAINWINDOW_H #include <QMainWindow> -#include <QModelIndex> #include <QAction> struct DiveList; class QSortFilterProxyModel; class DiveTripModel; + namespace Ui { class MainWindow; @@ -35,6 +35,8 @@ class MainWindow : public QMainWindow { Q_OBJECT public: + enum {COLLAPSED, EXPANDED}; + MainWindow(); ProfileGraphicsView *graphics(); MainTab *information(); @@ -71,6 +73,7 @@ private Q_SLOTS: void on_actionViewList_triggered(); void on_actionViewProfile_triggered(); void on_actionViewInfo_triggered(); + void on_actionViewGlobe_triggered(); void on_actionViewAll_triggered(); void on_actionPreviousDC_triggered(); void on_actionNextDC_triggered(); @@ -102,6 +105,7 @@ private: void redrawProfile(); void file_save(); void file_save_as(); + void setupSplitters(); }; MainWindow *mainWindow(); diff --git a/qt-ui/mainwindow.ui b/qt-ui/mainwindow.ui index fbf10cdf8..598068e3d 100644 --- a/qt-ui/mainwindow.ui +++ b/qt-ui/mainwindow.ui @@ -14,8 +14,8 @@ <string>MainWindow</string> </property> <widget class="QWidget" name="centralwidget"> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> <widget class="QSplitter" name="mainSplitter"> <property name="orientation"> <enum>Qt::Vertical</enum> @@ -92,7 +92,7 @@ </widget> </widget> </item> - <item> + <item row="1" column="0"> <widget class="KMessageWidget" name="mainErrorMessage" native="true"/> </item> </layout> @@ -147,7 +147,9 @@ <addaction name="actionViewList"/> <addaction name="actionViewProfile"/> <addaction name="actionViewInfo"/> + <addaction name="actionViewGlobe"/> <addaction name="actionViewAll"/> + <addaction name="separator"/> <addaction name="actionPreviousDC"/> <addaction name="actionNextDC"/> </widget> @@ -323,7 +325,7 @@ <string>View All</string> </property> <property name="shortcut"> - <string>Ctrl+4</string> + <string>Ctrl+5</string> </property> </action> <action name="actionPreviousDC"> @@ -365,6 +367,14 @@ <string>F1</string> </property> </action> + <action name="actionViewGlobe"> + <property name="text"> + <string>View Globe</string> + </property> + <property name="shortcut"> + <string>Ctrl+4</string> + </property> + </action> </widget> <customwidgets> <customwidget> |