Skip to content

Commit

Permalink
Show/Hide bookmarks option in display menu
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcliffe committed Dec 27, 2016
1 parent 1ec92e0 commit 79c8c41
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 2 deletions.
16 changes: 16 additions & 0 deletions src/AppConfig.cpp
Expand Up @@ -293,6 +293,7 @@ AppConfig::AppConfig() : configName("") {
mainSplit = -1;
visSplit = -1;
bookmarkSplit = -1;
bookmarksVisible.store(true);

#ifdef USE_HAMLIB
rigEnabled.store(false);
Expand Down Expand Up @@ -469,6 +470,14 @@ float AppConfig::getBookmarkSplit() {
return bookmarkSplit.load();
}

void AppConfig::setBookmarksVisible(bool state) {
bookmarksVisible.store(state);
}

bool AppConfig::getBookmarksVisible() {
return bookmarksVisible.load();
}


void AppConfig::setConfigName(std::string configName) {
this->configName = configName;
Expand Down Expand Up @@ -520,6 +529,7 @@ bool AppConfig::save() {
*window_node->newChild("main_split") = mainSplit.load();
*window_node->newChild("vis_split") = visSplit.load();
*window_node->newChild("bookmark_split") = bookmarkSplit.load();
*window_node->newChild("bookmark_visible") = bookmarksVisible.load();
}

DataNode *devices_node = cfg.rootNode()->newChild("devices");
Expand Down Expand Up @@ -695,6 +705,12 @@ bool AppConfig::load() {
win_node->getNext("bookmark_split")->element()->get(gVal);
bookmarkSplit.store(gVal);
}

if (win_node->hasAnother("bookmark_visible")) {
int bVal;
win_node->getNext("bookmark_visible")->element()->get(bVal);
bookmarksVisible.store(bVal);
}
}

if (cfg.rootNode()->hasAnother("devices")) {
Expand Down
5 changes: 4 additions & 1 deletion src/AppConfig.h
Expand Up @@ -127,6 +127,9 @@ class AppConfig {
void setBookmarkSplit(float value);
float getBookmarkSplit();

void setBookmarksVisible(bool state);
bool getBookmarksVisible();


#if USE_HAMLIB
int getRigModel();
Expand Down Expand Up @@ -176,6 +179,6 @@ class AppConfig {
#if USE_HAMLIB
std::atomic_int rigModel, rigRate;
std::string rigPort;
std::atomic_bool rigEnabled, rigFollowMode, rigControlMode, rigCenterLock, rigFollowModem;
std::atomic_bool rigEnabled, rigFollowMode, rigControlMode, rigCenterLock, rigFollowModem, bookmarksVisible;
#endif
};
22 changes: 21 additions & 1 deletion src/AppFrame.cpp
Expand Up @@ -364,6 +364,11 @@ AppFrame::AppFrame() :

bookmarkSplitter->SplitVertically( bookmarkView, mainVisSplitter );
mainSplitter->SplitHorizontally( demodPanel, bookmarkSplitter );

if (!wxGetApp().getConfig()->getBookmarksVisible()) {
bookmarkSplitter->Unsplit(bookmarkView);
bookmarkSplitter->Layout();
}

vbox->Add(mainSplitter, 1, wxEXPAND | wxALL, 0);

Expand Down Expand Up @@ -523,6 +528,9 @@ AppFrame::AppFrame() :
themeMenu->AppendRadioItem(wxID_THEME_HD, "HD")->Check(themeId==COLOR_THEME_HD);

displayMenu->AppendSubMenu(themeMenu, wxT("&Color Scheme"));

hideBookmarksItem = displayMenu->AppendCheckItem(wxID_DISPLAY_BOOKMARKS, wxT("Hide Bookmarks"));
hideBookmarksItem->Check(!wxGetApp().getConfig()->getBookmarksVisible());

GLFont::setScale((GLFont::GLFontScale)fontScale);

Expand Down Expand Up @@ -1012,6 +1020,9 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
demodTuner->Refresh();
SetTitle(CUBICSDR_TITLE);
currentSessionFile = "";
bookmarkSplitter->Unsplit(bookmarkView);
bookmarkSplitter->SplitVertically( bookmarkView, mainVisSplitter, wxGetApp().getConfig()->getBookmarkSplit() );
hideBookmarksItem->Check(false);
} else if (event.GetId() == wxID_CLOSE || event.GetId() == wxID_EXIT) {
Close(false);
} else if (event.GetId() == wxID_THEME_DEFAULT) {
Expand Down Expand Up @@ -1044,6 +1055,14 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
GLFont::setScale(GLFont::GLFONT_SCALE_LARGE);
//force all windows refresh
Refresh();
} else if (event.GetId() == wxID_DISPLAY_BOOKMARKS) {
if (hideBookmarksItem->IsChecked()) {
bookmarkSplitter->Unsplit(bookmarkView);
bookmarkSplitter->Layout();
} else {
bookmarkSplitter->SplitVertically( bookmarkView, mainVisSplitter, wxGetApp().getConfig()->getBookmarkSplit() );
bookmarkSplitter->Layout();
}
}

if (event.GetId() >= wxID_SETTINGS_BASE && event.GetId() < settingsIdMax) {
Expand Down Expand Up @@ -1311,7 +1330,8 @@ void AppFrame::OnClose(wxCloseEvent& event) {
wxGetApp().getConfig()->setModemPropsCollapsed(modemProps->isCollapsed());
wxGetApp().getConfig()->setMainSplit(mainSplitter->GetSashPosition());
wxGetApp().getConfig()->setVisSplit(mainVisSplitter->GetSashPosition());
wxGetApp().getConfig()->setBookmarkSplit(bookmarkSplitter->GetSashPosition());
if (!hideBookmarksItem->IsChecked()) wxGetApp().getConfig()->setBookmarkSplit(bookmarkSplitter->GetSashPosition());
wxGetApp().getConfig()->setBookmarksVisible(!hideBookmarksItem->IsChecked());
#ifdef USE_HAMLIB
wxGetApp().getConfig()->setRigEnabled(rigEnableMenuItem->IsChecked());
wxGetApp().getConfig()->setRigModel(rigModel);
Expand Down
3 changes: 3 additions & 0 deletions src/AppFrame.h
Expand Up @@ -49,6 +49,8 @@
#define wxID_THEME_HD 2105
#define wxID_THEME_RADAR 2106

#define wxID_DISPLAY_BOOKMARKS 2107

#define wxID_BANDWIDTH_BASE 2150
#define wxID_BANDWIDTH_MANUAL 2200

Expand Down Expand Up @@ -196,6 +198,7 @@ class AppFrame: public wxFrame {
wxMenuItem *rigCenterLockMenuItem;
wxMenuItem *rigFollowModemMenuItem;
wxMenuItem *sdrIFMenuItem;
wxMenuItem *hideBookmarksItem;
std::map<int, wxMenuItem *> rigSerialMenuItems;
std::map<int, wxMenuItem *> rigModelMenuItems;
int rigModel;
Expand Down
3 changes: 3 additions & 0 deletions src/forms/Bookmark/BookmarkView.cpp
Expand Up @@ -126,6 +126,9 @@ BookmarkView::BookmarkView( wxWindow* parent, wxWindowID id, const wxPoint& pos,


void BookmarkView::onUpdateTimer( wxTimerEvent& event ) {
if (!this->IsShown()) {
return;
}
if (doUpdateActive.load()) {
doUpdateActiveList();

Expand Down

0 comments on commit 79c8c41

Please sign in to comment.