From 393cd5f635d62195d4b6c0f796671ebe3acbe36d Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Mon, 8 Feb 2016 22:43:11 -0500 Subject: [PATCH] Add hover helptips, show hover helptips by default for new users. --- src/AppConfig.cpp | 17 ++++++++++++++++- src/AppConfig.h | 5 ++++- src/AppFrame.cpp | 10 ++++++++++ src/AppFrame.h | 2 ++ src/visual/InteractiveCanvas.cpp | 5 +++++ 5 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/AppConfig.cpp b/src/AppConfig.cpp index 42d3b6a..63d7eb1 100644 --- a/src/AppConfig.cpp +++ b/src/AppConfig.cpp @@ -198,6 +198,7 @@ AppConfig::AppConfig() : configName("") { winW.store(0); winH.store(0); winMax.store(false); + showTips.store(true); themeId.store(0); snap.store(1); centerFreq.store(100000000); @@ -253,6 +254,14 @@ bool AppConfig::getWindowMaximized() { return winMax.load(); } +void AppConfig::setShowTips(bool show) { + showTips.store(show); +} + +bool AppConfig::getShowTips() { + return showTips.load(); +} + wxRect *AppConfig::getWindow() { wxRect *r = NULL; if (winH.load() && winW.load()) { @@ -347,6 +356,7 @@ bool AppConfig::save() { *window_node->newChild("h") = winH.load(); *window_node->newChild("max") = winMax.load(); + *window_node->newChild("tips") = showTips.load(); *window_node->newChild("theme") = themeId.load(); *window_node->newChild("snap") = snap.load(); *window_node->newChild("center_freq") = centerFreq.load(); @@ -426,7 +436,7 @@ bool AppConfig::load() { if (cfg.rootNode()->hasAnother("window")) { int x,y,w,h; - int max; + int max,tips; DataNode *win_node = cfg.rootNode()->getNext("window"); @@ -447,6 +457,11 @@ bool AppConfig::load() { winMax.store(max?true:false); } + if (win_node->hasAnother("tips")) { + win_node->getNext("tips")->element()->get(tips); + showTips.store(tips?true:false); + } + if (win_node->hasAnother("theme")) { int theme; win_node->getNext("theme")->element()->get(theme); diff --git a/src/AppConfig.h b/src/AppConfig.h index b40ec12..8227c3b 100644 --- a/src/AppConfig.h +++ b/src/AppConfig.h @@ -70,6 +70,9 @@ public: void setWindowMaximized(bool max); bool getWindowMaximized(); + void setShowTips(bool show); + bool getShowTips(); + void setTheme(int themeId); int getTheme(); @@ -109,7 +112,7 @@ private: std::string configName; std::map deviceConfig; std::atomic_int winX,winY,winW,winH; - std::atomic_bool winMax; + std::atomic_bool winMax, showTips; std::atomic_int themeId; std::atomic_llong snap; std::atomic_llong centerFreq; diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index 468a147..668815e 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -552,6 +552,10 @@ void AppFrame::updateDeviceParams() { // Build settings menu wxMenu *newSettingsMenu = new wxMenu; + showTipMenuItem = newSettingsMenu->AppendCheckItem(wxID_SET_TIPS, "Show Hover Tips"); + if (wxGetApp().getConfig()->getShowTips()) { + showTipMenuItem->Check(); + } newSettingsMenu->Append(wxID_SET_FREQ_OFFSET, "Frequency Offset"); if (devInfo->hasCORR(SOAPY_SDR_RX, 0)) { newSettingsMenu->Append(wxID_SET_PPM, "Device PPM"); @@ -673,6 +677,12 @@ void AppFrame::OnMenu(wxCommandEvent& event) { activeDemodulator->setOutputDevice(event.GetId() - wxID_RT_AUDIO_DEVICE); activeDemodulator = NULL; } + } else if (event.GetId() == wxID_SET_TIPS ) { + if (wxGetApp().getConfig()->getShowTips()) { + wxGetApp().getConfig()->setShowTips(false); + } else { + wxGetApp().getConfig()->setShowTips(true); + } } else if (event.GetId() == wxID_SET_FREQ_OFFSET) { long ofs = wxGetNumberFromUser("Shift the displayed frequency by this amount.\ni.e. -125000000 for -125 MHz", "Frequency (Hz)", "Frequency Offset", wxGetApp().getOffset(), -2000000000, 2000000000, this); diff --git a/src/AppFrame.h b/src/AppFrame.h index df38196..a7eb54b 100644 --- a/src/AppFrame.h +++ b/src/AppFrame.h @@ -26,6 +26,7 @@ #define wxID_SET_FREQ_OFFSET 2001 #define wxID_RESET 2002 #define wxID_SET_PPM 2003 +#define wxID_SET_TIPS 2004 #define wxID_SDR_DEVICES 2008 #define wxID_AGC_CONTROL 2009 @@ -150,6 +151,7 @@ private: wxMenuItem *sdrIFMenuItem; std::map rigSerialMenuItems; std::map rigModelMenuItems; + wxMenuItem *showTipMenuItem; int rigModel; int rigSerialRate; long long rigSDRIF; diff --git a/src/visual/InteractiveCanvas.cpp b/src/visual/InteractiveCanvas.cpp index edd85dc..9ac9493 100644 --- a/src/visual/InteractiveCanvas.cpp +++ b/src/visual/InteractiveCanvas.cpp @@ -157,6 +157,11 @@ void InteractiveCanvas::OnMouseEnterWindow(wxMouseEvent& event) { void InteractiveCanvas::setStatusText(std::string statusText) { wxGetApp().getAppFrame()->GetStatusBar()->SetStatusText(statusText); + if (wxGetApp().getConfig()->getShowTips()) { + this->SetToolTip(statusText); + } else { + this->SetToolTip(""); + } } void InteractiveCanvas::setStatusText(std::string statusText, int value) {