diff --git a/forms/connectionslistitem.ui b/forms/connectionslistitem.ui
index 80e6beb5..434c5a29 100644
--- a/forms/connectionslistitem.ui
+++ b/forms/connectionslistitem.ui
@@ -61,6 +61,9 @@
-
+
+ Remove this connection
+
...
@@ -71,13 +74,25 @@
-
-
+
+
+ Where the connected map should be positioned relative to the current map
+
+
-
-
+
+
+ The name of the map to connect to the current map
+
+
-
-
+
+
+ The number of spaces to move the connected map perpendicular to its connected direction
+
+
@@ -87,6 +102,11 @@
QComboBox
+
+ NoScrollSpinBox
+ QSpinBox
+
+
diff --git a/forms/mainwindow.ui b/forms/mainwindow.ui
index c8bd5044..cdb4dcb8 100644
--- a/forms/mainwindow.ui
+++ b/forms/mainwindow.ui
@@ -2588,6 +2588,16 @@
4
+ -
+
+
+ <html><head/><body><p>Destination map name when using <span style=" font-weight:600;">Dive</span>. If empty, no such connection will exist.</p></body></html>
+
+
+ true
+
+
+
-
@@ -2601,6 +2611,20 @@
+ -
+
+
+ Open the selected Emerge Map
+
+
+ ...
+
+
+
+ :/icons/map_go.ico:/icons/map_go.ico
+
+
+
-
@@ -2628,27 +2652,6 @@
- -
-
-
- Open the selected Emerge Map
-
-
- ...
-
-
-
- :/icons/map_go.ico:/icons/map_go.ico
-
-
-
- -
-
-
- Emerge Map
-
-
-
-
@@ -2656,16 +2659,6 @@
- -
-
-
- <html><head/><body><p>Destination map name when using <span style=" font-weight:600;">Dive</span>. If empty, no such connection will exist.</p></body></html>
-
-
- true
-
-
-
-
@@ -2676,6 +2669,13 @@
+ -
+
+
+ Emerge Map
+
+
+
@@ -2717,6 +2717,12 @@
+
+
+ 230
+ 0
+
+
QFrame::StyledPanel
@@ -2740,6 +2746,9 @@
QFrame::NoFrame
+
+ Qt::ScrollBarAlwaysOff
+
true
diff --git a/include/editor.h b/include/editor.h
index 4906a4e1..f9bbe051 100644
--- a/include/editor.h
+++ b/include/editor.h
@@ -78,6 +78,7 @@ public:
void updateConnectionOffset(int offset);
void addNewConnection();
void removeConnection(ConnectionPixmapItem* connectionItem);
+ void removeSelectedConnection();
void addNewWildMonGroup(QWidget *window);
void deleteWildMonGroup();
void updateDiveMap(QString mapName);
diff --git a/include/mainwindow.h b/include/mainwindow.h
index 121fe1cd..16eee651 100644
--- a/include/mainwindow.h
+++ b/include/mainwindow.h
@@ -217,6 +217,7 @@ private slots:
void on_actionMove_triggered();
void on_actionMap_Shift_triggered();
+ void onDeleteKeyPressed();
void on_toolButton_deleteObject_clicked();
void addNewEvent(Event::Type type);
diff --git a/include/ui/connectionslistitem.h b/include/ui/connectionslistitem.h
index 75f7ba5f..ce8a0163 100644
--- a/include/ui/connectionslistitem.h
+++ b/include/ui/connectionslistitem.h
@@ -32,11 +32,13 @@ private:
protected:
void mousePressEvent(QMouseEvent *);
+ void mouseDoubleClickEvent(QMouseEvent *);
signals:
void edited();
- void deleted();
+ void deleteRequested();
void selected();
+ void doubleClicked();
private slots:
void on_comboBox_Direction_currentTextChanged(const QString &direction);
diff --git a/src/editor.cpp b/src/editor.cpp
index 10249363..98dca046 100644
--- a/src/editor.cpp
+++ b/src/editor.cpp
@@ -729,10 +729,12 @@ void Editor::populateConnectionsList() {
ui->comboBox_DiveMap->clear();
ui->comboBox_DiveMap->addItems(project->mapNames);
ui->comboBox_DiveMap->setCurrentText("");
+ ui->comboBox_DiveMap->lineEdit()->setClearButtonEnabled(true);
ui->comboBox_EmergeMap->clear();
ui->comboBox_EmergeMap->addItems(project->mapNames);
ui->comboBox_EmergeMap->setCurrentText("");
+ ui->comboBox_EmergeMap->lineEdit()->setClearButtonEnabled(true);
for (MapConnection* connection : map->connections) {
if (connection->direction == "dive") {
@@ -750,7 +752,6 @@ void Editor::populateConnectionsList() {
addConnectionToList(item);
}
-// TODO: Don't allow splitter resizing to shrink list items to the point where horizontal scroll is needed
void Editor::addConnectionToList(ConnectionPixmapItem * connectionItem) {
ConnectionsListItem *listItem = new ConnectionsListItem(ui->scrollAreaContents_ConnectionsList, connectionItem->connection, project->mapNames);
ui->layout_ConnectionsList->insertWidget(ui->layout_ConnectionsList->count() - 1, listItem); // Insert above the vertical spacer
@@ -758,11 +759,12 @@ void Editor::addConnectionToList(ConnectionPixmapItem * connectionItem) {
// Connect the pixmap item to the list item
connect(connectionItem, &ConnectionPixmapItem::connectionMoved, listItem, &ConnectionsListItem::updateUI);
connect(connectionItem, &ConnectionPixmapItem::highlightChanged, listItem, &ConnectionsListItem::setSelected);
+ connect(connectionItem, &ConnectionPixmapItem::destroyed, listItem, &ConnectionsListItem::deleteLater);
if (connectionItem == selected_connection_item)
listItem->setSelected(true);
- // Connect the list item to the pixmap item
connect(listItem, &ConnectionsListItem::selected, [this, connectionItem] {
+ // When the list item is selected, select the pixmap too
if (connectionItem == selected_connection_item) {
// Already selected, no change
return;
@@ -773,17 +775,23 @@ void Editor::addConnectionToList(ConnectionPixmapItem * connectionItem) {
selected_connection_item->updateHighlight(true);
});
connect(listItem, &ConnectionsListItem::edited, [this, connectionItem] {
+ // When the list item is edited update the pixmap
// TODO: This is probably slower than necessary (we don't need a full redraw if we're just moving it)
// TODO: Handle mirroring
redrawConnection(connectionItem);
emit editedMapData();
});
- connect(listItem, &ConnectionsListItem::deleted, [this, connectionItem] {
+ connect(listItem, &ConnectionsListItem::deleteRequested, [this, connectionItem] {
+ // 'Remove' button has been clicked. Delete the pixmap.
+ // The list item will be deleted via the earlier connection to the pixmap's 'destroyed' signal.
removeConnection(connectionItem);
});
+ connect(listItem, &ConnectionsListItem::doubleClicked, [this, connectionItem] {
+ // Double clicking the list item opens the connected map
+ emit connectionItemDoubleClicked(connectionItem->connection->map_name, map->name);
+ });
}
-// TODO: Connect to Delete key for selected connection
void Editor::removeConnection(ConnectionPixmapItem* connectionItem) {
if (!connectionItem)
return;
@@ -806,6 +814,10 @@ void Editor::removeConnection(ConnectionPixmapItem* connectionItem) {
emit editedMapData();
}
+void Editor::removeSelectedConnection() {
+ removeConnection(selected_connection_item);
+}
+
QPoint Editor::calculateConnectionPosition(const MapConnection *connection, const QPixmap &pixmap) {
int x = 0, y = 0;
const int mWidth = 16, mHeight = 16;
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 77df41fa..7de1c54b 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -150,9 +150,9 @@ void MainWindow::initExtraShortcuts() {
shortcutDuplicate_Events->setWhatsThis("Duplicate Selected Event(s)");
auto *shortcutDelete_Object = new Shortcut(
- {QKeySequence("Del"), QKeySequence("Backspace")}, this, SLOT(on_toolButton_deleteObject_clicked()));
+ {QKeySequence("Del"), QKeySequence("Backspace")}, this, SLOT(onDeleteKeyPressed()));
shortcutDelete_Object->setObjectName("shortcutDelete_Object");
- shortcutDelete_Object->setWhatsThis("Delete Selected Event(s)");
+ shortcutDelete_Object->setWhatsThis("Delete Selected Item(s)");
auto *shortcutToggle_Border = new Shortcut(QKeySequence(), ui->checkBox_ToggleBorder, SLOT(toggle()));
shortcutToggle_Border->setObjectName("shortcutToggle_Border");
@@ -2229,11 +2229,16 @@ void MainWindow::on_horizontalSlider_CollisionTransparency_valueChanged(int valu
this->editor->collision_item->draw(true);
}
-void MainWindow::on_toolButton_deleteObject_clicked() {
- if (ui->mainTabBar->currentIndex() != MainTab::Events) {
- // do not delete an event when not on event tab
- return;
+void MainWindow::onDeleteKeyPressed() {
+ auto tab = ui->mainTabBar->currentIndex();
+ if (tab == MainTab::Events) {
+ on_toolButton_deleteObject_clicked();
+ } else if (tab == MainTab::Connections) {
+ if (editor) editor->removeSelectedConnection();
}
+}
+
+void MainWindow::on_toolButton_deleteObject_clicked() {
if (editor && editor->selected_events) {
if (editor->selected_events->length()) {
DraggablePixmapItem *nextSelectedEvent = nullptr;
diff --git a/src/ui/connectionslistitem.cpp b/src/ui/connectionslistitem.cpp
index 096407b6..b9f456a3 100644
--- a/src/ui/connectionslistitem.cpp
+++ b/src/ui/connectionslistitem.cpp
@@ -57,6 +57,10 @@ void ConnectionsListItem::mousePressEvent(QMouseEvent *) {
this->setSelected(true);
}
+void ConnectionsListItem::mouseDoubleClickEvent(QMouseEvent *) {
+ emit doubleClicked();
+}
+
void ConnectionsListItem::on_comboBox_Direction_currentTextChanged(const QString &direction)
{
this->connection->direction = direction;
@@ -82,6 +86,5 @@ void ConnectionsListItem::on_spinBox_Offset_valueChanged(int offset)
void ConnectionsListItem::on_button_Delete_clicked()
{
- this->deleteLater();
- emit this->deleted();
+ emit this->deleteRequested();
}