Show/Hide bookmarks option in display menu

This commit is contained in:
Charles J. Cliffe 2016-12-27 15:36:33 -05:00
parent 1ec92e0d9e
commit 79c8c415e2
5 changed files with 47 additions and 2 deletions

View File

@ -293,6 +293,7 @@ AppConfig::AppConfig() : configName("") {
mainSplit = -1;
visSplit = -1;
bookmarkSplit = -1;
bookmarksVisible.store(true);
#ifdef USE_HAMLIB
rigEnabled.store(false);
@ -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;
@ -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");
@ -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")) {

View File

@ -127,6 +127,9 @@ public:
void setBookmarkSplit(float value);
float getBookmarkSplit();
void setBookmarksVisible(bool state);
bool getBookmarksVisible();
#if USE_HAMLIB
int getRigModel();
@ -176,6 +179,6 @@ private:
#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
};

View File

@ -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);
@ -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);
@ -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) {
@ -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) {
@ -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);

View File

@ -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
@ -196,6 +198,7 @@ private:
wxMenuItem *rigCenterLockMenuItem;
wxMenuItem *rigFollowModemMenuItem;
wxMenuItem *sdrIFMenuItem;
wxMenuItem *hideBookmarksItem;
std::map<int, wxMenuItem *> rigSerialMenuItems;
std::map<int, wxMenuItem *> rigModelMenuItems;
int rigModel;

View File

@ -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();