From b2727d774bf58c27b5086e88e2e610e05a01f90c Mon Sep 17 00:00:00 2001 From: martii Date: Sat, 21 Dec 2013 22:34:32 +0100 Subject: [PATCH] gui/scan_setup: show unit for motor speed Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/a0f29605017596f364e23d78268d0c573284bedb Author: martii Date: 2013-12-21 (Sat, 21 Dec 2013) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- data/locale/deutsch.locale | 2 +- data/locale/english.locale | 2 +- src/gui/scan_setup.cpp | 8 ++++++++ src/gui/widget/menue.cpp | 14 +++++++++++--- src/gui/widget/menue.h | 3 ++- 5 files changed, 23 insertions(+), 6 deletions(-) diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index 053857bed..7c3c4f06a 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -437,7 +437,7 @@ extra.zap_cycle Zap nur in Bouquet extra.zapit_fe_timeout Tuning Timeout extra.zapit_hvoltage High (13.5/ 18.5) Voltage extra.zapit_make_bouquet Kanalliste auffüllen -extra.zapit_motor_speed Rotor Drehzeit (10 = 1°/ sec) +extra.zapit_motor_speed Rotor Drehzeit extra.zapit_scanpids PIDs scannen/nutzen extra.zapit_sdt_changed Kanalliste wird neu geladen. fan_speed CPU-Lüftergeschwindigkeit diff --git a/data/locale/english.locale b/data/locale/english.locale index 2c8918381..c5bd4432b 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -437,7 +437,7 @@ extra.zap_cycle Zap cycle extra.zapit_fe_timeout Tune timeout extra.zapit_hvoltage 18V for rotor moving extra.zapit_make_bouquet Make Remaining Channels list -extra.zapit_motor_speed Motor moving speed (10 = 1deg/sec) +extra.zapit_motor_speed Motor moving speed extra.zapit_scanpids Scan/Use pids extra.zapit_sdt_changed Channels changed, reload settings. fan_speed CPU Fan speed diff --git a/src/gui/scan_setup.cpp b/src/gui/scan_setup.cpp index f65ca2f7e..0b4f8a5f2 100644 --- a/src/gui/scan_setup.cpp +++ b/src/gui/scan_setup.cpp @@ -606,6 +606,13 @@ int CScanSetup::showScanMenuFrontendSetup() return res; } +static std::string rotationSpeed2str(int i) +{ + char s[40]; + snprintf(s, sizeof(s), "%d.%d°/s", i / 10, i % 10); + return std::string(s); +} + int CScanSetup::showFrontendSetup(int number) { int shortcut = 1; @@ -737,6 +744,7 @@ int CScanSetup::showFrontendSetup(int number) setupMenu->addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_SATSETUP_EXTENDED_MOTOR)); CMenuOptionNumberChooser * nc = new CMenuOptionNumberChooser(LOCALE_EXTRA_ZAPIT_MOTOR_SPEED, (int *)&fe_config.motorRotationSpeed, allow_moptions, 0, 64, NULL); + nc->setNumberFormat(rotationSpeed2str); nc->setHint("", LOCALE_MENU_HINT_SCAN_MOTOR_SPEED); setupMenu->addItem(nc); msettings.Add(nc); diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index f3fd74796..57c305f68 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -1159,6 +1159,7 @@ CMenuOptionNumberChooser::CMenuOptionNumberChooser(const neutrino_locale_t name, optionString = non_localized_name; numberFormat = "%d"; + numberFormatFunction = NULL; observ = Observ; slider_on = sliderOn; } @@ -1187,11 +1188,15 @@ int CMenuOptionNumberChooser::exec(CMenuTarget*) int CMenuOptionNumberChooser::paint(bool selected) { const char * l_option; - char option_value[11]; + char option_value[40]; if ((localized_value_name == NONEXISTANT_LOCALE) || ((*optionValue) != localized_value)) { - sprintf(option_value, numberFormat.c_str(), ((*optionValue) + display_offset)); + if (numberFormatFunction) { + std::string s = numberFormatFunction(*optionValue + display_offset); + strncpy(option_value, s.c_str(), s.length()); + } else + sprintf(option_value, numberFormat.c_str(), *optionValue + display_offset); l_option = option_value; } else @@ -1243,7 +1248,10 @@ int CMenuOptionNumberChooser::getWidth(void) width += (w1 > w2) ? w1 : w2; - if (numberFormat != "%d") { + if (numberFormatFunction) { + std::string s = numberFormatFunction(0); + width += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(s.c_str(), true) - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("0", true); // arbitrary + } else if (numberFormat != "%d") { char format[numberFormat.length()]; snprintf(format, numberFormat.length(), numberFormat.c_str(), 0); width += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(format, true) - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("0", true); diff --git a/src/gui/widget/menue.h b/src/gui/widget/menue.h index 21e5e7297..cea625567 100644 --- a/src/gui/widget/menue.h +++ b/src/gui/widget/menue.h @@ -299,7 +299,7 @@ private: bool slider_on; CChangeObserver * observ; std::string numberFormat; - + std::string (*numberFormatFunction)(int num); public: CMenuOptionNumberChooser(const neutrino_locale_t name, int * const OptionValue, const bool Active, const int min_value, const int max_value, CChangeObserver * const Observ = NULL, const int print_offset = 0, const int special_value = 0, const neutrino_locale_t special_value_name = NONEXISTANT_LOCALE, const char * non_localized_name = NULL, bool sliderOn = false ); @@ -309,6 +309,7 @@ private: int isMenueOptionChooser(void) const{return 1;} int getWidth(void); void setNumberFormat(std::string format) { numberFormat = format; } + void setNumberFormat(std::string (*fun)(int)) { numberFormatFunction = fun; } }; class CMenuOptionChooser : public CAbstractMenuOptionChooser