Need some assistance understanding and modifying XBMC source code
#1
I'm attempting to produce an added feature to XBMC(one that I find quite useful). I have most of the changes made(and figured out) but slightly stumped on two things.

In GUISettings.cpp I have the following:

Code:
CSettingsCategory* acd = AddCategory(3, "audiocds", 620);
  AddBool(acd, "audiocds.autorun", 14085, false);
  AddBool(acd, "audiocds.autorip", 14096, false);
  AddBool(acd, "audiocds.autoeject", 14097, false);
  AddBool(acd, "audiocds.usecddb", 227, true);
  AddSeparator(acd, "audiocds.sep1");

What I would like to accomplish first is changing the bool of "audiocds.autorun" and "audiocds.autorip" based on one another.

For example:

If audiocds.autorun is true, audiocds.autorip needs to be false and vice versa. Both options can be false of course.

The second item I would like to accomplish is hiding the option "AddBool(acd, "audiocds.autoeject", 14097, false);" if audiocds.autorip is false.

Thanks in advanced...
Reply
#2
see CGUIWindowSettingsCategory::OnSettingChanged()
Reply
#3
that being said; this would be much more elegant if it was handled by a popup dialog like in most oses with the option to set an action as default.
Reply
#4
Not sure if this is right, but I put the following into CGUIWindowSettingsCategory::OnSettingChanged(), to hide my 'eject CD when finished' setting if autorip is false.

Code:
else if (strSetting.Equals("audiocds.autoeject"))
    { // hide setting if Autorip is turned off(false)
      CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
      if (pControl) pControl->SetEnabled(g_guiSettings.GetBool("audiocds.autorip"));
    }

And for switching the Auto Play/ Auto Rip:

Code:
else if (strSetting.Equals("audiocds.autorun"))
    {  // if auto play set to true, set auto rip to false
      if (g_guiSettings.GetBool("audiocds.autorun"))
        g_guiSettings.SetBool("audiocds.autorip", false);
    }
    else if (strSetting.Equals("audiocds.autorip"))
    {  // if auto rip set to true, set auto play to false
      if (g_guiSettings.GetBool("audiocds.autorip"))
        g_guiSettings.SetBool("audiocds.autorun", false);
    }

Am I headed in the right direction?
Reply
#5
Why don't you replace the two boolean options auto play and auto rip with a "spinbox" option providing the following choices: nothing, auto play, auto rip? Auto play and Auto rip exclude one another so this would be much cleaner in my opinion as you could also drop the OnSettingsChanged handling for these two options.
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
#6
agreed ^^. as such your code is correct.
Reply
#7
This is what I have come up with, changing it to SPIN_CONTROL_TEXT. In the process of compiling right now(wishing I had a multi-core processor to do so...)

Inside GUISetting.h

Code:
#define AUTOCD_NONE              0
#define AUTOCD_PLAY              1
#define AUTOCD_RIP               2

Inside GUISettings.cpp

Code:
CSettingsCategory* acd = AddCategory(3, "audiocds", 620);
  map<int,int> autocd;
  autocd.insert(make_pair(16018, AUTOCD_NONE));
  autocd.insert(make_pair(14085, AUTOCD_PLAY));
  autocd.insert(make_pair(14097, AUTOCD_RIP));
  AddInt(acd,"audocds.auto",14099,AUTOCD_NONE, autocd,SPIN_CONTROL_TEXT);
  AddBool(NULL, "audiocds.autorun", 14085, false);
  AddBool(NULL, "audiocds.autorip", 14096, false);
  AddBool(acd, "audiocds.usecddb", 227, true);


Inside GUIWindowSettingsCatagory.cpp

Code:
else if (strSetting.Equals("audiocds.auto"))
    {
      switch (g_guiSettings.GetInt("audiocds.auto"))
      {
        case AUTOCD_NONE: // If Set to None, Set autorip & autorun to false
          g_guiSettings.SetBool("audiocds.autorip", false);
          g_guiSettings.SetBool("audiocds.autorun", false);
          break;
        case AUTOCD_PLAY: // If Set to Play, Set autorip false & autorun to true
          g_guiSettings.SetBool("audiocds.autorip", false);
          g_guiSettings.SetBool("audiocds.autorun", true);
          break;
        case AUTOCD_RIP: // If Set to Rip, Set autorip true & autorun to false
          g_guiSettings.SetBool("audiocds.autorip", true);
          g_guiSettings.SetBool("audiocds.autorun", false);
          break;
        default:
          g_guiSettings.SetBool("audiocds.autorip", false);
          g_guiSettings.SetBool("audiocds.autorun", false);
          break;    
      }
    }

One thing I am not sure of is the use of the NULL in the AddBool.. I am hoping this allows the use of the Boolean settings with out it being visible on the settings window.. I thought keeping the boolean settings(mainly audiocds.autorun) is the proper way to go instead of messing with the already existing programming.

Crossing my fingers that I am on the right track...
Reply
#8
To make things easier to follow, next time please pastebin a patch or create a ticket in trac and attach the patch.

AddBool(NULL, ... is fine to hide a setting.

You have a typo there:
Code:
AddInt(acd,"audocds.auto",14099,AUTOCD_NONE, autocd,SPIN_CONTROL_TEXT);

"audiocds.auto" most likely. "audiocds.autoaction" might be more self-descriptive.

I'd simplify things and convert the code that uses audiocds.autorun and audiocds.autorip to use the new setting instead. It shouldn't be complicated: instead of testing the guisetting audiocds.autorun for true/false, test the guisetting audiocds.auto for one of the #defined values.

spiff?
Always read the Kodi online-manual, the FAQ and search the forum before posting.
Do not e-mail Kodi Team members directly asking for support. Read/follow the forum rules (wiki).
For troubleshooting and bug reporting please make sure you read this first.
Reply
#9
Thanks for the Typo catch... And you are correct that it would be better to actually change the testing of the Boolean to testing the value of audiocds.autoaction. Then the addition I made to GUIWindowSettingsCatagory.cpp is not needed(and probably less programming lol...)

Once I get this fine tuned I'll submit a patch on trac for review...
Reply

Logout Mark Read Team Forum Stats Members Help
Need some assistance understanding and modifying XBMC source code0