Example #1
0
//---------------------------------------------------------------------------
// Public methods
//---------------------------------------------------------------------------
LLPanelLogin::LLPanelLogin(const LLRect &rect,
						 BOOL show_server,
						 void (*callback)(S32 option, void* user_data),
						 void *cb_data)
:	LLPanel(),
	mLogoImage(),
	mCallback(callback),
	mCallbackData(cb_data),
	mListener(new LLPanelLoginListener(this))
{
	setBackgroundVisible(FALSE);
	setBackgroundOpaque(TRUE);

	// instance management
	if (LLPanelLogin::sInstance)
	{
		llwarns << "Duplicate instance of login view deleted" << llendl;
		// Don't leave bad pointer in gFocusMgr
		gFocusMgr.setDefaultKeyboardFocus(NULL);

		delete LLPanelLogin::sInstance;
	}

	mPasswordModified = FALSE;
	LLPanelLogin::sInstance = this;

	LLView* login_holder = gViewerWindow->getLoginPanelHolder();
	if (login_holder)
	{
		login_holder->addChild(this);
	}

	// Logo
	mLogoImage = LLUI::getUIImage("startup_logo");

	buildFromFile( "panel_login.xml");
	
	reshape(rect.getWidth(), rect.getHeight());

	getChild<LLLineEditor>("password_edit")->setKeystrokeCallback(onPassKey, this);

	// change z sort of clickable text to be behind buttons
	sendChildToBack(getChildView("forgot_password_text"));

	if(LLStartUp::getStartSLURL().getType() != LLSLURL::LOCATION)
	{
		LLSLURL slurl(gSavedSettings.getString("LoginLocation"));
		LLStartUp::setStartSLURL(slurl);
	}

	LLUICtrl& mode_combo = getChildRef<LLUICtrl>("mode_combo");
	mode_combo.setValue(gSavedSettings.getString("SessionSettingsFile"));
	mode_combo.setCommitCallback(boost::bind(&LLPanelLogin::onModeChange, this, getChild<LLUICtrl>("mode_combo")->getValue(), _2));

	LLComboBox* server_choice_combo = sInstance->getChild<LLComboBox>("server_combo");
	server_choice_combo->setCommitCallback(onSelectServer, NULL);
	LLComboBox* saved_login_choice_combo = sInstance->getChild<LLComboBox>("username_combo");
	// <FS:Ansariel> Clear password field while typing (FIRE-6266)
	saved_login_choice_combo->setFocusLostCallback(boost::bind(&usernameLostFocus, _1, this));
	// </FS:Ansariel> Clear password field while typing (FIRE-6266)
	saved_login_choice_combo->setCommitCallback(onSelectSavedLogin, NULL);
	updateServerCombo();

	childSetAction("delete_saved_login_btn", onClickDelete, this);
	childSetAction("connect_btn", onClickConnect, this);

	getChild<LLPanel>("login")->setDefaultBtn("connect_btn");

	std::string channel = LLVersionInfo::getChannel();
	std::string version = llformat("%s (%d)",
								   LLVersionInfo::getShortVersion().c_str(),
								   LLVersionInfo::getBuild());
	//LLTextBox* channel_text = getChild<LLTextBox>("channel_text");
	//channel_text->setTextArg("[CHANNEL]", channel); // though not displayed
	//channel_text->setTextArg("[VERSION]", version);
	//channel_text->setClickedCallback(onClickVersion, this);
	
	LLTextBox* forgot_password_text = getChild<LLTextBox>("forgot_password_text");
	forgot_password_text->setClickedCallback(onClickForgotPassword, NULL);

	LLTextBox* create_new_account_text = getChild<LLTextBox>("create_new_account_text");
	create_new_account_text->setClickedCallback(onClickNewAccount, NULL);

	LLTextBox* need_help_text = getChild<LLTextBox>("login_help");
	need_help_text->setClickedCallback(onClickHelp, NULL);
	
	LLTextBox* grid_mgr_help_text = getChild<LLTextBox>("grid_mgr_help_text");
	grid_mgr_help_text->setClickedCallback(onClickGridMgrHelp, NULL);
	
	// get the web browser control
	LLMediaCtrl* web_browser = getChild<LLMediaCtrl>("login_html");
	web_browser->addObserver(this);

	mLoginWidgets=getChild<LLView>("login_widgets");

	reshapeBrowser();

// <AW: opensim>
	web_browser->setVisible(true);
	web_browser->navigateToLocalPage( "loading", "loading.html" );
// </AW: opensim>

	updateSavedLoginsCombo();
	updateLocationCombo(false);

	// Show last logged in user favorites in "Start at" combo.
	//addUsersWithFavoritesToUsername();
	getChild<LLComboBox>("username_combo")->setTextChangedCallback(boost::bind(&LLPanelLogin::addFavoritesToStartLocation, this));
}
Example #2
0
//---------------------------------------------------------------------------
LLNotifyBox::LLNotifyBox(LLNotificationPtr notification,
						 BOOL layout_script_dialog)
	:	LLPanel(notification->getName(), LLRect(), BORDER_NO),
		LLEventTimer(notification->getExpiration() == LLDate() 
			? LLDate(LLDate::now().secondsSinceEpoch() + (F64)gSavedSettings.getF32("NotifyTipDuration")) 
			: notification->getExpiration()),
		LLInstanceTracker<LLNotifyBox, LLUUID>(notification->getID()),
	  mNotification(notification),
	  mIsTip(notification->getType() == "notifytip"),
	  mAnimating(TRUE),
	  mNextBtn(NULL),
	  mNumOptions(0),
	  mNumButtons(0),
	  mAddedDefaultBtn(FALSE),
	  mLayoutScriptDialog(layout_script_dialog)
{
	// clicking on a button does not steal current focus
	setIsChrome(TRUE);

	// class init
	if (!sFont)
	{
		sFont = LLFontGL::getFontSansSerif();
		sFontSmall = LLFontGL::getFontSansSerifSmall();
	}

	// setup paramaters
	mMessage = notification->getMessage();

	// initialize
	setFocusRoot(!mIsTip);

	// caution flag can be set explicitly by specifying it in the
	// notification payload, or it can be set implicitly if the
	// notify xml template specifies that it is a caution
	//
	// tip-style notification handle 'caution' differently -
	// they display the tip in a different color
	mIsCaution = notification->getPriority() >= NOTIFICATION_PRIORITY_HIGH;

	// Only animate first window
	if( gNotifyBoxView->getChildCount() > 0 )
		mAnimating = FALSE;
	else
		mAnimating = TRUE;

	LLNotificationFormPtr form(notification->getForm());

	mNumOptions = form->getNumElements();
		  
	LLRect rect = mIsTip ? getNotifyTipRect(mMessage)
		   		  		 : getNotifyRect(mNumOptions, layout_script_dialog, mIsCaution);
	setRect(rect);
	setFollows(mIsTip ? (FOLLOWS_BOTTOM|FOLLOWS_RIGHT) : (FOLLOWS_TOP|FOLLOWS_RIGHT));
	setBackgroundVisible(FALSE);
	setBackgroundOpaque(TRUE);

	LLIconCtrl* icon;
	LLTextEditor* text;

	const S32 TOP = getRect().getHeight() - (mIsTip ? (S32)sFont->getLineHeight() : 32);
	const S32 BOTTOM = (S32)sFont->getLineHeight();
	S32 x = HPAD + HPAD;
	S32 y = TOP;

	if (mIsTip)
	{
		// use the tip notification icon
		icon = new LLIconCtrl(std::string("icon"), LLRect(x, y, x+32, TOP-32), std::string("notify_tip_icon.tga"));
	}
	else if (mIsCaution)
	{
		// use the caution notification icon
		icon = new LLIconCtrl(std::string("icon"), LLRect(x, y, x+32, TOP-32), std::string("notify_caution_icon.tga"));
	}
	else
	{
		// use the default notification icon
		icon = new LLIconCtrl(std::string("icon"), LLRect(x, y, x+32, TOP-32), std::string("notify_box_icon.tga"));
	}

	icon->setMouseOpaque(FALSE);
	addChild(icon);

	x += HPAD + HPAD + 32;

	// add a caution textbox at the top of a caution notification
	LLTextBox* caution_box = NULL;
	if (mIsCaution && !mIsTip)
	{
		S32 caution_height = ((S32)sFont->getLineHeight() * 2) + VPAD;
		caution_box = new LLTextBox(
			std::string("caution_box"), 
			LLRect(x, y, getRect().getWidth() - 2, caution_height), 
			LLStringUtil::null, 
			sFont, 
			FALSE);

		caution_box->setFontStyle(LLFontGL::BOLD);
		caution_box->setColor(gColors.getColor("NotifyCautionWarnColor"));
		caution_box->setBackgroundColor(gColors.getColor("NotifyCautionBoxColor"));
		caution_box->setBorderVisible(FALSE);
		caution_box->setWrappedText(notification->getMessage());
		
		addChild(caution_box);

		// adjust the vertical position of the next control so that 
		// it appears below the caution textbox
		y = y - caution_height;
	}
	else
	{

		const S32 BTN_TOP = BOTTOM_PAD + (((mNumOptions-1+2)/3)) * (BTN_HEIGHT+VPAD);

		// Tokenization on \n is handled by LLTextBox

		const S32 MAX_LENGTH = 512 + 20 + 
			DB_FIRST_NAME_BUF_SIZE + 
			DB_LAST_NAME_BUF_SIZE +
			DB_INV_ITEM_NAME_BUF_SIZE;  // For script dialogs: add space for title.

		text = new LLTextEditor(std::string("box"),
								LLRect(x, y, getRect().getWidth()-2, mIsTip ? BOTTOM : BTN_TOP+16),
								MAX_LENGTH,
								mMessage,
								sFont,
								FALSE);
		text->setWordWrap(TRUE);
		text->setTabStop(FALSE);
		text->setMouseOpaque(FALSE);
		text->setBorderVisible(FALSE);
		text->setTakesNonScrollClicks(FALSE);
		text->setHideScrollbarForShortDocs(TRUE);
		text->setReadOnlyBgColor ( LLColor4::transparent ); // the background color of the box is manually 
															// rendered under the text box, therefore we want 
															// the actual text box to be transparent
		text->setReadOnlyFgColor ( gColors.getColor("NotifyTextColor") );
		text->setEnabled(FALSE); // makes it read-only
		text->setTabStop(FALSE); // can't tab to it (may be a problem for scrolling via keyboard)
		addChild(text);
	}

	if (mIsTip)
	{
		// TODO: Make a separate archive for these.
		LLChat chat(mMessage);
		chat.mSourceType = CHAT_SOURCE_SYSTEM;
		LLFloaterChat::getInstance(LLSD())->addChatHistory(chat);
	}
	else
	{
		LLButton* btn;
		btn = new LLButton(std::string("next"),
						   LLRect(getRect().getWidth()-26, BOTTOM_PAD + 20, getRect().getWidth()-2, BOTTOM_PAD),
						   std::string("notify_next.png"),
						   std::string("notify_next.png"),
						   LLStringUtil::null,
						   onClickNext,
						   this,
						   sFont);
		btn->setScaleImage(TRUE);
		btn->setToolTip(std::string("Next")); // *TODO: Translate
		addChild(btn);
		mNextBtn = btn;

		for (S32 i = 0; i < mNumOptions; i++)
		{

			LLSD form_element = form->getElement(i);
			if (form_element["type"].asString() != "button") 
			{
				continue;
			}

			addButton(form_element["name"].asString(), form_element["text"].asString(), TRUE, form_element["default"].asBoolean());
		}

		if (mNumButtons == 0)
		{
			addButton("OK", "OK", FALSE, TRUE);
			mAddedDefaultBtn = TRUE;
		}
		
		sNotifyBoxCount++;

		if (sNotifyBoxCount <= 0)
		{
			llwarns << "A notification was mishandled. sNotifyBoxCount = " << sNotifyBoxCount << llendl;
		}
		
		// If this is the only notify box, don't show the next button
		if (sNotifyBoxCount == 1
			&& mNextBtn)
		{
			mNextBtn->setVisible(FALSE);
		}
	}
}
Example #3
0
LLGroupNotifyBox::LLGroupNotifyBox(const std::string& subject,
                                   const std::string& message,
                                   const std::string& from_name,
                                   const LLUUID& group_id,
                                   const LLUUID& group_insignia,
                                   const std::string& group_name,
                                   const U32& t,
                                   const bool& has_inventory,
                                   const std::string& inventory_name,
                                   LLOfferInfo* inventory_offer)
    :	LLPanel(std::string("groupnotify"), LLGroupNotifyBox::getGroupNotifyRect(), BORDER_YES),
      mAnimating(TRUE),
      mTimer(),
      mGroupID(group_id),
      mHasInventory(has_inventory),
      mInventoryOffer(inventory_offer)
{
    setFocusRoot(TRUE);

    time_t timestamp = (time_t)t;

    std::string time_buf = g_formatted_time(timestamp);

    setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT);
    setBackgroundVisible(TRUE);
    setBackgroundOpaque(TRUE);

    // TODO: add a color for group notices
    setBackgroundColor( gColors.getColor("GroupNotifyBoxColor") );

    LLIconCtrl* icon;
    LLTextEditor* text;

    const S32 VPAD = 2;
    const S32 TOP = getRect().getHeight() - 32; // Get past the top menu bar
    const S32 BOTTOM_PAD = VPAD * 2;
    const S32 BTN_TOP = BOTTOM_PAD + BTN_HEIGHT + VPAD;
    const S32 RIGHT = getRect().getWidth() - HPAD - HPAD;
    const S32 LINE_HEIGHT = 16;

    const S32 LABEL_WIDTH = 64;
    const S32 ICON_WIDTH = 64;

    S32 y = TOP;
    S32 x = HPAD + HPAD;

    class NoticeText : public LLTextBox
    {
    public:
        NoticeText(const std::string& name, const LLRect& rect, const std::string& text = LLStringUtil::null, const LLFontGL* font = NULL)
            : LLTextBox(name, rect, text, font)
        {
            setHAlign(LLFontGL::RIGHT);
            setFontStyle(LLFontGL::DROP_SHADOW_SOFT);
            setBorderVisible(FALSE);
            setColor( gColors.getColor("GroupNotifyTextColor") );
            setBackgroundColor( gColors.getColor("GroupNotifyBoxColor") );
        }
    };


    // Title
    addChild(new NoticeText(std::string("title"),LLRect(x,y,RIGHT - HPAD,y - LINE_HEIGHT),std::string("Group Notice"),LLFontGL::sSansSerifHuge));

    y -= llfloor(1.5f*LINE_HEIGHT);

    x += HPAD + HPAD + ICON_WIDTH;

    std::stringstream from;
    from << "Sent by " << from_name << ", " << group_name;

    addChild(new NoticeText(std::string("group"),LLRect(x,y,RIGHT - HPAD,y - LINE_HEIGHT),from.str(),LLFontGL::sSansSerif));

    y -= (LINE_HEIGHT + VPAD);
    x = HPAD + HPAD;

    // TODO: change this to be the group icon.
    if (!group_insignia.isNull())
    {
        icon = new LLIconCtrl(std::string("icon"),
                              LLRect(x, y, x+ICON_WIDTH, y-ICON_WIDTH),
                              group_insignia);
    }
    else
    {
        icon = new LLIconCtrl(std::string("icon"),
                              LLRect(x, y, x+ICON_WIDTH, y-ICON_WIDTH),
                              std::string("notify_box_icon.tga"));
    }

    icon->setMouseOpaque(FALSE);
    addChild(icon);

    x += HPAD + HPAD + ICON_WIDTH;
    // If we have inventory with this message, leave room for the name.
    S32 box_bottom = BTN_TOP + (mHasInventory ? (LINE_HEIGHT + 2*VPAD) : 0);

    text = new LLViewerTextEditor(std::string("box"),
                                  LLRect(x, y, RIGHT, box_bottom),
                                  DB_GROUP_NOTICE_MSG_STR_LEN,
                                  LLStringUtil::null,
                                  LLFontGL::sSansSerif,
                                  FALSE);

    static const LLStyleSP headerstyle(new LLStyle(true,LLColor4::black,"SansSerifBig"));
    static const LLStyleSP datestyle(new LLStyle(true,LLColor4::black,"serif"));

    text->appendStyledText(subject,false,false,headerstyle);
    text->appendStyledText(time_buf,false,false,datestyle);
    // Sadly, our LLTextEditor can't handle both styled and unstyled text
    // at the same time.  Hence this space must be styled. JC
    text->appendColoredText(std::string(" "),false,false,LLColor4::grey4);
    text->appendColoredText(message,false,false,LLColor4::grey4);

    LLColor4 semi_transparent(1.0f,1.0f,1.0f,0.8f);
    text->setCursor(0,0);
    text->setEnabled(FALSE);
    text->setWordWrap(TRUE);
    //text->setTabStop(FALSE); // was interfering with copy-and-paste
    text->setTabsToNextField(TRUE);
    text->setMouseOpaque(TRUE);
    text->setBorderVisible(TRUE);
    text->setTakesNonScrollClicks(TRUE);
    text->setHideScrollbarForShortDocs(TRUE);
    text->setReadOnlyBgColor ( semi_transparent );
    text->setWriteableBgColor ( semi_transparent );

    addChild(text);

    y = box_bottom - VPAD;

    if (mHasInventory)
    {
        addChild(new NoticeText(std::string("subjecttitle"),LLRect(x,y,x + LABEL_WIDTH,y - LINE_HEIGHT),std::string("Attached: "),LLFontGL::sSansSerif));


        LLAssetType::EType atype;
        LLInventoryType::EType itype;
        atype = mInventoryOffer->mType;
        itype = LLInventoryType::defaultForAssetType( atype );

        LLUIImagePtr item_icon = get_item_icon(atype, itype, 0, FALSE);


        x += LABEL_WIDTH + HPAD;

        std::stringstream ss;
        ss << "        " << inventory_name;
        LLTextBox *line = new LLTextBox(std::string("object_name"),LLRect(x,y,RIGHT - HPAD,y - LINE_HEIGHT),ss.str(),LLFontGL::sSansSerif);
        line->setEnabled(FALSE);
        line->setBorderVisible(TRUE);
        line->setDisabledColor(LLColor4::blue4);
        line->setFontStyle(LLFontGL::NORMAL);
        line->setBackgroundVisible(true);
        line->setBackgroundColor( semi_transparent );
        addChild(line);

        icon = new LLIconCtrl(std::string("icon"),
                              LLRect(x, y, x+16, y-16),
                              item_icon->getName());
        icon->setMouseOpaque(FALSE);
        addChild(icon);
    }

    LLButton* btn;
    btn = new LLButton(std::string("next"),
                       LLRect(getRect().getWidth()-26, BOTTOM_PAD + 20, getRect().getWidth()-2, BOTTOM_PAD),
                       std::string("notify_next.png"),
                       std::string("notify_next.png"),
                       LLStringUtil::null,
                       onClickNext,
                       this,
                       LLFontGL::sSansSerif);
    btn->setToolTip(std::string("Next")); // *TODO: Translate
    btn->setScaleImage(TRUE);
    addChild(btn);
    mNextBtn = btn;

    S32 btn_width = 80;
    S32 wide_btn_width = 120;
    LLRect btn_rect;
    x = 3 * HPAD;

    btn_rect.setOriginAndSize(x,
                              BOTTOM_PAD,
                              btn_width,
                              BTN_HEIGHT);

    btn = new LLButton(std::string("OK"), btn_rect, LLStringUtil::null, onClickOk, this);
    addChild(btn, -1);
    setDefaultBtn(btn);

    x += btn_width + HPAD;


    btn_rect.setOriginAndSize(x,
                              BOTTOM_PAD,
                              wide_btn_width,
                              BTN_HEIGHT);

    btn = new LLButton(std::string("Group Notices"), btn_rect, LLStringUtil::null, onClickGroupInfo, this);
    btn->setToolTip(std::string("View past notices or opt-out of receiving these messages here.")); // TODO: Translate
    addChild(btn, -1);

    if (mHasInventory && mInventoryOffer)
    {
        x += wide_btn_width + HPAD;

        btn_rect.setOriginAndSize(x,
                                  BOTTOM_PAD,
                                  wide_btn_width,
                                  BTN_HEIGHT);

        std::string btn_lbl("");
        if(is_openable(mInventoryOffer->mType))
        {
            btn_lbl = "Open Attachment";
        }
        else
        {
            btn_lbl = "Save Attachment";
        }
        mSaveInventoryBtn = new LLButton(btn_lbl, btn_rect, LLStringUtil::null, onClickSaveInventory, this);
        mSaveInventoryBtn->setVisible(mHasInventory);
        addChild(mSaveInventoryBtn);
    }

    sGroupNotifyBoxCount++;

    // If this is the only notify box, don't show the next button
    if (sGroupNotifyBoxCount == 1)
    {
        mNextBtn->setVisible(FALSE);
    }
}