added possibility to define help texts for skin setup parameters

This commit is contained in:
louis 2015-08-14 17:23:12 +02:00
parent f44aabb7ac
commit a5d7d6437d
11 changed files with 110 additions and 29 deletions

View File

@ -428,3 +428,6 @@ Version 0.7.0
Version 0.7.1
- fixed bug that setup int parameters do not respect the max value
- added possibility to define help texts for skin setup parameters
Version 0.7.2

View File

@ -17,6 +17,7 @@
min NMTOKEN #IMPLIED
max NMTOKEN #IMPLIED
displaytext CDATA #REQUIRED
helptext CDATA #IMPLIED
options CDATA #IMPLIED
>

View File

@ -9,6 +9,7 @@ cSkinSetupParameter::cSkinSetupParameter(void) {
type = sptUnknown;
name = "";
displayText = "";
helpText = "";
min = 0;
max = 1000;
value = 0;
@ -106,11 +107,12 @@ void cSkinSetupMenu::InitIterators(void) {
subMenuIt = subMenus.begin();
}
void cSkinSetupMenu::SetParameter(eSetupParameterType paramType, string name, string displayText, string min, string max, string value, string options) {
void cSkinSetupMenu::SetParameter(eSetupParameterType paramType, string name, string displayText, string helpText, string min, string max, string value, string options) {
cSkinSetupParameter *param = new cSkinSetupParameter();
param->type = paramType;
param->name = name;
param->displayText = displayText;
param->helpText = helpText;
if (min.size() && paramType == sptInt) {
param->min = atoi(min.c_str());
@ -221,7 +223,7 @@ void cSkinSetup::SubMenuDone(void) {
}
}
void cSkinSetup::SetParameter(string type, string name, string displayText, string min, string max, string value, string options) {
void cSkinSetup::SetParameter(string type, string name, string displayText, string helpText, string min, string max, string value, string options) {
if (!type.size() || !name.size() || !displayText.size() || !value.size()) {
esyslog("skindesigner: invalid setup parameter for skin %s", skin.c_str());
return;
@ -238,7 +240,7 @@ void cSkinSetup::SetParameter(string type, string name, string displayText, stri
esyslog("skindesigner: invalid setup parameter for skin %s", skin.c_str());
return;
}
currentMenu->SetParameter(paramType, name, displayText, min, max, value, options);
currentMenu->SetParameter(paramType, name, displayText, helpText, min, max, value, options);
}
cSkinSetupParameter *cSkinSetup::GetNextParameter(void) {
@ -278,6 +280,10 @@ void cSkinSetup::TranslateSetup(void) {
if (Translate(param->displayText, transl)) {
param->displayText = transl;
}
string translHelp = "";
if (Translate(param->helpText, translHelp)) {
param->helpText = translHelp;
}
if (param->type == sptString && param->numOptions > 0) {
param->optionsTranslated = new const char*[param->numOptions];
for (int i = 0; i < param->numOptions; i++) {

View File

@ -29,6 +29,7 @@ public:
eSetupParameterType type;
string name;
string displayText;
string helpText;
int min;
int max;
int value;
@ -59,7 +60,7 @@ public:
void SetParent(cSkinSetupMenu *p) { parent = p; };
cSkinSetupMenu *GetParent(void) { return parent; };
void AddSubMenu(cSkinSetupMenu *sub) { subMenus.push_back(sub); };
void SetParameter(eSetupParameterType paramType, string name, string displayText, string min, string max, string value, string options);
void SetParameter(eSetupParameterType paramType, string name, string displayText, string helpText, string min, string max, string value, string options);
void InitIterators(void);
void InitParameterIterator(void) { paramIt = parameters.begin(); };
cSkinSetupParameter *GetNextParameter(bool deep = true);
@ -86,7 +87,7 @@ public:
bool ReadFromXML(void);
void SetSubMenu(string name, string displayText);
void SubMenuDone(void);
void SetParameter(string type, string name, string displayText, string min, string max, string value, string options);
void SetParameter(string type, string name, string displayText, string helpText, string min, string max, string value, string options);
void InitParameterIterator(void) { rootMenu->InitIterators(); };
cSkinSetupParameter *GetNextParameter(void);
cSkinSetupParameter *GetParameter(string name);

View File

@ -588,6 +588,8 @@ void cXmlParser::ParseSetupParameter(void) {
string paramName = "";
string attributeDisplayText = "displaytext";
string paramDisplayText = "";
string attributeHelpText = "helptext";
string paramHelpText = "";
string attributeMin = "min";
string paramMin = "";
string attributeMax = "max";
@ -599,12 +601,13 @@ void cXmlParser::ParseSetupParameter(void) {
GetAttribute(attributeType, paramType);
GetAttribute(attributeName, paramName);
GetAttribute(attributeDisplayText, paramDisplayText);
GetAttribute(attributeHelpText, paramHelpText);
GetAttribute(attributeMin, paramMin);
GetAttribute(attributeMax, paramMax);
GetAttribute(attributeOptions, paramOptions);
GetNodeValue(paramValue);
skinSetup->SetParameter(paramType, paramName, paramDisplayText, paramMin, paramMax, paramValue, paramOptions);
skinSetup->SetParameter(paramType, paramName, paramDisplayText, paramHelpText, paramMin, paramMax, paramValue, paramOptions);
}
void cXmlParser::ValidateAttributes(const char *nodeName, vector<stringpair> &attributes) {

View File

@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: vdr-skindesigner 0.0.1\n"
"Report-Msgid-Bugs-To: <see README>\n"
"POT-Creation-Date: 2015-07-17 17:02+0200\n"
"POT-Creation-Date: 2015-08-14 17:20+0200\n"
"PO-Revision-Date: 2014-09-27 11:02+0200\n"
"Last-Translator: Louis Braun <louis.braun@gmx.de>\n"
"Language-Team: \n"
@ -156,6 +156,9 @@ msgstr "Weitere verfügbare Skins"
msgid "Preview Skin"
msgstr "Skin Vorschau"
msgid "Help"
msgstr "Hilfe"
msgid "Author"
msgstr "Autor"
@ -164,3 +167,4 @@ msgstr "Benutze Schriften"
msgid "Supported Plugins"
msgstr "Unterstützte Plugins"

View File

@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: vdr-skindesigner 0.2.0\n"
"Report-Msgid-Bugs-To: <see README>\n"
"POT-Creation-Date: 2015-07-17 17:02+0200\n"
"POT-Creation-Date: 2015-08-14 17:20+0200\n"
"PO-Revision-Date: 2015-01-25 01:25+0200\n"
"Last-Translator: Rolf Ahrenberg\n"
"Language-Team: Finnish\n"
@ -156,6 +156,9 @@ msgstr ""
msgid "Preview Skin"
msgstr ""
msgid "Help"
msgstr ""
msgid "Author"
msgstr ""

47
setup.c
View File

@ -1,5 +1,6 @@
#include <vdr/interface.h>
#include "libcore/curlfuncs.h"
#include <vdr/menu.h>
#include "setup.h"
// --- cInstallManager -----------------------------------------------------------
@ -386,6 +387,12 @@ cOsdMenu(*cString::sprintf("%s: %s \"%s\" %s", trVDR("Setup"), tr("Skin"), skin.
SetMenuCategory(mcPluginSetup);
this->skin = skin;
this->menu = menu;
buttonRed = tr("Update");
buttonGreen = tr("Help");
buttonYellow = tr("Delete Skin");
showRed = false;
showYellow = false;
hadHelp = false;
Set();
}
@ -397,6 +404,9 @@ eOSState cSkindesignerSkinSetup::ProcessKey(eKeys Key) {
if (state == osEnd)
return osEnd;
state = cOsdMenu::ProcessKey(Key);
if (Key == kUp || Key == kDown) {
ShowButtons(Current());
}
if (state == osUnknown) {
switch (Key) {
case kOk: {
@ -443,6 +453,17 @@ eOSState cSkindesignerSkinSetup::ProcessKey(eKeys Key) {
state = osContinue;
break;
}
case kGreen: {
string helpText = helpTexts[Current()];
if (helpText.size() == 0) {
state = osContinue;
break;
}
const char* ItemText = Get(Current())->Text();
string title = *cString::sprintf("%s - %s", buttonGreen.c_str(), ItemText);
state = AddSubMenu(new cMenuText(title.c_str(), helpText.c_str()));
break;
}
default:
break;
}
@ -457,13 +478,11 @@ void cSkindesignerSkinSetup::Set(void) {
}
cSkinRepo *repo = config.GetSkinRepo(skin);
if (repo) {
if (repo->Type() == rtGit)
SetHelp(tr("Update"), NULL, tr("Delete Skin"), NULL);
else
SetHelp(NULL, NULL, tr("Delete Skin"), NULL);
}
if (repo && repo->Type() == rtGit)
showRed = true;
if (repo)
showYellow = true;
setupMenu->InitParameterIterator();
cSkinSetupParameter *param = NULL;
while (param = setupMenu->GetNextParameter(false)) {
@ -474,13 +493,27 @@ void cSkindesignerSkinSetup::Set(void) {
} else if (param->type == sptString) {
Add(new cMenuEditStraItem(param->displayText.c_str(), &param->value, param->numOptions, param->optionsTranslated));
}
helpTexts.push_back(param->helpText);
}
setupMenu->InitSubmenuIterator();
cSkinSetupMenu *subMenu = NULL;
while (subMenu = setupMenu->GetNextSubMenu(false)) {
Add(new cSkinSetupSubMenu(subMenu->GetName(), subMenu->GetDisplayText()));
helpTexts.push_back("");
}
ShowButtons(0, true);
}
void cSkindesignerSkinSetup::ShowButtons(int current, bool force) {
bool showGreen = helpTexts[current].size() > 0 ? true : false;
bool changed = false;
if ((hadHelp && !showGreen) || (!hadHelp && showGreen))
changed = true;
hadHelp = showGreen;
if (changed || force)
SetHelp(showRed ? buttonRed.c_str() : "", showGreen ? buttonGreen.c_str() : "", showYellow ? buttonYellow.c_str() : "", NULL);
}
// --- cSkindesignerSkinPreview -----------------------------------------------------------

View File

@ -93,6 +93,14 @@ class cSkindesignerSkinSetup : public cOsdMenu, cInstallManager {
private:
string skin;
string menu;
vector<string> helpTexts;
string buttonRed;
string buttonGreen;
string buttonYellow;
bool showRed;
bool showYellow;
bool hadHelp;
void ShowButtons(int current, bool force = false);
protected:
virtual eOSState ProcessKey(eKeys Key);
void Set(void);

View File

@ -3,12 +3,12 @@
<setup>
<menu>
<parameter type="int" name="fadetime" min="0" max="1000" displaytext="{tr(fadetext)}">0</parameter>
<parameter type="int" name="shifttimechannel" min="0" max="1000" displaytext="{tr(shifttimechanneltext)}">0</parameter>
<parameter type="int" name="shifttimedatetime" min="0" max="1000" displaytext="{tr(shifttimedatetimetext)}">0</parameter>
<parameter type="int" name="shifttimetimers" min="0" max="1000" displaytext="{tr(shifttimetimerstext)}">0</parameter>
<parameter type="bool" name="showdevices" displaytext="{tr(showdevices)}">0</parameter>
<parameter type="string" name="mainmenuorientation" displaytext="{tr(mainmenuorientation)}" options="horizontal,vertical">1</parameter>
<parameter type="int" name="fadetime" min="0" max="1000" displaytext="{tr(fadetext)}" helptext="{tr(helpfade)}">0</parameter>
<parameter type="int" name="shifttimechannel" min="0" max="1000" displaytext="{tr(shifttimechanneltext)}" helptext="{tr(helpshifttimechannel)}">0</parameter>
<parameter type="int" name="shifttimedatetime" min="0" max="1000" displaytext="{tr(shifttimedatetimetext)}" helptext="{tr(helpshifttimedatetime)}">0</parameter>
<parameter type="int" name="shifttimetimers" min="0" max="1000" displaytext="{tr(shifttimetimerstext)}" helptext="{tr(helpshifttimetimers)}">0</parameter>
<parameter type="bool" name="showdevices" displaytext="{tr(showdevices)}" helptext="{tr(helpshowdevices)}">0</parameter>
<parameter type="string" name="mainmenuorientation" displaytext="{tr(mainmenuorientation)}" helptext="{tr(helpmainmenuorientation)}" options="horizontal,vertical">1</parameter>
<parameter type="string" name="recmenuorientation" displaytext="{tr(recmenuorientation)}" options="horizontal,vertical">1</parameter>
<parameter type="string" name="weathermenuorientation" displaytext="{tr(weathermenuorientation)}" options="horizontal,vertical">1</parameter>
</menu>
@ -19,27 +19,51 @@
<trans lang="de_DE">Einblendzeit [ms]</trans>
<trans lang="fi_FI">Häivytyksen kesto [ms]</trans>
</token>
<token name="tr(helpfade)">
<trans lang="en_EN">Fade time in ms. If this is set to a value larger 0 all OSD elements beside the VDR menu fade in and out.</trans>
<trans lang="de_DE">Einblendzeit in ms. Ist dieser Wert auf einen Wert > 0 gesetzt, werden alle OSD Elemente ausser dem VDR Menu ein- und ausgeblendet</trans>
</token>
<token name="tr(shifttimechanneltext)">
<trans lang="en_EN">Shift time Channel Display [ms]</trans>
<trans lang="de_DE">Einfahrzeit Channel Display [ms]</trans>
</token>
<token name="tr(helpshifttimechannel)">
<trans lang="en_EN">Shifting time in ms. If this is set to a value larger 0 all OSD elements beside the VDR menu are shifted in and out from the bottom of the screen. If fadetime is also set to a value larger 0, still shifting is performed</trans>
<trans lang="de_DE">Einfahrzeit in ms. Ist dieser Wert auf einen Wert > 0 gesetzt, werden alle OSD Elemente ausser dem VDR Menu vom unteren Rand des Bildschirms herein- und herausgefahren. Falls fadetime ebenfalls auf einen Wert größer 0 gesetzt ist, wird das OSD trotzdem herein- und herausgefahren.</trans>
</token>
<token name="tr(shifttimedatetimetext)">
<trans lang="en_EN">Shift time Channel Date, Time, Weather [ms]</trans>
<trans lang="de_DE">Einfahrzeit Channel Date, Time, Wetter [ms]</trans>
</token>
<token name="tr(helpshifttimedatetime)">
<trans lang="en_EN">Shifting time of OSD Elements date, time and weather when switching in ms. If set to 0, the elements are shown immediately.</trans>
<trans lang="de_DE">Einfahrzeit der OSD Elemente Datum, Zeit und Wetter während des Umschaltens in ms. Steht dieser Wert auf 0, werden die Elemente sofort angezeigt.</trans>
</token>
<token name="tr(shifttimetimerstext)">
<trans lang="en_EN">Shift time Timers Main Menu [ms]</trans>
<trans lang="de_DE">Einfahrzeit Timer Hauptmenü [ms]</trans>
</token>
<token name="tr(helpshifttimetimers)">
<trans lang="en_EN">Shifting time of timers display in main menu in ms. If set to 0, the timers are shown immediately.</trans>
<trans lang="de_DE">Einfahrzeit der Timer im Hauptmenü in ms. Steht dieser Wert auf 0, werden die Timer sofort angezeigt.</trans>
</token>
<token name="tr(showdevices)">
<trans lang="en_EN">Show DVB device info when switching channel</trans>
<trans lang="de_DE">DVB Karten Info beim Umschalten anzeigen</trans>
<trans lang="en_EN">Show DVB device info</trans>
<trans lang="de_DE">DVB Karten Info anzeigen</trans>
<trans lang="fi_FI">Näytä DVB-tiedot kanavanvaihdossa</trans>
</token>
<token name="tr(helpshowdevices)">
<trans lang="en_EN">If set to true, information about usage of each available DVB device is displayed during channel switching and in the main menu</trans>
<trans lang="de_DE">Falls diese Option aktiviert ist, werden beim Umschalten und im Hauptmenü Informationen über alle verfügbaren DVB Devices ausgegeben.</trans>
</token>
<token name="tr(mainmenuorientation)">
<trans lang="en_EN">Orientation of main menu</trans>
<trans lang="de_DE">Ausrichtung des Hauptmenüs</trans>
</token>
<token name="tr(helpmainmenuorientation)">
<trans lang="en_EN">Orientation of main menu. If orientation is set to horizontal, only the current list element is displayed. If set to vertical, 8 elements are shown in the list.</trans>
<trans lang="de_DE">Ausrichtung des Hauptmenüs. Falls die Ausrichtung auf horizontal gesetzt ist, wird nur das aktuelle Listenelement ausgegeben. Ist die Ausrichtung vertikal, werden 8 Listenelemente angezeigt.</trans>
</token>
<token name="tr(recmenuorientation)">
<trans lang="en_EN">Orientation of recordings menu</trans>
<trans lang="de_DE">Ausrichtung des Aufzeichnugsmenüs</trans>

View File

@ -4,11 +4,6 @@
<fill color="{clrTransBlack}" />
</area>
</background>
<header>
<area x="0" y="0" width="75%" height="10%" layer="2">
<drawtext x="5" valign="center" font="{light}" fontsize="50%" color="{clrWhite}" text="{title}" />
</area>
</header>
<datetime>
<area x="75%" y="0" width="12%" height="10%" layer="2">
<drawtext align="right" y="15%" font="{light}" fontsize="30%" color="{clrWhite}" text="{dayname}" />
@ -70,6 +65,6 @@
</scrollbar>
<tab name="text" x="2%" y="10%" width="94%" height="80%" layer="2" scrollheight="{areaheight}/4">
<drawtextbox x="0" y="0" width="96%" font="{light}" fontsize="5%" color="{clrWhite}" text="{text}" />
<drawtextbox x="0" y="0" width="96%" font="{light}" fontsize="7%" color="{clrWhite}" text="{text}" />
</tab>
</menudetailedtext>