Пример #1
0
void AdvanceButtonDialog::insertSlot()
{
    int current = ui->slotListWidget->currentRow();
    int count = ui->slotListWidget->count();

    if (current != (count - 1))
    {
        SimpleKeyGrabberButton *blankButton = new SimpleKeyGrabberButton(this);
        QListWidgetItem *item = new QListWidgetItem();
        ui->slotListWidget->insertItem(current, item);
        item->setData(Qt::UserRole, QVariant::fromValue<SimpleKeyGrabberButton*>(blankButton));
        QHBoxLayout *layout= new QHBoxLayout();
        layout->addWidget(blankButton);
        QWidget *widget = new QWidget();
        widget->setLayout(layout);
        item->setSizeHint(widget->sizeHint());
        ui->slotListWidget->setItemWidget(item, widget);
        ui->slotListWidget->setCurrentItem(item);
        connectButtonEvents(blankButton);
        blankButton->refreshButtonLabel();

        this->button->insertAssignedSlot(0, 0, current);
        updateSlotsScrollArea(0);
    }
}
Пример #2
0
void AdvanceButtonDialog::insertDistanceSlot()
{
    int index = ui->slotListWidget->currentRow();
    SimpleKeyGrabberButton *tempbutton = ui->slotListWidget->currentItem()->data(Qt::UserRole).value<SimpleKeyGrabberButton*>();

    int tempDistance = 0;
    for (int i = 0; i < ui->slotListWidget->count(); i++)
    {
        SimpleKeyGrabberButton *button = ui->slotListWidget->item(i)->data(Qt::UserRole).value<SimpleKeyGrabberButton*>();
        JoyButtonSlot *tempbuttonslot = button->getValue();
        if (tempbuttonslot->getSlotMode() == JoyButtonSlot::JoyDistance)
        {
            tempDistance += tempbuttonslot->getSlotCode();
        }
        else if (tempbuttonslot->getSlotMode() == JoyButtonSlot::JoyCycle)
        {
            tempDistance = 0;
        }
    }

    int testDistance = ui->distanceSpinBox->value();
    if (testDistance + tempDistance <= 100)
    {
        tempbutton->setValue(testDistance, JoyButtonSlot::JoyDistance);

        // Stop all events on JoyButton
        this->button->eventReset();

        this->button->setAssignedSlot(testDistance, 0, index, JoyButtonSlot::JoyDistance);
        updateSlotsScrollArea(testDistance);
    }
}
Пример #3
0
void AdvanceButtonDialog::insertHoldSlot()
{
    SimpleKeyGrabberButton *tempbutton = ui->slotListWidget->currentItem()->data(Qt::UserRole).value<SimpleKeyGrabberButton*>();
    int actionTime = actionTimeConvert();
    if (actionTime > 0)
    {
        tempbutton->setValue(actionTime, JoyButtonSlot::JoyHold);
        updateSlotsScrollArea(actionTime);
    }
}
Пример #4
0
void AdvanceButtonDialog::insertCycleSlot()
{
    int index = ui->slotListWidget->currentRow();
    SimpleKeyGrabberButton *tempbutton = ui->slotListWidget->currentItem()->data(Qt::UserRole).value<SimpleKeyGrabberButton*>();
    tempbutton->setValue(1, JoyButtonSlot::JoyCycle);

    // Stop all events on JoyButton
    this->button->eventReset();

    this->button->setAssignedSlot(1, 0, index, JoyButtonSlot::JoyCycle);
    updateSlotsScrollArea(1);
}
Пример #5
0
void AdvanceButtonDialog::placeNewSlot(JoyButtonSlot *slot)
{
    int index = ui->slotListWidget->currentRow();
    SimpleKeyGrabberButton *tempbutton = ui->slotListWidget->currentItem()->data(Qt::UserRole).value<SimpleKeyGrabberButton*>();
    tempbutton->setValue(slot->getSlotCode(), slot->getSlotCodeAlias(), slot->getSlotMode());

    // Stop all events on JoyButton
    this->button->eventReset();

    this->button->setAssignedSlot(slot->getSlotCode(), slot->getSlotCodeAlias(), index, slot->getSlotMode());
    updateSlotsScrollArea(slot->getSlotCode());
    slot->deleteLater();
}
Пример #6
0
void AdvanceButtonDialog::insertDelaySlot()
{
    int index = ui->slotListWidget->currentRow();
    SimpleKeyGrabberButton *tempbutton = ui->slotListWidget->currentItem()->data(Qt::UserRole).value<SimpleKeyGrabberButton*>();
    int actionTime = actionTimeConvert();
    if (actionTime > 0)
    {
        tempbutton->setValue(actionTime, JoyButtonSlot::JoyDelay);
        // Stop all events on JoyButton
        this->button->eventReset();

        this->button->setAssignedSlot(actionTime, 0, index, JoyButtonSlot::JoyDelay);
        updateSlotsScrollArea(actionTime);
    }
}
Пример #7
0
void AdvanceButtonDialog::updateSelectedSlot(int value)
{
    SimpleKeyGrabberButton *grabbutton = static_cast<SimpleKeyGrabberButton*>(sender());
    JoyButtonSlot *tempbuttonslot = grabbutton->getValue();
    int index = ui->slotListWidget->currentRow();

    // Stop all events on JoyButton
    this->button->eventReset();

    this->button->setAssignedSlot(tempbuttonslot->getSlotCode(),
                                  tempbuttonslot->getSlotCodeAlias(),
                                  index,
                                  tempbuttonslot->getSlotMode());
    updateSlotsScrollArea(value);
}
Пример #8
0
void AdvanceButtonDialog::insertMouseSpeedModSlot()
{
    int index = ui->slotListWidget->currentRow();
    SimpleKeyGrabberButton *tempbutton = ui->slotListWidget->currentItem()->data(Qt::UserRole).value<SimpleKeyGrabberButton*>();
    int tempMouseMod = ui->mouseSpeedModSpinBox->value();
    if (tempMouseMod > 0)
    {
        tempbutton->setValue(tempMouseMod, JoyButtonSlot::JoyMouseSpeedMod);

        // Stop all events on JoyButton
        this->button->eventReset();

        this->button->setAssignedSlot(tempMouseMod, 0, index, JoyButtonSlot::JoyMouseSpeedMod);
        updateSlotsScrollArea(tempMouseMod);
    }
}
Пример #9
0
void AdvanceButtonDialog::placeNewSlot(JoyButtonSlot *slot)
{
    SimpleKeyGrabberButton *tempbutton = ui->slotListWidget->currentItem()->data(Qt::UserRole).value<SimpleKeyGrabberButton*>();
    tempbutton->setValue(slot->getSlotCode(), slot->getSlotMode());
    updateSlotsScrollArea(slot->getSlotCode());
}
Пример #10
0
void AdvanceButtonDialog::insertCycleSlot()
{
    SimpleKeyGrabberButton *tempbutton = ui->slotListWidget->currentItem()->data(Qt::UserRole).value<SimpleKeyGrabberButton*>();
    tempbutton->setValue(1, JoyButtonSlot::JoyCycle);
    updateSlotsScrollArea(1);
}