mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-09-02 18:31:12 +02:00
move weather setup to own source files
Origin commit data
------------------
Commit: e5c376c21b
Author: TangoCash <eric@loxat.de>
Date: 2022-01-18 (Tue, 18 Jan 2022)
This commit is contained in:
@@ -115,6 +115,7 @@ libneutrino_gui_a_SOURCES = \
|
|||||||
videosettings.cpp \
|
videosettings.cpp \
|
||||||
volumebar.cpp \
|
volumebar.cpp \
|
||||||
weather.cpp \
|
weather.cpp \
|
||||||
|
weather_setup.cpp \
|
||||||
webchannels_setup.cpp \
|
webchannels_setup.cpp \
|
||||||
xmltv_setup.cpp \
|
xmltv_setup.cpp \
|
||||||
zapit_setup.cpp
|
zapit_setup.cpp
|
||||||
|
@@ -33,8 +33,7 @@
|
|||||||
#include <system/helpers.h>
|
#include <system/helpers.h>
|
||||||
#include <system/debug.h>
|
#include <system/debug.h>
|
||||||
#include <gui/miscsettings_menu.h>
|
#include <gui/miscsettings_menu.h>
|
||||||
#include <gui/weather.h>
|
#include "gui/weather_setup.h"
|
||||||
#include <gui/weather_locations.h>
|
|
||||||
#include <gui/cec_setup.h>
|
#include <gui/cec_setup.h>
|
||||||
#include <gui/filebrowser.h>
|
#include <gui/filebrowser.h>
|
||||||
#include <gui/infoicons_setup.h>
|
#include <gui/infoicons_setup.h>
|
||||||
@@ -153,10 +152,6 @@ int CMiscMenue::exec(CMenuTarget *parent, const std::string &actionKey)
|
|||||||
{
|
{
|
||||||
return showMiscSettingsMenuPlugins();
|
return showMiscSettingsMenuPlugins();
|
||||||
}
|
}
|
||||||
else if (actionKey == "select_location")
|
|
||||||
{
|
|
||||||
return showMiscSettingsSelectWeatherLocation();
|
|
||||||
}
|
|
||||||
else if (actionKey == "epg_read_now" || actionKey == "epg_read_now_usermenu")
|
else if (actionKey == "epg_read_now" || actionKey == "epg_read_now_usermenu")
|
||||||
{
|
{
|
||||||
struct stat my_stat;
|
struct stat my_stat;
|
||||||
@@ -626,21 +621,9 @@ int CMiscMenue::showMiscSettingsMenuOnlineServices()
|
|||||||
ms_oservices->addIntroItems(LOCALE_MISCSETTINGS_ONLINESERVICES);
|
ms_oservices->addIntroItems(LOCALE_MISCSETTINGS_ONLINESERVICES);
|
||||||
|
|
||||||
// weather
|
// weather
|
||||||
weather_onoff = new CMenuOptionChooser(LOCALE_WEATHER_ENABLED, &g_settings.weather_enabled, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, CApiKey::check_weather_api_key());
|
CMenuForwarder *mf = new CMenuForwarder(LOCALE_WEATHER_ENABLED, true, NULL, new CWeatherSetup());
|
||||||
weather_onoff->setHint(NEUTRINO_ICON_HINT_SETTINGS, LOCALE_MENU_HINT_WEATHER_ENABLED);
|
mf->setHint(NEUTRINO_ICON_HINT_SETTINGS, LOCALE_MENU_HINT_WEATHER_ENABLED);
|
||||||
ms_oservices->addItem(weather_onoff);
|
ms_oservices->addItem(mf);
|
||||||
|
|
||||||
#if ENABLE_WEATHER_KEY_MANAGE
|
|
||||||
changeNotify(LOCALE_WEATHER_API_KEY, NULL);
|
|
||||||
CKeyboardInput weather_api_key_input(LOCALE_WEATHER_API_KEY, &g_settings.weather_api_key, 32, this);
|
|
||||||
CMenuForwarder *mf_we = new CMenuForwarder(LOCALE_WEATHER_API_KEY, true, weather_api_key_short, &weather_api_key_input);
|
|
||||||
mf_we->setHint(NEUTRINO_ICON_HINT_SETTINGS, LOCALE_MENU_HINT_WEATHER_API_KEY);
|
|
||||||
ms_oservices->addItem(mf_we);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
CMenuForwarder *mf_wl = new CMenuForwarder(LOCALE_WEATHER_LOCATION, g_settings.weather_enabled, g_settings.weather_city, this, "select_location");
|
|
||||||
mf_wl->setHint(NEUTRINO_ICON_HINT_SETTINGS, LOCALE_MENU_HINT_WEATHER_LOCATION);
|
|
||||||
ms_oservices->addItem(mf_wl);
|
|
||||||
|
|
||||||
ms_oservices->addItem(GenericMenuSeparator);
|
ms_oservices->addItem(GenericMenuSeparator);
|
||||||
|
|
||||||
@@ -733,40 +716,6 @@ int CMiscMenue::showMiscSettingsMenuPlugins()
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CMiscMenue::showMiscSettingsSelectWeatherLocation()
|
|
||||||
{
|
|
||||||
int select = 0;
|
|
||||||
int res = 0;
|
|
||||||
|
|
||||||
if (WEATHER_LOCATION_OPTION_COUNT > 1)
|
|
||||||
{
|
|
||||||
CMenuWidget *m = new CMenuWidget(LOCALE_WEATHER_LOCATION, NEUTRINO_ICON_LANGUAGE);
|
|
||||||
CMenuSelectorTarget *selector = new CMenuSelectorTarget(&select);
|
|
||||||
|
|
||||||
m->addItem(GenericMenuSeparator);
|
|
||||||
|
|
||||||
CMenuForwarder *mf;
|
|
||||||
for (size_t i = 0; i < WEATHER_LOCATION_OPTION_COUNT; i++)
|
|
||||||
{
|
|
||||||
mf = new CMenuForwarder(WEATHER_LOCATION_OPTIONS[i].key, true, NULL, selector, to_string(i).c_str());
|
|
||||||
mf->setHint(NEUTRINO_ICON_HINT_SETTINGS, WEATHER_LOCATION_OPTIONS[i].value.c_str());
|
|
||||||
m->addItem(mf);
|
|
||||||
}
|
|
||||||
|
|
||||||
m->enableSaveScreen();
|
|
||||||
res = m->exec(NULL, "");
|
|
||||||
|
|
||||||
delete selector;
|
|
||||||
|
|
||||||
if (!m->gotAction())
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
g_settings.weather_location = WEATHER_LOCATION_OPTIONS[select].value;
|
|
||||||
g_settings.weather_city = std::string(WEATHER_LOCATION_OPTIONS[select].key);
|
|
||||||
CWeather::getInstance()->setCoords(g_settings.weather_location, g_settings.weather_city);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
// CPU
|
// CPU
|
||||||
void CMiscMenue::showMiscSettingsMenuCPUFreq(CMenuWidget *ms_cpu)
|
void CMiscMenue::showMiscSettingsMenuCPUFreq(CMenuWidget *ms_cpu)
|
||||||
{
|
{
|
||||||
@@ -854,15 +803,6 @@ bool CMiscMenue::changeNotify(const neutrino_locale_t OptionName, void */*data*/
|
|||||||
ret = menu_return::RETURN_REPAINT;
|
ret = menu_return::RETURN_REPAINT;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else if (ARE_LOCALES_EQUAL(OptionName, LOCALE_WEATHER_API_KEY))
|
|
||||||
{
|
|
||||||
g_settings.weather_enabled = g_settings.weather_enabled && CApiKey::check_weather_api_key();
|
|
||||||
if (g_settings.weather_enabled)
|
|
||||||
weather_api_key_short = g_settings.weather_api_key.substr(0, 8) + "...";
|
|
||||||
else
|
|
||||||
weather_api_key_short.clear();
|
|
||||||
weather_onoff->setActive(CApiKey::check_weather_api_key());
|
|
||||||
}
|
|
||||||
else if (ARE_LOCALES_EQUAL(OptionName, LOCALE_TMDB_API_KEY))
|
else if (ARE_LOCALES_EQUAL(OptionName, LOCALE_TMDB_API_KEY))
|
||||||
{
|
{
|
||||||
g_settings.tmdb_enabled = g_settings.tmdb_enabled && CApiKey::check_tmdb_api_key();
|
g_settings.tmdb_enabled = g_settings.tmdb_enabled && CApiKey::check_tmdb_api_key();
|
||||||
|
@@ -52,7 +52,6 @@ class CMiscMenue : public CMenuTarget, CChangeObserver
|
|||||||
CMenuOptionChooser *epg_read;
|
CMenuOptionChooser *epg_read;
|
||||||
CMenuOptionChooser *epg_read_frequently;
|
CMenuOptionChooser *epg_read_frequently;
|
||||||
CMenuOptionChooser *epg_scan;
|
CMenuOptionChooser *epg_scan;
|
||||||
CMenuOptionChooser *weather_onoff;
|
|
||||||
CMenuOptionChooser *tmdb_onoff;
|
CMenuOptionChooser *tmdb_onoff;
|
||||||
CMenuOptionChooser *omdb_onoff;
|
CMenuOptionChooser *omdb_onoff;
|
||||||
CMenuOptionChooser *youtube_onoff;
|
CMenuOptionChooser *youtube_onoff;
|
||||||
@@ -67,7 +66,6 @@ class CMiscMenue : public CMenuTarget, CChangeObserver
|
|||||||
std::string epg_old_events;
|
std::string epg_old_events;
|
||||||
std::string epg_max_events;
|
std::string epg_max_events;
|
||||||
|
|
||||||
std::string weather_api_key_short;
|
|
||||||
std::string tmdb_api_key_short;
|
std::string tmdb_api_key_short;
|
||||||
std::string omdb_api_key_short;
|
std::string omdb_api_key_short;
|
||||||
std::string youtube_dev_id_short;
|
std::string youtube_dev_id_short;
|
||||||
@@ -80,7 +78,6 @@ class CMiscMenue : public CMenuTarget, CChangeObserver
|
|||||||
int showMiscSettingsMenuEnergy();
|
int showMiscSettingsMenuEnergy();
|
||||||
int showMiscSettingsMenuChanlist();
|
int showMiscSettingsMenuChanlist();
|
||||||
int showMiscSettingsMenuOnlineServices();
|
int showMiscSettingsMenuOnlineServices();
|
||||||
int showMiscSettingsSelectWeatherLocation();
|
|
||||||
int showMiscSettingsMenuPlugins();
|
int showMiscSettingsMenuPlugins();
|
||||||
void showMiscSettingsMenuCPUFreq(CMenuWidget *ms_cpu);
|
void showMiscSettingsMenuCPUFreq(CMenuWidget *ms_cpu);
|
||||||
public:
|
public:
|
||||||
|
144
src/gui/weather_setup.cpp
Normal file
144
src/gui/weather_setup.cpp
Normal file
@@ -0,0 +1,144 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2020 TangoCash
|
||||||
|
|
||||||
|
License: GPLv2
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation;
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "weather_setup.h"
|
||||||
|
|
||||||
|
#include <global.h>
|
||||||
|
#include <neutrino.h>
|
||||||
|
|
||||||
|
#include <gui/widget/icons.h>
|
||||||
|
#include <gui/widget/menue_options.h>
|
||||||
|
#include <gui/widget/stringinput.h>
|
||||||
|
#include <gui/widget/keyboard_input.h>
|
||||||
|
|
||||||
|
#include <gui/weather.h>
|
||||||
|
#include <gui/weather_locations.h>
|
||||||
|
|
||||||
|
#include <driver/screen_max.h>
|
||||||
|
|
||||||
|
#include <system/debug.h>
|
||||||
|
|
||||||
|
CWeatherSetup::CWeatherSetup()
|
||||||
|
{
|
||||||
|
width = 40;
|
||||||
|
selected = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
CWeatherSetup::~CWeatherSetup()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int CWeatherSetup::exec(CMenuTarget* parent, const std::string &actionKey)
|
||||||
|
{
|
||||||
|
dprintf(DEBUG_DEBUG, "init weather setup menu\n");
|
||||||
|
int res = menu_return::RETURN_REPAINT;
|
||||||
|
|
||||||
|
if (parent)
|
||||||
|
parent->hide();
|
||||||
|
|
||||||
|
if(actionKey == "select_location")
|
||||||
|
{
|
||||||
|
return showSelectWeatherLocation();
|
||||||
|
}
|
||||||
|
|
||||||
|
res = showWeatherSetup();
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CWeatherSetup::showWeatherSetup()
|
||||||
|
{
|
||||||
|
CMenuWidget *ms_oservices = new CMenuWidget(LOCALE_MISCSETTINGS_HEAD, NEUTRINO_ICON_SETTINGS, width, MN_WIDGET_ID_MISCSETUP_ONLINESERVICES);
|
||||||
|
ms_oservices->addIntroItems(LOCALE_MISCSETTINGS_ONLINESERVICES);
|
||||||
|
|
||||||
|
// weather
|
||||||
|
weather_onoff = new CMenuOptionChooser(LOCALE_WEATHER_ENABLED, &g_settings.weather_enabled, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, CApiKey::check_weather_api_key());
|
||||||
|
weather_onoff->setHint(NEUTRINO_ICON_HINT_SETTINGS, LOCALE_MENU_HINT_WEATHER_ENABLED);
|
||||||
|
ms_oservices->addItem(weather_onoff);
|
||||||
|
|
||||||
|
#if ENABLE_WEATHER_KEY_MANAGE
|
||||||
|
changeNotify(LOCALE_WEATHER_API_KEY, NULL);
|
||||||
|
CKeyboardInput weather_api_key_input(LOCALE_WEATHER_API_KEY, &g_settings.weather_api_key, 32, this);
|
||||||
|
CMenuForwarder *mf_we = new CMenuForwarder(LOCALE_WEATHER_API_KEY, true, weather_api_key_short, &weather_api_key_input);
|
||||||
|
mf_we->setHint(NEUTRINO_ICON_HINT_SETTINGS, LOCALE_MENU_HINT_WEATHER_API_KEY);
|
||||||
|
ms_oservices->addItem(mf_we);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
CMenuForwarder *mf_wl = new CMenuForwarder(LOCALE_WEATHER_LOCATION, g_settings.weather_enabled, g_settings.weather_city, this, "select_location");
|
||||||
|
mf_wl->setHint(NEUTRINO_ICON_HINT_SETTINGS, LOCALE_MENU_HINT_WEATHER_LOCATION);
|
||||||
|
ms_oservices->addItem(mf_wl);
|
||||||
|
|
||||||
|
int res = ms_oservices->exec (NULL, "");
|
||||||
|
selected = ms_oservices->getSelected();
|
||||||
|
delete ms_oservices;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CWeatherSetup::showSelectWeatherLocation()
|
||||||
|
{
|
||||||
|
int select = 0;
|
||||||
|
int res = 0;
|
||||||
|
|
||||||
|
if (WEATHER_LOCATION_OPTION_COUNT > 1)
|
||||||
|
{
|
||||||
|
CMenuWidget *m = new CMenuWidget(LOCALE_WEATHER_LOCATION, NEUTRINO_ICON_LANGUAGE);
|
||||||
|
CMenuSelectorTarget * selector = new CMenuSelectorTarget(&select);
|
||||||
|
|
||||||
|
m->addItem(GenericMenuSeparator);
|
||||||
|
|
||||||
|
CMenuForwarder* mf;
|
||||||
|
for (size_t i = 0; i < WEATHER_LOCATION_OPTION_COUNT; i++)
|
||||||
|
{
|
||||||
|
mf = new CMenuForwarder(WEATHER_LOCATION_OPTIONS[i].key, true, NULL, selector, to_string(i).c_str());
|
||||||
|
mf->setHint(NEUTRINO_ICON_HINT_SETTINGS, WEATHER_LOCATION_OPTIONS[i].value.c_str());
|
||||||
|
m->addItem(mf);
|
||||||
|
}
|
||||||
|
|
||||||
|
m->enableSaveScreen();
|
||||||
|
res = m->exec(NULL, "");
|
||||||
|
|
||||||
|
if (!m->gotAction())
|
||||||
|
return res;
|
||||||
|
|
||||||
|
delete selector;
|
||||||
|
}
|
||||||
|
g_settings.weather_location = WEATHER_LOCATION_OPTIONS[select].value;
|
||||||
|
g_settings.weather_city = std::string(WEATHER_LOCATION_OPTIONS[select].key);
|
||||||
|
CWeather::getInstance()->setCoords(g_settings.weather_location, g_settings.weather_city);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CWeatherSetup::changeNotify(const neutrino_locale_t OptionName, void * /*data*/)
|
||||||
|
{
|
||||||
|
int ret = menu_return::RETURN_NONE;
|
||||||
|
|
||||||
|
if (ARE_LOCALES_EQUAL(OptionName, LOCALE_WEATHER_API_KEY))
|
||||||
|
{
|
||||||
|
g_settings.weather_enabled = g_settings.weather_enabled && CApiKey::check_weather_api_key();
|
||||||
|
if (g_settings.weather_enabled)
|
||||||
|
weather_api_key_short = g_settings.weather_api_key.substr(0, 8) + "...";
|
||||||
|
else
|
||||||
|
weather_api_key_short.clear();
|
||||||
|
weather_onoff->setActive(CApiKey::check_weather_api_key());
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
46
src/gui/weather_setup.h
Normal file
46
src/gui/weather_setup.h
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2020 TangoCash
|
||||||
|
|
||||||
|
License: GPLv2
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation;
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __weather_setup__
|
||||||
|
#define __weather_setup__
|
||||||
|
|
||||||
|
#include <gui/widget/menue.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
class CWeatherSetup : public CMenuTarget, CChangeObserver
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
int width, selected;
|
||||||
|
|
||||||
|
CMenuOptionChooser * weather_onoff;
|
||||||
|
std::string weather_api_key_short;
|
||||||
|
|
||||||
|
int showWeatherSetup();
|
||||||
|
int showSelectWeatherLocation();
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
CWeatherSetup();
|
||||||
|
~CWeatherSetup();
|
||||||
|
int exec(CMenuTarget* parent, const std::string & actionKey);
|
||||||
|
bool changeNotify(const neutrino_locale_t OptionName, void * /*data*/);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
Reference in New Issue
Block a user