Upgrade signal/slot connections in Editor

This commit is contained in:
BigBahss 2021-02-14 09:48:50 -05:00 committed by huderlem
parent ef449f6f8d
commit 51dccf7773

View file

@ -316,7 +316,7 @@ void Editor::addNewWildMonGroup(QWidget *window) {
dialog.accept(); dialog.accept();
} }
}); });
connect(&buttonBox, SIGNAL(rejected()), &dialog, SLOT(reject())); connect(&buttonBox, &QDialogButtonBox::rejected, &dialog, &QDialog::reject);
form.addRow(&buttonBox); form.addRow(&buttonBox);
if (dialog.exec() == QDialog::Accepted) { if (dialog.exec() == QDialog::Accepted) {
@ -511,8 +511,8 @@ void Editor::configureEncounterJSON(QWidget *window) {
QDialogButtonBox buttonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, &dialog); QDialogButtonBox buttonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, &dialog);
connect(&buttonBox, SIGNAL(accepted()), &dialog, SLOT(accept())); connect(&buttonBox, &QDialogButtonBox::accepted, &dialog, &QDialog::accept);
connect(&buttonBox, SIGNAL(rejected()), &dialog, SLOT(reject())); connect(&buttonBox, &QDialogButtonBox::rejected, &dialog, &QDialog::reject);
// lambda: Get a QStringList of the existing field names. // lambda: Get a QStringList of the existing field names.
auto getFieldNames = [&tempFields]() { auto getFieldNames = [&tempFields]() {
@ -552,8 +552,8 @@ void Editor::configureEncounterJSON(QWidget *window) {
QDialog newNameDialog(nullptr, Qt::WindowTitleHint | Qt::WindowCloseButtonHint); QDialog newNameDialog(nullptr, Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
newNameDialog.setWindowModality(Qt::NonModal); newNameDialog.setWindowModality(Qt::NonModal);
QDialogButtonBox newFieldButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, &newNameDialog); QDialogButtonBox newFieldButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, &newNameDialog);
connect(&newFieldButtonBox, SIGNAL(accepted()), &newNameDialog, SLOT(accept())); connect(&newFieldButtonBox, &QDialogButtonBox::accepted, &newNameDialog, &QDialog::accept);
connect(&newFieldButtonBox, SIGNAL(rejected()), &newNameDialog, SLOT(reject())); connect(&newFieldButtonBox, &QDialogButtonBox::rejected, &newNameDialog, &QDialog::reject);
QLineEdit *newNameEdit = new QLineEdit; QLineEdit *newNameEdit = new QLineEdit;
newNameEdit->setClearButtonEnabled(true); newNameEdit->setClearButtonEnabled(true);
@ -1320,12 +1320,12 @@ void Editor::displayMetatileSelector() {
scene_metatiles = new QGraphicsScene; scene_metatiles = new QGraphicsScene;
if (!metatile_selector_item) { if (!metatile_selector_item) {
metatile_selector_item = new MetatileSelector(8, map); metatile_selector_item = new MetatileSelector(8, map);
connect(metatile_selector_item, SIGNAL(hoveredMetatileSelectionChanged(uint16_t)), connect(metatile_selector_item, &MetatileSelector::hoveredMetatileSelectionChanged,
this, SLOT(onHoveredMetatileSelectionChanged(uint16_t))); this, &Editor::onHoveredMetatileSelectionChanged);
connect(metatile_selector_item, SIGNAL(hoveredMetatileSelectionCleared()), connect(metatile_selector_item, &MetatileSelector::hoveredMetatileSelectionCleared,
this, SLOT(onHoveredMetatileSelectionCleared())); this, &Editor::onHoveredMetatileSelectionCleared);
connect(metatile_selector_item, SIGNAL(selectedMetatilesChanged()), connect(metatile_selector_item, &MetatileSelector::selectedMetatilesChanged,
this, SLOT(onSelectedMetatilesChanged())); this, &Editor::onSelectedMetatilesChanged);
metatile_selector_item->select(0); metatile_selector_item->select(0);
} else { } else {
metatile_selector_item->setMap(map); metatile_selector_item->setMap(map);
@ -1337,16 +1337,11 @@ void Editor::displayMetatileSelector() {
void Editor::displayMapMetatiles() { void Editor::displayMapMetatiles() {
map_item = new MapPixmapItem(map, this->metatile_selector_item, this->settings); map_item = new MapPixmapItem(map, this->metatile_selector_item, this->settings);
connect(map_item, SIGNAL(mouseEvent(QGraphicsSceneMouseEvent*,MapPixmapItem*)), connect(map_item, &MapPixmapItem::mouseEvent, this, &Editor::mouseEvent_map);
this, SLOT(mouseEvent_map(QGraphicsSceneMouseEvent*,MapPixmapItem*))); connect(map_item, &MapPixmapItem::startPaint, this, &Editor::onMapStartPaint);
connect(map_item, SIGNAL(startPaint(QGraphicsSceneMouseEvent*,MapPixmapItem*)), connect(map_item, &MapPixmapItem::endPaint, this, &Editor::onMapEndPaint);
this, SLOT(onMapStartPaint(QGraphicsSceneMouseEvent*,MapPixmapItem*))); connect(map_item, &MapPixmapItem::hoveredMapMetatileChanged, this, &Editor::onHoveredMapMetatileChanged);
connect(map_item, SIGNAL(endPaint(QGraphicsSceneMouseEvent*,MapPixmapItem*)), connect(map_item, &MapPixmapItem::hoveredMapMetatileCleared, this, &Editor::onHoveredMapMetatileCleared);
this, SLOT(onMapEndPaint(QGraphicsSceneMouseEvent*,MapPixmapItem*)));
connect(map_item, SIGNAL(hoveredMapMetatileChanged(const QPoint&)),
this, SLOT(onHoveredMapMetatileChanged(const QPoint&)));
connect(map_item, SIGNAL(hoveredMapMetatileCleared()),
this, SLOT(onHoveredMapMetatileCleared()));
map_item->draw(true); map_item->draw(true);
scene->addItem(map_item); scene->addItem(map_item);
@ -1366,13 +1361,13 @@ void Editor::displayMapMovementPermissions() {
scene->removeItem(collision_item); scene->removeItem(collision_item);
delete collision_item; delete collision_item;
} }
collision_item = new CollisionPixmapItem(map, this->movement_permissions_selector_item, this->metatile_selector_item, this->settings, &this->collisionOpacity); collision_item = new CollisionPixmapItem(map, this->movement_permissions_selector_item,
connect(collision_item, SIGNAL(mouseEvent(QGraphicsSceneMouseEvent*,CollisionPixmapItem*)), this->metatile_selector_item, this->settings, &this->collisionOpacity);
this, SLOT(mouseEvent_collision(QGraphicsSceneMouseEvent*,CollisionPixmapItem*))); connect(collision_item, &CollisionPixmapItem::mouseEvent, this, &Editor::mouseEvent_collision);
connect(collision_item, SIGNAL(hoveredMapMovementPermissionChanged(int, int)), connect(collision_item, &CollisionPixmapItem::hoveredMapMovementPermissionChanged,
this, SLOT(onHoveredMapMovementPermissionChanged(int, int))); this, &Editor::onHoveredMapMovementPermissionChanged);
connect(collision_item, SIGNAL(hoveredMapMovementPermissionCleared()), connect(collision_item, &CollisionPixmapItem::hoveredMapMovementPermissionCleared,
this, SLOT(onHoveredMapMovementPermissionCleared())); this, &Editor::onHoveredMapMovementPermissionCleared);
collision_item->draw(true); collision_item->draw(true);
scene->addItem(collision_item); scene->addItem(collision_item);
@ -1389,7 +1384,8 @@ void Editor::displayBorderMetatiles() {
selected_border_metatiles_item->draw(); selected_border_metatiles_item->draw();
scene_selected_border_metatiles->addItem(selected_border_metatiles_item); scene_selected_border_metatiles->addItem(selected_border_metatiles_item);
connect(selected_border_metatiles_item, SIGNAL(borderMetatilesChanged()), this, SLOT(onBorderMetatilesChanged())); connect(selected_border_metatiles_item, &BorderMetatilesPixmapItem::borderMetatilesChanged,
this, &Editor::onBorderMetatilesChanged);
} }
void Editor::displayCurrentMetatilesSelection() { void Editor::displayCurrentMetatilesSelection() {
@ -1421,10 +1417,10 @@ void Editor::displayMovementPermissionSelector() {
scene_collision_metatiles = new QGraphicsScene; scene_collision_metatiles = new QGraphicsScene;
if (!movement_permissions_selector_item) { if (!movement_permissions_selector_item) {
movement_permissions_selector_item = new MovementPermissionsSelector(); movement_permissions_selector_item = new MovementPermissionsSelector();
connect(movement_permissions_selector_item, SIGNAL(hoveredMovementPermissionChanged(uint16_t, uint16_t)), connect(movement_permissions_selector_item, &MovementPermissionsSelector::hoveredMovementPermissionChanged,
this, SLOT(onHoveredMovementPermissionChanged(uint16_t, uint16_t))); this, &Editor::onHoveredMovementPermissionChanged);
connect(movement_permissions_selector_item, SIGNAL(hoveredMovementPermissionCleared()), connect(movement_permissions_selector_item, &MovementPermissionsSelector::hoveredMovementPermissionCleared,
this, SLOT(onHoveredMovementPermissionCleared())); this, &Editor::onHoveredMovementPermissionCleared);
movement_permissions_selector_item->select(0, 3); movement_permissions_selector_item->select(0, 3);
} }
@ -1540,9 +1536,12 @@ void Editor::createConnectionItem(MapConnection* connection, bool hide) {
connection_edit_item->setY(y); connection_edit_item->setY(y);
connection_edit_item->setZValue(-1); connection_edit_item->setZValue(-1);
scene->addItem(connection_edit_item); scene->addItem(connection_edit_item);
connect(connection_edit_item, SIGNAL(connectionMoved(MapConnection*)), this, SLOT(onConnectionMoved(MapConnection*))); connect(connection_edit_item, &ConnectionPixmapItem::connectionMoved,
connect(connection_edit_item, SIGNAL(connectionItemSelected(ConnectionPixmapItem*)), this, SLOT(onConnectionItemSelected(ConnectionPixmapItem*))); this, &Editor::onConnectionMoved);
connect(connection_edit_item, SIGNAL(connectionItemDoubleClicked(ConnectionPixmapItem*)), this, SLOT(onConnectionItemDoubleClicked(ConnectionPixmapItem*))); connect(connection_edit_item, &ConnectionPixmapItem::connectionItemSelected,
this, &Editor::onConnectionItemSelected);
connect(connection_edit_item, &ConnectionPixmapItem::connectionItemDoubleClicked,
this, &Editor::onConnectionItemDoubleClicked);
connection_edit_items.append(connection_edit_item); connection_edit_items.append(connection_edit_item);
} }