diff options
author | jmarshallnz <jmarshallnz@svn> | 2010-09-12 07:19:56 +0000 |
---|---|---|
committer | jmarshallnz <jmarshallnz@svn> | 2010-09-12 07:19:56 +0000 |
commit | 38250a9fb69cba0216355c64569a3cb4c788d4a4 (patch) | |
tree | c96563068935bb05bfbd8990304649130b5703da | |
parent | 812fdcf789ef09c31c35ae0737e7a4a7299a719f (diff) |
changed: Use CVariant in CGUIDialogBoxBase/OK/Keyboard
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@33686 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
-rw-r--r-- | xbmc/FileSystem/IDirectory.cpp | 22 | ||||
-rw-r--r-- | xbmc/FileSystem/IDirectory.h | 7 | ||||
-rw-r--r-- | xbmc/GUIDialogBoxBase.cpp | 68 | ||||
-rw-r--r-- | xbmc/GUIDialogBoxBase.h | 17 | ||||
-rw-r--r-- | xbmc/GUIDialogKeyboard.cpp | 20 | ||||
-rw-r--r-- | xbmc/GUIDialogKeyboard.h | 9 | ||||
-rw-r--r-- | xbmc/GUIDialogOK.cpp | 2 | ||||
-rw-r--r-- | xbmc/GUIDialogOK.h | 2 |
8 files changed, 49 insertions, 98 deletions
diff --git a/xbmc/FileSystem/IDirectory.cpp b/xbmc/FileSystem/IDirectory.cpp index 9ff65b7061..9093194930 100644 --- a/xbmc/FileSystem/IDirectory.cpp +++ b/xbmc/FileSystem/IDirectory.cpp @@ -27,7 +27,6 @@ #include "GUIDialogKeyboard.h" #include "URL.h" #include "utils/PasswordManager.h" -#include "LocalizeStrings.h" using namespace XFILE; @@ -142,7 +141,7 @@ bool IDirectory::ProcessRequirements() if (type == "keyboard") { CStdString input; - if (CGUIDialogKeyboard::ShowAndGetInput(input, GetLocalized(m_requirements["heading"]), false)) + if (CGUIDialogKeyboard::ShowAndGetInput(input, m_requirements["heading"], false)) { m_requirements["input"] = input; return true; @@ -159,15 +158,7 @@ bool IDirectory::ProcessRequirements() } else if (type == "error") { - CGUIDialogOK *dialog = (CGUIDialogOK *)g_windowManager.GetWindow(WINDOW_DIALOG_OK); - if (dialog) - { - dialog->SetHeading(GetLocalized(m_requirements["heading"])); - dialog->SetLine(0, GetLocalized(m_requirements["line1"])); - dialog->SetLine(1, GetLocalized(m_requirements["line2"])); - dialog->SetLine(2, GetLocalized(m_requirements["line3"])); - dialog->DoModal(); - } + CGUIDialogOK::ShowAndGetInput(m_requirements["heading"], m_requirements["line1"], m_requirements["line2"], m_requirements["line3"]); } m_requirements.clear(); return false; @@ -202,12 +193,3 @@ void IDirectory::RequireAuthentication(const CStdString &url) m_requirements["type"] = "authenticate"; m_requirements["url"] = url; } - -CStdString IDirectory::GetLocalized(const CVariant &var) const -{ - if (var.isString()) - return var.asString(); - else if (var.isInteger()) - return g_localizeStrings.Get(var.asInteger()); - return ""; -} diff --git a/xbmc/FileSystem/IDirectory.h b/xbmc/FileSystem/IDirectory.h index 7bf9d3db7e..74b95718ea 100644 --- a/xbmc/FileSystem/IDirectory.h +++ b/xbmc/FileSystem/IDirectory.h @@ -136,13 +136,6 @@ protected: */ void RequireAuthentication(const CStdString &url); - /*! \brief Get a localized string from a variant - If the varaint is already a string we return directly, else if it's an integer we return the corresponding - localized string. - \param var the variant to localize. - */ - CStdString GetLocalized(const CVariant &var) const; - CStdString m_strFileMask; ///< Holds the file mask specified by SetMask() bool m_allowPrompting; ///< If true, the directory handlers may prompt the user DIR_CACHE_TYPE m_cacheDirectory; ///< If !DIR_CACHE_NEVER the directory is cached by g_directoryCache (defaults to DIR_CACHE_ONCE) diff --git a/xbmc/GUIDialogBoxBase.cpp b/xbmc/GUIDialogBoxBase.cpp index 2fb8b09140..0e71dfad2b 100644 --- a/xbmc/GUIDialogBoxBase.cpp +++ b/xbmc/GUIDialogBoxBase.cpp @@ -21,6 +21,7 @@ #include "GUIDialogBoxBase.h" #include "GUIWindowManager.h" +#include "LocalizeStrings.h" using namespace std; @@ -54,11 +55,11 @@ bool CGUIDialogBoxBase::IsConfirmed() const return m_bConfirmed; } -void CGUIDialogBoxBase::SetHeading(const string& strLine) +void CGUIDialogBoxBase::SetHeading(const CVariant& heading) { Initialize(); CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), 1); - msg.SetLabel(strLine); + msg.SetLabel(GetLocalized(heading)); if(OwningCriticalSection(g_graphicsContext)) OnMessage(msg); @@ -66,69 +67,23 @@ void CGUIDialogBoxBase::SetHeading(const string& strLine) g_windowManager.SendThreadMessage(msg, GetID()); } -void CGUIDialogBoxBase::SetHeading(int iString) -{ - Initialize(); - CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), 1); - if (iString) - msg.SetLabel(iString); - else - msg.SetLabel(""); - - if(OwningCriticalSection(g_graphicsContext)) - OnMessage(msg); - else - g_windowManager.SendThreadMessage(msg, GetID()); -} - -void CGUIDialogBoxBase::SetLine(int iLine, const string& strLine) +void CGUIDialogBoxBase::SetLine(int iLine, const CVariant& line) { Initialize(); CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), iLine + 2); - msg.SetLabel(strLine); + msg.SetLabel(GetLocalized(line)); if(OwningCriticalSection(g_graphicsContext)) OnMessage(msg); else g_windowManager.SendThreadMessage(msg, GetID()); - } -void CGUIDialogBoxBase::SetLine(int iLine, int iString) -{ - Initialize(); - CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), iLine + 2); - if (iString) - msg.SetLabel(iString); - else - msg.SetLabel(""); - - if(OwningCriticalSection(g_graphicsContext)) - OnMessage(msg); - else - g_windowManager.SendThreadMessage(msg, GetID()); -} - -void CGUIDialogBoxBase::SetChoice(int iButton, int iString) // iButton == 0 for no, 1 for yes -{ - Initialize(); - CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), 10+iButton); - if (iString) - msg.SetLabel(iString); - else - msg.SetLabel(""); - - if(OwningCriticalSection(g_graphicsContext)) - OnMessage(msg); - else - g_windowManager.SendThreadMessage(msg, GetID()); -} - -void CGUIDialogBoxBase::SetChoice(int iButton, const string& strString) // iButton == 0 for no, 1 for yes +void CGUIDialogBoxBase::SetChoice(int iButton, const CVariant &choice) // iButton == 0 for no, 1 for yes { Initialize(); CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), 10+iButton); - msg.SetLabel(strString); + msg.SetLabel(GetLocalized(choice)); if(OwningCriticalSection(g_graphicsContext)) OnMessage(msg); @@ -142,3 +97,12 @@ void CGUIDialogBoxBase::OnInitWindow() m_lastControlID = m_defaultControl; CGUIDialog::OnInitWindow(); } + +CStdString CGUIDialogBoxBase::GetLocalized(const CVariant &var) const +{ + if (var.isString()) + return var.asString(); + else if (var.isInteger() && var.asInteger()) + return g_localizeStrings.Get(var.asInteger()); + return ""; +} diff --git a/xbmc/GUIDialogBoxBase.h b/xbmc/GUIDialogBoxBase.h index 04c2b40bfa..6e679570eb 100644 --- a/xbmc/GUIDialogBoxBase.h +++ b/xbmc/GUIDialogBoxBase.h @@ -22,6 +22,7 @@ */ #include "GUIDialog.h" +#include "Variant.h" class CGUIDialogBoxBase : public CGUIDialog @@ -31,13 +32,17 @@ public: virtual ~CGUIDialogBoxBase(void); virtual bool OnMessage(CGUIMessage& message); bool IsConfirmed() const; - void SetLine(int iLine, const std::string& strLine); - void SetLine(int iLine, int iString); - void SetHeading(const std::string& strLine); - void SetHeading(int iString); - void SetChoice(int iButton, int iString); - void SetChoice(int iButton, const std::string& strString); + void SetLine(int iLine, const CVariant &line); + void SetHeading(const CVariant &heading); + void SetChoice(int iButton, const CVariant &choice); protected: + /*! \brief Get a localized string from a variant + If the varaint is already a string we return directly, else if it's an integer we return the corresponding + localized string. + \param var the variant to localize. + */ + CStdString GetLocalized(const CVariant &var) const; + virtual void OnInitWindow(); bool m_bConfirmed; }; diff --git a/xbmc/GUIDialogKeyboard.cpp b/xbmc/GUIDialogKeyboard.cpp index 1d76f3e194..acbd72350b 100644 --- a/xbmc/GUIDialogKeyboard.cpp +++ b/xbmc/GUIDialogKeyboard.cpp @@ -526,7 +526,7 @@ void CGUIDialogKeyboard::UpdateButtons() // Show keyboard with initial value (aTextString) and replace with result string. // Returns: true - successful display and input (empty result may return true or false depending on parameter) // false - unsucessful display of the keyboard or cancelled editing -bool CGUIDialogKeyboard::ShowAndGetInput(CStdString& aTextString, const CStdString &strHeading, bool allowEmptyResult, bool hiddenInput /* = false */) +bool CGUIDialogKeyboard::ShowAndGetInput(CStdString& aTextString, const CVariant &heading, bool allowEmptyResult, bool hiddenInput /* = false */) { CGUIDialogKeyboard *pKeyboard = (CGUIDialogKeyboard*)g_windowManager.GetWindow(WINDOW_DIALOG_KEYBOARD); @@ -536,7 +536,7 @@ bool CGUIDialogKeyboard::ShowAndGetInput(CStdString& aTextString, const CStdStri // setup keyboard pKeyboard->Initialize(); pKeyboard->CenterWindow(); - pKeyboard->SetHeading(strHeading); + pKeyboard->SetHeading(heading); pKeyboard->SetHiddenInput(hiddenInput); pKeyboard->SetText(aTextString); // do this using a thread message to avoid render() conflicts @@ -562,7 +562,7 @@ bool CGUIDialogKeyboard::ShowAndGetInput(CStdString& aTextString, bool allowEmpt // Shows keyboard and prompts for a password. // Differs from ShowAndVerifyNewPassword() in that no second verification is necessary. -bool CGUIDialogKeyboard::ShowAndGetNewPassword(CStdString& newPassword, const CStdString &heading, bool allowEmpty) +bool CGUIDialogKeyboard::ShowAndGetNewPassword(CStdString& newPassword, const CVariant &heading, bool allowEmpty) { return ShowAndGetInput(newPassword, heading, allowEmpty, true); } @@ -571,8 +571,7 @@ bool CGUIDialogKeyboard::ShowAndGetNewPassword(CStdString& newPassword, const CS // Differs from ShowAndVerifyNewPassword() in that no second verification is necessary. bool CGUIDialogKeyboard::ShowAndGetNewPassword(CStdString& newPassword) { - CStdString heading = g_localizeStrings.Get(12340); - return ShowAndGetNewPassword(newPassword, heading, false); + return ShowAndGetNewPassword(newPassword, 12340, false); } // \brief Show keyboard twice to get and confirm a user-entered password string. @@ -580,7 +579,7 @@ bool CGUIDialogKeyboard::ShowAndGetNewPassword(CStdString& newPassword) // \param heading Heading to display // \param allowEmpty Whether a blank password is valid or not. // \return true if successful display and user input entry/re-entry. false if unsucessful display, no user input, or canceled editing. -bool CGUIDialogKeyboard::ShowAndVerifyNewPassword(CStdString& newPassword, const CStdString &heading, bool allowEmpty) +bool CGUIDialogKeyboard::ShowAndVerifyNewPassword(CStdString& newPassword, const CVariant &heading, bool allowEmpty) { // Prompt user for password input CStdString userInput = ""; @@ -590,7 +589,7 @@ bool CGUIDialogKeyboard::ShowAndVerifyNewPassword(CStdString& newPassword, const } // success - verify the password CStdString checkInput = ""; - if (!ShowAndGetInput(checkInput, g_localizeStrings.Get(12341), allowEmpty, true)) + if (!ShowAndGetInput(checkInput, 12341, allowEmpty, true)) { // user cancelled, or invalid input return false; } @@ -770,3 +769,10 @@ bool CGUIDialogKeyboard::ShowAndGetFilter(CStdString &filter, bool searching) return ret; } +void CGUIDialogKeyboard::SetHeading(const CVariant &heading) +{ + if (heading.isString()) + m_strHeading = heading.asString(); + else if (heading.isInteger() && heading.asInteger()) + m_strHeading = g_localizeStrings.Get(heading.asInteger()); +} diff --git a/xbmc/GUIDialogKeyboard.h b/xbmc/GUIDialogKeyboard.h index 817fdecfb5..7b7e9f2dfa 100644 --- a/xbmc/GUIDialogKeyboard.h +++ b/xbmc/GUIDialogKeyboard.h @@ -22,6 +22,7 @@ */ #include "GUIDialog.h" +#include "utils/Variant.h" enum KEYBOARD {CAPS, LOWER, SYMBOLS }; @@ -33,18 +34,18 @@ public: virtual ~CGUIDialogKeyboard(void); virtual void FrameMove(); - void SetHeading(const CStdString& strHeading) {m_strHeading = strHeading;} ; + void SetHeading(const CVariant& heading); void SetText(const CStdString& aTextString); CStdString GetText() const; bool IsConfirmed() { return m_bIsConfirmed; }; void SetHiddenInput(bool hiddenInput) { m_hiddenInput = hiddenInput; }; static bool ShowAndGetInput(CStdString& aTextString, bool allowEmptyResult); - static bool ShowAndGetInput(CStdString& aTextString, const CStdString &strHeading, bool allowEmptyResult, bool hiddenInput = false); + static bool ShowAndGetInput(CStdString& aTextString, const CVariant &heading, bool allowEmptyResult, bool hiddenInput = false); static bool ShowAndGetNewPassword(CStdString& strNewPassword); - static bool ShowAndGetNewPassword(CStdString& newPassword, const CStdString &heading, bool allowEmpty); + static bool ShowAndGetNewPassword(CStdString& newPassword, const CVariant &heading, bool allowEmpty); static bool ShowAndVerifyNewPassword(CStdString& strNewPassword); - static bool ShowAndVerifyNewPassword(CStdString& newPassword, const CStdString &heading, bool allowEmpty); + static bool ShowAndVerifyNewPassword(CStdString& newPassword, const CVariant &heading, bool allowEmpty); static int ShowAndVerifyPassword(CStdString& strPassword, const CStdString& strHeading, int iRetries); static bool ShowAndGetFilter(CStdString& aTextString, bool searching); diff --git a/xbmc/GUIDialogOK.cpp b/xbmc/GUIDialogOK.cpp index 3edf5f23ae..1eb68d7df0 100644 --- a/xbmc/GUIDialogOK.cpp +++ b/xbmc/GUIDialogOK.cpp @@ -52,7 +52,7 @@ bool CGUIDialogOK::OnMessage(CGUIMessage& message) } // \brief Show CGUIDialogOK dialog, then wait for user to dismiss it. -void CGUIDialogOK::ShowAndGetInput(int heading, int line0, int line1, int line2) +void CGUIDialogOK::ShowAndGetInput(const CVariant &heading, const CVariant &line0, const CVariant &line1, const CVariant &line2) { CGUIDialogOK *dialog = (CGUIDialogOK *)g_windowManager.GetWindow(WINDOW_DIALOG_OK); if (!dialog) return; diff --git a/xbmc/GUIDialogOK.h b/xbmc/GUIDialogOK.h index 7995a0026c..083ef064fe 100644 --- a/xbmc/GUIDialogOK.h +++ b/xbmc/GUIDialogOK.h @@ -30,5 +30,5 @@ public: CGUIDialogOK(void); virtual ~CGUIDialogOK(void); virtual bool OnMessage(CGUIMessage& message); - static void ShowAndGetInput(int heading, int line0, int line1, int line2); + static void ShowAndGetInput(const CVariant &heading, const CVariant &line0, const CVariant &line1, const CVariant &line2); }; |