示例#1
0
void TextMessageDlg::timerEvent(QTimerEvent *event)
{
    if(m_local_typing_id == event->timerId())
    {
        if(m_textchanged)
        {
            ServerProperties srvprop;
            if(TT_GetServerProperties(ttInst, &srvprop))
            {
                TextMessage msg;
                ZERO_STRUCT(msg);
                msg.nFromUserID = TT_GetMyUserID(ttInst);
                msg.nMsgType = MSGTYPE_CUSTOM;
                msg.nToUserID = m_userid;
                QString cmd = makeCustomCommand(TT_INTCMD_TYPING_TEXT,
                                                QString::number((int)!ui.newmsgTextEdit->toPlainText().isEmpty()));
                COPY_TTSTR(msg.szMessage, cmd);
                if(TT_DoTextMessage(ttInst, &msg)>0)
                    emit(newMyselfTextMessage(msg));
            }
            m_textchanged = false;
        }
    }

    if(m_remote_typing_id == event->timerId())
    {
        ui.newmsgLabel->setText(tr("New message"));
        killTimer(m_remote_typing_id);
        m_remote_typing_id = 0;
    }
}
示例#2
0
ChangeStatusDlg::ChangeStatusDlg(QWidget* parent/* = 0*/)
    : QDialog(parent, QT_DEFAULT_DIALOG_HINTS)
{
    ui.setupUi(this);
    setWindowIcon(QIcon(APPICON));

    connect(this, SIGNAL(accepted()), SLOT(slotAccepted()));

    if(TT_GetUser(ttInst, TT_GetMyUserID(ttInst), &m_user))
    {
        switch(m_user.nStatusMode & STATUSMODE_MODE)
        {
        case STATUSMODE_AVAILABLE:
            ui.availBtn->setFocus();
            ui.availBtn->setChecked(true);
            break;
        case STATUSMODE_AWAY:
            ui.awayBtn->setFocus();
            ui.awayBtn->setChecked(true);
            break;
        case STATUSMODE_QUESTION :
            ui.questionBtn->setFocus();
            ui.questionBtn->setChecked(true);
            break;
        }
        ui.msgEdit->setText(_Q(m_user.szStatusMsg));
    }
}
示例#3
0
BOOL CPositionUsersDlg::OnInitDialog()
{
    CDialog::OnInitDialog();

    TRANSLATE(*this, IDD);

    users_t::const_iterator ite;
    int i=0;
    for(ite=m_users.begin();ite != m_users.end();ite++)
    {
        if(ite->first != TT_GetMyUserID(ttInst))
        {
            CUserButton* pBtn = new CUserButton();
            CRect rect;
            rect.left = 20;
            rect.right = rect.left + 35;
            rect.top = 20;
            rect.bottom = rect.top + 20;
            pBtn->Create( ite->second.szNickname, WS_CHILD|WS_VISIBLE|WS_TABSTOP, rect, this, 9001+i);  // give a unique ID (not strictly necessary)
            i++;
            pBtn->m_nBtnID = ite->second.nUserID;
            pBtn->SetFont(GetFont());

            m_mapUserBtn[ite->second.nUserID] = pBtn;
        }
    }

    PositionUsers();

    return TRUE;  // return TRUE unless you set the focus to a control
    // EXCEPTION: OCX Property Pages should return FALSE
}
示例#4
0
QString ChatTextEdit::addTextMessage(const TextMessage& msg)
{
    User user;
    if(!TT_GetUser(ttInst, msg.nFromUserID, &user))
        return QString();

    QString dt = getTimeStamp();
    QString line = dt;

    switch(msg.nMsgType)
    {
    case MSGTYPE_USER :
        line += QString("<%1> %2").arg(getDisplayName(user)).arg(_Q(msg.szMessage));
        break;
    case MSGTYPE_CHANNEL :
        if(msg.nChannelID != TT_GetMyChannelID(ttInst))
        {
            TTCHAR chpath[TT_STRLEN] = {};
            TT_GetChannelPath(ttInst, msg.nChannelID, chpath);
            line += QString("<%1->%2> %3").arg(getDisplayName(user))
                           .arg(_Q(chpath)).arg(_Q(msg.szMessage));
        }
        else
            line += QString("<%1> %2").arg(getDisplayName(user))
                           .arg(_Q(msg.szMessage));
        break;
    case MSGTYPE_BROADCAST :
        line += QString("<%1->BROADCAST> %2").arg(getDisplayName(user))
                       .arg(_Q(msg.szMessage));
        break;
    case MSGTYPE_CUSTOM : break;
    }

    if(TT_GetMyUserID(ttInst) == msg.nFromUserID)
    {
        QTextCharFormat format = textCursor().charFormat();
        QTextCharFormat original = format;
        format.setForeground(QBrush(Qt::darkGray));
        QTextCursor cursor = textCursor();
        cursor.setCharFormat(format);
        setTextCursor(cursor);
        appendPlainText(line);
        cursor.setCharFormat(original);
        setTextCursor(cursor);
    }
    else
        appendPlainText(line);
    limitText();

    return line;
}
void UserDesktopWidget::slotContextMenu(const QPoint& p)
{
    Q_UNUSED(p);

    //don't show context menu if we're currently using desktop access
    if(m_user.uPeerSubscriptions & SUBSCRIBE_DESKTOPINPUT)
        return;

    QMenu menu(this);
#ifndef USE_TT_PAINT
    QAction* save = menu.addAction(tr("&Save to Image File"));
#endif
    menu.addSeparator();

    QAction* access = NULL;
    if(m_access_requested)
        access = menu.addAction(tr("Retract &Desktop Access"));
    else
        access = menu.addAction(tr("Request &Desktop Access"));
    access->setIcon(QIcon(QString::fromUtf8(":/images/images/chalkstick.png")));
    QAction* result = menu.exec(QCursor::pos());
#ifndef USE_TT_PAINT
    if(result == save)
    {
        QString name = QFileDialog::getSaveFileName(this, tr("Save File"), 
                                                    "", tr("PNG files (*.png)"));
        if(name.size() && !m_image.save(name, "PNG"))
            QMessageBox::critical(this, tr("&Save to Image File"), tr("Failed to save file."));
    }
    else
#endif
    if(result == access)
    {
        TextMessage msg;
        ZERO_STRUCT(msg);
        msg.nFromUserID = TT_GetMyUserID(ttInst);
        msg.nMsgType = MSGTYPE_CUSTOM;
        msg.nToUserID = m_userid;
        m_access_requested = !m_access_requested;
        QString cmd = makeCustomCommand(TT_INTCMD_DESKTOP_ACCESS, 
                                        QString::number(m_access_requested));
        COPY_TTSTR(msg.szMessage, cmd);
        TT_DoTextMessage(ttInst, &msg);
    }
}
示例#6
0
void TextMessageDlg::slotSendMsg(const QString& txt_msg)
{
    if(txt_msg.isEmpty())
        return;

    TextMessage msg;
    ZERO_STRUCT(msg);
    msg.nFromUserID = TT_GetMyUserID(ttInst);
    msg.nChannelID = 0;
    msg.nMsgType = MSGTYPE_USER;
    msg.nToUserID = m_userid;
    COPY_TTSTR(msg.szMessage, txt_msg);
    if(TT_DoTextMessage(ttInst, &msg)>0)
    {
        ui.newmsgTextEdit->setPlainText("");
        newMsg(msg, true);
        emit(newMyselfTextMessage(msg));
        m_textchanged = false;
    }
}