示例#1
0
QString JoyButtonSlot::getSlotString()
{
    QString newlabel;

    if (deviceCode >= 0)
    {
        if (mode == JoyButtonSlot::JoyKeyboard)
        {
            newlabel = newlabel.append(keysymToKeyString(deviceCode, qkeyaliasCode).toUpper());
        }
        else if (mode == JoyButtonSlot::JoyMouseButton)
        {
            newlabel.append(tr("Mouse")).append(" ");
            switch (deviceCode)
            {
                case 1:
                    newlabel.append(tr("LB"));
                    break;
                case 2:
                    newlabel.append(tr("MB"));
                    break;
                case 3:
                    newlabel.append(tr("RB"));
                    break;
#ifdef Q_OS_WIN
                case 8:
                    newlabel.append(tr("B4"));
                    break;
                case 9:
                    newlabel.append(tr("B5"));
                    break;
#endif
                default:
                    newlabel.append(QString::number(deviceCode));
                    break;
            }
        }
        else if (mode == JoyMouseMovement)
        {
            newlabel.append(movementString());
        }
        else if (mode == JoyPause)
        {
            int minutes = deviceCode / 1000 / 60;
            int seconds = (deviceCode / 1000 % 60);
            int hundredths = deviceCode % 1000 / 10;

            newlabel.append(tr("Pause")).append(" ");
            if (minutes > 0)
            {
                newlabel.append(QString("%1:").arg(minutes, 2, 10, QChar('0')));
            }

            newlabel.append(QString("%1.%2")
                    .arg(seconds, 2, 10, QChar('0'))
                    .arg(hundredths, 2, 10, QChar('0')));
        }
        else if (mode == JoyHold)
        {
            int minutes = deviceCode / 1000 / 60;
            int seconds = (deviceCode / 1000 % 60);
            int hundredths = deviceCode % 1000 / 10;

            newlabel.append(tr("Hold")).append(" ");
            if (minutes > 0)
            {
                newlabel.append(QString("%1:").arg(minutes, 2, 10, QChar('0')));
            }

            newlabel.append(QString("%1.%2")
                    .arg(seconds, 2, 10, QChar('0'))
                    .arg(hundredths, 2, 10, QChar('0')));
        }
        else if (mode == JoyButtonSlot::JoyCycle)
        {
            newlabel.append(tr("Cycle"));
        }
        else if (mode == JoyDistance)
        {
            QString temp(tr("Distance"));
            temp.append(" ").append(QString::number(deviceCode).append("%"));
            newlabel.append(temp);
        }
        else if (mode == JoyRelease)
        {
            int minutes = deviceCode / 1000 / 60;
            int seconds = (deviceCode / 1000 % 60);
            int hundredths = deviceCode % 1000 / 10;

            newlabel.append(tr("Release")).append(" ");
            if (minutes > 0)
            {
                newlabel.append(QString("%1:").arg(minutes, 2, 10, QChar('0')));
            }

            newlabel.append(QString("%1.%2")
                    .arg(seconds, 2, 10, QChar('0'))
                    .arg(hundredths, 2, 10, QChar('0')));
        }
        else if (mode == JoyMouseSpeedMod)
        {
            QString temp;
            temp.append(tr("Mouse Mod")).append(" ");
            temp.append(QString::number(deviceCode).append("%"));
            newlabel.append(temp);
        }
        else if (mode == JoyKeyPress)
        {
            int minutes = deviceCode / 1000 / 60;
            int seconds = (deviceCode / 1000 % 60);
            int hundredths = deviceCode % 1000 / 10;

            QString temp;
            temp.append(tr("Press Time")).append(" ");
            if (minutes > 0)
            {
                temp.append(QString("%1:").arg(minutes, 2, 10, QChar('0')));
            }

            temp.append(QString("%1.%2")
                    .arg(seconds, 2, 10, QChar('0'))
                    .arg(hundredths, 2, 10, QChar('0')));

            newlabel.append(temp);
        }
        else if (mode == JoyDelay)
        {
            int minutes = deviceCode / 1000 / 60;
            int seconds = (deviceCode / 1000 % 60);
            int hundredths = deviceCode % 1000 / 10;

            QString temp;
            temp.append(tr("Delay")).append(" ");
            if (minutes > 0)
            {
                temp.append(QString("%1:").arg(minutes, 2, 10, QChar('0')));
            }

            temp.append(QString("%1.%2")
                    .arg(seconds, 2, 10, QChar('0'))
                    .arg(hundredths, 2, 10, QChar('0')));

            newlabel.append(temp);
        }
        else if (mode == JoyLoadProfile)
        {
            if (!textData.isEmpty())
            {
                QFileInfo profileInfo(textData);
                QString temp;
                temp.append(tr("Load %1").arg(profileInfo.baseName()));
                newlabel.append(temp);
            }
        }
        else if (mode == JoySetChange)
        {
            newlabel.append(tr("Set Change %1").arg(deviceCode+1));
        }
    }
    else
    {
        newlabel = newlabel.append(tr("[NO KEY]"));
    }

    return newlabel;
}
示例#2
0
// TODO hide lossless/hybrid/etc. when not available
OptionsSimple::OptionsSimple( Config *_config, /*OptionsDetailed* _optionsDetailed,*/ const QString &text, QWidget *parent )
    : QWidget( parent ),
    config( _config )
{
    const int fontHeight = QFontMetrics(QApplication::font()).boundingRect("M").size().height();

    QGridLayout *grid = new QGridLayout( this );
    grid->setMargin( fontHeight );
    grid->setSpacing( fontHeight );

    QLabel *lQuality = new QLabel( i18n("Quality:"), this );
    grid->addWidget( lQuality, 0, 0 );

    QHBoxLayout *topBoxQuality = new QHBoxLayout();
    grid->addLayout( topBoxQuality, 0, 1 );
    cProfile = new KComboBox( this );
    topBoxQuality->addWidget( cProfile );
    connect( cProfile, SIGNAL(activated(int)), this, SLOT(profileChanged()) );
    topBoxQuality->addSpacing( 0.25*fontHeight );
    pProfileRemove = new KPushButton( KIcon("edit-delete"), i18n("Remove"), this );
    topBoxQuality->addWidget( pProfileRemove );
    pProfileRemove->setToolTip( i18n("Remove the selected profile") );
    pProfileRemove->hide();
    connect( pProfileRemove, SIGNAL(clicked()), this, SLOT(profileRemove()) );
    pProfileInfo = new KPushButton( KIcon("dialog-information"), i18n("Info"), this );
    topBoxQuality->addWidget( pProfileInfo );
    pProfileInfo->setToolTip( i18n("Information about the selected profile") );
//     cProfile->setFixedHeight( pProfileInfo->minimumSizeHint().height() );
    connect( pProfileInfo, SIGNAL(clicked()), this, SLOT(profileInfo()) );
    topBoxQuality->addStretch( );

    topBoxQuality->addSpacing( fontHeight );

    QLabel *lFormat = new QLabel( i18n("Format:"), this );
    grid->addWidget( lFormat, 0, 2 );

    QHBoxLayout *topBoxFormat = new QHBoxLayout();
    grid->addLayout( topBoxFormat, 0, 3 );
    cFormat = new KComboBox( this );
    topBoxFormat->addWidget( cFormat );
//     connect( cFormat, SIGNAL(activated(int)), this, SLOT(formatChanged()) );
    connect( cFormat, SIGNAL(activated(int)), this, SLOT(somethingChanged()) );
    topBoxFormat->addSpacing( 0.25*fontHeight );
    pFormatInfo = new KPushButton( KIcon("dialog-information"), i18n("Info"), this );
    topBoxFormat->addWidget( pFormatInfo );
    pFormatInfo->setToolTip( i18n("Information about the selected file format") );
//     cFormat->setFixedHeight( pFormatInfo->minimumSizeHint().height() );
    connect( pFormatInfo, SIGNAL(clicked()), this, SLOT(formatInfo()) );
    topBoxFormat->addSpacing( 0.25*fontHeight );
    QLabel *formatHelp = new QLabel( "<a href=\"format-help\">" + i18n("More formats...") + "</a>", this );
    topBoxFormat->addWidget( formatHelp );
    connect( formatHelp, SIGNAL(linkActivated(const QString&)), this, SLOT(showHelp()) );
    topBoxFormat->addStretch( );

    QLabel *lOutput = new QLabel( i18n("Destination:"), this );
    grid->addWidget( lOutput, 1, 0 );

    QHBoxLayout *middleBox = new QHBoxLayout();
    grid->addLayout( middleBox, 1, 1, 1, 3 );
    outputDirectory = new OutputDirectory( config, this );
    middleBox->addWidget( outputDirectory );
    connect( outputDirectory, SIGNAL(modeChanged(int)), this, SLOT(outputDirectoryChanged()) );
    connect( outputDirectory, SIGNAL(directoryChanged(const QString&)), this, SLOT(outputDirectoryChanged()) );

    QHBoxLayout *estimSizeBox = new QHBoxLayout();
    grid->addLayout( estimSizeBox, 2, 0 );
    estimSizeBox->addStretch();
    lEstimSize = new QLabel( QString(QChar(8776))+"? B / min." );
    lEstimSize->hide(); // hide for now because most plugins report inaccurate data
    estimSizeBox->addWidget( lEstimSize );

    QLabel *lOptional = new QLabel( i18n("Optional:") );
    grid->addWidget( lOptional, 3, 0 );

    QHBoxLayout *optionalBox = new QHBoxLayout();
    grid->addLayout( optionalBox, 3, 1 );
    cReplayGain = new QCheckBox( i18n("Calculate Replay Gain tags"), this );
    optionalBox->addWidget( cReplayGain );
    connect( cReplayGain, SIGNAL(toggled(bool)), this, SLOT(somethingChanged()) );
    optionalBox->addStretch();

    QLabel *lInfo = new QLabel( text, this );
    grid->addWidget( lInfo, 4, 0, 1, 4, Qt::AlignVCenter | Qt::AlignCenter );
    grid->setRowStretch( 4, 1 );

    grid->setColumnStretch( 1, 1 );
    grid->setColumnStretch( 3, 1 );
}
示例#3
0
void JoyButtonSlot::readConfig(QXmlStreamReader *xml)
{
    if (xml->isStartElement() && xml->name() == "slot")
    {
        QString profile;

        xml->readNextStartElement();
        while (!xml->atEnd() && (!xml->isEndElement() && xml->name() != "slot"))
        {
            if (xml->name() == "code" && xml->isStartElement())
            {
                QString temptext = xml->readElementText();
                bool ok = false;
                unsigned int tempchoice = temptext.toInt(&ok, 0);
                if (ok)
                {
                    this->setSlotCode(tempchoice);
                }
            }
            else if (xml->name() == "profile" && xml->isStartElement())
            {
                QString temptext = xml->readElementText();
                profile = temptext;
                //this->setTextData(temptext);
            }
            else if (xml->name() == "mode" && xml->isStartElement())
            {
                QString temptext = xml->readElementText();

                if (temptext == "keyboard")
                {
                    this->setSlotMode(JoyKeyboard);
                }
                else if (temptext == "mousebutton")
                {
                    this->setSlotMode(JoyMouseButton);
                }
                else if (temptext == "mousemovement")
                {
                    this->setSlotMode(JoyMouseMovement);
                }
                else if (temptext == "pause")
                {
                    this->setSlotMode(JoyPause);
                }
                else if (temptext == "hold")
                {
                    this->setSlotMode(JoyHold);
                }
                else if (temptext == "cycle")
                {
                    this->setSlotMode(JoyCycle);
                }
                else if (temptext == "distance")
                {
                    this->setSlotMode(JoyDistance);
                }
                else if (temptext == "release")
                {
                    this->setSlotMode(JoyRelease);
                }
                else if (temptext == "mousespeedmod")
                {
                    this->setSlotMode(JoyMouseSpeedMod);
                }
                else if (temptext == "keypress")
                {
                    this->setSlotMode(JoyKeyPress);
                }
                else if (temptext == "delay")
                {
                    this->setSlotMode(JoyDelay);
                }
                else if (temptext == "loadprofile")
                {
                    this->setSlotMode(JoyLoadProfile);
                }
                else if (temptext == "setchange")
                {
                    this->setSlotMode(JoySetChange);
                }
            }
            else
            {
                xml->skipCurrentElement();
            }

            xml->readNextStartElement();
        }

        if (this->getSlotMode() == JoyButtonSlot::JoyKeyboard)
        {
            unsigned int virtualkey = AntKeyMapper::getInstance()->returnVirtualKey(this->getSlotCode());
            unsigned int tempkey = this->getSlotCode();

            if (virtualkey)
            {
                // Mapping found a valid native keysym.
                this->setSlotCode(virtualkey, tempkey);
            }
            else if ((unsigned int)this->getSlotCode() > QtKeyMapperBase::nativeKeyPrefix)
            {
                // Value is in the native key range. Remove prefix and use
                // new value as a native keysym.
                unsigned int temp = this->getSlotCode() - QtKeyMapperBase::nativeKeyPrefix;
                this->setSlotCode(temp);
            }
        }
        else if (this->getSlotMode() == JoyButtonSlot::JoyLoadProfile && !profile.isEmpty())
        {
            QFileInfo profileInfo(profile);
            if (!profileInfo.exists() || !(profileInfo.suffix() == "amgp" || profileInfo.suffix() == "xml"))
            {
                this->setTextData("");
            }
            else
            {
                this->setTextData(profile);
            }
        }
        else if (this->getSlotMode() == JoySetChange)
        {
            if (!this->getSlotCode() >= 0 && !this->getSlotCode() < InputDevice::NUMBER_JOYSETS)
            {
                this->setSlotCode(-1);
            }
        }
    }
}
示例#4
0
QString JoyButtonSlot::getSlotString()
{
    QString newlabel;

    if (deviceCode >= 0)
    {
        if (mode == JoyButtonSlot::JoyKeyboard)
        {
            unsigned int tempDeviceCode = deviceCode;
#ifdef Q_OS_WIN
            QtKeyMapperBase *nativeWinKeyMapper = AntKeyMapper::getInstance()->getNativeKeyMapper();
            if (nativeWinKeyMapper)
            {
                tempDeviceCode = nativeWinKeyMapper->returnVirtualKey(qkeyaliasCode);
            }
#endif
            newlabel = newlabel.append(keysymToKeyString(tempDeviceCode, qkeyaliasCode).toUpper());
        }
        else if (mode == JoyButtonSlot::JoyMouseButton)
        {
            newlabel.append(tr("Mouse")).append(" ");
            switch (deviceCode)
            {
                case 1:
                    newlabel.append(tr("LB"));
                    break;
                case 2:
                    newlabel.append(tr("MB"));
                    break;
                case 3:
                    newlabel.append(tr("RB"));
                    break;
#ifdef Q_OS_WIN
                case 8:
                    newlabel.append(tr("B4"));
                    break;
                case 9:
                    newlabel.append(tr("B5"));
                    break;
#endif
                default:
                    newlabel.append(QString::number(deviceCode));
                    break;
            }
        }
        else if (mode == JoyMouseMovement)
        {
            newlabel.append(movementString());
        }
        else if (mode == JoyPause)
        {
            int minutes = deviceCode / 1000 / 60;
            int seconds = (deviceCode / 1000 % 60);
            int hundredths = deviceCode % 1000 / 10;

            newlabel.append(tr("Pause")).append(" ");
            if (minutes > 0)
            {
                newlabel.append(QString("%1:").arg(minutes, 2, 10, QChar('0')));
            }

            newlabel.append(QString("%1.%2")
                    .arg(seconds, 2, 10, QChar('0'))
                    .arg(hundredths, 2, 10, QChar('0')));
        }
        else if (mode == JoyHold)
        {
            int minutes = deviceCode / 1000 / 60;
            int seconds = (deviceCode / 1000 % 60);
            int hundredths = deviceCode % 1000 / 10;

            newlabel.append(tr("Hold")).append(" ");
            if (minutes > 0)
            {
                newlabel.append(QString("%1:").arg(minutes, 2, 10, QChar('0')));
            }

            newlabel.append(QString("%1.%2")
                    .arg(seconds, 2, 10, QChar('0'))
                    .arg(hundredths, 2, 10, QChar('0')));
        }
        else if (mode == JoyButtonSlot::JoyCycle)
        {
            newlabel.append(tr("Cycle"));
        }
        else if (mode == JoyDistance)
        {
            QString temp(tr("Distance"));
            temp.append(" ").append(QString::number(deviceCode).append("%"));
            newlabel.append(temp);
        }
        else if (mode == JoyRelease)
        {
            int minutes = deviceCode / 1000 / 60;
            int seconds = (deviceCode / 1000 % 60);
            int hundredths = deviceCode % 1000 / 10;

            newlabel.append(tr("Release")).append(" ");
            if (minutes > 0)
            {
                newlabel.append(QString("%1:").arg(minutes, 2, 10, QChar('0')));
            }

            newlabel.append(QString("%1.%2")
                    .arg(seconds, 2, 10, QChar('0'))
                    .arg(hundredths, 2, 10, QChar('0')));
        }
        else if (mode == JoyMouseSpeedMod)
        {
            QString temp;
            temp.append(tr("Mouse Mod")).append(" ");
            temp.append(QString::number(deviceCode).append("%"));
            newlabel.append(temp);
        }
        else if (mode == JoyKeyPress)
        {
            int minutes = deviceCode / 1000 / 60;
            int seconds = (deviceCode / 1000 % 60);
            int hundredths = deviceCode % 1000 / 10;

            QString temp;
            temp.append(tr("Press Time")).append(" ");
            if (minutes > 0)
            {
                temp.append(QString("%1:").arg(minutes, 2, 10, QChar('0')));
            }

            temp.append(QString("%1.%2")
                    .arg(seconds, 2, 10, QChar('0'))
                    .arg(hundredths, 2, 10, QChar('0')));

            newlabel.append(temp);
        }
        else if (mode == JoyDelay)
        {
            int minutes = deviceCode / 1000 / 60;
            int seconds = (deviceCode / 1000 % 60);
            int hundredths = deviceCode % 1000 / 10;

            QString temp;
            temp.append(tr("Delay")).append(" ");
            if (minutes > 0)
            {
                temp.append(QString("%1:").arg(minutes, 2, 10, QChar('0')));
            }

            temp.append(QString("%1.%2")
                    .arg(seconds, 2, 10, QChar('0'))
                    .arg(hundredths, 2, 10, QChar('0')));

            newlabel.append(temp);
        }
        else if (mode == JoyLoadProfile)
        {
            if (!textData.isEmpty())
            {
                QFileInfo profileInfo(textData);
                QString temp;
                temp.append(tr("Load %1").arg(profileInfo.baseName()));
                newlabel.append(temp);
            }
        }
        else if (mode == JoySetChange)
        {
            newlabel.append(tr("Set Change %1").arg(deviceCode+1));
        }
        else if (mode == JoyTextEntry)
        {
            QString temp = textData;
            if (temp.length() > MAXTEXTENTRYDISPLAYLENGTH)
            {
                temp.truncate(MAXTEXTENTRYDISPLAYLENGTH - 3);
                temp.append("...");
            }
            newlabel.append(tr("[Text] %1").arg(temp));
        }
        else if (mode == JoyExecute)
        {
            QString temp;
            if (!textData.isEmpty())
            {
                QFileInfo tempFileInfo(textData);
                temp.append(tempFileInfo.fileName());
            }

            newlabel.append(tr("[Exec] %1").arg(temp));
        }
    }
    else
    {
        newlabel = newlabel.append(tr("[NO KEY]"));
    }

    return newlabel;
}