diff --git a/dialogsetup.cpp b/dialogsetup.cpp
index 7b355b4..0f88d4b 100644
--- a/dialogsetup.cpp
+++ b/dialogsetup.cpp
@@ -19,6 +19,7 @@ DialogSetup::DialogSetup(QWidget *parent) :
if (guiConf.vfoDisplayMode) ui->radioButton_vfoDispMode_UD->setChecked(true);
if (guiConf.darkTheme) ui->radioButton_themeDark->setChecked(true);
+ if (guiConf.peakHold) ui->checkBox_peakHold->setChecked(true);
}
DialogSetup::~DialogSetup()
@@ -45,4 +46,5 @@ void DialogSetup::on_buttonBox_accepted()
QSettings configFile(QString("catradio.ini"), QSettings::IniFormat);
configFile.setValue("vfoDisplayMode", guiConf.vfoDisplayMode);
configFile.setValue("darkTheme", guiConf.darkTheme);
+ configFile.setValue("peakHold", guiConf.peakHold);
}
diff --git a/dialogsetup.ui b/dialogsetup.ui
index bc4754c..870cb18 100644
--- a/dialogsetup.ui
+++ b/dialogsetup.ui
@@ -14,14 +14,52 @@
Setup
- -
-
-
- Qt::Horizontal
+
-
+
+
+ Theme
-
- QDialogButtonBox::Cancel|QDialogButtonBox::Ok
+
+
-
+
+
+ Default
+
+
+ true
+
+
+
+ -
+
+
+ Dark
+
+
+
+
+
+
+ -
+
+
+ QFrame::StyledPanel
+
+ QFrame::Raised
+
+
+
-
+
+
+ Meter Peak hold
+
+
+ true
+
+
+
+
-
@@ -50,7 +88,7 @@
- -
+
-
Qt::Vertical
@@ -63,30 +101,14 @@
- -
-
-
- Theme
+
-
+
+
+ Qt::Horizontal
+
+
+ QDialogButtonBox::Cancel|QDialogButtonBox::Ok
-
-
-
-
-
- Default
-
-
- true
-
-
-
- -
-
-
- Dark
-
-
-
-
diff --git a/guidata.h b/guidata.h
index 751958b..903f80f 100644
--- a/guidata.h
+++ b/guidata.h
@@ -7,6 +7,7 @@
typedef struct {
int vfoDisplayMode; //0: use Left/Right mouse button, 1: click digit Up or Down
bool darkTheme; //flag for Dark theme
+ bool peakHold; //meters peak hold
} guiConfig;
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 3e9348d..add55c0 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -120,6 +120,7 @@ MainWindow::MainWindow(QWidget *parent)
rigCom.fullPoll = configFile.value("fullPolling", true).toBool();
guiConf.vfoDisplayMode = configFile.value("vfoDisplayMode", 0).toInt();
guiConf.darkTheme = configFile.value("darkTheme", false).toBool();
+ guiConf.peakHold = configFile.value("peakHold", true).toBool();
//Window settings
restoreGeometry(configFile.value("WindowSettings/geometry").toByteArray());
restoreState(configFile.value("WindowSettings/state").toByteArray());
@@ -161,6 +162,10 @@ MainWindow::MainWindow(QWidget *parent)
}
//Light QFile darkStyleFile(":qdarkstyle/light/lightstyle.qss");
+ //Meter Peak hold
+ ui->progressBar_Smeter->setPeak(guiConf.peakHold);
+ ui->progressBar_Smeter->setPeakFactor(rigCom.rigRefresh/1000.0/2);
+
QApplication::setWheelScrollLines(10); //Mouse wheel scroll step
}
diff --git a/smeter.cpp b/smeter.cpp
index ad26a6b..eb1a5d8 100644
--- a/smeter.cpp
+++ b/smeter.cpp
@@ -36,9 +36,13 @@ SMeter::SMeter(QWidget *parent) : QWidget(parent)
shortStep = 10;
precision = 0;
- meterTx = 0;
+ meterTx = false;
currentValue = -54;
+ peakValue = currentValue;
+ peakFactor = 0.1;
+
+ peakHold = true;
}
void SMeter::paintEvent(QPaintEvent *)
@@ -53,6 +57,7 @@ void SMeter::paintEvent(QPaintEvent *)
drawMeter(&painter);
drawProgress(&painter);
+ if (peakHold) drawPeak(&painter);
drawScaleSMeter(&painter);
drawScalePWRMeter(&painter);
}
@@ -94,6 +99,8 @@ void SMeter::drawProgress(QPainter *painter)
double increment = length / (max - min);
double initX, initXX;
+ if (currentValue>max) currentValue = max;
+
if (currentValue>gate)
{
initX = (gate - min) * increment;
@@ -116,6 +123,47 @@ void SMeter::drawProgress(QPainter *painter)
painter->restore();
}
+void SMeter::drawPeak(QPainter *painter)
+{
+ double max, min;
+
+ painter->save();
+ painter->setPen(Qt::NoPen);
+
+ if (meterTx) //RF power meter
+ {
+ max = maxValue;
+ min = minValue;
+ }
+ else //SMeter
+ {
+ max = 60;
+ min = -54;
+ }
+
+ double length = width()-14;
+ double increment = length / (max - min);
+ double initX;
+
+ if (currentValue>=peakValue) peakValue = currentValue;
+ else peakValue = peakValue - peakFactor*(peakValue - currentValue);
+ if (peakValue>max) peakValue = max;
+
+ if (peakValue>=gateValue) painter->setBrush(QColor(Qt::red));
+ else painter->setBrush(progressColor);
+
+ initX = (peakValue - min) * increment;
+
+ QRect rect(initX - 2, height()/3+2+1, 2, height()/3-4-2);
+ painter->drawRect(rect);
+
+ //QPointF topPot = QPointF(initX, height()/3+2+1);
+ //QPointF bottomPot = QPointF(initX, height()*2/3-2-1);
+ //painter->drawLine(topPot, bottomPot);
+
+ painter->restore();
+}
+
void SMeter::drawScalePWRMeter(QPainter *painter)
{
painter->save();
@@ -338,3 +386,13 @@ void SMeter::setTx(bool Tx)
{
meterTx = Tx;
}
+
+void SMeter::setPeak(bool Peak)
+{
+ peakHold = Peak;
+}
+
+void SMeter::setPeakFactor(double factor)
+{
+ peakFactor = factor;
+}
diff --git a/smeter.h b/smeter.h
index 107c93e..73378bf 100644
--- a/smeter.h
+++ b/smeter.h
@@ -46,11 +46,14 @@ public slots:
void setValue(int value);
void setTx(bool Tx);
+ void setPeak(bool Peak);
+ void setPeakFactor(double factor);
protected:
void paintEvent(QPaintEvent *);
void drawMeter(QPainter *painter);
void drawProgress(QPainter *painter);
+ void drawPeak(QPainter *painter);
void drawScaleSMeter(QPainter *painter);
void drawScalePWRMeter(QPainter *painter);
@@ -64,8 +67,11 @@ private:
double value; //target value
double currentValue; //current value
+ double peakValue; //peak value
+ double peakFactor; //peak factor
bool meterTx; //Switch between SMeter or PowerMeter
+ bool peakHold; //Peak hold
QColor bgColor; //background color
QColor lineColor; //line color