示例#1
0
void TabletHandler::onToggleScreenMapping()
{
    Q_D( TabletHandler );

    foreach(const QString &tabletId, d->tabletInformationList.keys()) {
        if (!hasTablet(tabletId)) {
            continue;
        }

        QString curProfile = d->currentProfileList.value(tabletId);
        TabletProfile tabletProfile = d->profileManagerList.value(tabletId)->loadProfile(curProfile);
        DeviceProfile stylusProfile  = tabletProfile.getDevice(DeviceType::Stylus);
        ScreenSpace   screenSpace    = ScreenSpace(stylusProfile.getProperty(Property::ScreenSpace));

        if (screenSpace.isMonitor()) {
            // get next monitor - mapTabletToOutput() will handle disconnected monitors
            int screenNumber = screenSpace.getScreenNumber() + 1;
            screenSpace = ScreenSpace::monitor(screenNumber);
        } else {
            screenSpace = ScreenSpace::monitor(0);
        }

        mapPenToScreenSpace(tabletId, screenSpace.toString());
    }
}
示例#2
0
void TabletHandler::onTogglePenMode()
{
    Q_D( TabletHandler );

    foreach(const QString &tabletId, d->tabletInformationList.keys()) {
        if( !hasTablet(tabletId) || !hasDevice(tabletId, DeviceType::Stylus)) {
            continue;
        }

        // read current mode and screen space from profile
        QString curProfile = d->currentProfileList.value(tabletId);
        TabletProfile tabletProfile = d->profileManagerList.value(tabletId)->loadProfile(curProfile);
        DeviceProfile stylusProfile = tabletProfile.getDevice(DeviceType::Stylus);

        QString     trackingMode = stylusProfile.getProperty(Property::Mode);
        ScreenSpace screenSpace(stylusProfile.getProperty(Property::ScreenSpace));

        // toggle tracking mode
        if (trackingMode.contains(QLatin1String("relative"), Qt::CaseInsensitive)) {
            trackingMode = QLatin1String("absolute");

        } else {
            // if the new mode is "relative" we have to switch to full desktop
            // as screen mappings are not supported in absolute mode
            trackingMode = QLatin1String("relative");
            screenSpace  = ScreenSpace::desktop();
        }

        // map tablet to output which will also save the current mode in the profile
        mapDeviceToOutput(tabletId, DeviceType::Stylus, screenSpace, trackingMode, tabletProfile);
        mapDeviceToOutput(tabletId, DeviceType::Eraser, screenSpace, trackingMode, tabletProfile);

        d->profileManagerList.value(tabletId)->saveProfile(tabletProfile);
    }
}
示例#3
0
void TabletHandler::onToggleTouch()
{
    Q_D( TabletHandler );

    foreach(const QString &tabletId, d->tabletInformationList.keys()) {
        if( !hasDevice(tabletId, DeviceType::Touch) ) {
            continue;
        }

        QString touchMode = getProperty(tabletId, DeviceType::Touch, Property::Touch);

        // also save the touch on/off into the profile to remember the user selection after
        // the tablet was reconnected
        QString curProfile = d->currentProfileList.value(tabletId);
        TabletProfile tabletProfile = d->profileManagerList.value(tabletId)->loadProfile(curProfile);
        DeviceProfile touchProfile = tabletProfile.getDevice(DeviceType::Touch);

        if( touchMode.compare( QLatin1String( "off" ), Qt::CaseInsensitive) == 0 ) {
            setProperty(tabletId, DeviceType::Touch, Property::Touch, QLatin1String("on"));
            touchProfile.setProperty( Property::Touch, QLatin1String("on" ) );
        } else {
            setProperty(tabletId, DeviceType::Touch, Property::Touch, QLatin1String("off"));
            touchProfile.setProperty( Property::Touch, QLatin1String("off") );
        }

        tabletProfile.setDevice(touchProfile);
        d->profileManagerList.value(tabletId)->saveProfile(tabletProfile);
    }
}
示例#4
0
DeviceProfile QDesignerSharedSettings::deviceProfileAt(int idx) const
{
    DeviceProfile rc;
    if (idx < 0)
        return rc;
    const QStringList xmls = deviceProfileXml();
    if (idx >= xmls.size())
        return rc;
    QString errorMessage;
    if (!rc.fromXml(xmls.at(idx), &errorMessage)) {
        rc.clear();
        designerWarning(msgWarnDeviceProfileXml(errorMessage));
    }
    return rc;
}
示例#5
0
void DeviceProfileDialog::open()
{
    const QString fn = m_dlgGui->getOpenFileName(this, tr("Open profile"), QString(), fileFilter());
    if (fn.isEmpty())
        return;

    QFile file(fn);
    if (!file.open(QIODevice::ReadOnly|QIODevice::Text)) {
        critical(tr("Open Profile - Error"), tr("Unable to open the file '%1' for reading: %2").arg(fn, file.errorString()));
        return;
    }
    QString errorMessage;
    DeviceProfile newSettings;
    if (!newSettings.fromXml(QString::fromUtf8(file.readAll()), &errorMessage)) {
        critical(tr("Open Profile - Error"), tr("'%1' is not a valid profile: %2").arg(fn, errorMessage));
        return;
    }
    setDeviceProfile(newSettings);
}
示例#6
0
QDesignerSharedSettings::DeviceProfileList QDesignerSharedSettings::deviceProfiles() const
{
    DeviceProfileList rc;
    const QStringList xmls = deviceProfileXml();
    if (xmls.empty())
        return rc;
    // De-serialize
    QString errorMessage;
    DeviceProfile dp;
    const QStringList::const_iterator scend = xmls.constEnd();
    for (QStringList::const_iterator it = xmls.constBegin(); it != scend; ++it) {
        if (dp.fromXml(*it, &errorMessage)) {
            rc.push_back(dp);
        } else {
            designerWarning(msgWarnDeviceProfileXml(errorMessage));
        }
    }
    return rc;
}
示例#7
0
void DeviceProfileDialog::setDeviceProfile(const DeviceProfile &s)
{
    m_ui->m_nameLineEdit->setText(s.name());
    m_ui->m_systemFontComboBox->setCurrentFont(QFont(s.fontFamily()));
    const int fontSizeIndex = m_ui->m_systemFontSizeCombo->findData(QVariant(s.fontPointSize()));
    m_ui->m_systemFontSizeCombo->setCurrentIndex(fontSizeIndex != -1 ? fontSizeIndex : 0);
    m_ui->m_dpiChooser->setDPI(s.dpiX(), s.dpiY());
    const int styleIndex = m_ui->m_styleCombo->findData(s.style());
    m_ui->m_styleCombo->setCurrentIndex(styleIndex != -1 ? styleIndex : 0);
}
示例#8
0
DeviceProfile DeviceProfileDialog::deviceProfile() const
{
    DeviceProfile rc;
    rc.setName(m_ui->m_nameLineEdit->text());
    rc.setFontFamily(m_ui->m_systemFontComboBox->currentFont().family());
    rc.setFontPointSize(m_ui->m_systemFontSizeCombo->itemData(m_ui->m_systemFontSizeCombo->currentIndex()).toInt());

    int dpiX, dpiY;
    m_ui->m_dpiChooser->getDPI(&dpiX, &dpiY);
    rc.setDpiX(dpiX);
    rc.setDpiY(dpiY);

    rc.setStyle(m_ui->m_styleCombo->itemData(m_ui->m_styleCombo->currentIndex()).toString());

    return rc;
}
示例#9
0
void ButtonPageWidget::loadFromProfile()
{
    Q_D( ButtonPageWidget );

    ProfileManagement* profileManagement = &ProfileManagement::instance();
    DeviceProfile      padProfile        = profileManagement->loadDeviceProfile(DeviceType::Pad);
    QString            propertyValue;

    // set button shortcuts
    ButtonActionSelectorWidget* buttonSelector;

    for (int i = 1;i < 11 ;i++) {
        buttonSelector = this->findChild<ButtonActionSelectorWidget*>(QString::fromLatin1("button%1ActionSelector").arg(i));
        propertyValue  = padProfile.getButton(i);

        if (buttonSelector) {
            buttonSelector->setShortcut(ButtonShortcut(propertyValue));
        }
    }

    // set wheel and ring shortcuts
    propertyValue = padProfile.getProperty(Property::AbsWheelUp);
    d->ui->wheelUpSelector->setShortcut(ButtonShortcut(propertyValue));
    d->ui->ringUpSelector->setShortcut(ButtonShortcut(propertyValue));

    propertyValue = padProfile.getProperty(Property::AbsWheelDown);
    d->ui->wheelDownSelector->setShortcut(ButtonShortcut(propertyValue));
    d->ui->ringDownSelector->setShortcut(ButtonShortcut(propertyValue));

    // set strip shortcuts
    propertyValue = padProfile.getProperty(Property::StripLeftUp);
    d->ui->leftStripUpSelector->setShortcut(ButtonShortcut(propertyValue));

    propertyValue = padProfile.getProperty(Property::StripLeftDown);
    d->ui->leftStripDownSelector->setShortcut(ButtonShortcut(propertyValue));

    propertyValue = padProfile.getProperty(Property::StripRightUp);
    d->ui->rightStripUpSelector->setShortcut(ButtonShortcut(propertyValue));

    propertyValue = padProfile.getProperty(Property::StripRightDown);
    d->ui->rightStripDownSelector->setShortcut(ButtonShortcut(propertyValue));
}
示例#10
0
void ButtonPageWidget::saveToProfile()
{
    Q_D( ButtonPageWidget );

    ProfileManagement* profileManagement = &ProfileManagement::instance();
    DeviceProfile      padProfile        = profileManagement->loadDeviceProfile(DeviceType::Pad);

    // save button shortcuts
    ButtonActionSelectorWidget* buttonSelector;

    for (int i = 1 ; i < 11 ; ++i) {
        buttonSelector = this->findChild<ButtonActionSelectorWidget*>(QString::fromLatin1("button%1ActionSelector").arg(i));

        if (buttonSelector && buttonSelector->isEnabled()) {
            padProfile.setButton(i, buttonSelector->getShortcut().toString());
        } else {
            // Make sure only valid buttons are set.
            // If invalid button numbers are set they might overwrite mapped buttons.
            // For instance, if button 4 gets mapped to 9, then setting button 9 will
            // overwrite the value from button 4 unless the device actually has a
            // button 9 which would then in turn have another mapping to another X11
            // button number, e.g. 13.
            padProfile.setButton(i, QString());
        }
    }

    // save strip shortcuts - reset invalid ones - same reasons as above
    QString stripLUp, stripRUp, stripLDown, stripRDown;

    if (d->ui->touchStripGroupBox->isEnabled()) {
        if (d->ui->leftStripWidget->isEnabled()) {
            stripLUp   = d->ui->leftStripUpSelector->getShortcut().toString();
            stripLDown = d->ui->leftStripDownSelector->getShortcut().toString();
        }

        if (d->ui->rightStripWidget->isEnabled()) {
            stripRUp   = d->ui->rightStripUpSelector->getShortcut().toString();
            stripRDown = d->ui->rightStripDownSelector->getShortcut().toString();
        }
    }

    padProfile.setProperty(Property::StripLeftUp,    stripLUp);
    padProfile.setProperty(Property::StripLeftDown,  stripLDown);
    padProfile.setProperty(Property::StripRightUp,   stripRUp);
    padProfile.setProperty(Property::StripRightDown, stripRDown);

    // save wheel and ring shortcuts - reset invalid values - same reasons as above
    QString absWUp, absWDown;

    if (d->ui->touchRingGroupBox->isEnabled() || d->ui->wheelGroupBox->isEnabled()) {
        // ring and wheel shortcuts are treated the same but only one value may be written,
        // as the other one could be empty. Use whichever value we can get our hands on first.
        if (d->ui->ringUpSelector->getShortcut().isSet()) {
            absWUp = d->ui->ringUpSelector->getShortcut().toString();
        } else {
            absWUp = d->ui->wheelUpSelector->getShortcut().toString();
        }

        if (d->ui->ringDownSelector->getShortcut().isSet()) {
            absWDown = d->ui->ringDownSelector->getShortcut().toString();
        } else {
            absWDown = d->ui->wheelDownSelector->getShortcut().toString();
        }
    }

    padProfile.setProperty(Property::AbsWheelUp,    absWUp);
    padProfile.setProperty(Property::AbsWheel2Up,   absWUp);
    padProfile.setProperty(Property::AbsWheelDown,  absWDown);
    padProfile.setProperty(Property::AbsWheel2Down, absWDown);

    // save device profile
    profileManagement->saveDeviceProfile(padProfile);
}
示例#11
0
void CommonTestUtils::assertValues(DeviceProfile& profile, const char* name)
{
    foreach(const DeviceProperty& property, DeviceProperty::list()) {
        QCOMPARE(profile.getProperty(property.id()), property.id().key());
    }