Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

select settings with lvalues should store the index rather than the localized string #1691

Merged
merged 1 commit into from

3 participants

@jmarshallnz
Owner

Things that need testing:

  1. select settings with lvalues (they should store+retrieve index rather than localized string).
  2. select settings with fileenum (should return the file)
  3. select settings with values (should return values)

@MartijnKaijser @amet please test.

@amet

seems that 1 and 3 are fine, I cant get fileenum to work .. how was it supposed to be used?

@MartijnKaijser

If it is supposed to work like this:
id="file" type="select" source="/resources/lib/" mask=".py"

it works.
this saves selected filename.

@amet

also, below(or similar) is needed to have it select the actual default value

diff --git a/xbmc/addons/GUIDialogAddonSettings.cpp b/xbmc/addons/GUIDialogAddonSettings.cpp
index 4bd19d3f52e6628f0c9b9254cc504dfc01194300..f996123bed118557824df79e734cb46b9112584e 100644
--- a/xbmc/addons/GUIDialogAddonSettings.cpp
+++ b/xbmc/addons/GUIDialogAddonSettings.cpp
@@ -290,9 +290,10 @@ bool CGUIDialogAddonSettings::ShowVirtualKeyboard(int iControl)
             else if (setting->Attribute("lvalues"))
             { // localize
               CUtil::Tokenize(setting->Attribute("lvalues"), valuesVec, "|");
+              CStdString valueDefault = setting->Attribute("default");
               for (unsigned int i = 0; i < valuesVec.size(); i++)
               {
-                if (valuesVec[i] == value)
+                if (valuesVec[i] == valuesVec[atoi(valueDefault)])
                   selected = i;
                 CStdString value = m_addon->GetString(atoi(valuesVec[i]));
                 if (value.IsEmpty())
@@ -309,7 +310,7 @@ bool CGUIDialogAddonSettings::ShowVirtualKeyboard(int iControl)
             {
               pDlg->Add(valuesVec[i]);
               if (selected == (int)i || (selected < 0 && valuesVec[i].Equals(value)))
-                pDlg->SetSelected(i); // FIXME: the SetSelected() does not select "i", it always defaults to the first position
+                pDlg->SetSelected(valuesVec[i]); // FIXME: the SetSelected() does not select "i", it always defaults to the first position
             }
             pDlg->DoModal();
             int iSelected = pDlg->GetSelectedLabel();
@amet

ok, using what @MartijnKaijser posted works for me as well, one strange thing is that the list is in reverse alphabetical order. it would be nice if it was not in reverse, but I'd accept it as it is if that's all we can get :)

https://dl.dropbox.com/u/19359762/R_alpha.jpg

@MartijnKaijser

I'm not seeing the same as @amet All listed alphabetical.

@jmarshallnz
Owner

@amet: The default shouldn't be selected there, instead the previous value should be selected (i.e. how I had it).

There could be some clashing with the CStdString value in the loop - change that to

CStdString localized = m_addon->GetString(atoi(valuesVec[i]));
if (localized.IsEmpty())
localized = g_localizeStrings.Get(atoi(valuesVec[i]));
valuesVec[i] = localized;

@amet

@jmarshallnz nope, doesnt select default still

I added some logging and if (valuesVec[i] == value) is looking rather strange, valuesVec[i] is "30201|30202|30203 ...." and value is "11"

if (valuesVec[i] == valuesVec[atoi(value)]) is however correct(at least on my side) with changes you mentioned above

@jmarshallnz
Owner

Sorry - it should be if (i == atoi(value))

@amet

works here, thx!

@jmarshallnz jmarshallnz merged commit 65b6a3c into xbmc:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 28, 2012
  1. select settings with lvalues should store the index rather than the l…

    Jonathan Marshall authored
    …ocalized string
This page is out of date. Refresh to see the latest.
Showing with 25 additions and 7 deletions.
  1. +25 −7 xbmc/addons/GUIDialogAddonSettings.cpp
View
32 xbmc/addons/GUIDialogAddonSettings.cpp
@@ -283,6 +283,7 @@ bool CGUIDialogAddonSettings::ShowVirtualKeyboard(int iControl)
pDlg->SetHeading(label.c_str());
pDlg->Reset();
+ int selected = -1;
vector<CStdString> valuesVec;
if (setting->Attribute("values"))
CUtil::Tokenize(setting->Attribute("values"), valuesVec, "|");
@@ -291,10 +292,12 @@ bool CGUIDialogAddonSettings::ShowVirtualKeyboard(int iControl)
CUtil::Tokenize(setting->Attribute("lvalues"), valuesVec, "|");
for (unsigned int i = 0; i < valuesVec.size(); i++)
{
- CStdString value = m_addon->GetString(atoi(valuesVec[i]));
- if (value.IsEmpty())
- value = g_localizeStrings.Get(atoi(valuesVec[i]));
- valuesVec[i] = value;
+ if (i == atoi(value))
+ selected = i;
+ CStdString localized = m_addon->GetString(atoi(valuesVec[i]));
+ if (localized.IsEmpty())
+ localized = g_localizeStrings.Get(atoi(valuesVec[i]));
+ valuesVec[i] = localized;
}
}
else if (source)
@@ -305,15 +308,18 @@ bool CGUIDialogAddonSettings::ShowVirtualKeyboard(int iControl)
for (unsigned int i = 0; i < valuesVec.size(); i++)
{
pDlg->Add(valuesVec[i]);
- if (valuesVec[i].Equals(value))
+ if (selected == (int)i || (selected < 0 && valuesVec[i].Equals(value)))
pDlg->SetSelected(i); // FIXME: the SetSelected() does not select "i", it always defaults to the first position
}
pDlg->DoModal();
int iSelected = pDlg->GetSelectedLabel();
if (iSelected >= 0)
{
- value = valuesVec[iSelected];
- ((CGUIButtonControl*) control)->SetLabel2(value);
+ if (setting->Attribute("lvalues"))
+ value.Format("%i", iSelected);
+ else
+ value = valuesVec[iSelected];
+ ((CGUIButtonControl*) control)->SetLabel2(valuesVec[iSelected]);
}
}
}
@@ -706,6 +712,18 @@ void CGUIDialogAddonSettings::CreateControls()
{
if (isAddonSetting)
((CGUIButtonControl *)pControl)->SetLabel2(GetAddonNames(value));
+ else if (strcmpi(type, "select") == 0 && !lvalues.empty())
+ {
+ vector<string> valuesVec = StringUtils::Split(lvalues, "|");
+ int selected = atoi(value.c_str());
+ if (selected >= 0 && selected < (int)valuesVec.size())
+ {
+ CStdString label = m_addon->GetString(atoi(valuesVec[selected].c_str()));
+ if (label.empty())
+ label = g_localizeStrings.Get(atoi(valuesVec[selected].c_str()));
+ ((CGUIButtonControl *)pControl)->SetLabel2(label);
+ }
+ }
else
((CGUIButtonControl *)pControl)->SetLabel2(value);
}
Something went wrong with that request. Please try again.