From 150c6bf58605e4e4b0aad8ea6a51c1cf64a02d1f Mon Sep 17 00:00:00 2001
From: PianetaRadio <78976006+PianetaRadio@users.noreply.github.com>
Date: Tue, 12 Apr 2022 19:27:46 +0200
Subject: [PATCH] Removed external variable from vfodisplay widget
---
guidata.h | 2 +-
mainwindow.cpp | 7 +++++++
mainwindow.ui | 3 +++
vfodisplay.cpp | 15 +++++++++------
vfodisplay.h | 3 +++
5 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/guidata.h b/guidata.h
index a37c30d..0a794ab 100644
--- a/guidata.h
+++ b/guidata.h
@@ -5,7 +5,7 @@
typedef struct {
- int vfoDisplayMode; //0: use Left/Right mouse button, 1: click digit up or down
+ int vfoDisplayMode; //0: use Left/Right mouse button, 1: click digit Up or Down
} guiConfig;
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 4db431a..49618d1 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -234,6 +234,10 @@ void MainWindow::guiInit()
if (rig_has_set_func(my_rig, RIG_FUNC_TSQL)) ui->comboBox_toneType->addItem("TSQL"); //CTCSS Tx + Rx squelch
if (rig_has_set_func(my_rig, RIG_FUNC_CSQL)) ui->comboBox_toneType->addItem("DCS"); //DCS
+ //* VFO
+ ui->lineEdit_vfoMain->setMode(guiConf.vfoDisplayMode);
+ ui->lineEdit_vfoSub->setMode(guiConf.vfoDisplayMode);
+
//check for targetable sub VFO
if (my_rig->caps->rig_model != 2) //Hamlib 4.4 has bug for rigctld and targetable_vfo, skip check
{
@@ -1111,6 +1115,9 @@ void MainWindow::on_action_Setup_triggered()
DialogSetup setup;
setup.setModal(true);
setup.exec();
+
+ ui->lineEdit_vfoMain->setMode(guiConf.vfoDisplayMode);
+ ui->lineEdit_vfoSub->setMode(guiConf.vfoDisplayMode);
}
void MainWindow::on_action_AboutCatRadio_triggered()
diff --git a/mainwindow.ui b/mainwindow.ui
index fadaa51..d733d9f 100644
--- a/mainwindow.ui
+++ b/mainwindow.ui
@@ -346,6 +346,9 @@
35
+
+ PointingHandCursor
+
diff --git a/vfodisplay.cpp b/vfodisplay.cpp
index c71ab03..17eae0d 100644
--- a/vfodisplay.cpp
+++ b/vfodisplay.cpp
@@ -18,7 +18,6 @@
#include "vfodisplay.h"
-#include "guidata.h"
#include
#include
@@ -27,14 +26,13 @@
#include
-extern guiConfig guiConf;
-
-
vfoDisplay::vfoDisplay(QWidget *parent) : QWidget(parent)
{
lineColor = QColor(Qt::black);
bgColor = QColor(Qt::white);
textColor = QColor(Qt::black);
+
+ vfoDisplayMode = 0;
}
void vfoDisplay::paintEvent(QPaintEvent *)
@@ -103,6 +101,11 @@ void vfoDisplay::setValue(unsigned long value)
update();
}
+void vfoDisplay::setMode(int mode)
+{
+ vfoDisplayMode = mode;
+}
+
//* Tuning using mouse buttons
void vfoDisplay::mousePressEvent(QMouseEvent *event)
{
@@ -114,12 +117,12 @@ void vfoDisplay::mousePressEvent(QMouseEvent *event)
{
if (pointerPos.x() > (width()-3-(textWidth+2)*i+1) && pointerPos.x() < (width()-3-(textWidth+2)*(i-1)-1))
{
- if (guiConf.vfoDisplayMode && event->button() == Qt::LeftButton) //Up/Down mode
+ if (vfoDisplayMode && event->button() == Qt::LeftButton) //Up/Down mode
{
if (pointerPos.y() < height()/2) currentValue = currentValue + pow(10,i); //Up
else if (currentValue - pow(10,i) > 0) currentValue = currentValue - pow(10,i); //Down
}
- else if (!guiConf.vfoDisplayMode) //Left/Right mode
+ else if (!vfoDisplayMode) //Left/Right mode
{
if (event->button() == Qt::LeftButton) currentValue = currentValue + pow(10,i); //LeftButton
else if (currentValue - pow(10,i) > 0) currentValue = currentValue - pow(10,i); //RightButton
diff --git a/vfodisplay.h b/vfodisplay.h
index 9dee447..3006611 100644
--- a/vfodisplay.h
+++ b/vfodisplay.h
@@ -12,6 +12,7 @@ public:
public slots:
void setValue(unsigned long value);
+ void setMode(int mode);
signals:
void on_valueChanged(int value);
@@ -31,6 +32,8 @@ private:
unsigned long currentValue; //current frequency value (Hz)
unsigned long value; //target value
+ int vfoDisplayMode; //0: use Left/Right mouse button, 1: click digit Up or Down
+
int textWidth; //number width
};