Connections tab UI adjustments

This commit is contained in:
GriffinR 2024-07-08 11:44:23 -04:00
parent 7c6b33da1b
commit f1cfc3c78e
8 changed files with 100 additions and 47 deletions

View file

@ -61,6 +61,9 @@
</item>
<item row="3" column="2">
<widget class="QToolButton" name="button_Delete">
<property name="toolTip">
<string>Remove this connection</string>
</property>
<property name="text">
<string>...</string>
</property>
@ -71,13 +74,25 @@
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="NoScrollComboBox" name="comboBox_Direction"/>
<widget class="NoScrollComboBox" name="comboBox_Direction">
<property name="toolTip">
<string>Where the connected map should be positioned relative to the current map</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="NoScrollComboBox" name="comboBox_Map"/>
<widget class="NoScrollComboBox" name="comboBox_Map">
<property name="toolTip">
<string>The name of the map to connect to the current map</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="QSpinBox" name="spinBox_Offset"/>
<widget class="NoScrollSpinBox" name="spinBox_Offset">
<property name="toolTip">
<string>The number of spaces to move the connected map perpendicular to its connected direction</string>
</property>
</widget>
</item>
</layout>
</widget>
@ -87,6 +102,11 @@
<extends>QComboBox</extends>
<header>noscrollcombobox.h</header>
</customwidget>
<customwidget>
<class>NoScrollSpinBox</class>
<extends>QSpinBox</extends>
<header>noscrollspinbox.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../resources/images.qrc"/>

View file

@ -2588,6 +2588,16 @@
<property name="bottomMargin">
<number>4</number>
</property>
<item row="1" column="3">
<widget class="NoScrollComboBox" name="comboBox_DiveMap">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Destination map name when using &lt;span style=&quot; font-weight:600;&quot;&gt;Dive&lt;/span&gt;. If empty, no such connection will exist.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="4">
<spacer name="horizontalSpacer_6">
<property name="orientation">
@ -2601,6 +2611,20 @@
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QToolButton" name="button_OpenEmergeMap">
<property name="toolTip">
<string>Open the selected Emerge Map</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../resources/images.qrc">
<normaloff>:/icons/map_go.ico</normaloff>:/icons/map_go.ico</iconset>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QCheckBox" name="checkBox_MirrorConnections">
<property name="toolTip">
@ -2628,27 +2652,6 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QToolButton" name="button_OpenEmergeMap">
<property name="toolTip">
<string>Open the selected Emerge Map</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../resources/images.qrc">
<normaloff>:/icons/map_go.ico</normaloff>:/icons/map_go.ico</iconset>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_EmergeMap">
<property name="text">
<string>Emerge Map</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_DiveMap">
<property name="text">
@ -2656,16 +2659,6 @@
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="NoScrollComboBox" name="comboBox_DiveMap">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Destination map name when using &lt;span style=&quot; font-weight:600;&quot;&gt;Dive&lt;/span&gt;. If empty, no such connection will exist.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="NoScrollComboBox" name="comboBox_EmergeMap">
<property name="toolTip">
@ -2676,6 +2669,13 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_EmergeMap">
<property name="text">
<string>Emerge Map</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@ -2717,6 +2717,12 @@
</property>
</widget>
<widget class="QFrame" name="frame_EditConnectionsPanel">
<property name="minimumSize">
<size>
<width>230</width>
<height>0</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
@ -2740,6 +2746,9 @@
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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;

View file

@ -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;

View file

@ -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();
}