mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-14 16:11:50 -05:00
Add a contextual pop up menu to the wide graph
Initial button added is to set both Tx and Rx offset. Tidied up encapsulation issue in CPlotter class. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@8186 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
parent
0fa78a26c8
commit
f63f46e779
28
plotter.cpp
28
plotter.cpp
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
CPlotter::CPlotter(QWidget *parent) : //CPlotter Constructor
|
CPlotter::CPlotter(QWidget *parent) : //CPlotter Constructor
|
||||||
QFrame {parent},
|
QFrame {parent},
|
||||||
|
m_set_freq_action {new QAction {tr ("&Set Rx && Tx Offset"), this}},
|
||||||
m_bScaleOK {false},
|
m_bScaleOK {false},
|
||||||
m_bReference {false},
|
m_bReference {false},
|
||||||
m_bReference0 {false},
|
m_bReference0 {false},
|
||||||
@ -42,6 +43,19 @@ CPlotter::CPlotter(QWidget *parent) : //CPlotter Constructor
|
|||||||
setAutoFillBackground(false);
|
setAutoFillBackground(false);
|
||||||
setAttribute(Qt::WA_OpaquePaintEvent, false);
|
setAttribute(Qt::WA_OpaquePaintEvent, false);
|
||||||
setAttribute(Qt::WA_NoSystemBackground, true);
|
setAttribute(Qt::WA_NoSystemBackground, true);
|
||||||
|
|
||||||
|
// contextual pop up menu
|
||||||
|
setContextMenuPolicy (Qt::CustomContextMenu);
|
||||||
|
connect (this, &QWidget::customContextMenuRequested, [this] (QPoint const& pos) {
|
||||||
|
QMenu menu {this};
|
||||||
|
menu.addAction (m_set_freq_action);
|
||||||
|
auto const& connection = connect (m_set_freq_action, &QAction::triggered, [this, pos] () {
|
||||||
|
int newFreq = FreqfromX (pos.x ()) + .5;
|
||||||
|
emit setFreq1 (newFreq, newFreq);
|
||||||
|
});
|
||||||
|
menu.exec (mapToGlobal (pos));
|
||||||
|
disconnect (connection);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
CPlotter::~CPlotter() { } // Destructor
|
CPlotter::~CPlotter() { } // Destructor
|
||||||
@ -629,8 +643,9 @@ void CPlotter::setRxFreq (int x) //setRxFreq
|
|||||||
|
|
||||||
int CPlotter::rxFreq() {return m_rxFreq;} //rxFreq
|
int CPlotter::rxFreq() {return m_rxFreq;} //rxFreq
|
||||||
|
|
||||||
void CPlotter::mousePressEvent(QMouseEvent *event) //mousePressEvent
|
void CPlotter::mouseReleaseEvent (QMouseEvent * event)
|
||||||
{
|
{
|
||||||
|
if (Qt::LeftButton == event->button ()) {
|
||||||
int x=event->x();
|
int x=event->x();
|
||||||
if(x<0) x=0;
|
if(x<0) x=0;
|
||||||
if(x>m_Size.width()) x=m_Size.width();
|
if(x>m_Size.width()) x=m_Size.width();
|
||||||
@ -650,14 +665,23 @@ void CPlotter::mousePressEvent(QMouseEvent *event) //mousePressEvent
|
|||||||
int n=1;
|
int n=1;
|
||||||
if(ctrl) n+=100;
|
if(ctrl) n+=100;
|
||||||
emit freezeDecode1(n);
|
emit freezeDecode1(n);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
event->ignore (); // let parent handle
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPlotter::mouseDoubleClickEvent(QMouseEvent *event) //mouse2click
|
void CPlotter::mouseDoubleClickEvent (QMouseEvent * event)
|
||||||
{
|
{
|
||||||
|
if (Qt::LeftButton == event->button ()) {
|
||||||
bool ctrl = (event->modifiers() & Qt::ControlModifier);
|
bool ctrl = (event->modifiers() & Qt::ControlModifier);
|
||||||
int n=2;
|
int n=2;
|
||||||
if(ctrl) n+=100;
|
if(ctrl) n+=100;
|
||||||
emit freezeDecode1(n);
|
emit freezeDecode1(n);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
event->ignore (); // let parent handle
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPlotter::setNsps(int ntrperiod, int nsps) //setNsps
|
void CPlotter::setNsps(int ntrperiod, int nsps) //setNsps
|
||||||
|
20
plotter.h
20
plotter.h
@ -23,9 +23,11 @@
|
|||||||
|
|
||||||
extern bool g_single_decode;
|
extern bool g_single_decode;
|
||||||
|
|
||||||
|
class QAction;
|
||||||
|
|
||||||
class CPlotter : public QFrame
|
class CPlotter : public QFrame
|
||||||
{
|
{
|
||||||
Q_OBJECT;
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CPlotter(QWidget *parent = 0);
|
explicit CPlotter(QWidget *parent = 0);
|
||||||
@ -33,7 +35,6 @@ public:
|
|||||||
|
|
||||||
QSize minimumSizeHint() const;
|
QSize minimumSizeHint() const;
|
||||||
QSize sizeHint() const;
|
QSize sizeHint() const;
|
||||||
bool m_bScaleOK;
|
|
||||||
|
|
||||||
void draw(float swide[], bool bScroll, bool bRed); //Update the waterfall
|
void draw(float swide[], bool bScroll, bool bRed); //Update the waterfall
|
||||||
void SetRunningState(bool running);
|
void SetRunningState(bool running);
|
||||||
@ -84,15 +85,17 @@ public:
|
|||||||
void drawRed(int ia, int ib, float swide[]);
|
void drawRed(int ia, int ib, float swide[]);
|
||||||
void setVHF(bool bVHF);
|
void setVHF(bool bVHF);
|
||||||
void setRedFile(QString fRed);
|
void setRedFile(QString fRed);
|
||||||
|
bool scaleOK () const {return m_bScaleOK;}
|
||||||
signals:
|
signals:
|
||||||
void freezeDecode1(int n);
|
void freezeDecode1(int n);
|
||||||
void setFreq1(int rxFreq, int txFreq);
|
void setFreq1(int rxFreq, int txFreq);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//re-implemented widget event handlers
|
//re-implemented widget event handlers
|
||||||
void paintEvent(QPaintEvent *event);
|
void paintEvent(QPaintEvent *event) override;
|
||||||
void resizeEvent(QResizeEvent* event);
|
void resizeEvent(QResizeEvent* event) override;
|
||||||
|
void mouseReleaseEvent (QMouseEvent * event) override;
|
||||||
|
void mouseDoubleClickEvent (QMouseEvent * event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -100,6 +103,9 @@ private:
|
|||||||
int XfromFreq(float f);
|
int XfromFreq(float f);
|
||||||
float FreqfromX(int x);
|
float FreqfromX(int x);
|
||||||
|
|
||||||
|
QAction * m_set_freq_action;
|
||||||
|
|
||||||
|
bool m_bScaleOK;
|
||||||
bool m_bCurrent;
|
bool m_bCurrent;
|
||||||
bool m_bCumulative;
|
bool m_bCumulative;
|
||||||
bool m_bLinearAvg;
|
bool m_bLinearAvg;
|
||||||
@ -166,10 +172,6 @@ private:
|
|||||||
qint32 m_tol;
|
qint32 m_tol;
|
||||||
|
|
||||||
char m_sutc[6];
|
char m_sutc[6];
|
||||||
|
|
||||||
private slots:
|
|
||||||
void mousePressEvent(QMouseEvent *event);
|
|
||||||
void mouseDoubleClickEvent(QMouseEvent *event);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern QVector<QColor> g_ColorTbl;
|
extern QVector<QColor> g_ColorTbl;
|
||||||
|
@ -322,7 +322,7 @@ void WideGraph::on_spec2dComboBox_currentIndexChanged(const QString &arg1)
|
|||||||
if(arg1=="Reference") {
|
if(arg1=="Reference") {
|
||||||
ui->widePlot->setReference(true);
|
ui->widePlot->setReference(true);
|
||||||
}
|
}
|
||||||
if(ui->widePlot->m_bScaleOK) ui->widePlot->draw(swide,false,false);
|
if(ui->widePlot->scaleOK ()) ui->widePlot->draw(swide,false,false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WideGraph::on_fSplitSpinBox_valueChanged(int n) //fSplit
|
void WideGraph::on_fSplitSpinBox_valueChanged(int n) //fSplit
|
||||||
@ -454,7 +454,7 @@ void WideGraph::on_zeroSlider_valueChanged(int value) //Zero
|
|||||||
void WideGraph::on_gain2dSlider_valueChanged(int value) //Gain2
|
void WideGraph::on_gain2dSlider_valueChanged(int value) //Gain2
|
||||||
{
|
{
|
||||||
ui->widePlot->setPlot2dGain(value);
|
ui->widePlot->setPlot2dGain(value);
|
||||||
if(ui->widePlot->m_bScaleOK) {
|
if(ui->widePlot->scaleOK ()) {
|
||||||
ui->widePlot->draw(swide,false,false);
|
ui->widePlot->draw(swide,false,false);
|
||||||
if(m_mode=="QRA64") ui->widePlot->draw(swide,false,true);
|
if(m_mode=="QRA64") ui->widePlot->draw(swide,false,true);
|
||||||
}
|
}
|
||||||
@ -463,7 +463,7 @@ void WideGraph::on_gain2dSlider_valueChanged(int value) //Gain2
|
|||||||
void WideGraph::on_zero2dSlider_valueChanged(int value) //Zero2
|
void WideGraph::on_zero2dSlider_valueChanged(int value) //Zero2
|
||||||
{
|
{
|
||||||
ui->widePlot->setPlot2dZero(value);
|
ui->widePlot->setPlot2dZero(value);
|
||||||
if(ui->widePlot->m_bScaleOK) {
|
if(ui->widePlot->scaleOK ()) {
|
||||||
ui->widePlot->draw(swide,false,false);
|
ui->widePlot->draw(swide,false,false);
|
||||||
if(m_mode=="QRA64") ui->widePlot->draw(swide,false,true);
|
if(m_mode=="QRA64") ui->widePlot->draw(swide,false,true);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user