Fix #635 Round 2 for Bookmarkview on Windows, should be OK now

This commit is contained in:
vsonnier 2018-03-24 08:45:50 +01:00
parent 120d394f01
commit 00a864f741
4 changed files with 26 additions and 29 deletions

View File

@ -2973,24 +2973,24 @@ void AppFrame::toggleAllActiveDemodRecording() {
auto activeDemods = wxGetApp().getDemodMgr().getDemodulators(); auto activeDemods = wxGetApp().getDemodMgr().getDemodulators();
//by default, do a false => true for all:
bool stateToSet = true; bool stateToSet = true;
for (auto i : activeDemods) { for (auto i : activeDemods) {
if (i->isActive() && i->isRecording()) { if (i->isRecording()) {
stateToSet = false; stateToSet = false;
break; break;
} }
} }
for (auto i : activeDemods) { for (auto i : activeDemods) {
if (i->isActive() && i->isRecording() != stateToSet) {
i->setRecording(stateToSet); i->setRecording(stateToSet);
}
} }
//this effectively refresh the BookmarkView buttons, including Recording buttons.
wxGetApp().getBookmarkMgr().updateActiveList();
} }
void AppFrame::setWaterfallLinesPerSecond(int lps) { void AppFrame::setWaterfallLinesPerSecond(int lps) {
waterfallSpeedMeter->setUserInputValue(sqrt(lps)); waterfallSpeedMeter->setUserInputValue(sqrt(lps));
} }

View File

@ -553,10 +553,10 @@ bool DemodulatorInstance::isRecording()
void DemodulatorInstance::setRecording(bool recording_in) void DemodulatorInstance::setRecording(bool recording_in)
{ {
if (!recording.load() && recording_in) { if (recording_in) {
startRecording(); startRecording();
} }
else if (recording.load() && !recording_in) { else {
stopRecording(); stopRecording();
} }
} }

View File

@ -190,7 +190,7 @@ void BookmarkView::onUpdateTimer( wxTimerEvent& /* event */ ) {
} }
} }
bool BookmarkView::skipUserEvents() { bool BookmarkView::skipEvents() {
return !this->IsShown() || doUpdateActive || doUpdateBookmarks; return !this->IsShown() || doUpdateActive || doUpdateBookmarks;
} }
@ -511,6 +511,9 @@ void BookmarkView::doUpdateActiveList() {
m_treeView->SelectItem(selItem); m_treeView->SelectItem(selItem);
} }
// Add an extra refresh, that rebuilds the buttons from sratch.
activeSelection(lastActiveDemodulator);
delete prevSelCopy; delete prevSelCopy;
} }
@ -543,10 +546,6 @@ void BookmarkView::onTreeActivate( wxTreeEvent& event ) {
void BookmarkView::onTreeCollapse( wxTreeEvent& event ) { void BookmarkView::onTreeCollapse( wxTreeEvent& event ) {
if (skipUserEvents()) {
return;
}
bool searchState = (searchKeywords.size() != 0); bool searchState = (searchKeywords.size() != 0);
if (searchState) { if (searchState) {
@ -577,10 +576,6 @@ void BookmarkView::onTreeCollapse( wxTreeEvent& event ) {
void BookmarkView::onTreeExpanded( wxTreeEvent& event ) { void BookmarkView::onTreeExpanded( wxTreeEvent& event ) {
if (skipUserEvents()) {
return;
}
bool searchState = (searchKeywords.size() != 0); bool searchState = (searchKeywords.size() != 0);
if (searchState) { if (searchState) {
@ -816,9 +811,12 @@ void BookmarkView::onBookmarkChoice( wxCommandEvent & /* event */ ) {
} }
} }
void BookmarkView::activeSelection(DemodulatorInstancePtr dsel) { void BookmarkView::activeSelection(DemodulatorInstancePtr dsel) {
if (dsel == nullptr) {
return;
}
m_frequencyVal->SetLabelText(frequencyToStr(dsel->getFrequency())); m_frequencyVal->SetLabelText(frequencyToStr(dsel->getFrequency()));
m_bandwidthVal->SetLabelText(frequencyToStr(dsel->getBandwidth())); m_bandwidthVal->SetLabelText(frequencyToStr(dsel->getBandwidth()));
m_modulationVal->SetLabelText(dsel->getDemodulatorType()); m_modulationVal->SetLabelText(dsel->getDemodulatorType());
@ -1074,6 +1072,10 @@ void BookmarkView::activeBranchSelection() {
void BookmarkView::onTreeSelect( wxTreeEvent& event ) { void BookmarkView::onTreeSelect( wxTreeEvent& event ) {
if (skipEvents()) {
return;
}
wxTreeItemId itm = event.GetItem(); wxTreeItemId itm = event.GetItem();
TreeViewItem* tvi = dynamic_cast<TreeViewItem*>(m_treeView->GetItemData(itm)); TreeViewItem* tvi = dynamic_cast<TreeViewItem*>(m_treeView->GetItemData(itm));
@ -1119,10 +1121,6 @@ void BookmarkView::onTreeSelect( wxTreeEvent& event ) {
void BookmarkView::onTreeSelectChanging( wxTreeEvent& event ) { void BookmarkView::onTreeSelectChanging( wxTreeEvent& event ) {
if (skipUserEvents()) {
return;
}
event.Skip(); event.Skip();
} }
@ -1203,6 +1201,7 @@ void BookmarkView::onStartRecording( wxCommandEvent& /* event */ ) {
if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) { if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) {
if (!curSel->demod->isRecording() && wxGetApp().getConfig()->verifyRecordingPath()) { if (!curSel->demod->isRecording() && wxGetApp().getConfig()->verifyRecordingPath()) {
curSel->demod->setRecording(true); curSel->demod->setRecording(true);
wxGetApp().getBookmarkMgr().updateActiveList(); wxGetApp().getBookmarkMgr().updateActiveList();
} }
} }
@ -1216,6 +1215,7 @@ void BookmarkView::onStopRecording( wxCommandEvent& /* event */ ) {
if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) { if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) {
if (curSel->demod->isRecording()) { if (curSel->demod->isRecording()) {
curSel->demod->setRecording(false); curSel->demod->setRecording(false);
wxGetApp().getBookmarkMgr().updateActiveList(); wxGetApp().getBookmarkMgr().updateActiveList();
} }
} }
@ -1482,10 +1482,6 @@ void BookmarkView::onTreeEndDrag( wxTreeEvent& event ) {
void BookmarkView::onTreeItemGetTooltip( wxTreeEvent& event ) { void BookmarkView::onTreeItemGetTooltip( wxTreeEvent& event ) {
if (skipUserEvents()) {
return;
}
event.Skip(); event.Skip();
} }

View File

@ -162,7 +162,7 @@ protected:
void onActivateRange( wxCommandEvent& event ); void onActivateRange( wxCommandEvent& event );
void onUpdateRange( wxCommandEvent& event ); void onUpdateRange( wxCommandEvent& event );
bool skipUserEvents(); bool skipEvents();
TreeViewItem *itemToTVI(wxTreeItemId item); TreeViewItem *itemToTVI(wxTreeItemId item);
@ -201,4 +201,5 @@ protected:
std::vector<std::wstring> searchKeywords; std::vector<std::wstring> searchKeywords;
void setStatusText(std::string statusText); void setStatusText(std::string statusText);
}; };