diff --git a/src/Resources/xml/train-perspectives.xml b/src/Resources/xml/train-perspectives.xml index 66e018c1b..106ad858d 100644 --- a/src/Resources/xml/train-perspectives.xml +++ b/src/Resources/xml/train-perspectives.xml @@ -253,27 +253,6 @@ - - - - - - - - - - - - - - - - - - - - - @@ -410,4 +389,25 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Train/TrainSidebar.cpp b/src/Train/TrainSidebar.cpp index 69357e406..2fbe39089 100644 --- a/src/Train/TrainSidebar.cpp +++ b/src/Train/TrainSidebar.cpp @@ -865,6 +865,30 @@ TrainSidebar::workoutTreeWidgetSelectionChanged() // clean last if (prior) delete prior; + + // lets SWITCH PERSPECTIVE for the selected file, but only + // if everything has been initialised properly (aka lazy load) + if (trainView && trainView->page()) { + + Perspective::switchenum want=Perspective::None; + if (mediafile != "") want=Perspective::Video; // if media file selected + else want = (mode == ERG || mode == MRC) ? Perspective::Erg : Perspective::Slope; // mode always known + if (want == Perspective::Slope && ergFileQueryAdapter.hasGPS()) want=Perspective::Map; // Map without Video + + // if the current perspective allows automatic switching, + // we want a view type and the current page isn't what + // we want then lets go find one to switch to and switch + // to the first one that matches + if (trainView->page()->trainSwitch() != Perspective::None && want != Perspective::None && trainView->page()->trainSwitch() != want) { + + for(int i=0; iperspectives_.count(); i++) { + if (trainView->perspectives_[i]->trainSwitch() == want) { + context->mainWindow->switchPerspective(i); + break; + } + } + } + } } /* @@ -1595,31 +1619,6 @@ void TrainSidebar::Connect() gui_timer->start(REFRESHRATE); emit setNotification(tr("Connected.."), 2); - - // lets SWITCH PERSPECTIVE as we are connected, but only - // if everything has been initialised properly (aka lazy load) - // given the connect widget is on the train view it is unlikely - // below will ever be false, but no harm in checking - if (trainView && trainView->page()) { - - Perspective::switchenum want=Perspective::None; - if (mediafile != "") want=Perspective::Video; // if media file selected - else want = (mode == ERG || mode == MRC) ? Perspective::Erg : Perspective::Slope; // mode always known - if (want == Perspective::Slope && ergFileQueryAdapter.hasGPS()) want=Perspective::Map; // Map without Video - - // so we want a view type and the current page isn't what - // we want then lets go find one to switch to and switch - // to the first one that matches - if (want != Perspective::None && trainView->page()->trainSwitch() != want) { - - for(int i=0; iperspectives_.count(); i++) { - if (trainView->perspectives_[i]->trainSwitch() == want) { - context->mainWindow->switchPerspective(i); - break; - } - } - } - } } void TrainSidebar::Disconnect()