diff options
Diffstat (limited to 'qt-ui/maintab.cpp')
-rw-r--r-- | qt-ui/maintab.cpp | 59 |
1 files changed, 44 insertions, 15 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index dad1e8ec6..81c8a0724 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -108,6 +108,27 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), ui.scrollArea_2->viewport()->setPalette(p); ui.scrollArea_3->viewport()->setPalette(p); ui.scrollArea_4->viewport()->setPalette(p); + + // GroupBoxes in Gnome3 looks like I'v drawn them... + static const QString gnomeCss( + "QGroupBox {" + " background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1," + " stop: 0 #E0E0E0, stop: 1 #FFFFFF);" + " border: 2px solid gray;" + " border-radius: 5px;" + " margin-top: 1ex;" + "}" + "QGroupBox::title {" + " subcontrol-origin: margin;" + " subcontrol-position: top center;" + " padding: 0 3px;" + " background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1," + " stop: 0 #0E0E0, stop: 1 #FFFFFF);" + "}"); + Q_FOREACH(QGroupBox *box, findChildren<QGroupBox*>()){ + box->setStyleSheet(gnomeCss); + } + } ui.cylinders->view()->horizontalHeader()->setContextMenuPolicy(Qt::ActionsContextMenu); @@ -602,11 +623,6 @@ void MainTab::acceptChanges() else if (selected_dive == dive_table.nr - 1 && get_dive(dive_table.nr - 2)->number) current_dive->number = get_dive(dive_table.nr - 2)->number + 1; DivePlannerPointsModel::instance()->cancelPlan(); - // now make sure the selection logic is in a sane state - // it's ok to hold on to the dive pointer for this short stretch of code - // unselectDives() doesn't mess with the dive_table at all - mainWindow()->dive_list()->unselectDives(); - mainWindow()->dive_list()->selectDive(selected_dive, true, true); mainWindow()->showProfile(); mark_divelist_changed(TRUE); DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::NOTHING); @@ -614,19 +630,32 @@ void MainTab::acceptChanges() // each dive that was selected might have had the temperatures in its active divecomputer changed // so re-populate the temperatures - easiest way to do this is by calling fixup_dive Q_FOREACH(dive *d, notesBackup.keys()) { - fixup_dive(d); + if (d) + fixup_dive(d); } - editMode = NONE; - resetPallete(); - // now comes the scary moment... we need to re-sort dive table in case this dive wasn't the last - // so now all pointers become invalid - // fingers crossed that we aren't holding on to anything here - mainWindow()->dive_list()->rememberSelection(); - sort_table(&dive_table); - mainWindow()->refreshDisplay(); - mainWindow()->dive_list()->restoreSelection(); + if(editMode == ADD || editMode == MANUALLY_ADDED_DIVE){ + mainWindow()->dive_list()->unselectDives(); + struct dive *d = get_dive(dive_table.nr -1 ); + // HACK. this shouldn't be here. but apparently it's + // how we can know what was the newly added dive. + d->selected = true; + sort_table(&dive_table); + int i = 0; + for_each_dive(i,d){ + if (d->selected) break; + } + editMode = NONE; + mainWindow()->refreshDisplay(); + mainWindow()->dive_list()->selectDive( i, true ); + }else{ + editMode = NONE; + mainWindow()->dive_list()->rememberSelection(); + sort_table(&dive_table); + mainWindow()->refreshDisplay(); + mainWindow()->dive_list()->restoreSelection(); + } } void MainTab::resetPallete() |