void AddEditAutoProfileDialog::checkForReservedGUIDs(int index) { QVariant data = ui->devicesComboBox->itemData(index); if (index == 0) { ui->asDefaultCheckBox->setChecked(false); ui->asDefaultCheckBox->setEnabled(false); ui->asDefaultCheckBox->setToolTip(tr("Please use the main default profile selection.")); } else if (!data.isNull()) { InputDevice *device = data.value<InputDevice*>(); if (reservedGUIDs.contains(device->getGUIDString())) { ui->asDefaultCheckBox->setChecked(false); ui->asDefaultCheckBox->setEnabled(false); ui->asDefaultCheckBox->setToolTip(tr("A different profile is already selected as the default for this device.")); } else { ui->asDefaultCheckBox->setEnabled(true); ui->asDefaultCheckBox->setToolTip(tr("Select this profile to be the default loaded for\nthe specified device. The selection will be used instead\nof the all default profile option.")); } } }
void AddEditAutoProfileDialog::saveAutoProfileInformation() { info->setProfileLocation(ui->profileLineEdit->text()); int deviceIndex = ui->devicesComboBox->currentIndex(); if (deviceIndex > 0) { QVariant temp = ui->devicesComboBox->itemData(deviceIndex, Qt::UserRole); // Assume that if the following is not true, the GUID should // not be changed. if (!temp.isNull()) { InputDevice *device = ui->devicesComboBox->itemData(deviceIndex, Qt::UserRole).value<InputDevice*>(); info->setGUID(device->getGUIDString()); info->setDeviceName(device->getSDLName()); } } else { info->setGUID("all"); info->setDeviceName(""); } info->setExe(ui->applicationLineEdit->text()); info->setWindowClass(ui->winClassLineEdit->text()); info->setWindowName(ui->winNameLineEdit->text()); info->setDefaultState(ui->asDefaultCheckBox->isChecked()); //info->setActive(true); }
AddEditAutoProfileDialog::AddEditAutoProfileDialog(AutoProfileInfo *info, AntiMicroSettings *settings, QList<InputDevice*> *devices, QList<QString> &reservedGUIDS, bool edit, QWidget *parent) : QDialog(parent), ui(new Ui::AddEditAutoProfileDialog) { ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); this->info = info; this->settings = settings; this->editForm = edit; this->devices = devices; this->originalGUID = info->getGUID(); this->originalExe = info->getExe(); this->originalWindowClass = info->getWindowClass(); this->originalWindowName = info->getWindowName(); QListIterator<QString> iterGUIDs(reservedGUIDS); while (iterGUIDs.hasNext()) { QString guid = iterGUIDs.next(); if (!this->reservedGUIDs.contains(guid)) { this->reservedGUIDs.append(guid); } } bool allowDefault = false; if (info->getGUID() != "all" && info->getGUID() != "" && !this->reservedGUIDs.contains(info->getGUID())) { allowDefault = true; } if (allowDefault && info->getExe().isEmpty()) { ui->asDefaultCheckBox->setEnabled(true); if (info->isCurrentDefault()) { ui->asDefaultCheckBox->setChecked(true); } } else { ui->asDefaultCheckBox->setToolTip(tr("A different profile is already selected as the default for this device.")); } //if (!edit) //{ ui->devicesComboBox->addItem("all"); QListIterator<InputDevice*> iter(*devices); int found = -1; int numItems = 1; while (iter.hasNext()) { InputDevice *device = iter.next(); ui->devicesComboBox->addItem(device->getSDLName(), QVariant::fromValue<InputDevice*>(device)); if (device->getGUIDString() == info->getGUID()) { found = numItems; } numItems++; } if (!info->getGUID().isEmpty() && info->getGUID() != "all") { if (found >= 0) { ui->devicesComboBox->setCurrentIndex(found); } else { ui->devicesComboBox->addItem(tr("Current (%1)").arg(info->getDeviceName())); ui->devicesComboBox->setCurrentIndex(ui->devicesComboBox->count()-1); } } //} ui->profileLineEdit->setText(info->getProfileLocation()); ui->applicationLineEdit->setText(info->getExe()); ui->winClassLineEdit->setText(info->getWindowClass()); ui->winNameLineEdit->setText(info->getWindowName()); #ifdef Q_OS_UNIX ui->selectWindowPushButton->setVisible(false); #elif defined(Q_OS_WIN) ui->detectWinPropsSelectWindowPushButton->setVisible(false); ui->winClassLineEdit->setVisible(false); ui->winClassLabel->setVisible(false); //ui->winNameLineEdit->setVisible(false); //ui->winNameLabel->setVisible(false); #endif connect(ui->profileBrowsePushButton, SIGNAL(clicked()), this, SLOT(openProfileBrowseDialog())); connect(ui->applicationPushButton, SIGNAL(clicked()), this, SLOT(openApplicationBrowseDialog())); connect(ui->devicesComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(checkForReservedGUIDs(int))); connect(ui->applicationLineEdit, SIGNAL(textChanged(QString)), this, SLOT(checkForDefaultStatus())); connect(ui->winClassLineEdit, SIGNAL(textChanged(QString)), this, SLOT(checkForDefaultStatus())); connect(ui->winNameLineEdit, SIGNAL(textChanged(QString)), this, SLOT(checkForDefaultStatus())); #if defined(Q_OS_UNIX) connect(ui->detectWinPropsSelectWindowPushButton, SIGNAL(clicked()), this, SLOT(showCaptureHelpWindow())); #elif defined(Q_OS_WIN) connect(ui->selectWindowPushButton, SIGNAL(clicked()), this, SLOT(openWinAppProfileDialog())); #endif connect(this, SIGNAL(accepted()), this, SLOT(saveAutoProfileInformation())); }