Esempio n. 1
0
void screenAdded(QScreen* screen)
{
    screen->setOrientationUpdateMask((Qt::ScreenOrientations)0x0F);
    qDebug("\nscreenAdded %s siblings %d first %s", qPrintable(screen->name()), screen->virtualSiblings().count(),
        (screen->virtualSiblings().isEmpty() ? "none" : qPrintable(screen->virtualSiblings().first()->name())));
    PropertyWatcher *w = new PropertyWatcher(screen, QString::number(i++));
    QLineEdit *siblingsField = new QLineEdit();
    siblingsField->setObjectName("siblings");
    siblingsField->setReadOnly(true);
    w->layout()->insertRow(0, "virtualSiblings", siblingsField);
    updateSiblings(w);

    // This doesn't work.  If the multiple screens are part of
    // a virtual desktop (i.e. they are virtual siblings), then
    // setScreen has no effect, and we need the code below to
    // change the window geometry.  If on the other hand the
    // screens are really separate, so that windows are not
    // portable between them, XCreateWindow needs to have not just
    // a different root Window but also a different Display, in order to
    // put the window on the other screen.  That would require a
    // different QXcbConnection.  So this setScreen call doesn't seem useful.
    //w->windowHandle()->setScreen(screen);

    // But this works as long as the screens are all virtual siblings
    w->show();
    QRect geom = w->geometry();
    geom.moveCenter(screen->geometry().center());
    w->move(geom.topLeft());

    // workaround for the fact that virtualSiblings is not a property,
    // thus there is no change notification:
    // allow the user to update the field manually
    QObject::connect(w, &PropertyWatcher::updatedAllFields, &updateSiblings);
}
Esempio n. 2
0
void screenAdded(QScreen* screen)
{
    screen->setOrientationUpdateMask((Qt::ScreenOrientations)0x0F);
    qDebug("\nscreenAdded %s siblings %d first %s", qPrintable(screen->name()), screen->virtualSiblings().count(),
        (screen->virtualSiblings().isEmpty() ? "none" : qPrintable(screen->virtualSiblings().first()->name())));
    PropertyWatcher *w = new PropertyWatcher(screen, QString::number(i++));
    QLineEdit *siblingsField = new QLineEdit();
    siblingsField->setObjectName("siblings");
    siblingsField->setReadOnly(true);
    w->layout()->insertRow(0, "virtualSiblings", siblingsField);
    updateSiblings(w);

    // Set the screen via QDesktopWidget. This corresponds to setScreen() for the underlying
    // QWindow. This is essential when having separate X screens since the the positioning below is
    // not sufficient to get the windows show up on the desired screen.
    QList<QScreen *> screens = QGuiApplication::screens();
    int screenNumber = screens.indexOf(screen);
    Q_ASSERT(screenNumber >= 0);
    w->setParent(qApp->desktop()->screen(screenNumber));

    w->show();

    // Position the windows so that they end up at the center of the corresponding screen.
    QRect geom = w->geometry();
    geom.setSize(w->sizeHint());
    if (geom.height() > screen->geometry().height())
        geom.setHeight(screen->geometry().height() * 9 / 10);
    geom.moveCenter(screen->geometry().center());
    w->setGeometry(geom);

    props->insert(screen, w);

    // workaround for the fact that virtualSiblings is not a property,
    // thus there is no change notification:
    // allow the user to update the field manually
    QObject::connect(w, &PropertyWatcher::updatedAllFields, &updateSiblings);
}
Esempio n. 3
0
    : BindingConfigurationWidget(settings, bindingType, event->configKey(), parent),
      siblingsList(siblingsList)
{
    ui = new Ui_ToKeyConfig();
    const QString m_bindingSettingsKey = BindingConfigurationWidgetFactory::bindingSettingsKey(event, bindingType);
    ui->setupUi(this);
    connect(ui->cfg_eventtype_keypress, SIGNAL(toggled(bool)), this, SLOT(radioButtonChanged(bool)));
    connect(ui->cfg_eventtype_keyrelease, SIGNAL(toggled(bool)), this, SLOT(radioButtonChanged(bool)));
    connect(ui->cfg_eventtype_keydoubleclick, SIGNAL(toggled(bool)), this, SLOT(radioButtonChanged(bool)));
    connect(ui->cfg_keysymbol, SIGNAL(textChanged(QString)), this, SLOT(stringChanged(QString)));
    ui->cfg_keysymbol->setCompleter(new X11KeySymbolsCompleter(this));
    foreach(const QString keySym, X11KeySymbolsCompleter::keySymbols()) {
        ui->cfg_keysymbol->addItem(keySym, keySym);
    }

    connect(ui->cfg_keysymbol, SIGNAL(editTextChanged(QString)), this, SLOT(updateSiblings(QString)));
    QString eventtype = settings->value(m_bindingSettingsKey.arg("eventtype"), event->label()).toString();
    keySymbol = settings->value(m_bindingSettingsKey.arg("keysymbol")).toString();
    ui->cfg_keysymbol->lineEdit()->setText(keySymbol);
    ui->cfg_eventtype_keypress->setChecked(eventtype=="keypress");
    ui->cfg_eventtype_keyrelease->setChecked(eventtype=="keyrelease");
    ui->cfg_eventtype_keydoubleclick->setChecked(eventtype=="keydoubleclick");
}


void ToKeyConfig::updateSiblings(const QString &text)
{
    foreach(BindingConfigurationWidget *g_sibling, siblingsList->siblings(this)) {
        ToKeyConfig *sibling = (ToKeyConfig*) g_sibling;
        QString siblingKeySymbol = sibling->ui->cfg_keysymbol->lineEdit()->text();
        if((siblingKeySymbol.isEmpty() || siblingKeySymbol == keySymbol) && siblingKeySymbol != text)