示例#1
0
void wavrChatWindow::init(User *pLocalUser, User *pRemoteUser, bool connected) {
    localId = pLocalUser->id;
    localName = pLocalUser->name;

    peerId = pRemoteUser->id;
    peerIds.insert(peerId, pRemoteUser->id);
    peerNames.insert(peerId, pRemoteUser->name);
    peerStatuses.insert(peerId, pRemoteUser->status);
    peerCaps.insert(peerId, pRemoteUser->caps);

    this->pLocalUser = pLocalUser;

    pMessageLog->localId = localId;
    pMessageLog->peerId = peerId;
    pMessageLog->peerName = pRemoteUser->name;

    //  get the avatar image for the users
    pMessageLog->participantAvatars.insert(localId, pLocalUser->avatarPath);
    pMessageLog->participantAvatars.insert(peerId, pRemoteUser->avatarPath);

    createSmileyMenu();
    createToolBar();

    bConnected = connected;
    if(!bConnected)
        showStatus(IT_Disconnected, true);

    int index = wavrHelper::statusIndexFromCode(pRemoteUser->status);
    if(index != -1) {
        setWindowIcon(QIcon(statusPic[index]));
        if(statusType[index] == StatusTypeOffline)
            showStatus(IT_Offline, true);
        else if(statusType[index] == StatusTypeAway)
            showStatus(IT_Away, true);
        else if(statusType[index] == StatusTypeBusy)
            showStatus(IT_Busy, true);
    }

    pSettings = new wavrSettings();
    showSmiley = pSettings->value(IDS_EMOTICON, IDS_EMOTICON_VAL).toBool();
    pMessageLog->showSmiley = showSmiley;
    pMessageLog->autoFile = pSettings->value(IDS_AUTOFILE, IDS_AUTOFILE_VAL).toBool();
    pMessageLog->messageTime = pSettings->value(IDS_MESSAGETIME, IDS_MESSAGETIME_VAL).toBool();
    pMessageLog->messageDate = pSettings->value(IDS_MESSAGEDATE, IDS_MESSAGEDATE_VAL).toBool();
    pMessageLog->allowLinks = pSettings->value(IDS_ALLOWLINKS, IDS_ALLOWLINKS_VAL).toBool();
    pMessageLog->pathToLink = pSettings->value(IDS_PATHTOLINK, IDS_PATHTOLINK_VAL).toBool();
    pMessageLog->trimMessage = pSettings->value(IDS_TRIMMESSAGE, IDS_TRIMMESSAGE_VAL).toBool();
    clearOnClose = pSettings->value(IDS_CLEARONCLOSE, IDS_CLEARONCLOSE_VAL).toBool();

    setUIText();

    ui.txtMessage->setFocus();

    QString themePath = pSettings->value(IDS_THEME, IDS_THEME_VAL).toString();
    pMessageLog->initMessageLog(themePath);
    if(!clearOnClose)
        pMessageLog->restoreMessageLog(QDir(StdLocation::cacheDir()).absoluteFilePath("msg_" + peerId + ".tmp"));
}
示例#2
0
void lmcChatRoomWindow::init(User* pLocalUser, bool connected, QString thread)
{
	localId = pLocalUser->id;
	localName = pLocalUser->name;

	this->pLocalUser = pLocalUser;

	pMessageLog->localId = localId;

	//	get the avatar image for the users from the cache folder
	QDir cacheDir(StdLocation::cacheDir());
	QString fileName = "avt_" + localId + ".png";
	QString filePath = cacheDir.absoluteFilePath(fileName);
	pMessageLog->participantAvatars.insert(localId, filePath);

	threadId = thread;
	groupMode = !threadId.isNull();

	createUserMenu();
	createSmileyMenu();
	createToolBar();

	bConnected = connected;
    if ( !bConnected )
        showStatus( IT_Disconnected, true );

	pSoundPlayer = new lmcSoundPlayer();

	ui.tvUserList->setIconSize(QSize(16, 16));
    ui.tvUserList->header()->setSectionsMovable(false);
	ui.tvUserList->header()->setStretchLastSection(false);
    ui.tvUserList->header()->setSectionResizeMode(0, QHeaderView::Stretch);

	lmcUserTreeWidgetGroupItem *pItem = new lmcUserTreeWidgetGroupItem();
	pItem->setData(0, IdRole, GroupId);
	pItem->setData(0, TypeRole, "Group");
	pItem->setText(0, "Participants");
	pItem->setSizeHint(0, QSize(0, 22));
	ui.tvUserList->addTopLevelItem(pItem);
	ui.tvUserList->expandAll();

	pSettings = new lmcSettings();
	showSmiley = pSettings->value(IDS_EMOTICON, IDS_EMOTICON_VAL).toBool();
	pMessageLog->showSmiley = showSmiley;
	pMessageLog->autoFile = pSettings->value(IDS_AUTOFILE, IDS_AUTOFILE_VAL).toBool();
	pMessageLog->fontSizeVal = pSettings->value(IDS_FONTSIZE, IDS_FONTSIZE_VAL).toInt();
	pMessageLog->messageTime = pSettings->value(IDS_MESSAGETIME, IDS_MESSAGETIME_VAL).toBool();
	pMessageLog->messageDate = pSettings->value(IDS_MESSAGEDATE, IDS_MESSAGEDATE_VAL).toBool();
	pMessageLog->allowLinks = pSettings->value(IDS_ALLOWLINKS, IDS_ALLOWLINKS_VAL).toBool();
	pMessageLog->pathToLink = pSettings->value(IDS_PATHTOLINK, IDS_PATHTOLINK_VAL).toBool();
	pMessageLog->trimMessage = pSettings->value(IDS_TRIMMESSAGE, IDS_TRIMMESSAGE_VAL).toBool();
	QFont font = QApplication::font();
	font.fromString(pSettings->value(IDS_FONT, IDS_FONT_VAL).toString());
	messageColor = QApplication::palette().text().color();
	messageColor.setNamedColor(pSettings->value(IDS_COLOR, IDS_COLOR_VAL).toString());
	sendKeyMod = pSettings->value(IDS_SENDKEYMOD, IDS_SENDKEYMOD_VAL).toBool();

    if ( !groupMode )
    {
		restoreGeometry(pSettings->value(IDS_WINDOWPUBLICCHAT).toByteArray());
		ui.vSplitter->restoreState(pSettings->value(IDS_SPLITTERPUBLICCHATV).toByteArray());
		ui.hSplitter->restoreState(pSettings->value(IDS_SPLITTERPUBLICCHATH).toByteArray());
	}

	setUIText();

    setMessageFont( font );
    ui.txtMessage->setStyleSheet( "QTextEdit {color: " + messageColor.name() + ";}" );
	ui.txtMessage->setFocus();

	QString themePath = pSettings->value(IDS_THEME, IDS_THEME_VAL).toString();
	pMessageLog->initMessageLog(themePath);

	int viewType = pSettings->value(IDS_USERLISTVIEW, IDS_USERLISTVIEW_VAL).toInt();
	ui.tvUserList->setView((UserListView)viewType);

	//	Destroy the window when it closes if in group mode
	setAttribute(Qt::WA_DeleteOnClose, groupMode);

	//	Add the local user as a participant
	addUser(pLocalUser);
}