Пример #1
0
void UserVideoWidget::completePaint(const QRect& r, QPainter& painter)
{
    if(m_showvidtext && m_vidtext != VIDEOTEXT_NONE)
    {
        User user;
        if(TT_GetUser(ttInst, m_userid & VIDEOTYPE_USERMASK, &user))
        {
            QString text = QString("User #%1").arg(m_userid & VIDEOTYPE_USERMASK);
            switch(m_vidtext & VIDTEXT_SHOW_MASK)
            {
            case VIDTEXT_SHOW_NICKNAME :
                text = _Q(user.szNickname);
                break;
            case VIDTEXT_SHOW_USERNAME :
                text = _Q(user.szUsername);
                break;
            case VIDTEXT_SHOW_STATUSTEXT :
                text = _Q(user.szStatusMsg);
                break;
            }
            setVideoTextBox(r, m_vidtext_bg, m_vidtext_fg, text, m_vidtext, 
                            m_vidtext_w_pct, m_vidtext_h_pct, painter);
        }
    }
}
void BlockLocalPositionEstimator::updateSSParams()
{
	// input noise covariance matrix
	_R.setZero();
	_R(U_ax, U_ax) = _accel_xy_stddev.get() * _accel_xy_stddev.get();
	_R(U_ay, U_ay) = _accel_xy_stddev.get() * _accel_xy_stddev.get();
	_R(U_az, U_az) = _accel_z_stddev.get() * _accel_z_stddev.get();

	// process noise power matrix
	_Q.setZero();
	float pn_p_sq = _pn_p_noise_density.get() * _pn_p_noise_density.get();
	float pn_v_sq = _pn_v_noise_density.get() * _pn_v_noise_density.get();
	_Q(X_x, X_x) = pn_p_sq;
	_Q(X_y, X_y) = pn_p_sq;
	_Q(X_z, X_z) = pn_p_sq;
	_Q(X_vx, X_vx) = pn_v_sq;
	_Q(X_vy, X_vy) = pn_v_sq;
	_Q(X_vz, X_vz) = pn_v_sq;

	// technically, the noise is in the body frame,
	// but the components are all the same, so
	// ignoring for now
	float pn_b_sq = _pn_b_noise_density.get() * _pn_b_noise_density.get();
	_Q(X_bx, X_bx) = pn_b_sq;
	_Q(X_by, X_by) = pn_b_sq;
	_Q(X_bz, X_bz) = pn_b_sq;

	// terrain random walk noise
	float pn_t_sq = _pn_t_noise_density.get() * _pn_t_noise_density.get();
	_Q(X_tz, X_tz) = pn_t_sq;
}
Пример #3
0
void ChatTextEdit::updateServer(const ServerProperties& srvprop)
{
    appendPlainText("");

    QString dt = getTimeStamp();
    
    QTextCharFormat format = textCursor().charFormat();
    QTextCharFormat original = format;
    QTextCursor cursor = textCursor();
    
    //show 'joined new channel' in bold
    QFont font = format.font();
    font.setBold(true);
    format.setFont(font);
    cursor.setCharFormat(format);
    QString line = dt + tr("Server Name: %1").arg(_Q(srvprop.szServerName));;
    setTextCursor(cursor);
    appendPlainText(line);

    line = dt + tr("Message of the Day: %1").arg(_Q(srvprop.szMOTD)) + "\r\n";
    format.setForeground(QBrush(Qt::darkCyan));
    cursor.setCharFormat(format);
    setTextCursor(cursor);
    appendPlainText(line);

    //revert bold
    font.setBold(false);
    format.setFont(font);

    //revert to original
    cursor.setCharFormat(original);
    setTextCursor(cursor);
    limitText();
}
void BlockLocalPositionEstimator::updateSSParams()
{
	// input noise covariance matrix
	_R.setZero();
	_R(U_ax, U_ax) = _accel_xy_stddev.get() * _accel_xy_stddev.get();
	_R(U_ay, U_ay) = _accel_xy_stddev.get() * _accel_xy_stddev.get();
	_R(U_az, U_az) = _accel_z_stddev.get() * _accel_z_stddev.get();

	// process noise power matrix
	_Q.setZero();
	float pn_p_sq = _pn_p_noise_density.get() * _pn_p_noise_density.get();
	float pn_v_sq = _pn_v_noise_density.get() * _pn_v_noise_density.get();
	_Q(X_x, X_x) = pn_p_sq;
	_Q(X_y, X_y) = pn_p_sq;
	_Q(X_z, X_z) = pn_p_sq;
	_Q(X_vx, X_vx) = pn_v_sq;
	_Q(X_vy, X_vy) = pn_v_sq;
	_Q(X_vz, X_vz) = pn_v_sq;

	// technically, the noise is in the body frame,
	// but the components are all the same, so
	// ignoring for now
	float pn_b_sq = _pn_b_noise_density.get() * _pn_b_noise_density.get();
	_Q(X_bx, X_bx) = pn_b_sq;
	_Q(X_by, X_by) = pn_b_sq;
	_Q(X_bz, X_bz) = pn_b_sq;

	// terrain random walk noise ((m/s)/sqrt(hz)), scales with velocity
	float pn_t_noise_density =
		_pn_t_noise_density.get() +
		(_t_max_grade.get() / 100.0f) * sqrtf(_x(X_vx) * _x(X_vx) + _x(X_vy) * _x(X_vy));
	_Q(X_tz, X_tz) = pn_t_noise_density * pn_t_noise_density;
}
Пример #5
0
QVariant OnlineUsersModel::data(const QModelIndex& index, int role) const
{
    user_cache_t::const_iterator ii = m_users.find(index.internalId());
    Q_ASSERT(ii != m_users.end());
    if(ii == m_users.end())
        return QVariant();

    const User& user = ii.value();
    TTCHAR channel[TT_STRLEN] = {0};

    switch(role)
    {
    case Qt::DisplayRole :
        switch(index.column())
        {
        case COLUMN_USERID :
            return user.nUserID;
        case COLUMN_NICKNAME :
            return _Q(user.szNickname);
        case COLUMN_STATUSMSG :
            return _Q(user.szStatusMsg);
        case COLUMN_USERNAME :
            return _Q(user.szUsername);
        case COLUMN_CHANNEL :
            TT_GetChannelPath(ttInst, user.nChannelID, channel);
            return _Q(channel);
        case COLUMN_IPADDRESS :
            return _Q(user.szIPAddress);
        case COLUMN_VERSION :
            return getVersion(user);
        }
        break;
    }
    return QVariant();
}
Пример #6
0
void ChatTextEdit::joinedChannel(int channelid)
{
    TTCHAR buff[TT_STRLEN];
    Channel chan;
    if(!TT_GetChannel(ttInst, channelid, &chan))
        return;
    if(!TT_GetChannelPath(ttInst, channelid, buff))
        return;

    appendPlainText("");

    QString dt = getTimeStamp();
    
    QTextCharFormat format = textCursor().charFormat();
    QTextCharFormat original = format;
    QTextCursor cursor = textCursor();
    
    //show 'joined new channel' in bold
    QFont font = format.font();
    font.setBold(true);
    format.setFont(font);
    cursor.setCharFormat(format);
    QString line = dt + tr("Joined new channel");
    setTextCursor(cursor);
    appendPlainText(line);
    //revert bold
    font.setBold(false);
    format.setFont(font);
    
    //show channel name in green
    line = tr("Channel: %1").arg(_Q(buff));
    format.setForeground(QBrush(Qt::darkGreen));
    cursor.setCharFormat(format);
    setTextCursor(cursor);
    appendPlainText(line);

    //show topic in blue
    line = tr("Topic: %1").arg(_Q(chan.szTopic));
    format.setForeground(QBrush(Qt::darkBlue));
    cursor.setCharFormat(format);
    setTextCursor(cursor);
    appendPlainText(line);

    //show disk quota in red
    line = tr("Disk quota: %1 KBytes").arg(chan.nDiskQuota/1024);
    format.setForeground(QBrush(Qt::darkRed));
    cursor.setCharFormat(format);
    setTextCursor(cursor);
    appendPlainText(line);

    //revert to original
    cursor.setCharFormat(original);
    setTextCursor(cursor);
    limitText();
}
Пример #7
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;
}
Пример #8
0
// ----------------------------------------------------------------------------
std::string toSQL(const ProdInfo & pi) {
    std::ostringstream oss2;
    for (size_t i = 0; i < pi.categories.size(); ++i) {
        oss2 << pi.categories[i] << ";";
    }

    std::ostringstream oss;
    // INSERT INTO Product (ID, Description, Category, Title) VALUES (3, "Diet Coke bottle", "Trash", "Bottle");
    oss << "INSERT INTO `Product` (`ID`, `Description`, `Category`, `Title`) VALUES ("
        << pi.id << ", " << _Q(pi.description) << ", " << _Q(oss2.str())
        << ", " << _Q(pi.title) << ");"
        ;

    return oss.str();
}
Пример #9
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));
    }
}
Пример #10
0
UserVolumeDlg::UserVolumeDlg(int userid, QWidget * parent/* = 0*/)
: QDialog(parent, QT_DEFAULT_DIALOG_HINTS)
, m_userid(userid)
{
    ui.setupUi(this);
    setWindowIcon(QIcon(APPICON));

    ui.voicevolSlider->setRange(0, 100);
    ui.mfvolSlider->setRange(0, 100);

    connect(ui.voicevolSlider, SIGNAL(valueChanged(int)),
            SLOT(slotVolumeChanged(int)));
    connect(ui.voiceleftChkBox, SIGNAL(clicked()), SLOT(slotMuteChannel()));
    connect(ui.voicerightChkBox, SIGNAL(clicked()), SLOT(slotMuteChannel()));

    connect(ui.mfvolSlider, SIGNAL(valueChanged(int)),
            SLOT(slotVolumeChanged(int)));
    connect(ui.mfleftChkBox, SIGNAL(clicked()), SLOT(slotMuteChannel()));
    connect(ui.mfrightChkBox, SIGNAL(clicked()), SLOT(slotMuteChannel()));
    connect(ui.defaultsButton, SIGNAL(clicked()), SLOT(slotDefaults()));

    User user;
    if(TT_GetUser(ttInst, m_userid, &user))
        setWindowTitle(windowTitle() + QString(" - ") + _Q(user.szNickname));
    ui.voicevolSlider->setValue(refVolumeToPercent(user.nVolumeVoice));
    ui.mfvolSlider->setValue(refVolumeToPercent(user.nVolumeMediaFile));

    ui.voiceleftChkBox->setChecked(!user.stereoPlaybackVoice[0]);
    ui.voicerightChkBox->setChecked(!user.stereoPlaybackVoice[1]);
    ui.mfleftChkBox->setChecked(!user.stereoPlaybackMediaFile[0]);
    ui.mfrightChkBox->setChecked(!user.stereoPlaybackMediaFile[1]);
}
Пример #11
0
AboutDlg::AboutDlg(QWidget* parent)
: QDialog(parent, QT_DEFAULT_DIALOG_HINTS)
{
    ui.setupUi(this);
    setWindowIcon(QIcon(APPICON));

    QString compile = "Compiled on " __DATE__ " " __TIME__ ".\r\n"
                      "Version " TEAMTALK_VERSION ".\r\n";
    if(sizeof(void*) == 8)
        compile += QString("TeamTalk 64-bit DLL version %1.").arg(_Q(TT_GetVersion()));
    else
        compile += QString("TeamTalk 32-bit DLL version %1.").arg(_Q(TT_GetVersion()));
    ui.compileLabel->setText(compile);
    ui.versionLabel->setText(APPVERSION);
    ui.iconLabel->setPixmap(QPixmap(APPICON));
}
Пример #12
0
void UserVideoWidget::slotUpdateVideoTextBox()
{
    m_showvidtext = ttSettings->value(SETTINGS_DISPLAY_VIDEOTEXT_SHOW, false).toBool();

    if(m_showvidtext)
        m_nickname.clear();
    else
    {
        User user;
        if(TT_GetUser(ttInst, m_userid & VIDEOTYPE_USERMASK, &user))
            m_nickname = _Q(user.szNickname);
    }

    m_vidtext = ttSettings->value(SETTINGS_DISPLAY_VIDEOTEXT,
                                  SETTINGS_DISPLAY_VIDEOTEXT_DEFAULT).toUInt();
        
    m_vidtext_w_pct = ttSettings->value(SETTINGS_DISPLAY_VIDEOTEXT_WIDTH,
                                        SETTINGS_DISPLAY_VIDEOTEXT_WIDTH_DEFAULT).toInt();
    m_vidtext_h_pct = ttSettings->value(SETTINGS_DISPLAY_VIDEOTEXT_HEIGHT,
                                        SETTINGS_DISPLAY_VIDEOTEXT_HEIGHT_DEFAULT).toInt();

    m_vidtext_bg = ttSettings->value(SETTINGS_DISPLAY_VIDEOTEXT_BGCOLOR,
                                     SETTINGS_DISPLAY_VIDEOTEXT_BGCOLOR_DEFAULT)
                                     .value<QColor>();
    m_vidtext_fg = ttSettings->value(SETTINGS_DISPLAY_VIDEOTEXT_FGCOLOR,
                                     SETTINGS_DISPLAY_VIDEOTEXT_FGCOLOR_DEFAULT)
                                     .value<QColor>();
    update();
}
Пример #13
0
static long double _jn(int n, double * x)
{
    long double   Sum;
    long double   Fact;
    long double   y;
    register int  i;
    double        xx;
    long double   Xi;
    int           My;

    if ( n < 0 )
        return n & 1 ? _jn(-n, x) : -_jn(-n, x);

    if ((x[0] >= 17.7+0.0144*(n*n))) {
        Xi = x[0] - M_PI * (n*0.5 + 0.25);
        My = n*n << 2;

        return sqrt(M_2_PI / x[0]) * (_P(My, x) * cos(Xi) - _Q(My,x) * sin(Xi));
    }
    xx   = x[0] * 0.5;
    Sum  = 0.;
    Fact = 1.;
    y    = -xx * xx;

    for ( i = 1; i <= n; i++ )
        Fact *= xx/i;
    for ( i = 1; ; i++ ) {
        Sum  += Fact;
        Fact *= y / (i*(n+i));
        if ( EXPL (Sum) - EXPL(Fact) > 53 || !EXPL(Fact) )
            break;
    }
    return Sum;
}
Пример #14
0
void UserVideoDlg::slotUserUpdate(const User& user)
{
    if(user.nUserID != uservideoWidget->getUserID())
        return;

    if(user.nUserID == 0)
        setWindowTitle(tr("Video") + QString(" - ") + tr("Myself"));
    else
        setWindowTitle(tr("Video") + QString(" - ") + _Q(user.szNickname));
}
Пример #15
0
void UserDesktopDlg::slotUserUpdate(const User& user)
{
    if(user.nUserID != ui.userdesktopWidget->getUserID())
        return;

    if(user.nUserID == 0)
        setWindowTitle(tr("Desktop") + QString(" - ") + tr("Myself"));
    else
        setWindowTitle(tr("Desktop") + QString(" - ") + _Q(user.szNickname));
}
Пример #16
0
static long double  _yn ( int n, double* x )
{
    long double   Sum1;
    long double   Sum2;
    long double   Fact1;
    long double   Fact2;
    long double   F1;
    long double   F2;
    long double   y;
    register int  i;
    double        xx;
    long double   Xi;
    unsigned int  My;

    if ( EXPD (x[0]) == 0 )
        return -1./0.;	/* ignore the gcc warning, this is intentional */

    if ( (x[0] >= (n>=32 ? 25.8 : (n<8 ? 17.4+0.1*n : 16.2+0.3*n))) ) {
        Xi = x[0] - M_PI * (n*0.5+0.25);
        My = n*n << 2;

        return sqrt(M_2_PI / x[0]) * (_P(My,x) * sin(Xi) + _Q(My,x) * cos(Xi));
    }

    Sum1  = Sum2 = F1 = F2 = 0;
    Fact1 = 1. / (xx = x[0] * 0.5 );
    Fact2 = 1.;
    y     = xx*xx;

    for ( i = 1; i < n; i++ )
        Fact1 *= (n-i) / xx;

    for ( i = 1; i <= n; i++ ) {
        Sum1  += Fact1;
        if ( i == n )
            break;
        Fact1 *= y/(i*(n-i));
    }

    for (i=1; i<=n; i++) {
        Fact2 *= xx / i;
        F1    += 1. / i;
    }

    for ( i = 1; ; i++ ) {
        Sum2  += Fact2 * (F1+F2);
        Fact2 *= -y / (i*(n+i));
        if ( EXPL (Sum2) - EXPL (Fact2) > 53 || !EXPL (Fact2) )
            break;
        F1 += 1. / (n+i);
        F2 += 1. / i;
    }

    return M_1_PI * (2. * (M_C + log(xx)) * _jn (n, x) - Sum1 - Sum2);
}
Пример #17
0
void FileTransferDlg::updateFileTransfer(const FileTransfer& transfer)
{
    if(m_localfilename.isEmpty())
        m_localfilename = _Q(transfer.szLocalFilePath);

    setWindowTitle(_Q(transfer.szRemoteFileName));
    ui.filenameLabel->setText(_Q(transfer.szRemoteFileName));
    if(transfer.nFileSize>=1024)
        ui.filesizeLabel->setText(QString("%1 KBytes")
                                    .arg(transfer.nFileSize/1024));
    else
        ui.filesizeLabel->setText(QString("%1 Bytes").arg(transfer.nFileSize));
    double percent = 100.0;
    if(transfer.nFileSize)
        percent = transfer.nTransferred * 100 / transfer.nFileSize;
    ui.transferredLabel->setText(QString("%1/%2 - %3 %")
        .arg(transfer.nTransferred).arg(transfer.nFileSize).arg(percent));

    ui.progressBar->setValue((int)percent);

    int diff = transfer.nTransferred - m_lastTransferred;
    m_lastTransferred = transfer.nTransferred;

    double elapsed = m_start.secsTo(QTime::currentTime());
    double throughput = 0.0;
    if(elapsed)
    {
        throughput = transfer.nTransferred / elapsed;
        throughput /= 1024.0;
    }
    ui.throughputLabel->setText(tr("%1 KBytes/second, last second %2 bytes")
                                .arg(throughput).arg(diff));

    if(transfer.bInbound)
        ui.destinationLabel->setText(_Q(transfer.szLocalFilePath));
    else
    {
        TTCHAR chanpath[TT_STRLEN] = {0};
        TT_GetChannelPath(ttInst, transfer.nChannelID, chanpath);
        ui.destinationLabel->setText(_Q(chanpath));
    }
}
Пример #18
0
Glib::ustring __Q(const char* fmt)
{
	try
	{
		return Glib::ustring::compose(_Q(fmt) + "%1", Format_aux::correct_glib_format_value(""));
	}
	catch(Glib::ConvertError&)
	{
		return _("[[Invalid encoding]]");
	}
}
Пример #19
0
bool getSoundDevice(const QString& devid, const QVector<SoundDevice>& devs,
                    SoundDevice& dev)
{
    if(devid.isEmpty())
        return false;

    for(int i=0;i<devs.size();i++)
        if(_Q(devs[i].szDeviceID) == devid)
        {
            dev = devs[i];
            return true;
        }
    return false;
}
Пример #20
0
bool initVideoCapture(const QString& devid, const VideoFormat& fmt)
{
    QString use_devid = devid;
    if(use_devid.isEmpty())
    {
        int count = 1;
        QVector<VideoCaptureDevice> devs(1);
        TT_GetVideoCaptureDevices(&devs[0], &count);
        if(count)
            use_devid = _Q(devs[0].szDeviceID);
    }

    return TT_InitVideoCaptureDevice(ttInst, _W(use_devid), &fmt);
}
Пример #21
0
UserVideoWidget::UserVideoWidget(QWidget * parent, int userid,
                                 int border_width)
  : UserImageWidget(parent, userid, true, border_width)
  , m_novideo_count(0)
  , m_showvidtext(false)
{
    Q_ASSERT(userid & VIDEOTYPE_MASK);

    slotUpdateVideoTextBox();
    startTimer(1000);

    User user;
    TT_GetUser(ttInst, m_userid & VIDEOTYPE_USERMASK, &user);

    if(userid & VIDEOTYPE_CAPTURE)
    {
        if((userid & VIDEOTYPE_USERMASK) == 0)
            m_textmsg = tr("Waiting for local video");
        else
            m_textmsg = tr("Waiting for video from %1").arg(_Q(user.szNickname));
    }

    if(userid & VIDEOTYPE_MEDIAFILE)
        m_textmsg = tr("Waiting for media file from %1").arg(_Q(user.szNickname));

    m_video_frame = acquireVideo();

#if !defined(USE_TT_PAINT) && !USE_VIDEO_SHAREDMEM_ZEROCOPY
    if(m_video_frame)
    {
        m_image = QImage(m_video_frame->nWidth, m_video_frame->nHeight,
                         QImage::Format_RGB32);
        if(m_mirrored)
            m_image = m_image.mirrored(true, true);
    }
#endif
}
Пример #22
0
QString getHotKeyText(const hotkey_t& hotkey)
{
#ifdef Q_OS_WIN32
    QString key;
    for(int i=0;i<hotkey.size();i++)
    {
        TTCHAR buff[TT_STRLEN] = {0};
        TT_HotKey_GetKeyString(ttInst, hotkey[i], buff);
        key += (i == hotkey.size()-1)? _Q(buff):_Q(buff) + " + ";
    }
    return key;
#elif defined(Q_OS_LINUX)
    Q_UNUSED(ttInst);
    int keys[4] = {0, 0, 0, 0};
    for(int i=0;i<hotkey.size();i++)
        keys[i] = hotkey[i];
        
    QKeySequence keyseq(keys[0], keys[1], keys[2], keys[3]);
    return keyseq.toString();
#elif defined(Q_OS_DARWIN)
    Q_UNUSED(ttInst);
    /*
    QString key;
    if(hotkey.size())
        key = QString::number(hotkey[0]);

    for(int i=1;i<hotkey.size();i++)
        key += " + " + QString::number(hotkey[i]);

    return key;
    */
    return GetMacOSHotKeyText(hotkey);
#else
    return QString("Unknown");
#endif

}
Пример #23
0
QVariant BannedUsersModel::data ( const QModelIndex & index, int role /*= Qt::DisplayRole */) const
{
    Q_ASSERT(index.isValid());
    switch(role)
    {
    case Qt::DisplayRole :
        Q_ASSERT(index.row() < m_users.size());
        switch(index.column())
        {
        case COLUMN_INDEX_NICKNAME :
            return _Q(m_users[index.row()].szNickname);
        case COLUMN_INDEX_USERNAME :
            return _Q(m_users[index.row()].szUsername);
        case COLUMN_INDEX_BANTIME :
            return _Q(m_users[index.row()].szBanTime);
        case COLUMN_INDEX_CHANPATH :
            return _Q(m_users[index.row()].szChannelPath);
        case COLUMN_INDEX_IPADDRESS : 
            return _Q(m_users[index.row()].szIPAddress);
        }
        break;
    }
    return QVariant();
}
Пример #24
0
void TextMessageDlg::newMsg(const TextMessage& msg, bool store)
{
    switch(msg.nMsgType)
    {
    case MSGTYPE_USER :
    {
        QString line = ui.historyTextEdit->addTextMessage(msg);
        ui.newmsgLabel->setText(tr("New message"));

        QString folder = ttSettings->value(SETTINGS_MEDIASTORAGE_USERLOGFOLDER).toString();
        if(store && folder.size())
        {
            User user;
            if(TT_GetUser(ttInst, m_userid, &user))
            {
                if(!m_logFile.isOpen())
                    openLogFile(m_logFile, folder, _Q(user.szNickname));
            }
            writeLogEntry(m_logFile, line);
        }
    }
    break;
    case MSGTYPE_CUSTOM :
    {
        QStringList cmd_msg = getCustomCommand(msg);
        if(cmd_msg.size() >= 2 && cmd_msg[0] == TT_INTCMD_TYPING_TEXT)
        {
            if(cmd_msg[1] == "1")
            {
                ui.newmsgLabel->setText(tr("New message - remote user typing."));
                if(m_remote_typing_id)
                    killTimer(m_remote_typing_id);
                m_remote_typing_id = startTimer(REMOTE_TYPING_DELAY);
            }
            else
            {
                if(m_remote_typing_id)
                    killTimer(m_remote_typing_id);
                m_remote_typing_id = 0;
                ui.newmsgLabel->setText(tr("New message"));
            }
        }
        break;
    }
    default :
        break;
    }
}
Пример #25
0
std::tuple<Eigen::MatrixXf, Eigen::VectorXf> dart::QWeightedError::computeGNParam(const Eigen::VectorXf &diff) {
    // compute error from joint deviation
    const float e = diff.transpose()*_Q*diff;

    Eigen::MatrixXf deriv = Eigen::MatrixXf::Zero(diff.size(), 1);

    for(unsigned int i=0; i<diff.size(); i++) {
        // original derivation
        //deriv(i) = diff.dot(_Q.row(i)) + diff.dot(_Q.col(i)) - (diff[i]*_Q(i,i));
        // negative direction, this works
        //deriv(i) = - diff.dot(_Q.row(i)) + diff.dot(_Q.col(i)) - (diff[i]*_Q(i,i));
        deriv(i) = - ( diff.dot(_Q.row(i) + _Q.col(i).transpose()) - (diff[i]*_Q(i,i)) );
    }

    // Jacobian of error, e.g. the partial derivation of the error w.r.t. to each joint value
    // For an error of zero, its partial derivative is not defined. Therefore we set its derivative to 0.
    const Eigen::MatrixXf J = (diff.array()==0).select(0, deriv);

    const Eigen::VectorXf JTe = J.array()*e;

    return std::make_tuple(J, JTe);
}
Пример #26
0
void
GBEvolutionAniso::computeQpProperties()
{
  RealTensorValue M0 = _GBmob0;
  Real JtoeV = 6.24150974e18;// joule to eV conversion  for (unsigned i(0); i < _dim; ++i)


  M0 *= _time_scale/(JtoeV*(_length_scale*_length_scale*_length_scale*_length_scale));//Convert to lengthscale^4/(eV*timescale);

  _sigma[_qp] = _GBenergy*JtoeV*(_length_scale*_length_scale);// eV/nm^2
  
  if (_GBmob0_exi)
  {
    
    for (unsigned i(0); i <= _dim; ++i)
    {
      for (unsigned j(0); j <= _dim; ++j)
      {
          _M_GB[_qp](i,j) = M0(i,j)*std::exp(-_Q(i,j)/(_kb*_T[_qp]));
      }
    }
  }
  else
    _M_GB[_qp] = M0; //Convert to lengthscale^4/(eV*timescale) alread done in line 65

  _l_GB[_qp] = _wGB; //in the length scale of the system
  _L[_qp] = 4.0/3.0*_M_GB[_qp]/_l_GB[_qp];
  _kappa[_qp] = 3.0/4.0*_sigma[_qp]*_l_GB[_qp];
  _gamma[_qp] = 1.5;
  _mu[_qp] = 3.0/4.0*1/_f0s*_sigma[_qp]/_l_GB[_qp];
  _entropy_diff[_qp] = 8.0e3*JtoeV; //J/(K mol) converted to eV(K mol)
  _molar_volume[_qp] = _molar_vol/(_length_scale*_length_scale*_length_scale); //m^3/mol converted to ls^3/mol
  _act_wGB[_qp] = 0.5e-9/_length_scale;
  _tgrad_corr_mult[_qp] = _mu[_qp]*9.0/8.0;

}
Пример #27
0
void TextMessageDlg::slotUpdateUser(const User& user)
{
    if(user.nUserID == m_userid)
        this->setWindowTitle(tr("Messages") + " - " + _Q(user.szNickname));
}
Пример #28
0
Main_window::Main_window(const Main_window_settings& settings)
:
	m::gtk::Window("", settings.window, 800, 600, 0),
	gui(new Gui)
{
	Client_settings& client_settings = get_client_settings();
	Main_window_settings& main_window_settings = client_settings.gui.main_window;

	// Заголовок окна -->
		this->gui->orig_window_title = APP_NAME;

		if(get_application().get_config_dir_path() != get_default_config_dir_path())
			this->gui->orig_window_title = " (" + get_application().get_config_dir_path() + ")";

		Gtk::Window::set_title(this->gui->orig_window_title);
	// Заголовок окна <--

	// Трей
	show_tray_icon(client_settings.gui.show_tray_icon);

	// Меню -->
		this->gui->ui_manager = Gtk::UIManager::create();
		Glib::RefPtr<Gtk::ActionGroup> action_group = Gtk::ActionGroup::create();


		action_group->add(
			app_icons::create_action("app", app_icons::ICON_APP, APP_NAME),
			sigc::mem_fun(*this, &Main_window::on_tray_activated)
		);


		action_group->add(Gtk::Action::create("file", _("_File")));
		action_group->add(
			Gtk::Action::create("create", Gtk::Stock::NEW, _("_Create")),
			sigc::mem_fun(*this, &Main_window::on_create_callback)
		);
		action_group->add(
			Gtk::Action::create("open", Gtk::Stock::OPEN, _("_Open a torrent")),
			sigc::mem_fun(*this, &Main_window::on_open_callback)
		);
		action_group->add(
			Gtk::Action::create("open_magnet", Gtk::Stock::JUMP_TO, _("_Open a magnet link")),
			sigc::mem_fun(*this, &Main_window::on_open_magnet_callback)
		);
		action_group->add(
			Gtk::Action::create("quit", Gtk::Stock::QUIT, _("_Quit")),
			sigc::mem_fun(get_application(), &Application::close
		));


		action_group->add(Gtk::Action::create("edit", _("_Edit")));
		action_group->add(
			app_icons::create_action("statistics", app_icons::ICON_STATISTICS, _("_Statistics")),
			sigc::mem_fun(*this, &Main_window::on_show_statistics_callback)
		);
		action_group->add(
			Gtk::Action::create("preferences", Gtk::Stock::PREFERENCES, _("_Preferences")),
			sigc::mem_fun(*this, &Main_window::on_show_settings_window_callback)
		);


		action_group->add(Gtk::Action::create("view", _("_View")));

		// Toolbar -->
			action_group->add(Gtk::Action::create("toolbar", _("_Toolbar")));

			this->gui->menu_show_toolbar_action = Gtk::ToggleAction::create(
				"toolbar/show", _Q("'Show ...' toggle|_Show"), "",
				get_client_settings().gui.show_toolbar
			);
			action_group->add(
				this->gui->menu_show_toolbar_action,
				sigc::mem_fun(*this, &Main_window::on_show_toolbar_toggled_callback)
			);

			// Стиль панели инструментов -->
			{
				Gtk::RadioButtonGroup radio_group;
				std::map< m::gtk::toolbar::Style, Glib::RefPtr<Gtk::RadioAction> > toolbar_style_buttons;

				action_group->add(Gtk::Action::create("toolbar/style", _("Toolbar _style")));

				action_group->add(
					toolbar_style_buttons[m::gtk::toolbar::DEFAULT] = Gtk::RadioAction::create(
						radio_group, "toolbar/style/default", _("_Desktop default")
					),
					sigc::bind<m::gtk::toolbar::Style>(
						sigc::mem_fun(*this, &Main_window::change_toolbar_style),
						m::gtk::toolbar::DEFAULT
					)
				);

				action_group->add(
					toolbar_style_buttons[m::gtk::toolbar::ICONS] = Gtk::RadioAction::create(
						radio_group, "toolbar/style/icons", _("_Icons")
					),
					sigc::bind<m::gtk::toolbar::Style>(
						sigc::mem_fun(*this, &Main_window::change_toolbar_style),
						m::gtk::toolbar::ICONS
					)
				);

				action_group->add(
					toolbar_style_buttons[m::gtk::toolbar::TEXT] = Gtk::RadioAction::create(
						radio_group, "toolbar/style/text", _("_Text")
					),
					sigc::bind<m::gtk::toolbar::Style>(
						sigc::mem_fun(*this, &Main_window::change_toolbar_style),
						m::gtk::toolbar::TEXT
					)
				);

				action_group->add(
					toolbar_style_buttons[m::gtk::toolbar::BOTH] = Gtk::RadioAction::create(
						radio_group, "toolbar/style/both", _("_Both")
					),
					sigc::bind<m::gtk::toolbar::Style>(
						sigc::mem_fun(*this, &Main_window::change_toolbar_style),
						m::gtk::toolbar::BOTH
					)
				);

				action_group->add(
					toolbar_style_buttons[m::gtk::toolbar::BOTH_HORIZ] = Gtk::RadioAction::create(
						radio_group, "toolbar/style/both_horiz", _("Both _horizontal")
					),
					sigc::bind<m::gtk::toolbar::Style>(
						sigc::mem_fun(*this, &Main_window::change_toolbar_style),
						m::gtk::toolbar::BOTH_HORIZ
					)
				);

				toolbar_style_buttons[get_client_settings().gui.toolbar_style]->set_active();
			}
			// Стиль панели инструментов <--
		// Toolbar <--

		// Categories <--
		{
			Glib::RefPtr<Gtk::ToggleAction> action;

			action_group->add(Gtk::Action::create("categories", _("_Categories")));

			action = Gtk::ToggleAction::create(
				"categories/show", _Q("'Show ...' toggle|_Show"), "",
				get_client_settings().gui.main_window.torrents_viewport.categories_view->visible
			);
			action_group->add(
				action,
				sigc::bind< Glib::RefPtr<Gtk::ToggleAction> >(
					sigc::mem_fun(*this->gui, &Main_window::Gui::on_show_categories_toggle_cb), action)
			);

			action = Gtk::ToggleAction::create(
				"categories/show_names", _("Show _names"), "",
				get_client_settings().gui.main_window.torrents_viewport.categories_view->show_names
			);
			action_group->add(
				action,
				sigc::bind< Glib::RefPtr<Gtk::ToggleAction> >(
					sigc::mem_fun(*this->gui, &Main_window::Gui::on_show_categories_names_toggle_cb), action)
			);

			action = Gtk::ToggleAction::create(
				"categories/show_counters", _("Show _counters"), "",
				get_client_settings().gui.main_window.torrents_viewport.categories_view->show_counters
			);
			action_group->add(
				action,
				sigc::bind< Glib::RefPtr<Gtk::ToggleAction> >(
					sigc::mem_fun(*this->gui, &Main_window::Gui::on_show_categories_counters_toggle_cb), action)
			);
		}
		// Categories <--

		// Torrents -->
			action_group->add(Gtk::Action::create("torrents", _("_Torrents")));


			action_group->add(Gtk::Action::create("resume", Gtk::Stock::MEDIA_PLAY, _("_Resume")));
			action_group->add(
				app_icons::create_action("resume/all", app_icons::ICON_DOWNLOAD_AND_UPLOAD, _("_All")),
				sigc::bind<Torrents_group>(
					sigc::mem_fun(*this, &Main_window::on_resume_torrents_callback),
					ALL
				)
			);
			action_group->add(
				app_icons::create_action("resume/downloads", app_icons::ICON_DOWNLOAD, _("_Downloads")),
				sigc::bind<Torrents_group>(
					sigc::mem_fun(*this, &Main_window::on_resume_torrents_callback),
					DOWNLOADS
				)
			);
			action_group->add(
				app_icons::create_action("resume/uploads", app_icons::ICON_UPLOAD, _("_Uploads")),
				sigc::bind<Torrents_group>(
					sigc::mem_fun(*this, &Main_window::on_resume_torrents_callback),
					UPLOADS
				)
			);


			action_group->add(Gtk::Action::create("pause", Gtk::Stock::MEDIA_PAUSE, _("_Pause")));
			action_group->add(
				app_icons::create_action("pause/all", app_icons::ICON_DOWNLOAD_AND_UPLOAD, _("_All")),
				sigc::bind<Torrents_group>(
					sigc::mem_fun(*this, &Main_window::on_pause_torrents_callback),
					ALL
				)
			);
			action_group->add(
				app_icons::create_action("pause/downloads", app_icons::ICON_DOWNLOAD, _("_Downloads")),
				sigc::bind<Torrents_group>(
					sigc::mem_fun(*this, &Main_window::on_pause_torrents_callback),
					DOWNLOADS
				)
			);
			action_group->add(
				app_icons::create_action("pause/uploads", app_icons::ICON_UPLOAD, _("_Uploads")),
				sigc::bind<Torrents_group>(
					sigc::mem_fun(*this, &Main_window::on_pause_torrents_callback),
					UPLOADS
				)
			);


			// Temporary -->
				gui->resume_temporary = Gtk::Action::create(
					"resume_temporary", Gtk::Stock::MEDIA_PLAY, _("R_esume temporary"));
				action_group->add(gui->resume_temporary);

				action_group->add(
					app_icons::create_action("resume_temporary/all", app_icons::ICON_DOWNLOAD_AND_UPLOAD, _("_All")),
					sigc::bind< std::pair<Temporary_action,Torrents_group> >(
						sigc::mem_fun(*this, &Main_window::on_temporary_process_torrents_cb),
						std::pair<Temporary_action,Torrents_group>( TEMPORARY_ACTION_RESUME, ALL )
					)
				);
				action_group->add(
					app_icons::create_action("resume_temporary/downloads", app_icons::ICON_DOWNLOAD, _("_Downloads")),
					sigc::bind< std::pair<Temporary_action,Torrents_group> >(
						sigc::mem_fun(*this, &Main_window::on_temporary_process_torrents_cb),
						std::pair<Temporary_action,Torrents_group>( TEMPORARY_ACTION_RESUME, DOWNLOADS )
					)
				);
				action_group->add(
					app_icons::create_action("resume_temporary/uploads", app_icons::ICON_UPLOAD, _("_Uploads")),
					sigc::bind< std::pair<Temporary_action,Torrents_group> >(
						sigc::mem_fun(*this, &Main_window::on_temporary_process_torrents_cb),
						std::pair<Temporary_action,Torrents_group>( TEMPORARY_ACTION_RESUME, UPLOADS )
					)
				);


				gui->pause_temporary = Gtk::Action::create(
					"pause_temporary", Gtk::Stock::MEDIA_PAUSE, _("P_ause temporary"));
				action_group->add(gui->pause_temporary);

				action_group->add(
					app_icons::create_action("pause_temporary/all", app_icons::ICON_DOWNLOAD_AND_UPLOAD, _("_All")),
					sigc::bind< std::pair<Temporary_action,Torrents_group> >(
						sigc::mem_fun(*this, &Main_window::on_temporary_process_torrents_cb),
						std::pair<Temporary_action,Torrents_group>( TEMPORARY_ACTION_PAUSE, ALL )
					)
				);
				action_group->add(
					app_icons::create_action("pause_temporary/downloads", app_icons::ICON_DOWNLOAD, _("_Downloads")),
					sigc::bind< std::pair<Temporary_action,Torrents_group> >(
						sigc::mem_fun(*this, &Main_window::on_temporary_process_torrents_cb),
						std::pair<Temporary_action,Torrents_group>( TEMPORARY_ACTION_PAUSE, DOWNLOADS )
					)
				);
				action_group->add(
					app_icons::create_action("pause_temporary/uploads", app_icons::ICON_UPLOAD, _("_Uploads")),
					sigc::bind< std::pair<Temporary_action,Torrents_group> >(
						sigc::mem_fun(*this, &Main_window::on_temporary_process_torrents_cb),
						std::pair<Temporary_action,Torrents_group>( TEMPORARY_ACTION_PAUSE, UPLOADS )
					)
				);

				gui->complete_temporary_action = Gtk::Action::create(
					"complete_temporary_action", Gtk::Stock::APPLY, _("C_omplete pending temporary action"));
				action_group->add(
					gui->complete_temporary_action,
					sigc::bind<bool>( sigc::mem_fun(*this, &Main_window::on_interrupt_temporary_action_cb), true )
				);

				gui->cancel_temporary_action = Gtk::Action::create(
					"cancel_temporary_action", Gtk::Stock::STOP, _("_Cancel pending temporary action"));
				action_group->add(
					gui->cancel_temporary_action,
					sigc::bind<bool>( sigc::mem_fun(*this, &Main_window::on_interrupt_temporary_action_cb), false )
				);
			// Temporary <--
		// Torrents <--


		action_group->add(
			app_icons::create_action("set_upload_rate_limit", app_icons::ICON_UPLOAD, _("Set _upload rate limit")),
			sigc::bind<Traffic_type>(
				sigc::mem_fun(*this, &Main_window::on_change_rate_limit_callback),
				UPLOAD
			)
		);
		action_group->add(
			app_icons::create_action("set_download_rate_limit",
				app_icons::ICON_DOWNLOAD, _("Set _download rate limit")),
			sigc::bind<Traffic_type>(
				sigc::mem_fun(*this, &Main_window::on_change_rate_limit_callback),
				DOWNLOAD
			)
		);


		action_group->add(Gtk::Action::create("help", _("_Help")));
		action_group->add(
			Gtk::Action::create("about", Gtk::Stock::ABOUT, _("_About")),
			sigc::mem_fun(*this, &Main_window::on_show_about_dialog_callback)
		);

		this->gui->ui_manager->insert_action_group(action_group);

		Glib::ustring ui_info =
			"<ui>"
			"	<menubar name='menu_bar'>"

			"		<menu action='file'>"
			"			<menuitem action='create'/>"
			"			<menuitem action='open'/>"
			"			<menuitem action='open_magnet'/>"
			"			<menuitem action='quit'/>"
			"		</menu>"

			"		<menu action='edit'>"
			"			<menuitem action='statistics'/>"
			"			<menuitem action='preferences'/>"
			"		</menu>"

			"		<menu action='view'>"
			"			<menu action='toolbar'>"
			"				<menuitem action='toolbar/show'/>"
			"				<menu action='toolbar/style'>"
			"					<menuitem action='toolbar/style/default'/>"
			"					<menuitem action='toolbar/style/icons'/>"
			"					<menuitem action='toolbar/style/text'/>"
			"					<menuitem action='toolbar/style/both'/>"
			"					<menuitem action='toolbar/style/both_horiz'/>"
			"				</menu>"
			"			</menu>"
			"			<menu action='categories'>"
			"				<menuitem action='categories/show'/>"
			"				<menuitem action='categories/show_names'/>"
			"				<menuitem action='categories/show_counters'/>"
			"			</menu>"
			"		</menu>"

			"		<menu action='torrents'>"

			"			<menu action='resume'>"
			"				<menuitem action='resume/all'/>"
			"				<menuitem action='resume/uploads'/>"
			"				<menuitem action='resume/downloads'/>"
			"			</menu>"
			"			<menu action='pause'>"
			"				<menuitem action='pause/all'/>"
			"				<menuitem action='pause/uploads'/>"
			"				<menuitem action='pause/downloads'/>"
			"			</menu>"

			"			<separator/>"

			"			<menu action='resume_temporary'>"
			"				<menuitem action='resume_temporary/all'/>"
			"				<menuitem action='resume_temporary/uploads'/>"
			"				<menuitem action='resume_temporary/downloads'/>"
			"			</menu>"
			"			<menu action='pause_temporary'>"
			"				<menuitem action='pause_temporary/all'/>"
			"				<menuitem action='pause_temporary/uploads'/>"
			"				<menuitem action='pause_temporary/downloads'/>"
			"			</menu>"
			"			<menuitem action='complete_temporary_action'/>"
			"			<menuitem action='cancel_temporary_action'/>"

			"		</menu>"

			"		<menu action='help'>"
			"			<menuitem action='about'/>"
			"		</menu>"

			"	</menubar>"


			"	<popup name='appindicator'>"
			"		<menuitem action='app'/>"

			"		<separator/>"

			"		<menuitem action='open'/>"
			"		<menuitem action='open_magnet'/>"

			"		<separator/>"

			"		<menu action='resume'>"
			"			<menuitem action='resume/all'/>"
			"			<menuitem action='resume/uploads'/>"
			"			<menuitem action='resume/downloads'/>"
			"		</menu>"
			"		<menu action='pause'>"
			"			<menuitem action='pause/all'/>"
			"			<menuitem action='pause/uploads'/>"
			"			<menuitem action='pause/downloads'/>"
			"		</menu>"

			"		<separator/>"

			"		<menu action='resume_temporary'>"
			"			<menuitem action='resume_temporary/all'/>"
			"			<menuitem action='resume_temporary/uploads'/>"
			"			<menuitem action='resume_temporary/downloads'/>"
			"		</menu>"
			"		<menu action='pause_temporary'>"
			"			<menuitem action='pause_temporary/all'/>"
			"			<menuitem action='pause_temporary/uploads'/>"
			"			<menuitem action='pause_temporary/downloads'/>"
			"		</menu>"
			"		<menuitem action='complete_temporary_action'/>"
			"		<menuitem action='cancel_temporary_action'/>"

			"		<separator/>"

			"		<menuitem action='set_upload_rate_limit'/>"
			"		<menuitem action='set_download_rate_limit'/>"

			"		<separator/>"

			"		<menuitem action='quit'/>"
			"	</popup>"


			"	<popup name='tray_popup_menu'>"
			"		<menuitem action='open'/>"
			"		<menuitem action='open_magnet'/>"

			"		<separator/>"

			"		<menu action='resume'>"
			"			<menuitem action='resume/all'/>"
			"			<menuitem action='resume/uploads'/>"
			"			<menuitem action='resume/downloads'/>"
			"		</menu>"
			"		<menu action='pause'>"
			"			<menuitem action='pause/all'/>"
			"			<menuitem action='pause/uploads'/>"
			"			<menuitem action='pause/downloads'/>"
			"		</menu>"

			"		<separator/>"

			"		<menu action='resume_temporary'>"
			"			<menuitem action='resume_temporary/all'/>"
			"			<menuitem action='resume_temporary/uploads'/>"
			"			<menuitem action='resume_temporary/downloads'/>"
			"		</menu>"
			"		<menu action='pause_temporary'>"
			"			<menuitem action='pause_temporary/all'/>"
			"			<menuitem action='pause_temporary/uploads'/>"
			"			<menuitem action='pause_temporary/downloads'/>"
			"		</menu>"
			"		<menuitem action='complete_temporary_action'/>"
			"		<menuitem action='cancel_temporary_action'/>"

			"		<separator/>"

			"		<menuitem action='set_upload_rate_limit'/>"
			"		<menuitem action='set_download_rate_limit'/>"

			"		<separator/>"

			"		<menuitem action='quit'/>"
			"	</popup>"

			"</ui>";

		this->gui->ui_manager->add_ui_from_string(ui_info);
		this->add_accel_group(this->gui->ui_manager->get_accel_group());
	// Меню <--


	Gtk::VBox* main_vbox = Gtk::manage(new Gtk::VBox());
	this->add(*main_vbox);

	// Панель меню -->
		Gtk::Widget* menu_bar = this->gui->ui_manager->get_widget("/menu_bar");
		main_vbox->pack_start(*menu_bar, false, true);
	// Панель меню <--

	// Панель инструментов
	main_vbox->pack_start(this->gui->toolbar, false, false);

	// Список торрентов -->
		this->gui->torrents_viewport = Gtk::manage(new Torrents_viewport(main_window_settings.torrents_viewport));
		main_vbox->pack_start(*this->gui->torrents_viewport, true, true);

		// Настройки отдельных виджетов
		this->gui->torrents_viewport->get_log_view().set_max_lines(client_settings.gui.max_log_lines);
	// Список торрентов <--

	// status bar -->
	{
		Gtk::Alignment* alignment = Gtk::manage(new Gtk::Alignment());
		alignment->property_top_padding() = m::gtk::VBOX_SPACING / 2;
		main_vbox->pack_start(*alignment, false, false);

		alignment->add(this->gui->status_bar);
		this->gui->status_bar.push("");
	}
	// status bar <--

	// AppIndicator -->
	#if HAVE_APP_INDICATOR
	{
		app_indicator_set_menu(this->gui->appindicator, GTK_MENU(
			gtk_ui_manager_get_widget(this->gui->ui_manager->gobj(), "/ui/appindicator")));

		g_signal_connect(G_OBJECT(this->gui->appindicator), APP_INDICATOR_SIGNAL_CONNECTION_CHANGED,
			G_CALLBACK(&Main_window::on_appindicator_connection_changed), this);
	}
	#endif
	// AppIndicator <--


	// Панель инструментов -->
	{
		// Заполнять ее лучше в самом конце, когда уже созданы все необходимые
		// виджеты.

		Gtk::ToolButton* button;


		button = Gtk::manage(new Gtk::ToolButton(Gtk::Stock::NEW));
		button->set_label(_("Create"));
		button->set_tooltip_text(_("Create a new torrent"));
		button->set_is_important();
		this->gui->toolbar.append(
			*button,
			sigc::mem_fun(*this, &Main_window::on_create_callback)
		);

		button = Gtk::manage(new Gtk::ToolButton(Gtk::Stock::OPEN));
		button->set_label(_("Open"));
		button->set_tooltip_text(_("Open a torrent"));
		button->set_is_important();
		this->gui->toolbar.append(
			*button,
			sigc::mem_fun(*this, &Main_window::on_open_callback)
		);


		button = Gtk::manage(new Gtk::ToolButton(Gtk::Stock::JUMP_TO));
		button->set_label(_("Magnet link"));
		button->set_tooltip_text(_("Open a magnet link"));
		button->set_is_important();
		this->gui->toolbar.append(
			*button,
			sigc::mem_fun(*this, &Main_window::on_open_magnet_callback)
		);


		this->gui->toolbar.append(
			*Gtk::manage(new Gtk::SeparatorToolItem())
		);


		button = this->gui->toolbar_resume_button = Gtk::manage(new Gtk::ToolButton(Gtk::Stock::MEDIA_PLAY));
		button->set_label(_("Resume"));
		button->set_tooltip_text(_("Resume torrent(s)"));
		button->set_is_important();
		this->gui->toolbar.append(
			*button,
			sigc::bind<Torrent_process_action>(
				sigc::mem_fun(*this->gui->torrents_viewport, &Torrents_viewport::process_torrents),
				RESUME
			)
		);

		button = this->gui->toolbar_pause_button = Gtk::manage(new Gtk::ToolButton(Gtk::Stock::MEDIA_PAUSE));
		button->set_label(_("Pause"));
		button->set_tooltip_text(_("Pause torrent(s)"));
		button->set_is_important();
		this->gui->toolbar.append(
			*button,
			sigc::bind<Torrent_process_action>(
				sigc::mem_fun(*this->gui->torrents_viewport, &Torrents_viewport::process_torrents),
				PAUSE
			)
		);

		button = this->gui->toolbar_remove_button = Gtk::manage(new Gtk::ToolButton(Gtk::Stock::REMOVE));
		button->set_label(_("Remove"));
		button->set_tooltip_text(_("Remove torrent(s)"));
		button->set_is_important();
		this->gui->toolbar.append(
			*button,
			sigc::bind<Torrent_process_action>(
				sigc::mem_fun(*this->gui->torrents_viewport, &Torrents_viewport::process_torrents),
				REMOVE
			)
		);


		this->gui->toolbar.append(
			*Gtk::manage(new Gtk::SeparatorToolItem())
		);


		button = Gtk::manage(new Gtk::ToolButton());
		button->set_label(_("Statistics"));
		app_icons::set_for_tool_button(*button, app_icons::ICON_STATISTICS);
		button->set_tooltip_text(_("Statistics"));
		button->set_is_important();
		this->gui->toolbar.append(
			*button,
			sigc::mem_fun(*this, &Main_window::on_show_statistics_callback)
		);

		button = Gtk::manage(new Gtk::ToolButton(Gtk::Stock::PREFERENCES));
		button->set_label(_("Preferences"));
		button->set_tooltip_text(_("Preferences"));
		button->set_is_important();
		this->gui->toolbar.append(
			*button,
			sigc::mem_fun(*this, &Main_window::on_show_settings_window_callback)
		);


		this->gui->toolbar.show_all_children();
		if(get_client_settings().gui.show_toolbar)
			this->gui->toolbar.show();

		this->gui->toolbar.set_no_show_all();
	}
	// Панель инструментов <--


	// Устанавливаем интервал обновления GUI
	this->set_gui_update_interval(client_settings.gui.update_interval);

	// Обновление доступных в данный момент кнопок -->
		this->on_torrent_process_actions_changed_callback(0);

		gui->torrent_process_actions_changed_connection =
			this->gui->torrents_viewport->signal_torrent_process_actions_changed().connect(
				sigc::mem_fun(*this, &Main_window::on_torrent_process_actions_changed_callback)
			);
	// Обновление доступных в данный момент кнопок <--

	// Автоматическое сохранение настроек
	gui->autosave_settings_connection = Glib::signal_timeout().connect(
		sigc::mem_fun(*this, &Main_window::on_save_settings_timeout), SAVE_SETTINGS_INTERVAL
	);

	// Обработчик сигнала на изменение состояния окна
	this->signal_window_state_event().connect(sigc::mem_fun(
		*this, &Main_window::on_window_state_changed_callback
	));

	// Закрытие окна
	this->signal_delete_event().connect(sigc::mem_fun(*this, &Main_window::on_close_callback));

	if(client_settings.gui.show_tray_icon && client_settings.gui.hide_app_to_tray_at_startup)
		this->show_all_children();
	else
		this->show_all();

	// В gtkmm 2.16.0 (Ubuntu 9.04) есть небольшая бага, из-за которой
	// this->show_all() отображает даже элементы меню, для которых была
	// выполнена Gtk::Action::set_visible(false).
	// Поэтому скрываем элементы меню в самый последний момент.
	COMPATIBILITY
	gui->complete_temporary_action->set_visible(true);
	gui->cancel_temporary_action->set_visible(true);
}
Пример #29
0
 */

#include "nvc0/nvc0_context.h"
#include "nvc0/nvc0_query_hw_metric.h"
#include "nvc0/nvc0_query_hw_sm.h"

#define _Q(i,n,t,d) { NVC0_HW_METRIC_QUERY_##i, n, PIPE_DRIVER_QUERY_TYPE_##t, d }
static const struct nvc0_hw_metric_cfg {
   unsigned id;
   const char *name;
   enum pipe_driver_query_type type;
   const char *desc;
} nvc0_hw_metric_queries[] = {
   _Q(ACHIEVED_OCCUPANCY,
      "metric-achieved_occupancy",
      PERCENTAGE,
      "Ratio of the average active warps per active cycle to the maximum "
      "number of warps supported on a multiprocessor"),

   _Q(BRANCH_EFFICIENCY,
      "metric-branch_efficiency",
      PERCENTAGE,
      "Ratio of non-divergent branches to total branches"),

   _Q(INST_ISSUED,
      "metric-inst_issued",
      UINT64,
      "The number of instructions issued"),

   _Q(INST_PER_WRAP,
      "metric-inst_per_wrap",
Пример #30
0
QStringList getCustomCommand(const TextMessage& msg)
{
    return _Q(msg.szMessage).split("\r\n");
}