diff options
Diffstat (limited to 'linden/indra/newview/llfloaterhtmlhelp.cpp')
-rw-r--r-- | linden/indra/newview/llfloaterhtmlhelp.cpp | 100 |
1 files changed, 80 insertions, 20 deletions
diff --git a/linden/indra/newview/llfloaterhtmlhelp.cpp b/linden/indra/newview/llfloaterhtmlhelp.cpp index 5337c07..2a22a40 100644 --- a/linden/indra/newview/llfloaterhtmlhelp.cpp +++ b/linden/indra/newview/llfloaterhtmlhelp.cpp | |||
@@ -35,6 +35,8 @@ | |||
35 | #include "llfloaterhtmlhelp.h" | 35 | #include "llfloaterhtmlhelp.h" |
36 | #include "llfloaterhtml.h" | 36 | #include "llfloaterhtml.h" |
37 | 37 | ||
38 | #include "llchat.h" | ||
39 | #include "llfloaterchat.h" | ||
38 | #include "llparcel.h" | 40 | #include "llparcel.h" |
39 | #include "lluictrlfactory.h" | 41 | #include "lluictrlfactory.h" |
40 | #include "llwebbrowserctrl.h" | 42 | #include "llwebbrowserctrl.h" |
@@ -42,6 +44,7 @@ | |||
42 | #include "llviewercontrol.h" | 44 | #include "llviewercontrol.h" |
43 | #include "llviewerparcelmgr.h" | 45 | #include "llviewerparcelmgr.h" |
44 | #include "llweb.h" | 46 | #include "llweb.h" |
47 | #include "lltrans.h" | ||
45 | #include "llui.h" | 48 | #include "llui.h" |
46 | #include "roles_constants.h" | 49 | #include "roles_constants.h" |
47 | 50 | ||
@@ -59,7 +62,9 @@ LLFloaterMediaBrowser::LLFloaterMediaBrowser(const LLSD& media_data) | |||
59 | 62 | ||
60 | void LLFloaterMediaBrowser::draw() | 63 | void LLFloaterMediaBrowser::draw() |
61 | { | 64 | { |
62 | childSetEnabled("go", !mAddressCombo->getValue().asString().empty()); | 65 | BOOL url_exists = !mAddressCombo->getValue().asString().empty(); |
66 | childSetEnabled("go", url_exists); | ||
67 | childSetEnabled("set_home", url_exists); | ||
63 | LLParcel* parcel = LLViewerParcelMgr::getInstance()->getAgentParcel(); | 68 | LLParcel* parcel = LLViewerParcelMgr::getInstance()->getAgentParcel(); |
64 | if(parcel) | 69 | if(parcel) |
65 | { | 70 | { |
@@ -85,6 +90,8 @@ BOOL LLFloaterMediaBrowser::postBuild() | |||
85 | childSetAction("close", onClickClose, this); | 90 | childSetAction("close", onClickClose, this); |
86 | childSetAction("open_browser", onClickOpenWebBrowser, this); | 91 | childSetAction("open_browser", onClickOpenWebBrowser, this); |
87 | childSetAction("assign", onClickAssign, this); | 92 | childSetAction("assign", onClickAssign, this); |
93 | childSetAction("home", onClickHome, this); | ||
94 | childSetAction("set_home", onClickSetHome, this); | ||
88 | 95 | ||
89 | buildURLHistory(); | 96 | buildURLHistory(); |
90 | return TRUE; | 97 | return TRUE; |
@@ -147,6 +154,7 @@ void LLFloaterMediaBrowser::onLocationChange( const EventType& eventIn ) | |||
147 | childSetEnabled("back", mBrowser->canNavigateBack()); | 154 | childSetEnabled("back", mBrowser->canNavigateBack()); |
148 | childSetEnabled("forward", mBrowser->canNavigateForward()); | 155 | childSetEnabled("forward", mBrowser->canNavigateForward()); |
149 | childSetEnabled("reload", TRUE); | 156 | childSetEnabled("reload", TRUE); |
157 | gSavedSettings.setString("BrowserLastVisited", truncated_url); | ||
150 | } | 158 | } |
151 | 159 | ||
152 | LLFloaterMediaBrowser* LLFloaterMediaBrowser::showInstance(const LLSD& media_url) | 160 | LLFloaterMediaBrowser* LLFloaterMediaBrowser::showInstance(const LLSD& media_url) |
@@ -157,6 +165,46 @@ LLFloaterMediaBrowser* LLFloaterMediaBrowser::showInstance(const LLSD& media_url | |||
157 | return floaterp; | 165 | return floaterp; |
158 | } | 166 | } |
159 | 167 | ||
168 | //static | ||
169 | void LLFloaterMediaBrowser::toggle() | ||
170 | { | ||
171 | LLFloaterMediaBrowser* self = LLFloaterMediaBrowser::getInstance(); | ||
172 | |||
173 | if(self->getVisible()) | ||
174 | { | ||
175 | self->close(); | ||
176 | } | ||
177 | else | ||
178 | { | ||
179 | //Show home url if new session, last visited if not | ||
180 | std::string last_url = gSavedSettings.getString("BrowserLastVisited"); | ||
181 | if(last_url.empty()) | ||
182 | last_url = gSavedSettings.getString("BrowserHome"); | ||
183 | showInstance(last_url); | ||
184 | } | ||
185 | } | ||
186 | |||
187 | //static | ||
188 | void LLFloaterMediaBrowser::helpF1() | ||
189 | { | ||
190 | std::string url = gSavedSettings.getString("HelpSupportURL"); | ||
191 | LLSD payload; | ||
192 | payload["url"] = url; | ||
193 | |||
194 | LLNotifications::instance().add("ClickOpenF1Help", LLSD(), payload, onClickF1HelpLoadURL); | ||
195 | } | ||
196 | |||
197 | // static | ||
198 | bool LLFloaterMediaBrowser::onClickF1HelpLoadURL(const LLSD& notification, const LLSD& response) | ||
199 | { | ||
200 | S32 option = LLNotification::getSelectedOption(notification, response); | ||
201 | if (option == 0) | ||
202 | { | ||
203 | LLWeb::loadURL(notification["payload"]["url"].asString()); | ||
204 | } | ||
205 | return false; | ||
206 | } | ||
207 | |||
160 | //static | 208 | //static |
161 | void LLFloaterMediaBrowser::onEnterAddress(LLUICtrl* ctrl, void* user_data) | 209 | void LLFloaterMediaBrowser::onEnterAddress(LLUICtrl* ctrl, void* user_data) |
162 | { | 210 | { |
@@ -235,8 +283,35 @@ void LLFloaterMediaBrowser::onClickAssign(void* user_data) | |||
235 | LLViewerParcelMgr::getInstance()->sendParcelPropertiesUpdate( parcel, true ); | 283 | LLViewerParcelMgr::getInstance()->sendParcelPropertiesUpdate( parcel, true ); |
236 | // now check for video | 284 | // now check for video |
237 | LLViewerParcelMedia::update( parcel ); | 285 | LLViewerParcelMedia::update( parcel ); |
286 | } | ||
238 | 287 | ||
288 | // static | ||
289 | void LLFloaterMediaBrowser::onClickHome(void* user_data) | ||
290 | { | ||
291 | LLFloaterMediaBrowser* self = (LLFloaterMediaBrowser*)user_data; | ||
292 | if (self) | ||
293 | { | ||
294 | if (self->mBrowser) | ||
295 | { | ||
296 | std::string home_url = gSavedSettings.getString("BrowserHome"); | ||
297 | self->mBrowser->navigateTo(home_url); | ||
298 | } | ||
299 | } | ||
300 | } | ||
239 | 301 | ||
302 | void LLFloaterMediaBrowser::onClickSetHome(void* user_data) | ||
303 | { | ||
304 | LLFloaterMediaBrowser* self = (LLFloaterMediaBrowser*)user_data; | ||
305 | std::string url = self->mCurrentURL; | ||
306 | if(!url.empty()) | ||
307 | { | ||
308 | LLChat chat; | ||
309 | std::string log_message = LLTrans::getString("new_home_page") + " "; | ||
310 | log_message += url; | ||
311 | chat.mText = log_message; | ||
312 | LLFloaterChat::addChat(chat, FALSE, FALSE); | ||
313 | gSavedSettings.setString("BrowserHome", url); | ||
314 | } | ||
240 | } | 315 | } |
241 | 316 | ||
242 | void LLFloaterMediaBrowser::openMedia(const std::string& media_url) | 317 | void LLFloaterMediaBrowser::openMedia(const std::string& media_url) |
@@ -259,8 +334,10 @@ public: | |||
259 | virtual void draw(); | 334 | virtual void draw(); |
260 | 335 | ||
261 | static void show(std::string url, std::string title); | 336 | static void show(std::string url, std::string title); |
337 | |||
338 | private: | ||
262 | static void onClickBack( void* data ); | 339 | static void onClickBack( void* data ); |
263 | static void onClickHome( void* data ); | 340 | //static void onClickHome( void* data ); |
264 | static void onClickForward( void* data ); | 341 | static void onClickForward( void* data ); |
265 | static void onClickClose( void* data ); | 342 | static void onClickClose( void* data ); |
266 | 343 | ||
@@ -273,7 +350,6 @@ public: | |||
273 | 350 | ||
274 | static bool onClickF1HelpLoadURL(const LLSD& notification, const LLSD& response); | 351 | static bool onClickF1HelpLoadURL(const LLSD& notification, const LLSD& response); |
275 | 352 | ||
276 | protected: | ||
277 | LLWebBrowserCtrl* mWebBrowser; | 353 | LLWebBrowserCtrl* mWebBrowser; |
278 | static LLFloaterHtmlHelp* sInstance; | 354 | static LLFloaterHtmlHelp* sInstance; |
279 | LLButton* mBackButton; | 355 | LLButton* mBackButton; |
@@ -303,7 +379,7 @@ LLFloaterHtmlHelp::LLFloaterHtmlHelp(std::string start_url, std::string title) | |||
303 | LLUICtrlFactory::getInstance()->buildFloater( this, "floater_html_help.xml" ); | 379 | LLUICtrlFactory::getInstance()->buildFloater( this, "floater_html_help.xml" ); |
304 | 380 | ||
305 | childSetAction("back_btn", onClickBack, this); | 381 | childSetAction("back_btn", onClickBack, this); |
306 | childSetAction("home_btn", onClickHome, this); | 382 | //childSetAction("home_btn", onClickHome, this); |
307 | childSetAction("forward_btn", onClickForward, this); | 383 | childSetAction("forward_btn", onClickForward, this); |
308 | 384 | ||
309 | if (!title.empty()) | 385 | if (!title.empty()) |
@@ -439,22 +515,6 @@ void LLFloaterHtmlHelp::onClickBack( void* data ) | |||
439 | } | 515 | } |
440 | 516 | ||
441 | //////////////////////////////////////////////////////////////////////////////// | 517 | //////////////////////////////////////////////////////////////////////////////// |
442 | // | ||
443 | void LLFloaterHtmlHelp::onClickHome( void* data ) | ||
444 | { | ||
445 | LLFloaterHtmlHelp* self = ( LLFloaterHtmlHelp* )data; | ||
446 | if ( self ) | ||
447 | { | ||
448 | // get the home page URL (which can differ from the start URL) from XML and go there | ||
449 | LLWebBrowserCtrl* web_browser = self->getChild<LLWebBrowserCtrl>("html_help_browser" ); | ||
450 | if ( web_browser ) | ||
451 | { | ||
452 | web_browser->navigateHome(); | ||
453 | }; | ||
454 | }; | ||
455 | } | ||
456 | |||
457 | //////////////////////////////////////////////////////////////////////////////// | ||
458 | // | 518 | // |
459 | void LLFloaterHtmlHelp::onClickForward( void* data ) | 519 | void LLFloaterHtmlHelp::onClickForward( void* data ) |
460 | { | 520 | { |