Exemplo n.º 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;
    }
}
Exemplo n.º 2
0
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);
    }
}