Skip to content
This repository
Browse code

Merge pull request #2577 from leechguy/CONTROL_AUTOLOGIN

Set autologin profile via the GUI
  • Loading branch information...
commit a3b51400385e5b18763d56e93e1a0a5bc5f683f7 2 parents 8172cd2 + f9f40dd
authored April 09, 2013
77  addons/skin.confluence/720p/SettingsProfile.xml
@@ -68,8 +68,8 @@
68 68
 				<posx>10</posx>
69 69
 				<posy>90</posy>
70 70
 				<width>250</width>
71  
-				<height>80</height>
72  
-				<textoffsety>13</textoffsety>
  71
+				<height>72</height>
  72
+				<textoffsety>8</textoffsety>
73 73
 				<label>20096</label>
74 74
 				<font>font24_title</font>
75 75
 				<align>right</align>
@@ -78,13 +78,13 @@
78 78
 				<texturefocus border="5">MenuItemFO.png</texturefocus>
79 79
 				<onleft>2</onleft>
80 80
 				<onright>2</onright>
81  
-				<onup>4</onup>
82  
-				<ondown>4</ondown>
  81
+				<onup>5</onup>
  82
+				<ondown>5</ondown>
83 83
 				<enable>!Window.IsVisible(ProfileSettings)</enable>
84 84
 			</control>
85 85
 			<control type="label">
86 86
 				<posx>250</posx>
87  
-				<posy>135</posy>
  87
+				<posy>130</posy>
88 88
 				<width>240</width>
89 89
 				<height>25</height>
90 90
 				<font>font13</font>
@@ -96,7 +96,7 @@
96 96
 			</control>
97 97
 			<control type="label">
98 98
 				<posx>250</posx>
99  
-				<posy>135</posy>
  99
+				<posy>130</posy>
100 100
 				<width>240</width>
101 101
 				<height>25</height>
102 102
 				<font>font13</font>
@@ -106,9 +106,64 @@
106 106
 				<label>1223</label>
107 107
 				<visible>!System.HasLoginScreen</visible>
108 108
 			</control>
  109
+			<control type="button" id="5"> 
  110
+				<description>Choose auto login user</description> 
  111
+				<posx>10</posx> 
  112
+				<posy>161</posy> 
  113
+				<width>250</width> 
  114
+				<height>72</height> 
  115
+				<textoffsety>8</textoffsety> 
  116
+				<label>31960</label> 
  117
+				<font>font24_title</font> 
  118
+				<align>right</align> 
  119
+				<aligny>top</aligny> 
  120
+				<texturenofocus border="5">MenuItemNF.png</texturenofocus> 
  121
+				<texturefocus border="5">MenuItemFO.png</texturefocus> 
  122
+				<onleft>2</onleft> 
  123
+				<onright>2</onright> 
  124
+				<onup>4</onup> 
  125
+				<ondown>4</ondown> 
  126
+				<visible>!System.HasLoginScreen</visible> 
  127
+				<enable>!Window.IsVisible(ProfileSettings) + !System.HasLoginScreen</enable> 
  128
+			</control> 
  129
+			<control type="button"> 
  130
+				<description>Choose auto login user (grayed out)</description> 
  131
+				<posx>10</posx> 
  132
+				<posy>161</posy> 
  133
+				<width>250</width> 
  134
+				<height>72</height> 
  135
+				<textoffsety>8</textoffsety> 
  136
+				<label>31960</label> 
  137
+				<font>font24_title</font> 
  138
+				<textcolor>grey2</textcolor> 
  139
+				<align>right</align> 
  140
+				<aligny>top</aligny> 
  141
+				<texturenofocus border="5">MenuItemNF.png</texturenofocus> 
  142
+				<texturefocus border="5">MenuItemFO.png</texturefocus> 
  143
+				<onleft>2</onleft> 
  144
+				<onright>2</onright> 
  145
+				<onup>4</onup> 
  146
+				<ondown>4</ondown> 
  147
+				<visible>System.HasLoginScreen</visible> 
  148
+				<enable>false</enable> 
  149
+			</control> 
  150
+			<control type="label"> 
  151
+				<posx>247</posx> 
  152
+				<posy>201</posy> 
  153
+				<width>200</width> 
  154
+				<height>25</height> 
  155
+				<font>font13caps</font> 
  156
+				<textcolor>grey2</textcolor> 
  157
+				<align>right</align> 
  158
+ 				<aligny>center</aligny> 
  159
+				<label>$INFO[System.ProfileAutoLogin]</label> 
  160
+				<scroll>Control.HasFocus(5)</scroll> 
  161
+				<scrollspeed>30</scrollspeed> 
  162
+				<visible>!System.HasLoginScreen</visible> 
  163
+			</control> 
109 164
 			<control type="group">
110 165
 				<posx>20</posx>
111  
-				<posy>210</posy>
  166
+				<posy>260</posy>
112 167
 				<control type="image">
113 168
 					<posx>0</posx>
114 169
 					<posy>0</posy>
@@ -121,7 +176,7 @@
121 176
 				</control>
122 177
 				<control type="label">
123 178
 					<posx>0</posx>
124  
-					<posy>220</posy>
  179
+					<posy>210</posy>
125 180
 					<width>240</width>
126 181
 					<height>20</height>
127 182
 					<font>font12_title</font>
@@ -132,7 +187,7 @@
132 187
 				</control>
133 188
 				<control type="label">
134 189
 					<posx>0</posx>
135  
-					<posy>245</posy>
  190
+					<posy>235</posy>
136 191
 					<width>240</width>
137 192
 					<height>20</height>
138 193
 					<font>font13</font>
@@ -143,7 +198,7 @@
143 198
 				</control>
144 199
 				<control type="label">
145 200
 					<posx>0</posx>
146  
-					<posy>280</posy>
  201
+					<posy>265</posy>
147 202
 					<width>240</width>
148 203
 					<height>30</height>
149 204
 					<font>font12_title</font>
@@ -154,7 +209,7 @@
154 209
 				</control>
155 210
 				<control type="label">
156 211
 					<posx>0</posx>
157  
-					<posy>305</posy>
  212
+					<posy>290</posy>
158 213
 					<width>240</width>
159 214
 					<height>30</height>
160 215
 					<font>font13</font>
4  addons/skin.confluence/language/English/strings.po
@@ -667,3 +667,7 @@ msgstr ""
667 667
 msgctxt "#31959"
668 668
 msgid "SYSTEM"
669 669
 msgstr ""
  670
+
  671
+msgctxt "#31960"
  672
+msgid "Auto login"
  673
+msgstr ""
5  language/English/strings.po
@@ -11887,3 +11887,8 @@ msgstr ""
11887 11887
 msgctxt "#37013"
11888 11888
 msgid "(Directors Comments)"
11889 11889
 msgstr ""
  11890
+
  11891
+#: xbmc/GUIInfoManager.cpp
  11892
+msgctxt "#37014"
  11893
+msgid "Most recent"
  11894
+msgstr ""
13  xbmc/GUIInfoManager.cpp
@@ -268,6 +268,7 @@ const infomap system_labels[] =  {{ "hasnetwork",       SYSTEM_ETHERNET_LINK_ACT
268 268
                                   { "profilename",      SYSTEM_PROFILENAME },
269 269
                                   { "profilethumb",     SYSTEM_PROFILETHUMB },
270 270
                                   { "profilecount",     SYSTEM_PROFILECOUNT },
  271
+                                  { "profileautologin", SYSTEM_PROFILEAUTOLOGIN },
271 272
                                   { "progressbar",      SYSTEM_PROGRESS_BAR },
272 273
                                   { "batterylevel",     SYSTEM_BATTERY_LEVEL },
273 274
                                   { "friendlyname",     SYSTEM_FRIENDLY_NAME },
@@ -1751,6 +1752,18 @@ CStdString CGUIInfoManager::GetLabel(int info, int contextWindow, CStdString *fa
1751 1752
   case SYSTEM_PROFILECOUNT:
1752 1753
     strLabel.Format("%i", CProfilesManager::Get().GetNumberOfProfiles());
1753 1754
     break;
  1755
+  case SYSTEM_PROFILEAUTOLOGIN:
  1756
+    {
  1757
+      int profileId = CProfilesManager::Get().GetAutoLoginProfileId();
  1758
+      if (profileId == -1)
  1759
+        strLabel = g_localizeStrings.Get(37014); // Most recent
  1760
+      else
  1761
+      {
  1762
+        const CProfile *profile = CProfilesManager::Get().GetProfile(profileId);
  1763
+        strLabel = profile->getName();
  1764
+      }
  1765
+    }
  1766
+    break;
1754 1767
   case SYSTEM_LANGUAGE:
1755 1768
     strLabel = g_guiSettings.GetString("locale.language");
1756 1769
     break;
2  xbmc/GUIInfoManager.h
@@ -418,6 +418,8 @@ namespace INFO
418 418
 #define FANART_COLOR3               1002
419 419
 #define FANART_IMAGE                1003
420 420
 
  421
+#define SYSTEM_PROFILEAUTOLOGIN     1004
  422
+
421 423
 #define PVR_CONDITIONS_START        1100
422 424
 #define PVR_IS_RECORDING            (PVR_CONDITIONS_START)
423 425
 #define PVR_HAS_TIMER               (PVR_CONDITIONS_START + 1)
14  xbmc/profiles/ProfilesManager.h
@@ -142,6 +142,20 @@ class CProfilesManager : public ISettingsHandler
142 142
 
143 143
   int GetCurrentProfileId() const { return GetCurrentProfile().getId(); }
144 144
 
  145
+  /*! \brief Retrieve the autologin profile id
  146
+    Retrieves the autologin profile id. When set to -1, then the last
  147
+    used profile will be loaded
  148
+    \return the id to the autologin profile
  149
+    */
  150
+  int GetAutoLoginProfileId() const { return m_autoLoginProfile; }
  151
+
  152
+  /*! \brief Retrieve the autologin profile id
  153
+    Retrieves the autologin profile id. When set to -1, then the last
  154
+    used profile will be loaded
  155
+    \return the id to the autologin profile
  156
+    */
  157
+  void SetAutoLoginProfileId(const int profileId) { m_autoLoginProfile = profileId; }
  158
+
145 159
   std::string GetUserDataFolder() const;
146 160
   std::string GetProfileUserDataFolder() const;
147 161
   std::string GetDatabaseFolder() const;
54  xbmc/profiles/windows/GUIWindowSettingsProfile.cpp
@@ -24,6 +24,7 @@
24 24
 #include "profiles/ProfilesManager.h"
25 25
 #include "Application.h"
26 26
 #include "dialogs/GUIDialogContextMenu.h"
  27
+#include "dialogs/GUIDialogSelect.h"
27 28
 #include "profiles/dialogs/GUIDialogProfileSettings.h"
28 29
 #include "network/Network.h"
29 30
 #include "utils/URIUtils.h"
@@ -41,6 +42,7 @@ using namespace XFILE;
41 42
 #define CONTROL_PROFILES 2
42 43
 #define CONTROL_LASTLOADED_PROFILE 3
43 44
 #define CONTROL_LOGINSCREEN 4
  45
+#define CONTROL_AUTOLOGIN 5
44 46
 
45 47
 CGUIWindowSettingsProfile::CGUIWindowSettingsProfile(void)
46 48
     : CGUIWindow(WINDOW_SETTINGS_PROFILES, "SettingsProfile.xml")
@@ -168,6 +170,17 @@ bool CGUIWindowSettingsProfile::OnMessage(CGUIMessage& message)
168 170
         CProfilesManager::Get().Save();
169 171
         return true;
170 172
       }
  173
+      else if (iControl == CONTROL_AUTOLOGIN)
  174
+      {
  175
+    	int currentId = CProfilesManager::Get().GetAutoLoginProfileId();
  176
+        int profileId;
  177
+        if (GetAutoLoginProfileChoice(profileId) && (currentId != profileId))
  178
+        {
  179
+          CProfilesManager::Get().SetAutoLoginProfileId(profileId);
  180
+          CProfilesManager::Get().Save();
  181
+        }
  182
+        return true;
  183
+      }
171 184
     }
172 185
     break;
173 186
   }
@@ -219,3 +232,44 @@ void CGUIWindowSettingsProfile::OnInitWindow()
219 232
   CGUIWindow::OnInitWindow();
220 233
 }
221 234
 
  235
+bool CGUIWindowSettingsProfile::GetAutoLoginProfileChoice(int &iProfile)
  236
+{
  237
+  CGUIDialogSelect *dialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
  238
+  if (!dialog) return false;
  239
+
  240
+  // add items
  241
+  // "Most recent" option comes first, so up indices by 1
  242
+  int autoLoginProfileId = CProfilesManager::Get().GetAutoLoginProfileId() + 1;
  243
+  CFileItemList items;
  244
+  CFileItemPtr item(new CFileItem());
  245
+  item->SetLabel(g_localizeStrings.Get(37014)); // Most recent
  246
+  item->SetIconImage("unknown-user.png");
  247
+  items.Add(item);
  248
+
  249
+  for (unsigned int i = 0; i < CProfilesManager::Get().GetNumberOfProfiles(); i++)
  250
+  {
  251
+    const CProfile *profile = CProfilesManager::Get().GetProfile(i);
  252
+    CStdString locked = g_localizeStrings.Get(profile->getLockMode() > 0 ? 20166 : 20165);
  253
+    CFileItemPtr item(new CFileItem(profile->getName()));
  254
+    item->SetProperty("Addon.Summary", locked); // lock setting
  255
+    CStdString thumb = profile->getThumb();
  256
+    if (thumb.IsEmpty())
  257
+      thumb = "unknown-user.png";
  258
+    item->SetIconImage(thumb);
  259
+    items.Add(item);
  260
+  }
  261
+
  262
+  dialog->SetHeading(20093); // Profile name
  263
+  dialog->Reset();
  264
+  dialog->SetUseDetails(true);
  265
+  dialog->EnableButton(true, 222); // Cancel
  266
+  dialog->SetItems(&items);
  267
+  dialog->SetSelected(autoLoginProfileId);
  268
+  dialog->DoModal();
  269
+
  270
+  if (dialog->IsButtonPressed() || dialog->GetSelectedLabel() < 0)
  271
+    return false; // user cancelled
  272
+  iProfile = dialog->GetSelectedLabel() - 1;
  273
+
  274
+  return true;
  275
+}
1  xbmc/profiles/windows/GUIWindowSettingsProfile.h
@@ -41,4 +41,5 @@ class CGUIWindowSettingsProfile :
41 41
   void LoadList();
42 42
   void SetLastLoaded();
43 43
   void ClearListItems();
  44
+  bool GetAutoLoginProfileChoice(int &iProfile);
44 45
 };

0 notes on commit a3b5140

Please sign in to comment.
Something went wrong with that request. Please try again.