void GeneralCardItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { if (Config.FreeChoose && Qt::RightButton == event->button()) { FreeChooseDialog *general_changer = new FreeChooseDialog(QApplication::focusWidget()); connect(general_changer, SIGNAL(general_chosen(QString)), this, SLOT(changeGeneral(QString))); general_changer->exec(); general_changer->deleteLater(); return; } if (frozen) return; QPointF totalMove = mapToParent(event->pos()) - _m_lastMousePressScenePos; if (totalMove.x() * totalMove.x() + totalMove.y() * totalMove.y() < _S_MOVE_JITTER_TOLERANCE) emit clicked(); else emit released(); if (auto_back) { goBack(true, false); } }
void BanlistDialog::doAddButton() { FreeChooseDialog *chooser = new FreeChooseDialog(this, (list->objectName() == "Pairs")); connect(chooser, SIGNAL(general_chosen(QString)), this, SLOT(addGeneral(QString))); connect(chooser, SIGNAL(pair_chosen(QString, QString)), this, SLOT(addPair(QString, QString))); chooser->exec(); }
void BanlistDialog::doAdd2ndButton() { FreeChooseDialog *chooser = new FreeChooseDialog(this, false); connect(chooser, SIGNAL(general_chosen(QString)), this, SLOT(add2ndGeneral(QString))); chooser->exec(); }
connect(ok, SIGNAL(clicked()), this, SLOT(accept())); connect(this, SIGNAL(accepted()), this, SLOT(save())); QHBoxLayout *hlayout = new QHBoxLayout; hlayout->addStretch(); hlayout->addWidget(add); hlayout->addWidget(remove); hlayout->addWidget(ok); layout->addWidget(list); layout->addLayout(hlayout); setLayout(layout); FreeChooseDialog *chooser = new FreeChooseDialog(this, false); connect(add, SIGNAL(clicked()), chooser, SLOT(exec())); connect(chooser, SIGNAL(general_chosen(QString)), this, SLOT(addGeneral(QString))); } void KOFBanlistDialog::addGeneral(const QString &name){ const General *general = Sanguosha->getGeneral(name); QIcon icon(general->getPixmapPath("tiny")); QString text = Sanguosha->translate(name); QListWidgetItem *item = new QListWidgetItem(icon, text, list); item->setData(Qt::UserRole, name); } void KOFBanlistDialog::removeGeneral(){ int row = list->currentRow(); if(row != -1) delete list->takeItem(row); }