Skip to content

Commit

Permalink
split 'samplerateChanged' event handler; remove useless 'this->'
Browse files Browse the repository at this point in the history
Signed-off-by: Martin <Ho-Ro@users.noreply.github.com>
  • Loading branch information
Ho-Ro committed Aug 8, 2023
1 parent db08415 commit 9a3d953
Show file tree
Hide file tree
Showing 10 changed files with 308 additions and 309 deletions.
77 changes: 38 additions & 39 deletions openhantek/src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,18 +279,17 @@ MainWindow::MainWindow( HantekDsoControl *dsoControl, DsoSettings *settings, Exp
} );

// Connect signals to DSO controller and widget
connect( horizontalDock, &HorizontalDock::samplerateChanged, dsoControl, [ dsoControl, this ]() {
dsoControl->setSamplerate( dsoSettings->scope.horizontal.samplerate );
this->dsoWidget->updateSamplerate( dsoSettings->scope.horizontal.samplerate );
} );
connect( horizontalDock, &HorizontalDock::samplerateChanged, dsoControl,
[ dsoControl, this ]() { dsoControl->setSamplerate( dsoSettings->scope.horizontal.samplerate ); } );
connect( horizontalDock, &HorizontalDock::samplerateChanged, dsoWidget,
[ this ]() { dsoWidget->updateSamplerate( dsoSettings->scope.horizontal.samplerate ); } );
connect( horizontalDock, &HorizontalDock::timebaseChanged, triggerDock, &TriggerDock::timebaseChanged );
connect( horizontalDock, &HorizontalDock::timebaseChanged, dsoControl, [ dsoControl, this ]() {
dsoControl->setRecordTime( dsoSettings->scope.horizontal.timebase * DIVS_TIME );
} );
connect( horizontalDock, &HorizontalDock::timebaseChanged, this->dsoWidget,
connect( horizontalDock, &HorizontalDock::timebaseChanged, dsoControl,
[ dsoControl, this ]() { dsoControl->setRecordTime( dsoSettings->scope.horizontal.timebase * DIVS_TIME ); } );
connect( horizontalDock, &HorizontalDock::timebaseChanged, dsoWidget,
[ this ]() { dsoWidget->updateTimebase( dsoSettings->scope.horizontal.timebase ); } );
connect( spectrumDock, &SpectrumDock::frequencybaseChanged, this,
[ this ]( double frequencybase ) { this->dsoWidget->updateFrequencybase( frequencybase ); } );
connect( spectrumDock, &SpectrumDock::frequencybaseChanged, dsoWidget,
[ this ]( double frequencybase ) { dsoWidget->updateFrequencybase( frequencybase ); } );
connect( dsoControl, &HantekDsoControl::samplerateChanged, horizontalDock,
[ this, horizontalDock, spectrumDock ]( double samplerate ) {
// The timebase was set, let's adapt the samplerate accordingly
Expand Down Expand Up @@ -374,22 +373,22 @@ MainWindow::MainWindow( HantekDsoControl *dsoControl, DsoSettings *settings, Exp

// Started/stopped signals from oscilloscope
connect( dsoControl, &HantekDsoControl::showSamplingStatus, this, [ this ]( bool enabled ) {
QSignalBlocker blocker( this->ui->actionSampling );
QSignalBlocker blocker( ui->actionSampling );
if ( enabled ) {
this->ui->actionSampling->setIcon( this->iconPause );
this->ui->actionSampling->setText( tr( "Stop" ) );
this->ui->actionSampling->setStatusTip( tr( "Stop the oscilloscope" ) );
ui->actionSampling->setIcon( iconPause );
ui->actionSampling->setText( tr( "Stop" ) );
ui->actionSampling->setStatusTip( tr( "Stop the oscilloscope" ) );
} else {
this->ui->actionSampling->setIcon( this->iconPlay );
this->ui->actionSampling->setText( tr( "Start" ) );
this->ui->actionSampling->setStatusTip( tr( "Start the oscilloscope" ) );
ui->actionSampling->setIcon( iconPlay );
ui->actionSampling->setText( tr( "Start" ) );
ui->actionSampling->setStatusTip( tr( "Start the oscilloscope" ) );
}
this->ui->actionSampling->setChecked( enabled );
ui->actionSampling->setChecked( enabled );
} );
connect( this->ui->actionSampling, &QAction::triggered, dsoControl, &HantekDsoControl::enableSamplingUI );
this->ui->actionSampling->setChecked( dsoControl->isSamplingUI() );
connect( ui->actionSampling, &QAction::triggered, dsoControl, &HantekDsoControl::enableSamplingUI );
ui->actionSampling->setChecked( dsoControl->isSamplingUI() );

connect( this->ui->actionRefresh, &QAction::triggered, dsoControl, &HantekDsoControl::restartSampling );
connect( ui->actionRefresh, &QAction::triggered, dsoControl, &HantekDsoControl::restartSampling );

connect( dsoControl, &HantekDsoControl::samplerateLimitsChanged, horizontalDock, &HorizontalDock::setSamplerateLimits );
connect( dsoControl, &HantekDsoControl::samplerateSet, horizontalDock, &HorizontalDock::setSamplerateSteps );
Expand All @@ -415,8 +414,8 @@ MainWindow::MainWindow( HantekDsoControl *dsoControl, DsoSettings *settings, Exp
dsoWidget->updateTimebase( dsoSettings->scope.horizontal.timebase );

for ( ChannelID channel = 0; channel < spec->channels; ++channel ) {
this->dsoWidget->updateVoltageUsed( channel, dsoSettings->scope.voltage[ channel ].used );
this->dsoWidget->updateSpectrumUsed( channel, dsoSettings->scope.spectrum[ channel ].used );
dsoWidget->updateVoltageUsed( channel, dsoSettings->scope.voltage[ channel ].used );
dsoWidget->updateSpectrumUsed( channel, dsoSettings->scope.spectrum[ channel ].used );
}
}
} );
Expand Down Expand Up @@ -445,28 +444,28 @@ MainWindow::MainWindow( HantekDsoControl *dsoControl, DsoSettings *settings, Exp
dsoSettings->mainWindowGeometry = saveGeometry();
dsoSettings->mainWindowState = saveState();

DsoConfigDialog *configDialog = new DsoConfigDialog( this->dsoSettings, this );
DsoConfigDialog *configDialog = new DsoConfigDialog( dsoSettings, this );
configDialog->setModal( true );
configDialog->show();
} );

connect( this->ui->actionPhosphor, &QAction::toggled, this, [ this ]( bool enabled ) {
connect( ui->actionPhosphor, &QAction::toggled, this, [ this ]( bool enabled ) {
dsoSettings->view.digitalPhosphor = enabled;

if ( dsoSettings->view.digitalPhosphor )
this->ui->actionPhosphor->setStatusTip( tr( "Disable fading of previous graphs" ) );
ui->actionPhosphor->setStatusTip( tr( "Disable fading of previous graphs" ) );
else
this->ui->actionPhosphor->setStatusTip( tr( "Enable fading of previous graphs" ) );
ui->actionPhosphor->setStatusTip( tr( "Enable fading of previous graphs" ) );
} );
this->ui->actionPhosphor->setChecked( dsoSettings->view.digitalPhosphor );
ui->actionPhosphor->setChecked( dsoSettings->view.digitalPhosphor );

connect( ui->actionHistogram, &QAction::toggled, this, [ this ]( bool enabled ) {
dsoSettings->scope.histogram = enabled;

if ( dsoSettings->scope.histogram )
this->ui->actionHistogram->setStatusTip( tr( "Hide histogram" ) );
ui->actionHistogram->setStatusTip( tr( "Hide histogram" ) );
else
this->ui->actionHistogram->setStatusTip( tr( "Show histogram" ) );
ui->actionHistogram->setStatusTip( tr( "Show histogram" ) );
} );
ui->actionHistogram->setChecked( dsoSettings->scope.histogram );
ui->actionHistogram->setEnabled( scope->horizontal.format == Dso::GraphFormat::TY );
Expand All @@ -475,23 +474,23 @@ MainWindow::MainWindow( HantekDsoControl *dsoControl, DsoSettings *settings, Exp
dsoSettings->view.zoom = enabled;

if ( dsoSettings->view.zoom )
this->ui->actionZoom->setStatusTip( tr( "Hide magnified scope" ) );
ui->actionZoom->setStatusTip( tr( "Hide magnified scope" ) );
else
this->ui->actionZoom->setStatusTip( tr( "Show magnified scope" ) );
ui->actionZoom->setStatusTip( tr( "Show magnified scope" ) );

this->dsoWidget->updateZoom( enabled );
dsoWidget->updateZoom( enabled );
} );
ui->actionZoom->setChecked( dsoSettings->view.zoom );

connect( ui->actionMeasure, &QAction::toggled, this, [ this ]( bool enabled ) {
dsoSettings->view.cursorsVisible = enabled;

if ( dsoSettings->view.cursorsVisible )
this->ui->actionMeasure->setStatusTip( tr( "Hide measurements" ) );
ui->actionMeasure->setStatusTip( tr( "Hide measurements" ) );
else
this->ui->actionMeasure->setStatusTip( tr( "Show measurements" ) );
ui->actionMeasure->setStatusTip( tr( "Show measurements" ) );

this->dsoWidget->updateCursorGrid( enabled );
dsoWidget->updateCursorGrid( enabled );
} );
ui->actionMeasure->setChecked( dsoSettings->view.cursorsVisible );

Expand All @@ -503,11 +502,11 @@ MainWindow::MainWindow( HantekDsoControl *dsoControl, DsoSettings *settings, Exp
[ this ]() { openDocument( FrequencyGeneratorModificationName ); } );

connect( ui->actionAbout, &QAction::triggered, this, [ this ]() {
QString deviceSpec = this->dsoSettings->deviceName == "DEMO"
QString deviceSpec = dsoSettings->deviceName == "DEMO"
? tr( "<p>Demo Mode</p>" )
: tr( "<p>Device: %1 (%2), FW%3</p>" )
.arg( this->dsoSettings->deviceName, this->dsoSettings->deviceID ) // device type, ser. num
.arg( this->dsoSettings->deviceFW, 4, 16,
.arg( dsoSettings->deviceName, dsoSettings->deviceID ) // device type, ser. num
.arg( dsoSettings->deviceFW, 4, 16,
QChar( '0' ) ); // FW version
QMessageBox::about(
this, QString( "%1 (%2)" ).arg( QCoreApplication::applicationName(), VERSION ),
Expand Down
60 changes: 30 additions & 30 deletions openhantek/translations/openhantek_de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1363,12 +1363,12 @@
<translation>Ungültiger Befehl</translation>
</message>
<message>
<location filename="../src/mainwindow.cpp" line="381"/>
<location filename="../src/mainwindow.cpp" line="380"/>
<source>Stop the oscilloscope</source>
<translation>Das Oszilloskop anhalten</translation>
</message>
<message>
<location filename="../src/mainwindow.cpp" line="380"/>
<location filename="../src/mainwindow.cpp" line="379"/>
<source>Stop</source>
<translation>Stop</translation>
</message>
Expand Down Expand Up @@ -1452,23 +1452,23 @@
<translation>Export der aufgenommenen Daten im %1-Format zur weiteren Verarbeitung</translation>
</message>
<message>
<location filename="../src/mainwindow.cpp" line="384"/>
<location filename="../src/mainwindow.cpp" line="383"/>
<source>Start</source>
<translation>Start</translation>
</message>
<message>
<location filename="../src/mainwindow.cpp" line="385"/>
<location filename="../src/mainwindow.cpp" line="384"/>
<source>Start the oscilloscope</source>
<translation>Startet das Oszilloskop</translation>
</message>
<message>
<location filename="../src/mainwindow.cpp" line="406"/>
<location filename="../src/mainwindow.cpp" line="405"/>
<source>Open file</source>
<translation>Datei öffnen</translation>
</message>
<message>
<location filename="../src/mainwindow.cpp" line="406"/>
<location filename="../src/mainwindow.cpp" line="431"/>
<location filename="../src/mainwindow.cpp" line="405"/>
<location filename="../src/mainwindow.cpp" line="430"/>
<source>Settings (*.conf)</source>
<translation>Einstellungen (*.conf)</translation>
</message>
Expand Down Expand Up @@ -1577,67 +1577,67 @@
<translation>Kalibriere Offset</translation>
</message>
<message>
<location filename="../src/mainwindow.cpp" line="431"/>
<location filename="../src/mainwindow.cpp" line="430"/>
<source>Save settings</source>
<translation>Einstellungen speichern</translation>
</message>
<message>
<location filename="../src/mainwindow.cpp" line="457"/>
<location filename="../src/mainwindow.cpp" line="456"/>
<source>Disable fading of previous graphs</source>
<translation>Nachleuchten von vorigen Graphen deaktivieren</translation>
</message>
<message>
<location filename="../src/mainwindow.cpp" line="459"/>
<location filename="../src/mainwindow.cpp" line="458"/>
<source>Enable fading of previous graphs</source>
<translation>Nachleuchten von vorigen Graphen aktivieren</translation>
</message>
<message>
<location filename="../src/mainwindow.cpp" line="467"/>
<location filename="../src/mainwindow.cpp" line="466"/>
<source>Hide histogram</source>
<translation>Histogramm ausblenden</translation>
</message>
<message>
<location filename="../src/mainwindow.cpp" line="469"/>
<location filename="../src/mainwindow.cpp" line="468"/>
<source>Show histogram</source>
<translation>Histogramm einblenden</translation>
</message>
<message>
<location filename="../src/mainwindow.cpp" line="478"/>
<location filename="../src/mainwindow.cpp" line="477"/>
<source>Hide magnified scope</source>
<translation>Vergrößerte Anzeige ausblenden</translation>
</message>
<message>
<location filename="../src/mainwindow.cpp" line="480"/>
<location filename="../src/mainwindow.cpp" line="479"/>
<source>Show magnified scope</source>
<translation>Vergrößerte Anzeige anzeigen</translation>
</message>
<message>
<location filename="../src/mainwindow.cpp" line="490"/>
<location filename="../src/mainwindow.cpp" line="489"/>
<source>Hide measurements</source>
<translation>Messwerte ausblenden</translation>
</message>
<message>
<location filename="../src/mainwindow.cpp" line="492"/>
<location filename="../src/mainwindow.cpp" line="491"/>
<source>Show measurements</source>
<translation>Messwerte anzeigen</translation>
</message>
<message>
<location filename="../src/mainwindow.cpp" line="507"/>
<location filename="../src/mainwindow.cpp" line="506"/>
<source>&lt;p&gt;Demo Mode&lt;/p&gt;</source>
<translation>&lt;p&gt;Demo-Modus&lt;/p&gt;</translation>
</message>
<message>
<location filename="../src/mainwindow.cpp" line="508"/>
<location filename="../src/mainwindow.cpp" line="507"/>
<source>&lt;p&gt;Device: %1 (%2), FW%3&lt;/p&gt;</source>
<translation>&lt;p&gt;Device: %1 (%2), FW%3&lt;/p&gt;</translation>
</message>
<message>
<location filename="../src/mainwindow.cpp" line="514"/>
<location filename="../src/mainwindow.cpp" line="513"/>
<source>&lt;p&gt;Open source software for Hantek6022 USB oscilloscopes&lt;/p&gt;&lt;p&gt;Maintainer: Martin Homuth-Rosemann&lt;/p&gt;&lt;p&gt;Copyright &amp;copy; 2010, 2011 Oliver Haag&lt;/p&gt;&lt;p&gt;Copyright &amp;copy; 2012-%1 OpenHantek community&lt;br/&gt;&lt;a href=&apos;https://github.com/OpenHantek&apos;&gt;https://github.com/OpenHantek&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Open source firmware copyright &amp;copy; 2019-%1 Ho-Ro&lt;br/&gt;&lt;a href=&apos;https://github.com/Ho-Ro/Hantek6022API&apos;&gt;https://github.com/Ho-Ro/Hantek6022API&lt;/a&gt;&lt;/p&gt;</source>
<translation>&lt;p&gt;Open-Source-Software für Hantek6022 USB-Oscilloskope&lt;/p&gt;&lt;p&gt;Betreuer: Martin Homuth-Rosemann&lt;/p&gt;&lt;p&gt;Copyright &amp;copy; 2010, 2011 Oliver Haag&lt;/p&gt;&lt;p&gt;Copyright &amp;copy; 2012-%1 OpenHantek community&lt;br/&gt;&lt;a href=&apos;https://github.com/OpenHantek&apos;&gt;https://github.com/OpenHantek&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Open-Source-Firmware Copyright &amp;copy; 2019-%1 Ho-Ro&lt;br/&gt;&lt;a href=&apos;https://github.com/Ho-Ro/Hantek6022API&apos;&gt;https://github.com/Ho-Ro/Hantek6022API&lt;/a&gt;&lt;/p&gt;</translation>
</message>
<message>
<location filename="../src/mainwindow.cpp" line="525"/>
<location filename="../src/mainwindow.cpp" line="524"/>
<source>&lt;p&gt;Graphic: %1 - GLSL version %2&lt;/p&gt;&lt;p&gt;Qt version: %3&lt;/p&gt;</source>
<translation></translation>
</message>
Expand All @@ -1662,50 +1662,50 @@
<translation type="vanished">&lt;p&gt;Open-Source-Software für Hantek6022 USB Oszilloskope&lt;/p&gt;&lt;p&gt;Copyright &amp;copy; 2010, 2011 Oliver Haag&lt;/p&gt;&lt;p&gt;Copyright &amp;copy; 2012-2020 OpenHantek community&lt;br/&gt;&lt;a href=&apos;https://github.com/OpenHantek&apos;&gt;https://github.com/OpenHantek&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Open-Source-Firmware - Copyright &amp;copy; 2019-2020 Ho-Ro&lt;br/&gt;&lt;a href=&apos;https://github.com/Ho-Ro/Hantek6022API&apos;&gt;https://github.com/Ho-Ro/Hantek6022API&lt;/a&gt;&lt;/p&gt;</translation>
</message>
<message>
<location filename="../src/mainwindow.cpp" line="529"/>
<location filename="../src/mainwindow.cpp" line="528"/>
<source>&lt;p&gt;Running since %1 seconds.&lt;/p&gt;</source>
<translation>&lt;p&gt;Laufzeit %1 Sekunden.&lt;/p&gt;</translation>
</message>
<message>
<location filename="../src/mainwindow.cpp" line="560"/>
<location filename="../src/mainwindow.cpp" line="559"/>
<source>%1: %2</source>
<translation>%1: %2</translation>
</message>
<message>
<location filename="../src/mainwindow.cpp" line="595"/>
<location filename="../src/mainwindow.cpp" line="594"/>
<source>yyyy-MM-dd hh:mm:ss</source>
<translation></translation>
</message>
<message>
<location filename="../src/mainwindow.cpp" line="596"/>
<location filename="../src/mainwindow.cpp" line="595"/>
<source>yyyyMMdd_hhmmss</source>
<translation></translation>
</message>
<message>
<location filename="../src/mainwindow.cpp" line="629"/>
<location filename="../src/mainwindow.cpp" line="643"/>
<location filename="../src/mainwindow.cpp" line="628"/>
<location filename="../src/mainwindow.cpp" line="642"/>
<source>Write error
%1</source>
<translation>Schreibfehler
%1</translation>
</message>
<message>
<location filename="../src/mainwindow.cpp" line="632"/>
<location filename="../src/mainwindow.cpp" line="631"/>
<source>Image (*.png *.jpg)</source>
<translation>Bild (*.png *.jpg)</translation>
</message>
<message>
<location filename="../src/mainwindow.cpp" line="632"/>
<location filename="../src/mainwindow.cpp" line="631"/>
<source>Portable Document Format (*.pdf)</source>
<translation>Portables Dokumentenformat (*.pdf)</translation>
</message>
<message>
<location filename="../src/mainwindow.cpp" line="633"/>
<location filename="../src/mainwindow.cpp" line="632"/>
<source>Save screenshot</source>
<translation>Screenshot speichen</translation>
</message>
<message>
<location filename="../src/mainwindow.cpp" line="666"/>
<location filename="../src/mainwindow.cpp" line="665"/>
<source>Print oscillograph</source>
<translation>Oszillogramm drucken</translation>
</message>
Expand Down
Loading

0 comments on commit 9a3d953

Please sign in to comment.