@@ -297,6 +297,185 @@ void WorkbenchPage::saveSettings() const
297297 saveAutoReplyRules ();
298298}
299299
300+ void WorkbenchPage::copySessionConfigFrom (const WorkbenchPage &source)
301+ {
302+ refreshPorts ();
303+
304+ const int portIndex = m_portCombo->findData (source.m_portCombo ->currentData ());
305+ if (portIndex >= 0 ) {
306+ m_portCombo->setCurrentIndex (portIndex);
307+ }
308+ m_baudCombo->setCurrentText (source.m_baudCombo ->currentText ());
309+ m_dataBitsCombo->setCurrentText (source.m_dataBitsCombo ->currentText ());
310+ const int parityIndex = m_parityCombo->findData (source.m_parityCombo ->currentData ());
311+ if (parityIndex >= 0 ) {
312+ m_parityCombo->setCurrentIndex (parityIndex);
313+ }
314+ const int stopIndex = m_stopBitsCombo->findData (source.m_stopBitsCombo ->currentData ());
315+ if (stopIndex >= 0 ) {
316+ m_stopBitsCombo->setCurrentIndex (stopIndex);
317+ }
318+ const int flowIndex = m_flowControlCombo->findData (source.m_flowControlCombo ->currentData ());
319+ if (flowIndex >= 0 ) {
320+ m_flowControlCombo->setCurrentIndex (flowIndex);
321+ }
322+ m_rtsCheck->setChecked (source.m_rtsCheck ->isChecked ());
323+ m_dtrCheck->setChecked (source.m_dtrCheck ->isChecked ());
324+ m_autoOpenCheck->setChecked (source.m_autoOpenCheck ->isChecked ());
325+
326+ if (m_displayModeSegment->contains (source.currentDisplayMode ())) {
327+ m_displayModeSegment->setCurrentItem (source.currentDisplayMode ());
328+ }
329+ selectEncodingOption (m_receiveEncodingCombo, source.receiveEncodingKey ());
330+ {
331+ const QSignalBlocker blocker (m_saveReceiveCheck);
332+ m_saveReceiveCheck->setChecked (source.m_saveReceiveCheck ->isChecked ());
333+ }
334+ closeReceiveCapture ();
335+ m_autoScrollCheck->setChecked (source.m_autoScrollCheck ->isChecked ());
336+ m_timestampCheck->setChecked (source.m_timestampCheck ->isChecked ());
337+ m_pauseCheck->setChecked (false );
338+ const int frameModeIndex = m_frameModeCombo->findData (source.frameBreakModeKey ());
339+ if (frameModeIndex >= 0 ) {
340+ m_frameModeCombo->setCurrentIndex (frameModeIndex);
341+ }
342+ m_framePatternEdit->setText (source.m_framePatternEdit ->text ());
343+ m_frameFixedLengthSpin->setValue (source.m_frameFixedLengthSpin ->value ());
344+ m_frameBreakIntervalSpin->setValue (source.m_frameBreakIntervalSpin ->value ());
345+ m_autoFrameBreakCheck->setChecked (source.m_autoFrameBreakCheck ->isChecked ());
346+ updateFrameControlState ();
347+
348+ const int autoLogFormatIndex = m_autoLogFormatCombo->findData (source.autoLogFormatKey ());
349+ if (autoLogFormatIndex >= 0 ) {
350+ m_autoLogFormatCombo->setCurrentIndex (autoLogFormatIndex);
351+ }
352+ m_autoLogMaxSizeSpin->setValue (source.m_autoLogMaxSizeSpin ->value ());
353+ {
354+ const QSignalBlocker blocker (m_autoLogCheck);
355+ m_autoLogCheck->setChecked (source.m_autoLogCheck ->isChecked ());
356+ }
357+ resetAutoLogSession ();
358+ updateAutoLogStatus ();
359+
360+ m_hexSendCheck->setChecked (source.m_hexSendCheck ->isChecked ());
361+ m_showTxCheck->setChecked (source.m_showTxCheck ->isChecked ());
362+ m_txColorButton->setColor (source.selectedTxColor ());
363+ m_txColorButton->setEnabled (m_showTxCheck->isChecked ());
364+ m_loopCheck->setChecked (false );
365+ m_autoReconnectCheck->setChecked (source.m_autoReconnectCheck ->isChecked ());
366+ m_loopIntervalSpin->setValue (source.m_loopIntervalSpin ->value ());
367+ selectEncodingOption (m_sendEncodingCombo, source.sendEncodingKey ());
368+ const int checksumAlgorithmIndex = m_checksumAlgorithmCombo->findData (source.checksumAlgorithmKey ());
369+ if (checksumAlgorithmIndex >= 0 ) {
370+ m_checksumAlgorithmCombo->setCurrentIndex (checksumAlgorithmIndex);
371+ }
372+ const int checksumByteOrderIndex =
373+ m_checksumByteOrderCombo->findData (AppChecksum::byteOrderKey (source.checksumByteOrder ()));
374+ if (checksumByteOrderIndex >= 0 ) {
375+ m_checksumByteOrderCombo->setCurrentIndex (checksumByteOrderIndex);
376+ }
377+ m_checksumAppendCheck->setChecked (source.m_checksumAppendCheck ->isChecked ());
378+ const int lineEndingIndex = m_lineEndingCombo->findData (source.selectedLineEndingKey ());
379+ if (lineEndingIndex >= 0 ) {
380+ m_lineEndingCombo->setCurrentIndex (lineEndingIndex);
381+ }
382+
383+ m_sendEdit->setPlainText (source.m_sendEdit ->toPlainText ());
384+ m_sendHistory = source.m_sendHistory ;
385+ updateHistoryCombo ();
386+
387+ m_sendPackets = source.m_sendPackets ;
388+ m_packetGroupEdit->setText (source.m_packetGroupEdit ->text ());
389+ m_packetNameEdit->setText (source.m_packetNameEdit ->text ());
390+ m_packetNoteEdit->setText (source.m_packetNoteEdit ->text ());
391+ m_packetPayloadEdit->setPlainText (source.m_packetPayloadEdit ->toPlainText ());
392+ const int packetModeIndex = m_packetModeCombo->findData (source.m_packetModeCombo ->currentData ());
393+ if (packetModeIndex >= 0 ) {
394+ m_packetModeCombo->setCurrentIndex (packetModeIndex);
395+ }
396+ const int packetLineEndingIndex = m_packetLineEndingCombo->findData (source.m_packetLineEndingCombo ->currentData ());
397+ if (packetLineEndingIndex >= 0 ) {
398+ m_packetLineEndingCombo->setCurrentIndex (packetLineEndingIndex);
399+ }
400+ m_packetEnabledCheck->setChecked (source.m_packetEnabledCheck ->isChecked ());
401+ updatePacketTable ();
402+
403+ const int modbusFunctionIndex = m_modbusFunctionCombo->findData (source.m_modbusFunctionCombo ->currentData ());
404+ if (modbusFunctionIndex >= 0 ) {
405+ m_modbusFunctionCombo->setCurrentIndex (modbusFunctionIndex);
406+ }
407+ m_modbusSlaveSpin->setValue (source.m_modbusSlaveSpin ->value ());
408+ m_modbusAddressSpin->setValue (source.m_modbusAddressSpin ->value ());
409+ m_modbusQuantitySpin->setValue (source.m_modbusQuantitySpin ->value ());
410+ m_modbusValuesEdit->setPlainText (source.m_modbusValuesEdit ->toPlainText ());
411+ updateModbusUi ();
412+
413+ m_macroSteps = source.m_macroSteps ;
414+ m_macroNameEdit->setText (source.m_macroNameEdit ->text ());
415+ m_macroPayloadEdit->setPlainText (source.m_macroPayloadEdit ->toPlainText ());
416+ m_macroExpectedEdit->setText (source.m_macroExpectedEdit ->text ());
417+ const int macroModeIndex = m_macroModeCombo->findData (source.m_macroModeCombo ->currentData ());
418+ if (macroModeIndex >= 0 ) {
419+ m_macroModeCombo->setCurrentIndex (macroModeIndex);
420+ }
421+ const int macroLineEndingIndex = m_macroLineEndingCombo->findData (source.m_macroLineEndingCombo ->currentData ());
422+ if (macroLineEndingIndex >= 0 ) {
423+ m_macroLineEndingCombo->setCurrentIndex (macroLineEndingIndex);
424+ }
425+ const int macroResponseModeIndex =
426+ m_macroResponseModeCombo->findData (source.m_macroResponseModeCombo ->currentData ());
427+ if (macroResponseModeIndex >= 0 ) {
428+ m_macroResponseModeCombo->setCurrentIndex (macroResponseModeIndex);
429+ }
430+ m_macroTimeoutSpin->setValue (source.m_macroTimeoutSpin ->value ());
431+ m_macroDelaySpin->setValue (source.m_macroDelaySpin ->value ());
432+ m_macroLoopCountSpin->setValue (source.m_macroLoopCountSpin ->value ());
433+ m_macroAbortOnFailureCheck->setChecked (source.m_macroAbortOnFailureCheck ->isChecked ());
434+ updateMacroTable ();
435+
436+ m_autoReplyRules = source.m_autoReplyRules ;
437+ m_autoReplyNameEdit->setText (source.m_autoReplyNameEdit ->text ());
438+ m_autoReplyPatternEdit->setText (source.m_autoReplyPatternEdit ->text ());
439+ m_autoReplyPayloadEdit->setPlainText (source.m_autoReplyPayloadEdit ->toPlainText ());
440+ const int autoReplyMatchIndex =
441+ m_autoReplyMatchModeCombo->findData (source.m_autoReplyMatchModeCombo ->currentData ());
442+ if (autoReplyMatchIndex >= 0 ) {
443+ m_autoReplyMatchModeCombo->setCurrentIndex (autoReplyMatchIndex);
444+ }
445+ const int autoReplyResponseIndex =
446+ m_autoReplyResponseModeCombo->findData (source.m_autoReplyResponseModeCombo ->currentData ());
447+ if (autoReplyResponseIndex >= 0 ) {
448+ m_autoReplyResponseModeCombo->setCurrentIndex (autoReplyResponseIndex);
449+ }
450+ const int autoReplyLineEndingIndex =
451+ m_autoReplyLineEndingCombo->findData (source.m_autoReplyLineEndingCombo ->currentData ());
452+ if (autoReplyLineEndingIndex >= 0 ) {
453+ m_autoReplyLineEndingCombo->setCurrentIndex (autoReplyLineEndingIndex);
454+ }
455+ m_autoReplyDelaySpin->setValue (source.m_autoReplyDelaySpin ->value ());
456+ m_autoReplyEnabledCheck->setChecked (source.m_autoReplyEnabledCheck ->isChecked ());
457+ updateAutoReplyTable ();
458+
459+ m_filePathEdit->setText (source.m_filePathEdit ->text ());
460+ m_fileChunkSizeSpin->setValue (source.m_fileChunkSizeSpin ->value ());
461+ m_fileIntervalSpin->setValue (source.m_fileIntervalSpin ->value ());
462+ updateFileSendUi (false );
463+ updateFileProgress ();
464+
465+ m_records.clear ();
466+ m_pendingRecordIndexes.clear ();
467+ m_terminalSearchMatches.clear ();
468+ m_terminalCurrentSearchMatch = -1 ;
469+ m_terminalStartRecord = 0 ;
470+ m_rxCount = 0 ;
471+ m_txCount = 0 ;
472+ m_lastStatsRxCount = 0 ;
473+ m_lastStatsTxCount = 0 ;
474+ m_terminalView->clear ();
475+ updateCounters ();
476+ updateRateStats ();
477+ }
478+
300479void WorkbenchPage::setTerminalFontFamily (const QString &family) { applyTerminalFont (family); }
301480
302481void WorkbenchPage::applyTerminalFont (const QString &family)
0 commit comments