aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llfloaterhtmlhelp.cpp
diff options
context:
space:
mode:
authorMcCabe Maxsted2009-01-21 18:45:08 -0700
committerMcCabe Maxsted2009-01-21 18:45:08 -0700
commit5ba642526c3343eddf120b3cfbf3bdb23c1fdf95 (patch)
treee0f79432d6b7ca8e5ecbe9d995c8d9f771404089 /linden/indra/newview/llfloaterhtmlhelp.cpp
parentmerged in jacek's fixes for inv icons (diff)
downloadmeta-impy-5ba642526c3343eddf120b3cfbf3bdb23c1fdf95.zip
meta-impy-5ba642526c3343eddf120b3cfbf3bdb23c1fdf95.tar.gz
meta-impy-5ba642526c3343eddf120b3cfbf3bdb23c1fdf95.tar.bz2
meta-impy-5ba642526c3343eddf120b3cfbf3bdb23c1fdf95.tar.xz
Fixed browser layout, toggling; removed legacy browser code
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llfloaterhtmlhelp.cpp323
1 files changed, 55 insertions, 268 deletions
diff --git a/linden/indra/newview/llfloaterhtmlhelp.cpp b/linden/indra/newview/llfloaterhtmlhelp.cpp
index 7fe4d59..f637624 100644
--- a/linden/indra/newview/llfloaterhtmlhelp.cpp
+++ b/linden/indra/newview/llfloaterhtmlhelp.cpp
@@ -32,7 +32,6 @@
32#include "llviewerprecompiledheaders.h" 32#include "llviewerprecompiledheaders.h"
33 33
34#include "llfloaterhtmlhelp.h" 34#include "llfloaterhtmlhelp.h"
35#include "llfloaterhtml.h"
36 35
37#include "llparcel.h" 36#include "llparcel.h"
38#include "lluictrlfactory.h" 37#include "lluictrlfactory.h"
@@ -50,6 +49,13 @@
50#include "llviewerparcelmedia.h" 49#include "llviewerparcelmedia.h"
51#include "llcombobox.h" 50#include "llcombobox.h"
52 51
52#include "llchat.h"
53#include "lllineeditor.h"
54#include "llfloaterchat.h"
55#include "lltrans.h"
56
57// static
58LLFloaterMediaBrowser* LLFloaterMediaBrowser::sInstance = NULL;
53 59
54LLFloaterMediaBrowser::LLFloaterMediaBrowser(const LLSD& media_data) 60LLFloaterMediaBrowser::LLFloaterMediaBrowser(const LLSD& media_data)
55{ 61{
@@ -118,7 +124,7 @@ void LLFloaterMediaBrowser::buildURLHistory()
118 124
119void LLFloaterMediaBrowser::onClose(bool app_quitting) 125void LLFloaterMediaBrowser::onClose(bool app_quitting)
120{ 126{
121 //setVisible(FALSE); 127 //setVisible(FALSE)
122 destroy(); 128 destroy();
123} 129}
124 130
@@ -155,20 +161,52 @@ void LLFloaterMediaBrowser::onLocationChange( const EventType& eventIn )
155 161
156LLFloaterMediaBrowser* LLFloaterMediaBrowser::showInstance(const LLSD& media_url) 162LLFloaterMediaBrowser* LLFloaterMediaBrowser::showInstance(const LLSD& media_url)
157{ 163{
158 LLFloaterMediaBrowser* floaterp = LLUISingleton<LLFloaterMediaBrowser, VisibilityPolicy<LLFloater> >::showInstance(media_url); 164 LLFloaterMediaBrowser* sInstance = LLUISingleton<LLFloaterMediaBrowser, VisibilityPolicy<LLFloater> >::showInstance(media_url);
159 165
160 floaterp->openMedia(media_url.asString()); 166 sInstance->openMedia(media_url.asString());
161 return floaterp; 167 return sInstance;
162} 168}
163 169
164void LLFloaterMediaBrowser::show() 170//static
171void LLFloaterMediaBrowser::toggle()
172{
173 bool visible = LLFloaterMediaBrowser::instanceVisible();
174 LLFloaterMediaBrowser* self = sInstance->getInstance();
175
176 if(visible && self)
177 {
178 self->close();
179 }
180 else
181 {
182 //Show home url if new session, last visited if not
183 std::string last_url = gSavedSettings.getString("BrowserLastVisited");
184 if(last_url.empty())
185 last_url = gSavedSettings.getString("BrowserHome");
186 showInstance(last_url);
187 }
188}
189
190//static
191void LLFloaterMediaBrowser::helpF1()
192{
193 std::string url = gSavedSettings.getString("HelpSupportURL");
194 std::string* url_copy = new std::string(url);
195
196 gViewerWindow->alertXml("ClickOpenF1Help", onClickF1HelpLoadURL, url_copy);
197}
198
199// static
200void LLFloaterMediaBrowser::onClickF1HelpLoadURL(S32 option, void* userdata)
165{ 201{
166 //Show home url if new session, last visited if not 202 std::string* urlp = (std::string*)userdata;
167 std::string last_url = gSavedSettings.getString("BrowserLastVisited"); 203 if (0 == option)
168 if(last_url.empty()) 204 {
169 last_url = gSavedSettings.getString("BrowserHome"); 205 showInstance(urlp->c_str());
170 showInstance(last_url); 206 }
207 delete urlp;
171} 208}
209
172//static 210//static
173void LLFloaterMediaBrowser::onEnterAddress(LLUICtrl* ctrl, void* user_data) 211void LLFloaterMediaBrowser::onEnterAddress(LLUICtrl* ctrl, void* user_data)
174{ 212{
@@ -225,7 +263,7 @@ void LLFloaterMediaBrowser::onClickOpenWebBrowser(void* user_data)
225 std::string url = self->mCurrentURL.empty() ? 263 std::string url = self->mCurrentURL.empty() ?
226 self->mBrowser->getHomePageUrl() : 264 self->mBrowser->getHomePageUrl() :
227 self->mCurrentURL; 265 self->mCurrentURL;
228 LLWeb::loadURLExternal(url); 266 LLWeb::loadURL(url);
229} 267}
230 268
231void LLFloaterMediaBrowser::onClickAssign(void* user_data) 269void LLFloaterMediaBrowser::onClickAssign(void* user_data)
@@ -247,8 +285,6 @@ void LLFloaterMediaBrowser::onClickAssign(void* user_data)
247 LLViewerParcelMgr::getInstance()->sendParcelPropertiesUpdate( parcel, true ); 285 LLViewerParcelMgr::getInstance()->sendParcelPropertiesUpdate( parcel, true );
248 // now check for video 286 // now check for video
249 LLViewerParcelMedia::update( parcel ); 287 LLViewerParcelMedia::update( parcel );
250
251
252} 288}
253 289
254void LLFloaterMediaBrowser::onClickHome(void* user_data) 290void LLFloaterMediaBrowser::onClickHome(void* user_data)
@@ -270,6 +306,11 @@ void LLFloaterMediaBrowser::onClickSetHome(void* user_data)
270 std::string url = self->mCurrentURL; 306 std::string url = self->mCurrentURL;
271 if(!url.empty()) 307 if(!url.empty())
272 { 308 {
309 LLChat chat;
310 std::string log_message = LLTrans::getString("new_home_page") + " ";
311 log_message += url;
312 chat.mText = log_message;
313 LLFloaterChat::addChat(chat, FALSE, FALSE);
273 gSavedSettings.setString("BrowserHome", url); 314 gSavedSettings.setString("BrowserHome", url);
274 } 315 }
275} 316}
@@ -279,257 +320,3 @@ void LLFloaterMediaBrowser::openMedia(const std::string& media_url)
279 mBrowser->setHomePageUrl(media_url); 320 mBrowser->setHomePageUrl(media_url);
280 mBrowser->navigateTo(media_url); 321 mBrowser->navigateTo(media_url);
281} 322}
282
283LLViewerHtmlHelp gViewerHtmlHelp;
284
285class LLFloaterHtmlHelp :
286 public LLFloater,
287 public LLWebBrowserCtrlObserver
288{
289public:
290 LLFloaterHtmlHelp(std::string start_url, std::string title);
291 virtual ~LLFloaterHtmlHelp();
292
293 virtual void onClose( bool app_quitting );
294 virtual void draw();
295
296 static void show(std::string url, std::string title);
297 static void onClickBack( void* data );
298 static void onClickHome( void* data );
299 static void onClickForward( void* data );
300 static void onClickClose( void* data );
301
302 // browser observer impls
303 virtual void onStatusTextChange( const EventType& eventIn );
304 virtual void onLocationChange( const EventType& eventIn );
305
306 // used for some stats logging - will be removed at some point
307 static BOOL sFloaterOpened;
308
309 static void onClickF1HelpLoadURL(S32 option, void* userdata);
310
311protected:
312 LLWebBrowserCtrl* mWebBrowser;
313 static LLFloaterHtmlHelp* sInstance;
314 LLButton* mBackButton;
315 LLButton* mForwardButton;
316 LLButton* mCloseButton;
317 LLTextBox* mStatusText;
318 std::string mStatusTextContents;
319 std::string mCurrentUrl;
320 std::string mSupportUrl;
321};
322
323LLFloaterHtmlHelp* LLFloaterHtmlHelp::sInstance = 0;
324
325BOOL LLFloaterHtmlHelp::sFloaterOpened = FALSE;
326
327////////////////////////////////////////////////////////////////////////////////
328//
329LLFloaterHtmlHelp::LLFloaterHtmlHelp(std::string start_url, std::string title)
330: LLFloater( std::string("HTML Help") ),
331 mWebBrowser( 0 ),
332 mStatusTextContents( LLStringUtil::null ),
333 mCurrentUrl( LLStringUtil::null )
334{
335 sInstance = this;
336
337 // create floater from its XML definition
338 LLUICtrlFactory::getInstance()->buildFloater( this, "floater_html_help.xml" );
339
340 childSetAction("back_btn", onClickBack, this);
341 childSetAction("home_btn", onClickHome, this);
342 childSetAction("forward_btn", onClickForward, this);
343
344 if (!title.empty())
345 {
346 setTitle(title);
347 }
348
349 mWebBrowser = getChild<LLWebBrowserCtrl>("html_help_browser" );
350 if ( mWebBrowser )
351 {
352 // observe browser control events
353 mWebBrowser->addObserver( this );
354
355 if (start_url != "")
356 {
357 mWebBrowser->navigateTo( start_url );
358 }
359 else
360 {
361 // if the last page we were at before the client was closed is valid, go there and
362 // override what is in the XML file
363 // (not when the window was closed - it's only ever hidden - not closed)
364 std::string lastPageUrl = gSavedSettings.getString( "HtmlHelpLastPage" );
365 if ( lastPageUrl != "" )
366 {
367 mWebBrowser->navigateTo( lastPageUrl );
368 };
369 }
370 };
371}
372
373////////////////////////////////////////////////////////////////////////////////
374//
375LLFloaterHtmlHelp::~LLFloaterHtmlHelp()
376{
377 // stop observing browser events
378 if ( mWebBrowser )
379 {
380 mWebBrowser->remObserver( this );
381 };
382
383 // save position of floater
384 gSavedSettings.setRect( "HtmlHelpRect", getRect() );
385
386 // save the location we were at when SL closed
387 gSavedSettings.setString( "HtmlHelpLastPage", mCurrentUrl );
388
389 sInstance = 0;
390}
391
392////////////////////////////////////////////////////////////////////////////////
393// virtual
394void LLFloaterHtmlHelp::draw()
395{
396 // enable/disable buttons depending on state
397 if ( mWebBrowser )
398 {
399 bool enable_back = mWebBrowser->canNavigateBack();
400 childSetEnabled( "back_btn", enable_back );
401
402 bool enable_forward = mWebBrowser->canNavigateForward();
403 childSetEnabled( "forward_btn", enable_forward );
404 };
405
406 LLFloater::draw();
407}
408
409////////////////////////////////////////////////////////////////////////////////
410//
411void LLFloaterHtmlHelp::show(std::string url, std::string title)
412{
413 LLFloaterHtml* floater_html = LLFloaterHtml::getInstance();
414 floater_html->setVisible(FALSE);
415
416 if(url.empty())
417 {
418 url = floater_html->getSupportUrl();
419 }
420 std::string* url_copy = new std::string(url);
421
422 gViewerWindow->alertXml("ClickOpenF1Help", onClickF1HelpLoadURL, url_copy);
423
424}
425
426// static
427void LLFloaterHtmlHelp::onClickF1HelpLoadURL(S32 option, void* userdata)
428{
429 std::string* urlp = (std::string*)userdata;
430 if (0 == option)
431 {
432 LLWeb::loadURL(urlp->c_str());
433 }
434 delete urlp;
435}
436
437////////////////////////////////////////////////////////////////////////////////
438//
439void LLFloaterHtmlHelp::onClose( bool app_quitting )
440{
441 setVisible( false );
442}
443
444////////////////////////////////////////////////////////////////////////////////
445//
446void LLFloaterHtmlHelp::onClickClose( void* data )
447{
448 LLFloaterHtmlHelp* self = ( LLFloaterHtmlHelp* )data;
449
450 self->setVisible( false );
451}
452
453////////////////////////////////////////////////////////////////////////////////
454//
455void LLFloaterHtmlHelp::onClickBack( void* data )
456{
457 LLFloaterHtmlHelp* self = ( LLFloaterHtmlHelp* )data;
458 if ( self )
459 {
460 if ( self->mWebBrowser )
461 {
462 self->mWebBrowser->navigateBack();
463 };
464 };
465}
466
467////////////////////////////////////////////////////////////////////////////////
468//
469void LLFloaterHtmlHelp::onClickHome( void* data )
470{
471 LLFloaterHtmlHelp* self = ( LLFloaterHtmlHelp* )data;
472 if ( self )
473 {
474 // get the home page URL (which can differ from the start URL) from XML and go there
475 LLWebBrowserCtrl* web_browser = self->getChild<LLWebBrowserCtrl>("html_help_browser" );
476 if ( web_browser )
477 {
478 web_browser->navigateHome();
479 };
480 };
481}
482
483////////////////////////////////////////////////////////////////////////////////
484//
485void LLFloaterHtmlHelp::onClickForward( void* data )
486{
487 LLFloaterHtmlHelp* self = ( LLFloaterHtmlHelp* )data;
488 if ( self )
489 {
490 if ( self->mWebBrowser )
491 {
492 self->mWebBrowser->navigateForward();
493 };
494 };
495}
496
497////////////////////////////////////////////////////////////////////////////////
498//
499void LLFloaterHtmlHelp::onStatusTextChange( const EventType& eventIn )
500{
501 mStatusTextContents = std::string( eventIn.getStringValue() );
502
503 childSetText("status_text", mStatusTextContents);
504}
505
506////////////////////////////////////////////////////////////////////////////////
507//
508void LLFloaterHtmlHelp::onLocationChange( const EventType& eventIn )
509{
510 llinfos << "MOZ> Location changed to " << eventIn.getStringValue() << llendl;
511 mCurrentUrl = std::string( eventIn.getStringValue() );
512}
513
514////////////////////////////////////////////////////////////////////////////////
515//
516LLViewerHtmlHelp::LLViewerHtmlHelp()
517{
518 LLUI::setHtmlHelp(this);
519}
520
521LLViewerHtmlHelp::~LLViewerHtmlHelp()
522{
523 LLUI::setHtmlHelp(NULL);
524}
525
526void LLViewerHtmlHelp::show()
527{
528 LLFloaterHtmlHelp::show("", "");
529}
530
531void LLViewerHtmlHelp::show(std::string url)
532{
533 std::string title; // empty
534 LLFloaterHtmlHelp::show(url, title);
535}