added: possibility to hide a profile on the login screen #1041

Closed
wants to merge 1 commit into
from
@@ -6490,7 +6490,9 @@ msgctxt "#20126"
msgid "Log off"
msgstr ""
-#empty string with id 20127
+msgctxt "#20127"
+msgid "Hidden on login screen"
+msgstr ""
msgctxt "#20128"
msgid "Go to root"
@@ -104,10 +104,13 @@ void CGUIDialogProfileSettings::CreateSettings()
if (!m_bShowDetails && m_locks.mode == LOCK_MODE_EVERYONE && g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE)
AddButton(4,20066);
+ if (m_bShowDetails)
+ AddBool(5,20127,&m_hide);
+
if (!m_bIsDefault && m_bShowDetails)
{
SettingInfo setting;
- setting.id = 5;
+ setting.id = 6;
setting.name = g_localizeStrings.Get(20060);
setting.data = &m_iDbMode;
setting.type = SettingInfo::SPIN;
@@ -120,7 +123,7 @@ void CGUIDialogProfileSettings::CreateSettings()
m_settings.push_back(setting);
SettingInfo setting2;
- setting2.id = 6;
+ setting2.id = 7;
setting2.name = g_localizeStrings.Get(20094);
setting2.data = &m_iSourcesMode;
setting2.type = SettingInfo::SPIN;
@@ -267,6 +270,7 @@ bool CGUIDialogProfileSettings::ShowForProfile(unsigned int iProfile, bool first
dialog->m_iDbMode = 2;
dialog->m_iSourcesMode = 2;
dialog->m_locks = CProfile::CLock();
+ dialog->m_hide = false;
bool bLock = g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser;
dialog->m_locks.addonManager = bLock;
@@ -299,6 +303,7 @@ bool CGUIDialogProfileSettings::ShowForProfile(unsigned int iProfile, bool first
dialog->m_strDirectory = profile->getDirectory();
dialog->m_iDbMode = profile->canWriteDatabases()?0:1;
dialog->m_iSourcesMode = profile->canWriteSources()?0:1;
+ dialog->m_hide = profile->Hidden();
if (profile->hasDatabases())
dialog->m_iDbMode += 2;
if (profile->hasSources())
@@ -385,6 +390,7 @@ bool CGUIDialogProfileSettings::ShowForProfile(unsigned int iProfile, bool first
profile->setDatabases((dialog->m_iDbMode & 2) == 2);
profile->setSources((dialog->m_iSourcesMode & 2) == 2);
profile->SetLocks(dialog->m_locks);
+ profile->SetHidden(dialog->m_hide);
g_settings.SaveProfiles(PROFILES_FILE);
return true;
@@ -57,6 +57,7 @@ class CGUIDialogProfileSettings : public CGUIDialogSettings
bool m_bIsDefault;
bool m_bIsNewUser;
bool m_bShowDetails;
+ bool m_hide;
CProfile::CLock m_locks;
CStdString m_strDefaultImage;
@@ -55,6 +55,7 @@ CProfile::CProfile(const CStdString &directory, const CStdString &name, const in
m_bSources = true;
m_bCanWriteSources = true;
m_bAddons = true;
+ m_hide = false;
}
CProfile::~CProfile(void)
@@ -82,6 +83,7 @@ void CProfile::Load(const TiXmlNode *node, int nextIdProfile)
XMLUtils::GetBoolean(node, "canwritedatabases", m_bCanWrite);
XMLUtils::GetBoolean(node, "hassources", m_bSources);
XMLUtils::GetBoolean(node, "canwritesources", m_bCanWriteSources);
+ XMLUtils::GetBoolean(node, "hidden", m_hide);
XMLUtils::GetBoolean(node, "lockaddonmanager", m_locks.addonManager);
XMLUtils::GetBoolean(node, "locksettings", m_locks.settings);
XMLUtils::GetBoolean(node, "lockfiles", m_locks.files);
@@ -113,6 +115,7 @@ void CProfile::Save(TiXmlNode *root) const
XMLUtils::SetBoolean(node, "canwritedatabases", m_bCanWrite);
XMLUtils::SetBoolean(node, "hassources", m_bSources);
XMLUtils::SetBoolean(node, "canwritesources", m_bCanWriteSources);
+ XMLUtils::SetBoolean(node, "hidden", m_hide);
XMLUtils::SetBoolean(node, "lockaddonmanager", m_locks.addonManager);
XMLUtils::SetBoolean(node, "locksettings", m_locks.settings);
XMLUtils::SetBoolean(node, "lockfiles", m_locks.files);
View
@@ -76,6 +76,7 @@ class CProfile
bool filesLocked() const { return m_locks.files; }
bool programsLocked() const { return m_locks.programs; }
const CLock &GetLocks() const { return m_locks; }
+ bool Hidden() const { return m_hide; }
void setName(const CStdString& name) {m_name = name;}
void setDirectory(const CStdString& directory) {m_directory = directory;}
@@ -87,6 +88,7 @@ class CProfile
void setSources(bool bHas) { m_bSources = bHas; }
void setWriteSources(bool bCan) { m_bCanWriteSources = bCan; }
void SetLocks(const CLock &locks);
+ void SetHidden(bool hidden) { m_hide = hidden; }
private:
CStdString m_directory;
@@ -99,5 +101,6 @@ class CProfile
bool m_bSources;
bool m_bCanWriteSources;
bool m_bAddons;
+ bool m_hide;
CLock m_locks;
};
@@ -98,7 +98,7 @@ bool CGUIWindowLoginScreen::OnMessage(CGUIMessage& message)
}
else if (iAction == ACTION_SELECT_ITEM || iAction == ACTION_MOUSE_LEFT_CLICK)
{
- int iItem = m_viewControl.GetSelectedItem();
+ int iItem = m_vecItems->Get(m_viewControl.GetSelectedItem())->GetProperty("profile_index").asInteger();
bool bCanceled;
bool bOkay = g_passwordManager.IsProfileLockUnlocked(iItem, bCanceled);
@@ -190,6 +190,9 @@ void CGUIWindowLoginScreen::Update()
for (unsigned int i=0;i<g_settings.GetNumProfiles(); ++i)
{
const CProfile *profile = g_settings.GetProfile(i);
+ if (profile->Hidden())
+ continue;
+
CFileItemPtr item(new CFileItem(profile->getName()));
CStdString strLabel;
if (profile->getDate().IsEmpty())
@@ -201,6 +204,7 @@ void CGUIWindowLoginScreen::Update()
if (profile->getThumb().IsEmpty() || profile->getThumb().Equals("-"))
item->SetThumbnailImage("unknown-user.png");
item->SetLabelPreformated(true);
+ item->SetProperty("profile_index",i);
m_vecItems->Add(item);
}
m_viewControl.SetItems(*m_vecItems);
@@ -215,11 +219,13 @@ bool CGUIWindowLoginScreen::OnPopupMenu(int iItem)
// mark the item
m_vecItems->Get(iItem)->Select(true);
+ int item = m_vecItems->Get(iItem)->GetProperty("profile_index").asInteger();
+
CContextButtons choices;
choices.Add(1, 20067);
/* if (m_viewControl.GetSelectedItem() != 0) // no deleting the default profile
choices.Add(2, 117); */
- if (iItem == 0 && g_passwordManager.iMasterLockRetriesLeft == 0)
+ if (item == 0 && g_passwordManager.iMasterLockRetriesLeft == 0)
choices.Add(3, 12334);
int choice = CGUIDialogContextMenu::ShowAndGetChoice(choices);
@@ -237,12 +243,11 @@ bool CGUIWindowLoginScreen::OnPopupMenu(int iItem)
return false;
if (choice == 1)
- CGUIDialogProfileSettings::ShowForProfile(m_viewControl.GetSelectedItem());
+ CGUIDialogProfileSettings::ShowForProfile(item);
if (choice == 2)
{
- int iDelete = m_viewControl.GetSelectedItem();
m_viewControl.Clear();
- g_settings.DeleteProfile(iDelete);
+ g_settings.DeleteProfile(item);
Update();
m_viewControl.SetSelectedItem(0);
}