Skip to content

Commit

Permalink
Fixing #293 - Pressing Enter saves QSO
Browse files Browse the repository at this point in the history
Enter saves the QSO only if:

1) QSO is started (QSO Time is running)
2) Field RST(s/r) or field from row A or row B is focused
3) Focused field is not a Callsign, POTA, SOTA, WWFT
  • Loading branch information
foldynl committed Dec 18, 2023
1 parent f0e14b3 commit 1dd1a0e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ TBC - 0.31.0
- [NEW] - Main Window - Current profile name is shown (issue #282)
- [NEW] - Import - Details can be saved to file (issue #284)
- [NEW] - Added Simplified Chinese translation (PR #285 thank BG7JAF)
- [NEW] - New Contact - Enter saves QSO if QSO time is running (issue #293 - partial)
- [NEW] - RIG Widget - RIT/XIT are displayed with user-friendly units (issue #294)
- Fixed ADI Import is too slow (issue #270)
- Improved Import/Export Performance
Expand Down
20 changes: 20 additions & 0 deletions ui/NewContactWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include <QMessageBox>
#include <QSqlField>
#include <QTimeZone>
#include <QKeyEvent>

#include "core/Rig.h"
#include "core/Rotator.h"
#include "NewContactWidget.h"
Expand Down Expand Up @@ -215,6 +217,7 @@ NewContactWidget::NewContactWidget(QWidget *parent) :
connect(uiDynamic->wwffEdit, &QLineEdit::textChanged, this, &NewContactWidget::wwffChanged);

ui->rstSentEdit->installEventFilter(this);
ui->rstRcvdEdit->installEventFilter(this);

/**************/
/* SHORTCUTs */
Expand Down Expand Up @@ -1242,6 +1245,21 @@ bool NewContactWidget::eventFilter(QObject *object, QEvent *event)
startContactTimer();
}
}

// Event handle to handle Enter press event for the Custom UI row.
if ( event->type() == QEvent::KeyPress
&& static_cast<QKeyEvent *>(event)
&& ( static_cast<QKeyEvent *>(event)->key() == Qt::Key_Return
|| static_cast<QKeyEvent *>(event)->key() == Qt::Key_Enter )
&& contactTimer->isActive()
&& object != ui->callsignEdit //following fields have a different Enter handling
&& object != uiDynamic->potaEdit
&& object != uiDynamic->sotaEdit
&& object != uiDynamic->wwffEdit )
{
saveContact();
}

return false;
}

Expand Down Expand Up @@ -2259,6 +2277,7 @@ void NewContactWidget::setupCustomUi()
if ( rowItem->widget() != nullptr)
{
qCDebug(runtime) << "Removing widget" << rowItem->widget()->objectName();
rowItem->widget()->removeEventFilter(this); // only row fields has Special Event Filter (enter handling)
rowItem->widget()->setHidden(true);
}
}
Expand Down Expand Up @@ -2337,6 +2356,7 @@ QList<QWidget *> NewContactWidget::setupCustomUiRow(QHBoxLayout *row, const QLis
continue;
}

currCustomWidget->installEventFilter(this); // only row fields have a special event filter (enter handling)
qCDebug(runtime) << "Adding widget" << currCustomWidget->objectName();
row->addWidget(currCustomWidget);
ret << currCustomWidget;
Expand Down

0 comments on commit 1dd1a0e

Please sign in to comment.