kopia lustrzana https://github.com/PianetaRadio/CatRadio
rodzic
724a3dc356
commit
dfa37bedec
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -14,14 +14,52 @@
|
|||
<string>Setup</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="3" column="0">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_theme">
|
||||
<property name="title">
|
||||
<string>Theme</string>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_themeDefault">
|
||||
<property name="text">
|
||||
<string>Default</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_themeDark">
|
||||
<property name="text">
|
||||
<string>Dark</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_peakHold">
|
||||
<property name="text">
|
||||
<string>Meter Peak hold</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
|
@ -50,7 +88,7 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="3" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
|
@ -63,30 +101,14 @@
|
|||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_theme">
|
||||
<property name="title">
|
||||
<string>Theme</string>
|
||||
<item row="4" column="0">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_themeDefault">
|
||||
<property name="text">
|
||||
<string>Default</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_themeDark">
|
||||
<property name="text">
|
||||
<string>Dark</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
60
smeter.cpp
60
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;
|
||||
}
|
||||
|
|
6
smeter.h
6
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
|
||||
|
|
Ładowanie…
Reference in New Issue