summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorVadim ProductEngine <vsavchuk@productengine.com>2011-12-09 17:59:29 +0200
committerVadim ProductEngine <vsavchuk@productengine.com>2011-12-09 17:59:29 +0200
commit702410cef75e0cc10258964b86b093f2205ef462 (patch)
tree97323ef69ed74674c92be91ef509ffe95284c3be /indra
parent86847b753befbca31e4aadeff111acd398f9612d (diff)
EXP-1671 FIXED Enable/disable the translation checkbox in the nearby chat floater whenever translation preferences change.
The checkbox is also updated when the nearby chat floater is opened.
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llfloatertranslationsettings.cpp2
-rw-r--r--indra/newview/llnearbychatbar.cpp12
-rw-r--r--indra/newview/llnearbychatbar.h2
-rwxr-xr-xindra/newview/lltranslate.cpp18
-rwxr-xr-xindra/newview/lltranslate.h16
5 files changed, 50 insertions, 0 deletions
diff --git a/indra/newview/llfloatertranslationsettings.cpp b/indra/newview/llfloatertranslationsettings.cpp
index 959edff713..428a02e9f0 100644
--- a/indra/newview/llfloatertranslationsettings.cpp
+++ b/indra/newview/llfloatertranslationsettings.cpp
@@ -29,6 +29,7 @@
#include "llfloatertranslationsettings.h"
// Viewer includes
+#include "llnearbychatbar.h"
#include "lltranslate.h"
#include "llviewercontrol.h" // for gSavedSettings
@@ -292,5 +293,6 @@ void LLFloaterTranslationSettings::onBtnOK()
gSavedSettings.setString("TranslationService", getSelectedService());
gSavedSettings.setString("BingTranslateAPIKey", getEnteredBingKey());
gSavedSettings.setString("GoogleTranslateAPIKey", getEnteredGoogleKey());
+ LLNearbyChatBar::getInstance()->enableTranslationCheckbox(LLTranslate::isTranslationConfigured());
closeFloater(false);
}
diff --git a/indra/newview/llnearbychatbar.cpp b/indra/newview/llnearbychatbar.cpp
index 114472ba56..4f8559718f 100644
--- a/indra/newview/llnearbychatbar.cpp
+++ b/indra/newview/llnearbychatbar.cpp
@@ -48,6 +48,7 @@
#include "llrootview.h"
#include "llviewerchat.h"
#include "llnearbychat.h"
+#include "lltranslate.h"
#include "llresizehandle.h"
@@ -112,6 +113,12 @@ BOOL LLNearbyChatBar::postBuild()
return TRUE;
}
+// virtual
+void LLNearbyChatBar::onOpen(const LLSD& key)
+{
+ enableTranslationCheckbox(LLTranslate::isTranslationConfigured());
+}
+
bool LLNearbyChatBar::applyRectControl()
{
bool rect_controlled = LLFloater::applyRectControl();
@@ -156,6 +163,11 @@ void LLNearbyChatBar::showHistory()
}
}
+void LLNearbyChatBar::enableTranslationCheckbox(BOOL enable)
+{
+ getChild<LLUICtrl>("translate_chat_checkbox")->setEnabled(enable);
+}
+
void LLNearbyChatBar::draw()
{
displaySpeakingIndicator();
diff --git a/indra/newview/llnearbychatbar.h b/indra/newview/llnearbychatbar.h
index e9734899b3..866e07f123 100644
--- a/indra/newview/llnearbychatbar.h
+++ b/indra/newview/llnearbychatbar.h
@@ -43,6 +43,7 @@ public:
~LLNearbyChatBar() {}
virtual BOOL postBuild();
+ /*virtual*/ void onOpen(const LLSD& key);
static LLNearbyChatBar* getInstance();
@@ -60,6 +61,7 @@ public:
static void sendChatFromViewer(const LLWString &wtext, EChatType type, BOOL animate);
void showHistory();
+ void enableTranslationCheckbox(BOOL enable);
/*virtual*/void setMinimized(BOOL b);
protected:
diff --git a/indra/newview/lltranslate.cpp b/indra/newview/lltranslate.cpp
index 7eb54271f4..c1cc9c7bc4 100755
--- a/indra/newview/lltranslate.cpp
+++ b/indra/newview/lltranslate.cpp
@@ -95,6 +95,12 @@ bool LLGoogleTranslationHandler::parseResponse(
return parseTranslation(root, translation, detected_lang);
}
+// virtual
+bool LLGoogleTranslationHandler::isConfigured() const
+{
+ return !getAPIKey().empty();
+}
+
// static
void LLGoogleTranslationHandler::parseErrorResponse(
const Json::Value& root,
@@ -218,6 +224,12 @@ bool LLBingTranslationHandler::parseResponse(
return true;
}
+// virtual
+bool LLBingTranslationHandler::isConfigured() const
+{
+ return !getAPIKey().empty();
+}
+
// static
std::string LLBingTranslationHandler::getAPIKey()
{
@@ -332,6 +344,12 @@ std::string LLTranslate::getTranslateLanguage()
}
// static
+bool LLTranslate::isTranslationConfigured()
+{
+ return getPreferredHandler().isConfigured();
+}
+
+// static
const LLTranslationAPIHandler& LLTranslate::getPreferredHandler()
{
EService service = SERVICE_BING;
diff --git a/indra/newview/lltranslate.h b/indra/newview/lltranslate.h
index c2330daa81..424bc14587 100755
--- a/indra/newview/lltranslate.h
+++ b/indra/newview/lltranslate.h
@@ -89,6 +89,11 @@ public:
std::string& detected_lang,
std::string& err_msg) const = 0;
+ /**
+ * @return if the handler is configured to function properly
+ */
+ virtual bool isConfigured() const = 0;
+
virtual ~LLTranslationAPIHandler() {}
protected:
@@ -115,6 +120,7 @@ public:
std::string& translation,
std::string& detected_lang,
std::string& err_msg) const;
+ /*virtual*/ bool isConfigured() const;
private:
static void parseErrorResponse(
@@ -148,6 +154,7 @@ public:
std::string& translation,
std::string& detected_lang,
std::string& err_msg) const;
+ /*virtual*/ bool isConfigured() const;
private:
static std::string getAPIKey();
};
@@ -275,8 +282,17 @@ public :
* @param key Key to verify.
*/
static void verifyKey(KeyVerificationReceiverPtr& receiver, const std::string& key);
+
+ /**
+ * @return translation target language
+ */
static std::string getTranslateLanguage();
+ /**
+ * @return true if translation is configured properly.
+ */
+ static bool isTranslationConfigured();
+
private:
static const LLTranslationAPIHandler& getPreferredHandler();
static const LLTranslationAPIHandler& getHandler(EService service);