diff --git a/src/dialogs/confdialog.cxx b/src/dialogs/confdialog.cxx index a788cf52..97c3a89b 100644 --- a/src/dialogs/confdialog.cxx +++ b/src/dialogs/confdialog.cxx @@ -139,6 +139,13 @@ static void cb_btnClearOnSave(Fl_Check_Button* o, void*) { progdefaults.changed = true; } +Fl_Check_Button *btnAutoFillQSO=(Fl_Check_Button *)0; + +static void cb_btnAutoFillQSO(Fl_Check_Button* o, void*) { + progdefaults.autofill_qso_fields = o->value(); +progdefaults.changed = true; +} + Fl_Group *tabWfallRestart=(Fl_Group *)0; Fl_Counter *cntrWfwidth=(Fl_Counter *)0; @@ -2124,7 +2131,7 @@ static const char szBaudRates[] = "300|600|1200|2400|4800|9600|19200|38400|57600 { tabsUI = new Fl_Tabs(0, 25, 500, 345); tabsUI->selection_color(FL_LIGHT1); { tabUserInterface = new Fl_Group(0, 50, 500, 320, _("General")); - { Fl_Group* o = new Fl_Group(5, 60, 490, 223); + { Fl_Group* o = new Fl_Group(5, 60, 490, 256); o->box(FL_ENGRAVED_FRAME); { Fl_Check_Button* o = btnShowTooltips = new Fl_Check_Button(15, 70, 120, 20, _("Show tooltips")); btnShowTooltips->down_box(FL_DOWN_BOX); @@ -2147,19 +2154,19 @@ static const char szBaudRates[] = "300|600|1200|2400|4800|9600|19200|38400|57600 mnuScheme->add("plastic"); mnuScheme->value(mnuScheme->find_item(progdefaults.ui_scheme.c_str())); } // Fl_Choice* mnuScheme - { Fl_Check_Button* o = btnRXClicks = new Fl_Check_Button(15, 220, 305, 20, _("Double-click on RX text enters QSO data")); + { Fl_Check_Button* o = btnRXClicks = new Fl_Check_Button(15, 247, 305, 20, _("Double-click on RX text enters QSO data")); btnRXClicks->down_box(FL_DOWN_BOX); btnRXClicks->callback((Fl_Callback*)cb_btnRXClicks); o->value(progdefaults.rxtext_clicks_qso_data); } // Fl_Check_Button* btnRXClicks - { Fl_Check_Button* o = btnRXTooltips = new Fl_Check_Button(15, 250, 282, 20, _("Show callsign tooltips in received text")); + { Fl_Check_Button* o = btnRXTooltips = new Fl_Check_Button(15, 277, 282, 20, _("Show callsign tooltips in received text")); btnRXTooltips->down_box(FL_DOWN_BOX); btnRXTooltips->callback((Fl_Callback*)cb_btnRXTooltips); o->value(progdefaults.rxtext_tooltips); } // Fl_Check_Button* btnRXTooltips o->end(); } // Fl_Group* o - { Fl_Group* o = new Fl_Group(15, 130, 212, 80, _("QSO logging")); + { Fl_Group* o = new Fl_Group(15, 130, 258, 107, _("QSO logging")); o->box(FL_ENGRAVED_FRAME); o->align(FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE); { Fl_Check_Button* o = btnNagMe = new Fl_Check_Button(25, 155, 155, 20, _("Prompt to save log")); @@ -2173,6 +2180,11 @@ static const char szBaudRates[] = "300|600|1200|2400|4800|9600|19200|38400|57600 btnClearOnSave->callback((Fl_Callback*)cb_btnClearOnSave); o->value(progdefaults.ClearOnSave); } // Fl_Check_Button* btnClearOnSave + { Fl_Check_Button* o = btnAutoFillQSO = new Fl_Check_Button(25, 207, 225, 20, _("Auto-fill Country and Azimuth")); + btnAutoFillQSO->down_box(FL_DOWN_BOX); + btnAutoFillQSO->callback((Fl_Callback*)cb_btnAutoFillQSO); + o->value(progdefaults.autofill_qso_fields); + } // Fl_Check_Button* btnAutoFillQSO o->end(); } // Fl_Group* o tabUserInterface->end(); diff --git a/src/dialogs/confdialog.fl b/src/dialogs/confdialog.fl index c4621b18..70c935d5 100644 --- a/src/dialogs/confdialog.fl +++ b/src/dialogs/confdialog.fl @@ -69,7 +69,7 @@ static const char szBaudRates[] = "300|600|1200|2400|4800|9600|19200|38400|57600 code {} {} Fl_Window {} { label {Fldigi configuration} open - xywh {557 80 500 400} type Double color 45 selection_color 51 labelsize 18 align 80 visible + xywh {557 96 500 400} type Double color 45 selection_color 51 labelsize 18 align 80 visible } { Fl_Tabs tabsConfigure {open xywh {0 0 500 372} color 50 selection_color 50 @@ -143,7 +143,7 @@ progdefaults.changed = true;} xywh {0 50 500 320} } { Fl_Group {} {open - xywh {5 60 490 223} box ENGRAVED_FRAME + xywh {5 60 490 256} box ENGRAVED_FRAME } { Fl_Check_Button btnShowTooltips { label {Show tooltips} @@ -177,20 +177,20 @@ progdefaults.changed = true;} label {Double-click on RX text enters QSO data} callback {progdefaults.rxtext_clicks_qso_data = o->value(); progdefaults.changed = true;} - xywh {15 220 305 20} down_box DOWN_BOX + xywh {15 247 305 20} down_box DOWN_BOX code0 {o->value(progdefaults.rxtext_clicks_qso_data);} } Fl_Check_Button btnRXTooltips { label {Show callsign tooltips in received text} callback {progdefaults.rxtext_tooltips = o->value(); -progdefaults.changed = true;} selected - xywh {15 250 282 20} down_box DOWN_BOX +progdefaults.changed = true;} + xywh {15 277 282 20} down_box DOWN_BOX code0 {o->value(progdefaults.rxtext_tooltips);} } } Fl_Group {} { label {QSO logging} open - xywh {15 130 212 80} box ENGRAVED_FRAME align 21 + xywh {15 130 258 107} box ENGRAVED_FRAME align 21 } { Fl_Check_Button btnNagMe { label {Prompt to save log} @@ -206,6 +206,13 @@ progdefaults.changed = true;} tooltip {Clear log entries after saving or using macro } xywh {25 181 125 20} down_box DOWN_BOX code0 {o->value(progdefaults.ClearOnSave);} } + Fl_Check_Button btnAutoFillQSO { + label {Auto-fill Country and Azimuth} + callback {progdefaults.autofill_qso_fields = o->value(); +progdefaults.changed = true;} selected + xywh {25 207 225 20} down_box DOWN_BOX + code0 {o->value(progdefaults.autofill_qso_fields);} + } } } Fl_Group tabWfallRestart { diff --git a/src/dialogs/fl_digi.cxx b/src/dialogs/fl_digi.cxx index 4cceedba..acf6f8b1 100644 --- a/src/dialogs/fl_digi.cxx +++ b/src/dialogs/fl_digi.cxx @@ -116,6 +116,8 @@ #include "re.h" #include "network.h" #include "spot.h" +#include "dxcc.h" +#include "locator.h" #include "logbook.h" @@ -1294,21 +1296,57 @@ void cb_ResetSerNbr() updateOutSerNo(); } +void cb_loc(Fl_Widget* w, void*) +{ + oktoclear = false; + + if (!inpLoc->size() || !progdefaults.autofill_qso_fields) + return; + + double lon[2], lat[2], distance, azimuth; + if (locator2longlat(&lon[0], &lat[0], progdefaults.myLocator.c_str()) == RIG_OK && + locator2longlat(&lon[1], &lat[1], inpLoc->value()) == RIG_OK && + qrb(lon[0], lat[0], lon[1], lat[1], &distance, &azimuth) == RIG_OK) { + char az[4]; + snprintf(az, sizeof(az), "%3.0f", azimuth); + inpAZ->value(az); + } +} + +void cb_call(Fl_Widget* w, void*) +{ + oktoclear = false; + + inpTimeOn->value(inpTimeOff->value()); + if (inpCall->size()) { + SearchLastQSO(inpCall->value()); + if (EnableDupCheck) + DupCheck(inpCall->value()); + } + + if (!progdefaults.autofill_qso_fields) + return; + const struct dxcc* e = dxcc_lookup(inpCall->value()); + if (!e) + return; + + double lon, lat, distance, azimuth; + if (locator2longlat(&lon, &lat, progdefaults.myLocator.c_str()) == RIG_OK && + qrb(lon, lat, -e->longitude, e->latitude, &distance, &azimuth) == RIG_OK) { + char az[4]; + snprintf(az, sizeof(az), "%3.0f", azimuth); + inpAZ->value(az); + } + + inpCountry->value(e->country); + inpCountry->position(0); +} + void cb_log(Fl_Widget* w, void*) { oktoclear = false; - if (w == inpCall) { - string temp = inpCall->value(); - for (size_t i = 0; i < temp.length(); i++) - temp[i] = toupper(temp[i]); - inpCall->value(temp.c_str()); - inpTimeOn->value(inpTimeOff->value()); - SearchLastQSO(temp.c_str()); - if (EnableDupCheck) - DupCheck(temp.c_str()); - - } - restoreFocus(); + if (w == btnQRZ) + restoreFocus(); } void qsoClear_cb(Fl_Widget *b, void *) @@ -2244,6 +2282,7 @@ void create_fl_digi_main() { inpCall = new Fl_Input2(rightof(inpTimeOff) + pad, y2, w_inpCall, qh - pad, _("Call")); inpCall->tooltip(""); inpCall->align(FL_ALIGN_TOP | FL_ALIGN_LEFT); + inpCall->when(FL_WHEN_CHANGED | FL_WHEN_ENTER_KEY); inpName = new Fl_Input2(rightof(inpCall) + pad, y2, w_inpName, qh - pad, _("Name")); inpName->tooltip(""); @@ -2291,6 +2330,7 @@ void create_fl_digi_main() { inpLoc = new Fl_Input2(rightof(fm4box), y3, w_inpLOC, qh - pad, ""); inpLoc->tooltip(""); inpLoc->align(FL_ALIGN_INSIDE); + inpLoc->when(FL_WHEN_CHANGED | FL_WHEN_ENTER_KEY); Fl_Box *fm5box = new Fl_Box(rightof(inpLoc), y3, w_fm5, qh - pad, _("Az")); fm5box->align(FL_ALIGN_INSIDE); @@ -2357,11 +2397,13 @@ void create_fl_digi_main() { Y = Hmenu + Hqsoframe + Hnotes + pad; - Fl_Widget* logfields[] = { inpCall, inpName, inpTimeOn, inpRstIn, inpRstOut, - inpQth, inpVEprov, inpCountry, inpAZ, inpLoc, inpNotes, + Fl_Widget* logfields[] = { inpName, inpTimeOn, inpRstIn, inpRstOut, + inpQth, inpVEprov, inpCountry, inpAZ, inpNotes, inpSerNo, inpXchg1, inpXchg1, inpXchg1 }; for (size_t i = 0; i < sizeof(logfields)/sizeof(*logfields); i++) logfields[i]->callback(cb_log); + inpCall->callback(cb_call); + inpLoc->callback(cb_loc); int sw = DEFAULT_SW; MixerFrame = new Fl_Group(0,Y,sw, Hrcvtxt + Hxmttxt); diff --git a/src/include/confdialog.h b/src/include/confdialog.h index cadb23e1..6081e75d 100644 --- a/src/include/confdialog.h +++ b/src/include/confdialog.h @@ -30,6 +30,7 @@ extern Fl_Check_Button *btnRXClicks; extern Fl_Check_Button *btnRXTooltips; extern Fl_Check_Button *btnNagMe; extern Fl_Check_Button *btnClearOnSave; +extern Fl_Check_Button *btnAutoFillQSO; extern Fl_Group *tabWfallRestart; #include extern Fl_Counter *cntrWfwidth; diff --git a/src/include/configuration.h b/src/include/configuration.h index 4bd0cb2a..206c8af7 100644 --- a/src/include/configuration.h +++ b/src/include/configuration.h @@ -162,6 +162,7 @@ ELEM_(bool, menuicons, "MENUICONS", true) \ ELEM_(bool, rxtext_clicks_qso_data, "RXTEXTCLICKS", false) \ ELEM_(bool, rxtext_tooltips, "RXTEXTTOOLTIPS", false) \ + ELEM_(bool, autofill_qso_fields, "AUTOFILLQSO", false) \ /* QRZ */ \ ELEM_(int, QRZ, "QRZTYPE", 0) /* Not available */ \ ELEM_(std::string, QRZpathname, "QRZPATHNAME", "") \ diff --git a/src/logbook/logsupport.cxx b/src/logbook/logsupport.cxx index f71672f1..780f42b3 100644 --- a/src/logbook/logsupport.cxx +++ b/src/logbook/logsupport.cxx @@ -340,6 +340,8 @@ int SearchLog(const char *callsign, const char*** data) void SearchLastQSO(const char *callsign) { size_t len = strlen(callsign); + if (!len) + return; char* re = new char[len + 3]; snprintf(re, len + 3, "^%s$", callsign); diff --git a/src/main.cxx b/src/main.cxx index efdc713b..5d278a38 100644 --- a/src/main.cxx +++ b/src/main.cxx @@ -305,7 +305,8 @@ int main(int argc, char ** argv) if (!pskrep_start()) LOG_ERROR("Could not start PSK reporter: %s", pskrep_error()); - dxcc_open(string(HomeDir).append("cty.dat").c_str()); + if (progdefaults.rxtext_tooltips || progdefaults.autofill_qso_fields) + dxcc_open(string(HomeDir).append("cty.dat").c_str()); int ret = Fl::run(); diff --git a/src/misc/dxcc.cxx b/src/misc/dxcc.cxx index a68f84a9..23e96f9c 100644 --- a/src/misc/dxcc.cxx +++ b/src/misc/dxcc.cxx @@ -105,7 +105,7 @@ void dxcc_close(void) const dxcc* dxcc_lookup(const char* callsign) { - if (!cmap) + if (!cmap || !callsign || !*callsign) return NULL; string sstr;