From 9e2cb2f4a00a6acc48738f9df788ad5adfc7d62a Mon Sep 17 00:00:00 2001
From: Steven Bennetts <steve@lindenlab.com>
Date: Fri, 28 Aug 2009 08:04:26 +0000
Subject: DEV-38942 Eliminate startModal() from LLModalDialog Also moved TOS
 and Critical floaters to login debug menu for testing

---
 indra/llui/llmodaldialog.cpp                      |  8 ++--
 indra/llui/llmodaldialog.h                        | 10 ++--
 indra/newview/llfloaterpreference.cpp             | 56 ++++++++++++++++-------
 indra/newview/llfloatertos.cpp                    |  2 +-
 indra/newview/llimview.cpp                        | 21 +++++----
 indra/newview/llpanellogin.cpp                    | 24 ----------
 indra/newview/llviewerwindow.cpp                  | 11 +++--
 indra/newview/skins/default/xui/en/menu_login.xml | 16 +++++++
 8 files changed, 81 insertions(+), 67 deletions(-)

(limited to 'indra')

diff --git a/indra/llui/llmodaldialog.cpp b/indra/llui/llmodaldialog.cpp
index c8162fe466..f77ec5f4c7 100644
--- a/indra/llui/llmodaldialog.cpp
+++ b/indra/llui/llmodaldialog.cpp
@@ -44,11 +44,10 @@
 // static
 std::list<LLModalDialog*> LLModalDialog::sModalStack;
 
-LLModalDialog::LLModalDialog( const LLSD& key, S32 width, S32 height, BOOL modal )
+LLModalDialog::LLModalDialog( const LLSD& key, BOOL modal )
 	: LLFloater(key),
 	  mModal( modal )
 {
-	setRect(LLRect( 0, height, width, 0 ));
 	if (modal)
 	{
 		setCanMinimize(FALSE);
@@ -98,7 +97,8 @@ void LLModalDialog::reshape(S32 width, S32 height, BOOL called_from_parent)
 	centerOnScreen();
 }
 
-void LLModalDialog::startModal()
+// virtual
+void LLModalDialog::onOpen(const LLSD& key)
 {
 	if (mModal)
 	{
@@ -116,8 +116,6 @@ void LLModalDialog::startModal()
 
 		sModalStack.push_front( this );
 	}
-
-	setVisible( TRUE );
 }
 
 void LLModalDialog::stopModal()
diff --git a/indra/llui/llmodaldialog.h b/indra/llui/llmodaldialog.h
index 4d5073024b..9d716a1880 100644
--- a/indra/llui/llmodaldialog.h
+++ b/indra/llui/llmodaldialog.h
@@ -45,18 +45,16 @@ class LLModalDialog;
 class LLModalDialog : public LLFloater
 {
 public:
-	LLModalDialog( const LLSD& key, S32 width, S32 height, BOOL modal = true );
+	LLModalDialog( const LLSD& key, BOOL modal = true );
 	/*virtual*/ ~LLModalDialog();
 	
 	/*virtual*/ BOOL 	postBuild();
 	
 	/*virtual*/ void	openFloater(const LLSD& key = LLSD());
+	/*virtual*/ void	onOpen(const LLSD& key);
 	
 	/*virtual*/ void 	reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
 	
-	/*virtual*/ void	startModal();
-	/*virtual*/ void	stopModal();
-
 	/*virtual*/ BOOL	handleMouseDown(S32 x, S32 y, MASK mask);
 	/*virtual*/ BOOL	handleMouseUp(S32 x, S32 y, MASK mask);
 	/*virtual*/ BOOL	handleHover(S32 x, S32 y, MASK mask);
@@ -68,7 +66,8 @@ public:
 	/*virtual*/ void	setVisible(BOOL visible);
 	/*virtual*/ void	draw();
 
-	BOOL isModal() const { return mModal; }
+	BOOL 			isModal() const { return mModal; }
+	void			stopModal();
 
 	static void		onAppFocusLost();
 	static void		onAppFocusGained();
@@ -79,6 +78,7 @@ protected:
 	void			centerOnScreen();
 
 private:
+	
 	LLFrameTimer 	mVisibleTime;
 	const BOOL		mModal;
 
diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index b395e1128c..3e4065d5d0 100644
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -111,26 +111,38 @@ const F32 MIN_USER_FAR_CLIP = 64.f;
 const S32 ASPECT_RATIO_STR_LEN = 100;
 
 class LLVoiceSetKeyDialog : public LLModalDialog
-	{
-	public:
-		LLVoiceSetKeyDialog(LLFloaterPreference* parent);
-		~LLVoiceSetKeyDialog();
-		
-		BOOL handleKeyHere(KEY key, MASK mask);
-		static void onCancel(void* user_data);
+{
+public:
+	LLVoiceSetKeyDialog(const LLSD& key);
+	~LLVoiceSetKeyDialog();
+	
+	/*virtual*/ BOOL postBuild();
+	
+	void setParent(LLFloaterPreference* parent) { mParent = parent; }
+	
+	BOOL handleKeyHere(KEY key, MASK mask);
+	static void onCancel(void* user_data);
 		
-	private:
-		LLFloaterPreference* mParent;
-	};
+private:
+	LLFloaterPreference* mParent;
+};
 
-LLVoiceSetKeyDialog::LLVoiceSetKeyDialog(LLFloaterPreference* parent)
-: LLModalDialog(LLSD(), 240, 100), mParent(parent)
+LLVoiceSetKeyDialog::LLVoiceSetKeyDialog(const LLSD& key)
+  : LLModalDialog(key),
+	mParent(NULL)
+{
+// 	LLUICtrlFactory::getInstance()->buildFloater(this, "floater_select_key.xml", NULL);
+}
+
+//virtual
+BOOL LLVoiceSetKeyDialog::postBuild()
 {
-	LLUICtrlFactory::getInstance()->buildFloater(this, "floater_select_key.xml", NULL);
 	childSetAction("Cancel", onCancel, this);
 	childSetFocus("Cancel");
 	
 	gFocusMgr.setKeystrokesOnly(TRUE);
+	
+	return TRUE;
 }
 
 LLVoiceSetKeyDialog::~LLVoiceSetKeyDialog()
@@ -145,7 +157,7 @@ BOOL LLVoiceSetKeyDialog::handleKeyHere(KEY key, MASK mask)
 	{
 		result = FALSE;
 	}
-	else
+	else if (mParent)
 	{
 		mParent->setKey(key);
 	}
@@ -294,7 +306,14 @@ LLFloaterPreference::LLFloaterPreference(const LLSD& key)
 	mOriginalIMViaEmail(false)
 {
 	//Build Floater is now Called from 	LLFloaterReg::add("preferences", "floater_preferences.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreference>);
-          
+	
+	static bool registered_dialog = false;
+	if (!registered_dialog)
+	{
+		LLFloaterReg::add("voice_set_key", "floater_select_key.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLVoiceSetKeyDialog>);
+		registered_dialog = true;
+	}
+	
 	mCommitCallbackRegistrar.add("Pref.Apply",				boost::bind(&LLFloaterPreference::onBtnApply, this));
 	mCommitCallbackRegistrar.add("Pref.Cancel",				boost::bind(&LLFloaterPreference::onBtnCancel, this));
 	mCommitCallbackRegistrar.add("Pref.OK",					boost::bind(&LLFloaterPreference::onBtnOK, this));
@@ -980,8 +999,11 @@ void LLFloaterPreference::cleanupBadSetting()
 
 void LLFloaterPreference::onClickSetKey()
 {
-	LLVoiceSetKeyDialog* dialog = new LLVoiceSetKeyDialog(this);
-	dialog->startModal();
+	LLVoiceSetKeyDialog* dialog = LLFloaterReg::showTypedInstance<LLVoiceSetKeyDialog>("voice_set_key", LLSD(), TRUE);
+	if (dialog)
+	{
+		dialog->setParent(this);
+	}
 }
 
 void LLFloaterPreference::setKey(KEY key)
diff --git a/indra/newview/llfloatertos.cpp b/indra/newview/llfloatertos.cpp
index 1060a5e031..1c3443ae80 100644
--- a/indra/newview/llfloatertos.cpp
+++ b/indra/newview/llfloatertos.cpp
@@ -53,7 +53,7 @@
 
 
 LLFloaterTOS::LLFloaterTOS(const LLSD& message)
-:	LLModalDialog( message, 100, 100 ),
+:	LLModalDialog( message ),
 	mMessage(message.asString()),
 	mWebBrowserWindowId( 0 ),
 	mLoadCompleteCount( 0 )
diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp
index 4cbf88f3da..404751a44a 100644
--- a/indra/newview/llimview.cpp
+++ b/indra/newview/llimview.cpp
@@ -840,10 +840,9 @@ BOOL LLFloaterIM::postBuild()
 // Class LLIncomingCallDialog
 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 LLIncomingCallDialog::LLIncomingCallDialog(const LLSD& payload) :
-	LLModalDialog(payload, 240, 200),
+	LLModalDialog(payload),
 	mPayload(payload)
 {
-	LLUICtrlFactory::getInstance()->buildFloater(this, "floater_incoming_call.xml", NULL);
 }
 
 BOOL LLIncomingCallDialog::postBuild()
@@ -1134,6 +1133,13 @@ LLIMMgr::LLIMMgr() :
 	mFriendObserver(NULL),
 	mIMReceived(FALSE)
 {
+	static bool registered_dialog = false;
+	if (!registered_dialog)
+	{
+		LLFloaterReg::add("incoming_call", "floater_incoming_call.xml.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLIncomingCallDialog>);
+		registered_dialog = true;
+	}
+		
 	mFriendObserver = new LLIMViewFriendObserver(this);
 	LLAvatarTracker::instance().addObserver(mFriendObserver);
 
@@ -1535,8 +1541,7 @@ void LLIMMgr::inviteToSession(
 		{
 			if (notify_box_type == "VoiceInviteP2P" || notify_box_type == "VoiceInviteAdHoc")
 			{
-				LLIncomingCallDialog *dialog = new LLIncomingCallDialog(payload);
-				dialog->startModal();
+				LLFloaterReg::showInstance("incoming_call", payload, TRUE);
 			}
 			else
 			{
@@ -1544,10 +1549,7 @@ void LLIMMgr::inviteToSession(
 				args["NAME"] = caller_name;
 				args["GROUP"] = session_name;
 
-				LLNotifications::instance().add(notify_box_type, 
-						args, 
-							payload,
-							&inviteUserResponse);
+				LLNotifications::instance().add(notify_box_type, args, payload, &inviteUserResponse);
 			}
 		}
 		mPendingInvitations[session_id.asString()] = LLSD();
@@ -1563,8 +1565,7 @@ void LLIMMgr::onInviteNameLookup(LLSD payload, const LLUUID& id, const std::stri
 
 	if (notify_box_type == "VoiceInviteP2P" || notify_box_type == "VoiceInviteAdHoc")
 	{
-		LLIncomingCallDialog *dialog = new LLIncomingCallDialog(payload);
-		dialog->startModal();
+		LLFloaterReg::showInstance("incoming_call", payload, TRUE);
 	}
 	else
 	{
diff --git a/indra/newview/llpanellogin.cpp b/indra/newview/llpanellogin.cpp
index 167446d380..ef830d5f03 100644
--- a/indra/newview/llpanellogin.cpp
+++ b/indra/newview/llpanellogin.cpp
@@ -410,15 +410,6 @@ BOOL LLPanelLogin::handleKeyHere(KEY key, MASK mask)
 		return TRUE;
 	}
 
-	if (('T' == key) && (MASK_CONTROL == mask))
-	{	// previously was "Test Floater"
-		if(gSavedSettings.getBOOL("QAMode"))
-		{
-			LLFloaterReg::showInstance("ui_preview", LLSD(), TRUE);
-			return TRUE;
-		}
-	}
-	
 	if ( KEY_F1 == key )
 	{
 		llinfos << "Spawning HTML help window" << llendl;
@@ -426,21 +417,6 @@ BOOL LLPanelLogin::handleKeyHere(KEY key, MASK mask)
 		return TRUE;
 	}
 
-# if !LL_RELEASE_FOR_DOWNLOAD
-	if ( KEY_F2 == key )
-	{
-		llinfos << "Spawning floater TOS window (TOS)" << llendl;
-		LLFloaterReg::showInstance("message_tos",LLSD(""));
-		return TRUE;
-	}
-	if ( KEY_F3 == key )
-	{
-		llinfos << "Spawning floater TOS window (critical message)" << llendl;
-		LLFloaterReg::showInstance("message_critical",LLSD(""));
-		return TRUE;
-	}
-#endif
-
 	if (KEY_RETURN == key && MASK_NONE == mask)
 	{
 		// let the panel handle UICtrl processing: calls onClickConnect()
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 36499fd191..9bdf9d2aac 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -1686,6 +1686,10 @@ void LLViewerWindow::shutdownViews()
 		gMorphView->setVisible(FALSE);
 	}
 	
+	// Delete Tool Tip
+	delete mToolTip;
+	mToolTip = NULL;
+	
 	// Delete all child views.
 	delete mRootView;
 	mRootView = NULL;
@@ -1695,15 +1699,12 @@ void LLViewerWindow::shutdownViews()
 	gIMMgr = NULL;
 	gHoverView = NULL;
 
-	gFloaterView		= NULL;
-	gMorphView			= NULL;
+	gFloaterView = NULL;
+	gMorphView = NULL;
 
 	gHUDView = NULL;
 
 	gNotifyBoxView = NULL;
-
-	delete mToolTip;
-	mToolTip = NULL;
 }
 
 void LLViewerWindow::shutdownGL()
diff --git a/indra/newview/skins/default/xui/en/menu_login.xml b/indra/newview/skins/default/xui/en/menu_login.xml
index 642087baff..46d13cdc0b 100644
--- a/indra/newview/skins/default/xui/en/menu_login.xml
+++ b/indra/newview/skins/default/xui/en/menu_login.xml
@@ -109,5 +109,21 @@
              function="ShowFloater"
              parameter="test_list_view" />
         </menu_item_call>
+        <menu_item_call
+         label="Show TOS"
+         layout="topleft"
+         name="TOS">
+            <menu_item_call.on_click
+             function="ShowFloater"
+             parameter="message_tos" />
+        </menu_item_call>
+        <menu_item_call
+         label="Show Critical Message"
+         layout="topleft"
+         name="TOS">
+            <menu_item_call.on_click
+             function="ShowFloater"
+             parameter="message_critical" />
+        </menu_item_call>
     </menu>
 </menu_bar>
-- 
cgit v1.2.3