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); } }
void AdvanceButtonDialog::performStatsWidgetRefresh(QListWidgetItem *item) { SimpleKeyGrabberButton *tempbutton = item->data(Qt::UserRole).value<SimpleKeyGrabberButton*>(); JoyButtonSlot *slot = tempbutton->getValue(); if (slot->getSlotMode() == JoyButtonSlot::JoyPause) { refreshTimeComboBoxes(slot); } else if (slot->getSlotMode() == JoyButtonSlot::JoyRelease) { refreshTimeComboBoxes(slot); } else if (slot->getSlotMode() == JoyButtonSlot::JoyHold) { refreshTimeComboBoxes(slot); } else if (slot->getSlotMode() == JoyButtonSlot::JoyKeyPress) { refreshTimeComboBoxes(slot); } else if (slot->getSlotMode() == JoyButtonSlot::JoyDelay) { refreshTimeComboBoxes(slot); } else if (slot->getSlotMode() == JoyButtonSlot::JoyDistance) { disconnect(ui->distanceSpinBox, SIGNAL(valueChanged(int)), this, SLOT(checkSlotDistanceUpdate())); ui->distanceSpinBox->setValue(slot->getSlotCode()); connect(ui->distanceSpinBox, SIGNAL(valueChanged(int)), this, SLOT(checkSlotDistanceUpdate())); }
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); } }
void AdvanceButtonDialog::updateSlotsScrollArea(int value) { int index = ui->slotListWidget->currentRow(); int itemcount = ui->slotListWidget->count(); if (index == (itemcount - 1) && value > 0) { appendBlankKeyGrabber(); } else if (index < (itemcount - 1) && value == 0) { QListWidgetItem *item = ui->slotListWidget->takeItem(index); delete item; item = 0; } this->button->clearSlotsEventReset(); 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->getSlotCode() > 0) { JoyButtonSlot *buttonslot = new JoyButtonSlot(tempbuttonslot->getSlotCode(), tempbuttonslot->getSlotMode()); this->button->setAssignedSlot(buttonslot->getSlotCode(), buttonslot->getSlotMode()); } } changeTurboForSequences(); emit slotsChanged(); }
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); } }
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); }
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(); }
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); } }
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); }
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); } }
void AdvanceButtonDialog::changeTurboForSequences() { bool containsSequences = false; for (int i = 0; i < ui->slotListWidget->count() && !containsSequences; i++) { SimpleKeyGrabberButton *button = ui->slotListWidget->item(i)->data(Qt::UserRole).value<SimpleKeyGrabberButton*>(); JoyButtonSlot *tempbuttonslot = button->getValue(); if (tempbuttonslot->getSlotCode() > 0 && (tempbuttonslot->getSlotMode() == JoyButtonSlot::JoyPause || tempbuttonslot->getSlotMode() == JoyButtonSlot::JoyHold || tempbuttonslot->getSlotMode() == JoyButtonSlot::JoyDistance ) ) { containsSequences = true; } } if (containsSequences) { if (ui->turboCheckbox->isChecked()) { ui->turboCheckbox->setChecked(false); this->button->setUseTurbo(false); emit turboChanged(false); } if (ui->turboCheckbox->isEnabled()) { ui->turboCheckbox->setEnabled(false); emit turboButtonEnabledChange(false); } } else { if (!ui->turboCheckbox->isEnabled()) { ui->turboCheckbox->setEnabled(true); emit turboButtonEnabledChange(true); } } }
AdvanceButtonDialog::AdvanceButtonDialog(JoyButton *button, QWidget *parent) : QDialog(parent, Qt::Dialog), ui(new Ui::AdvanceButtonDialog) { ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); this->button = button; oldRow = 0; if (this->button->getToggleState()) { ui->toggleCheckbox->setChecked(true); } if (this->button->isUsingTurbo()) { ui->turboCheckbox->setChecked(true); ui->turboSlider->setEnabled(true); } int interval = this->button->getTurboInterval() / 10; if (interval < MINIMUMTURBO) { interval = JoyButton::ENABLEDTURBODEFAULT / 10; } ui->turboSlider->setValue(interval); this->changeTurboText(interval); QListIterator<JoyButtonSlot*> iter(*(this->button->getAssignedSlots())); while (iter.hasNext()) { JoyButtonSlot *buttonslot = iter.next(); SimpleKeyGrabberButton *existingCode = new SimpleKeyGrabberButton(this); existingCode->setText(buttonslot->getSlotString()); existingCode->setValue(buttonslot->getSlotCode(), buttonslot->getSlotCodeAlias(), buttonslot->getSlotMode()); QListWidgetItem *item = new QListWidgetItem(); item->setData(Qt::UserRole, QVariant::fromValue<SimpleKeyGrabberButton*>(existingCode)); QHBoxLayout *layout= new QHBoxLayout(); layout->setContentsMargins(10, 0, 10, 0); layout->addWidget(existingCode); QWidget *widget = new QWidget(); widget->setLayout(layout); item->setSizeHint(widget->sizeHint()); ui->slotListWidget->addItem(item); ui->slotListWidget->setItemWidget(item, widget); connectButtonEvents(existingCode); } appendBlankKeyGrabber(); populateSetSelectionComboBox(); if (this->button->getSetSelection() > -1 && this->button->getChangeSetCondition() != JoyButton::SetChangeDisabled) { int selectIndex = (int)this->button->getChangeSetCondition(); selectIndex += this->button->getSetSelection() * 3; if (this->button->getOriginSet() < this->button->getSetSelection()) { selectIndex -= 3; } ui->setSelectionComboBox->setCurrentIndex(selectIndex); } fillTimeComboBoxes(); ui->actionTenthsComboBox->setCurrentIndex(1); updateActionTimeLabel(); changeTurboForSequences(); if (button->isCycleResetActive()) { ui->autoResetCycleCheckBox->setEnabled(true); ui->autoResetCycleCheckBox->setChecked(true); checkCycleResetWidgetStatus(true); } if (button->getCycleResetTime() != 0) { populateAutoResetInterval(); } updateWindowTitleButtonName(); connect(ui->turboCheckbox, SIGNAL(clicked(bool)), ui->turboSlider, SLOT(setEnabled(bool))); connect(ui->turboSlider, SIGNAL(valueChanged(int)), this, SLOT(checkTurboIntervalValue(int))); connect(ui->insertSlotButton, SIGNAL(clicked()), this, SLOT(insertSlot())); connect(ui->deleteSlotButton, SIGNAL(clicked()), this, SLOT(deleteSlot())); connect(ui->clearAllPushButton, SIGNAL(clicked()), this, SLOT(clearAllSlots())); connect(ui->pausePushButton, SIGNAL(clicked()), this, SLOT(insertPauseSlot())); connect(ui->holdPushButton, SIGNAL(clicked()), this, SLOT(insertHoldSlot())); connect(ui->cyclePushButton, SIGNAL(clicked()), this, SLOT(insertCycleSlot())); connect(ui->distancePushButton, SIGNAL(clicked()), this, SLOT(insertDistanceSlot())); connect(ui->releasePushButton, SIGNAL(clicked()), this, SLOT(insertReleaseSlot())); connect(ui->actionHundredthsComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateActionTimeLabel())); connect(ui->actionSecondsComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateActionTimeLabel())); connect(ui->actionMinutesComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateActionTimeLabel())); connect(ui->actionTenthsComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateActionTimeLabel())); connect(ui->toggleCheckbox, SIGNAL(clicked(bool)), button, SLOT(setToggle(bool))); connect(ui->turboCheckbox, SIGNAL(clicked(bool)), this, SLOT(checkTurboSetting(bool))); connect(ui->setSelectionComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateSetSelection())); connect(ui->mouseModPushButton, SIGNAL(clicked()), this, SLOT(insertMouseSpeedModSlot())); connect(ui->slotListWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(performStatsWidgetRefresh(QListWidgetItem*))); connect(ui->actionHundredthsComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(checkSlotTimeUpdate())); connect(ui->actionTenthsComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(checkSlotTimeUpdate())); connect(ui->actionSecondsComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(checkSlotTimeUpdate())); connect(ui->actionMinutesComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(checkSlotTimeUpdate())); connect(ui->distanceSpinBox, SIGNAL(valueChanged(int)), this, SLOT(checkSlotDistanceUpdate())); connect(ui->mouseSpeedModSpinBox, SIGNAL(valueChanged(int)), this, SLOT(checkSlotMouseModUpdate())); connect(ui->pressTimePushButton, SIGNAL(clicked()), this, SLOT(insertKeyPressSlot())); connect(ui->delayPushButton, SIGNAL(clicked()), this, SLOT(insertDelaySlot())); connect(ui->autoResetCycleCheckBox, SIGNAL(clicked(bool)), this, SLOT(checkCycleResetWidgetStatus(bool))); connect(ui->autoResetCycleCheckBox, SIGNAL(clicked(bool)), this, SLOT(setButtonCycleReset(bool))); connect(ui->resetCycleDoubleSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setButtonCycleResetInterval(double))); connect(button, SIGNAL(toggleChanged(bool)), ui->toggleCheckbox, SLOT(setChecked(bool))); connect(button, SIGNAL(turboChanged(bool)), this, SLOT(checkTurboSetting(bool))); }
void AdvanceButtonDialog::placeNewSlot(JoyButtonSlot *slot) { SimpleKeyGrabberButton *tempbutton = ui->slotListWidget->currentItem()->data(Qt::UserRole).value<SimpleKeyGrabberButton*>(); tempbutton->setValue(slot->getSlotCode(), slot->getSlotMode()); updateSlotsScrollArea(slot->getSlotCode()); }
void AdvanceButtonDialog::insertCycleSlot() { SimpleKeyGrabberButton *tempbutton = ui->slotListWidget->currentItem()->data(Qt::UserRole).value<SimpleKeyGrabberButton*>(); tempbutton->setValue(1, JoyButtonSlot::JoyCycle); updateSlotsScrollArea(1); }
AdvanceButtonDialog::AdvanceButtonDialog(JoyButton *button, QWidget *parent) : QDialog(parent, Qt::Window), ui(new Ui::AdvanceButtonDialog) { ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); this->button = button; oldRow = 0; if (this->button->getToggleState()) { ui->toggleCheckbox->setChecked(true); } if (this->button->isUsingTurbo()) { ui->turboCheckbox->setChecked(true); ui->turboSlider->setEnabled(true); } int interval = this->button->getTurboInterval() / 10; if (interval < MINIMUMTURBO) { interval = JoyButton::ENABLEDTURBODEFAULT / 10; } ui->turboSlider->setValue(interval); this->changeTurboText(interval); QListIterator<JoyButtonSlot*> iter(*(this->button->getAssignedSlots())); while (iter.hasNext()) { JoyButtonSlot *buttonslot = iter.next(); SimpleKeyGrabberButton *existingCode = new SimpleKeyGrabberButton(this); existingCode->setText(buttonslot->getSlotString()); existingCode->setValue(buttonslot->getSlotCode(), buttonslot->getSlotMode()); //existingCode->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); connectButtonEvents(existingCode); QListWidgetItem *item = new QListWidgetItem(); ui->slotListWidget->addItem(item); item->setData(Qt::UserRole, QVariant::fromValue<SimpleKeyGrabberButton*>(existingCode)); QHBoxLayout *layout= new QHBoxLayout(); layout->addWidget(existingCode); QWidget *widget = new QWidget(); widget->setLayout(layout); item->setSizeHint(widget->sizeHint()); ui->slotListWidget->setItemWidget(item, widget); } appendBlankKeyGrabber(); if (this->button->getSetSelection() > -1 && this->button->getChangeSetCondition() != JoyButton::SetChangeDisabled) { int offset = (int)this->button->getChangeSetCondition(); ui->setSelectionComboBox->setCurrentIndex((this->button->getSetSelection() * 3) + offset); } if (this->button->getOriginSet() == 0) { ui->setSelectionComboBox->model()->removeRows(1, 3); } else if (this->button->getOriginSet() == 1) { ui->setSelectionComboBox->model()->removeRows(4, 3); } else if (this->button->getOriginSet() == 2) { ui->setSelectionComboBox->model()->removeRows(7, 3); } else if (this->button->getOriginSet() == 3) { ui->setSelectionComboBox->model()->removeRows(10, 3); } else if (this->button->getOriginSet() == 4) { ui->setSelectionComboBox->model()->removeRows(13, 3); } else if (this->button->getOriginSet() == 5) { ui->setSelectionComboBox->model()->removeRows(16, 3); } else if (this->button->getOriginSet() == 6) { ui->setSelectionComboBox->model()->removeRows(19, 3); } else if (this->button->getOriginSet() == 7) { ui->setSelectionComboBox->model()->removeRows(22, 3); } updateActionTimeLabel(); changeTurboForSequences(); setWindowTitle(tr("Advanced").append(": ").append(button->getPartialName())); connect(ui->turboCheckbox, SIGNAL(clicked(bool)), ui->turboSlider, SLOT(setEnabled(bool))); connect(ui->turboSlider, SIGNAL(valueChanged(int)), this, SLOT(checkTurboIntervalValue(int))); connect(ui->insertSlotButton, SIGNAL(clicked()), this, SLOT(insertSlot())); connect(ui->deleteSlotButton, SIGNAL(clicked()), this, SLOT(deleteSlot())); connect(ui->clearAllPushButton, SIGNAL(clicked()), this, SLOT(clearAllSlots())); connect(ui->pausePushButton, SIGNAL(clicked()), this, SLOT(insertPauseSlot())); connect(ui->holdPushButton, SIGNAL(clicked()), this, SLOT(insertHoldSlot())); connect(ui->cyclePushButton, SIGNAL(clicked()), this, SLOT(insertCycleSlot())); connect(ui->distancePushButton, SIGNAL(clicked()), this, SLOT(insertDistanceSlot())); connect(ui->releasePushButton, SIGNAL(clicked()), this, SLOT(insertReleaseSlot())); connect(ui->actionSecondsComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateActionTimeLabel())); connect(ui->actionMillisecondsComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateActionTimeLabel())); connect(ui->toggleCheckbox, SIGNAL(clicked(bool)), button, SLOT(setToggle(bool))); connect(ui->turboCheckbox, SIGNAL(clicked(bool)), this, SLOT(checkTurboSetting(bool))); connect(ui->setSelectionComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateSetSelection())); connect(button, SIGNAL(toggleChanged(bool)), ui->toggleCheckbox, SLOT(setChecked(bool))); connect(button, SIGNAL(turboChanged(bool)), this, SLOT(checkTurboSetting(bool))); }