diff options
Diffstat (limited to 'qt-ui/mainwindow.cpp')
-rw-r--r-- | qt-ui/mainwindow.cpp | 79 |
1 files changed, 64 insertions, 15 deletions
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index a927c0231..53546fa67 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -45,9 +45,9 @@ MainWindow::MainWindow() : ui(new Ui::MainWindow()), helpView(0) connect(ui->ListWidget, SIGNAL(currentDiveChanged(int)), this, SLOT(current_dive_changed(int))); connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(readSettings())); connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui->ListWidget, SLOT(update())); + connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui->ListWidget, SLOT(reloadHeaderActions())); connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui->ProfileWidget, SLOT(refresh())); ui->mainErrorMessage->hide(); - ui->ProfileWidget->setFocusProxy(ui->ListWidget); ui->ListWidget->reload(DiveTripModel::TREE); initialUiSetup(); readSettings(); @@ -87,10 +87,27 @@ void MainWindow::on_actionNew_triggered() void MainWindow::on_actionOpen_triggered() { - QString filename = QFileDialog::getOpenFileName(this, tr("Open File"), QDir::homePath(), filter()); + QSettings settings; + QString lastDir = QDir::homePath(); + + settings.beginGroup("FileDialog"); + if (settings.contains("LastDir")) { + if(QDir::setCurrent(settings.value("LastDir").toString())) { + lastDir = settings.value("LastDir").toString(); + } + } + settings.endGroup(); + + QString filename = QFileDialog::getOpenFileName(this, tr("Open File"), lastDir, filter()); if (filename.isEmpty()) return; + // Keep last open dir + QFileInfo fileInfo(filename); + settings.beginGroup("FileDialog"); + settings.setValue("LastDir",fileInfo.dir().path()); + settings.endGroup(); + // Needed to convert to char* QByteArray fileNamePtr = filename.toLocal8Bit(); @@ -194,7 +211,15 @@ void MainWindow::on_actionEditDeviceNames_triggered() void MainWindow::on_actionAddDive_triggered() { - qDebug("actionAddDive"); + struct dive *dive; + dive = alloc_dive(); + record_dive(dive); + process_dives(FALSE, FALSE); + + ui->InfoWidget->reload(); + ui->globe->reload(); + ui->ListWidget->reload(DiveTripModel::TREE); + ui->ListWidget->setFocus(); } void MainWindow::on_actionRenumber_triggered() @@ -217,32 +242,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() @@ -382,6 +429,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"); @@ -473,6 +521,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"); |