Fixed message reply dialog to be non-modal

This commit is contained in:
Jordan Sherer 2018-09-11 13:35:29 -04:00
parent fddca6522e
commit 9f25842c79
10 changed files with 90 additions and 45 deletions

View File

@ -306,6 +306,7 @@ set (wsjtx_CXXSRCS
varicode.cpp varicode.cpp
SelfDestructMessageBox.cpp SelfDestructMessageBox.cpp
messagereplydialog.cpp messagereplydialog.cpp
keyeater.cpp
APRSISClient.cpp APRSISClient.cpp
mainwindow.cpp mainwindow.cpp
Configuration.cpp Configuration.cpp

29
keyeater.cpp Normal file
View File

@ -0,0 +1,29 @@
#include "keyeater.h"
bool EscapeKeyPressEater::eventFilter(QObject *obj, QEvent *event){
if (event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
if(keyEvent->key() == Qt::Key_Escape){
return true;
}
}
// standard event processing
return QObject::eventFilter(obj, event);
}
bool EnterKeyPressEater::eventFilter(QObject *obj, QEvent *event){
if (event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
if(keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return){
bool processed = false;
emit this->enterKeyPressed(obj, keyEvent, &processed);
if(processed){
return true;
}
}
}
// standard event processing
return QObject::eventFilter(obj, event);
}

33
keyeater.h Normal file
View File

@ -0,0 +1,33 @@
#ifndef KEYEATER_H
#define KEYEATER_H
#include <QObject>
#include <QKeyEvent>
class EscapeKeyPressEater : public QObject
{
Q_OBJECT
public:
EscapeKeyPressEater(){}
virtual ~EscapeKeyPressEater(){}
protected:
bool eventFilter(QObject *obj, QEvent *event);
};
class EnterKeyPressEater : public QObject
{
Q_OBJECT
public:
EnterKeyPressEater(){}
virtual ~EnterKeyPressEater(){}
protected:
bool eventFilter(QObject *obj, QEvent *event);
public:
Q_SIGNAL void enterKeyPressed(QObject *obj, QKeyEvent *evt, bool *pProcessed);
};
#endif // KEYEATER_H

View File

@ -8182,7 +8182,7 @@ void MainWindow::setXIT(int n, Frequency base)
void MainWindow::qsy(int hzDelta){ void MainWindow::qsy(int hzDelta){
setRig(m_freqNominal + hzDelta); setRig(m_freqNominal + hzDelta);
setFreqOffsetForRestore(1500, false); setFreqOffsetForRestore(m_wideGraph->centerFreq(), false);
} }
void MainWindow::setFreqOffsetForRestore(int freq, bool shouldRestore){ void MainWindow::setFreqOffsetForRestore(int freq, bool shouldRestore){
@ -9729,6 +9729,7 @@ void MainWindow::processAlertReplyForCommand(CommandDetail d, QString from, QStr
QSound::play(wav); QSound::play(wav);
} }
msgBox->setModal(false);
msgBox->show(); msgBox->show();
} }

View File

@ -45,6 +45,7 @@
#include "varicode.h" #include "varicode.h"
#include "MessageClient.hpp" #include "MessageClient.hpp"
#include "APRSISClient.h" #include "APRSISClient.h"
#include "keyeater.h"
#define NUM_JT4_SYMBOLS 206 //(72+31)*2, embedded sync #define NUM_JT4_SYMBOLS 206 //(72+31)*2, embedded sync
#define NUM_JT65_SYMBOLS 126 //63 data + 63 sync #define NUM_JT65_SYMBOLS 126 //63 data + 63 sync
@ -932,47 +933,6 @@ private:
void writeFoxQSO(QString msg); void writeFoxQSO(QString msg);
}; };
class EscapeKeyPressEater : public QObject
{
Q_OBJECT
protected:
bool eventFilter(QObject *obj, QEvent *event){
if (event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
if(keyEvent->key() == Qt::Key_Escape){
return true;
}
}
// standard event processing
return QObject::eventFilter(obj, event);
}
};
class EnterKeyPressEater : public QObject
{
Q_OBJECT
protected:
bool eventFilter(QObject *obj, QEvent *event){
if (event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
if(keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return){
bool processed = false;
emit this->enterKeyPressed(obj, keyEvent, &processed);
if(processed){
return true;
}
}
}
// standard event processing
return QObject::eventFilter(obj, event);
}
public:
Q_SIGNAL void enterKeyPressed(QObject *obj, QKeyEvent *evt, bool *pProcessed);
};
extern int killbyname(const char* progName); extern int killbyname(const char* progName);
extern void getDev(int* numDevices,char hostAPI_DeviceName[][50], extern void getDev(int* numDevices,char hostAPI_DeviceName[][50],
int minChan[], int maxChan[], int minChan[], int maxChan[],

View File

@ -10,6 +10,18 @@ MessageReplyDialog::MessageReplyDialog(QWidget *parent) :
ui(new Ui::MessageReplyDialog) ui(new Ui::MessageReplyDialog)
{ {
ui->setupUi(this); ui->setupUi(this);
auto enterFilter = new EnterKeyPressEater();
connect(enterFilter, &EnterKeyPressEater::enterKeyPressed, this, [this](QObject *, QKeyEvent *, bool *pProcessed){
if(QApplication::keyboardModifiers() & Qt::ShiftModifier){
if(pProcessed) *pProcessed = false;
return;
}
if(pProcessed) *pProcessed = true;
this->accept();
});
ui->textEdit->installEventFilter(enterFilter);
} }
MessageReplyDialog::~MessageReplyDialog() MessageReplyDialog::~MessageReplyDialog()

View File

@ -2,6 +2,7 @@
#define MESSAGEREPLYDIALOG_H #define MESSAGEREPLYDIALOG_H
#include <QDialog> #include <QDialog>
#include "keyeater.h"
namespace Ui { namespace Ui {
class MessageReplyDialog; class MessageReplyDialog;

View File

@ -215,7 +215,7 @@ void WideGraph::on_bppSpinBox_valueChanged(int n) //b
} }
void WideGraph::on_qsyPushButton_clicked(){ void WideGraph::on_qsyPushButton_clicked(){
int hzDelta = rxFreq() - ui->centerSpinBox->value(); int hzDelta = rxFreq() - centerFreq();
emit qsy(hzDelta); emit qsy(hzDelta);
} }
@ -269,6 +269,11 @@ int WideGraph::rxFreq() //rxFr
return ui->widePlot->rxFreq(); return ui->widePlot->rxFreq();
} }
int WideGraph::centerFreq()
{
return ui->centerSpinBox->value();
}
int WideGraph::nStartFreq() //nStartFreq int WideGraph::nStartFreq() //nStartFreq
{ {
return ui->widePlot->startFreq(); return ui->widePlot->startFreq();

View File

@ -29,6 +29,7 @@ public:
void dataSink2(float s[], float df3, int ihsym, int ndiskdata); void dataSink2(float s[], float df3, int ihsym, int ndiskdata);
void setRxFreq(int n); void setRxFreq(int n);
int rxFreq(); int rxFreq();
int centerFreq();
int nStartFreq(); int nStartFreq();
int Fmin(); int Fmin();
int Fmax(); int Fmax();

View File

@ -73,7 +73,8 @@ SOURCES += \
MessageClient.cpp \ MessageClient.cpp \
SelfDestructMessageBox.cpp \ SelfDestructMessageBox.cpp \
APRSISClient.cpp \ APRSISClient.cpp \
messagereplydialog.cpp messagereplydialog.cpp \
keyeater.cpp
HEADERS += qt_helpers.hpp \ HEADERS += qt_helpers.hpp \
pimpl_h.hpp pimpl_impl.hpp \ pimpl_h.hpp pimpl_impl.hpp \
@ -98,7 +99,8 @@ HEADERS += qt_helpers.hpp \
MessageClient.hpp \ MessageClient.hpp \
SelfDestructMessageBox.h \ SelfDestructMessageBox.h \
APRSISClient.h \ APRSISClient.h \
messagereplydialog.h messagereplydialog.h \
keyeater.h
INCLUDEPATH += qmake_only INCLUDEPATH += qmake_only