Added visual strikethrough for transmitted text
This commit is contained in:
		
							parent
							
								
									335b6d13f6
								
							
						
					
					
						commit
						bb91fac20d
					
				| @ -252,6 +252,7 @@ set (wsjtx_CXXSRCS | |||||||
|   main.cpp |   main.cpp | ||||||
|   wsprnet.cpp |   wsprnet.cpp | ||||||
|   WSPRBandHopping.cpp |   WSPRBandHopping.cpp | ||||||
|  |   TransmitTextEdit.cpp | ||||||
|   ) |   ) | ||||||
| 
 | 
 | ||||||
| set (wsjt_CXXSRCS | set (wsjt_CXXSRCS | ||||||
|  | |||||||
							
								
								
									
										53
									
								
								TransmitTextEdit.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								TransmitTextEdit.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,53 @@ | |||||||
|  | #include "TransmitTextEdit.h" | ||||||
|  | 
 | ||||||
|  | #include <QDebug> | ||||||
|  | 
 | ||||||
|  | TransmitTextEdit::TransmitTextEdit(QWidget *parent): | ||||||
|  |     QTextEdit(parent) | ||||||
|  | { | ||||||
|  |     connect(this, &QTextEdit::selectionChanged, this, &TransmitTextEdit::on_selectionChanged); | ||||||
|  |     connect(this, &QTextEdit::cursorPositionChanged, this, &TransmitTextEdit::on_selectionChanged); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void TransmitTextEdit::markCharsSent(int n){ | ||||||
|  |     // update sent display
 | ||||||
|  |     auto c = textCursor(); | ||||||
|  |     c.movePosition(QTextCursor::Start); | ||||||
|  |     c.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, n); | ||||||
|  | 
 | ||||||
|  |     auto ch = c.charFormat(); | ||||||
|  |     ch.setFontStrikeOut(true); | ||||||
|  |     c.mergeCharFormat(ch); | ||||||
|  | 
 | ||||||
|  |     // keep track
 | ||||||
|  |     m_sent = n; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // override
 | ||||||
|  | void TransmitTextEdit::setPlainText(const QString &text){ | ||||||
|  |     QTextEdit::setPlainText(text); | ||||||
|  |     m_sent = 0; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // override
 | ||||||
|  | void TransmitTextEdit::clear(){ | ||||||
|  |     QTextEdit::clear(); | ||||||
|  |     m_sent = 0; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // slot
 | ||||||
|  | void TransmitTextEdit::on_selectionChanged(){ | ||||||
|  |     auto c = textCursor(); | ||||||
|  |     int start = c.selectionStart(); | ||||||
|  |     int end = c.selectionEnd(); | ||||||
|  |     if(end < start){ | ||||||
|  |         int x = end; | ||||||
|  |         end = start; | ||||||
|  |         start = x; | ||||||
|  |     } | ||||||
|  |     qDebug() << "selection" << start << end; | ||||||
|  | 
 | ||||||
|  |     if(start <= m_sent){ | ||||||
|  |         qDebug() << "selection in protected zone" << start << "<=" << m_sent; | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										22
									
								
								TransmitTextEdit.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								TransmitTextEdit.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,22 @@ | |||||||
|  | #ifndef TRANSMITTEXTEDIT_H | ||||||
|  | #define TRANSMITTEXTEDIT_H | ||||||
|  | 
 | ||||||
|  | #include <QTextEdit> | ||||||
|  | 
 | ||||||
|  | class TransmitTextEdit : public QTextEdit | ||||||
|  | { | ||||||
|  | public: | ||||||
|  |     TransmitTextEdit(QWidget *parent); | ||||||
|  | 
 | ||||||
|  |     void markCharsSent(int n); | ||||||
|  |     void setPlainText(const QString &text); | ||||||
|  |     void clear(); | ||||||
|  | 
 | ||||||
|  | public slots: | ||||||
|  |     void on_selectionChanged(); | ||||||
|  | 
 | ||||||
|  | private: | ||||||
|  |     int m_sent; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | #endif // TRANSMITTEXTEDIT_H
 | ||||||
| @ -83,7 +83,8 @@ SOURCES += \ | |||||||
|     Inbox.cpp \ |     Inbox.cpp \ | ||||||
|     messagewindow.cpp \ |     messagewindow.cpp \ | ||||||
|     SpotClient.cpp \ |     SpotClient.cpp \ | ||||||
|     TCPClient.cpp |     TCPClient.cpp \ | ||||||
|  |     TransmitTextEdit.cpp | ||||||
| 
 | 
 | ||||||
| HEADERS  += qt_helpers.hpp \ | HEADERS  += qt_helpers.hpp \ | ||||||
|   pimpl_h.hpp pimpl_impl.hpp \ |   pimpl_h.hpp pimpl_impl.hpp \ | ||||||
| @ -118,7 +119,8 @@ HEADERS  += qt_helpers.hpp \ | |||||||
|     messagewindow.h \ |     messagewindow.h \ | ||||||
|     SpotClient.h \ |     SpotClient.h \ | ||||||
|     TCPClient.h \ |     TCPClient.h \ | ||||||
|     logbook/n3fjp.h |     logbook/n3fjp.h \ | ||||||
|  |     TransmitTextEdit.h | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| INCLUDEPATH += qmake_only | INCLUDEPATH += qmake_only | ||||||
|  | |||||||
| @ -1918,6 +1918,9 @@ void MainWindow::initializeDummyData(){ | |||||||
|     c.setCharFormat(f); |     c.setCharFormat(f); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  |     ui->extFreeTextMsgEdit->setPlainText("HELLO BRAVE NEW WORLD"); | ||||||
|  |     ui->extFreeTextMsgEdit->markCharsSent(6); | ||||||
|  | 
 | ||||||
|     logHeardGraph("KN4CRD", "OH8STN"); |     logHeardGraph("KN4CRD", "OH8STN"); | ||||||
|     logHeardGraph("KN4CRD", "K0OG"); |     logHeardGraph("KN4CRD", "K0OG"); | ||||||
|     logHeardGraph("K0OG", "KN4CRD"); |     logHeardGraph("K0OG", "KN4CRD"); | ||||||
| @ -5397,9 +5400,18 @@ void MainWindow::startTx2() | |||||||
| void MainWindow::stopTx() | void MainWindow::stopTx() | ||||||
| { | { | ||||||
|   Q_EMIT endTransmitMessage (); |   Q_EMIT endTransmitMessage (); | ||||||
|  | 
 | ||||||
|   auto dt = DecodedText(m_currentMessage.trimmed(), m_currentMessageBits, m_nSubMode); |   auto dt = DecodedText(m_currentMessage.trimmed(), m_currentMessageBits, m_nSubMode); | ||||||
|   last_tx_label.setText("Last Tx: " + dt.message()); //m_currentMessage.trimmed());
 |   last_tx_label.setText("Last Tx: " + dt.message()); //m_currentMessage.trimmed());
 | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  |   // start message marker
 | ||||||
|  |   // - keep track of the total message sent so far, and mark it having been sent
 | ||||||
|  |   m_totalTxMessage.append(dt.message()); | ||||||
|  |   ui->extFreeTextMsgEdit->markCharsSent(m_totalTxMessage.length()); | ||||||
|  |   qDebug() << "total sent:\n" << m_totalTxMessage; | ||||||
|  |   // end message marker
 | ||||||
|  | 
 | ||||||
|   m_btxok = false; |   m_btxok = false; | ||||||
|   m_transmitting = false; |   m_transmitting = false; | ||||||
|   g_iptt=0; |   g_iptt=0; | ||||||
| @ -6224,18 +6236,18 @@ QString MainWindow::createMessageTransmitQueue(QString const& text, bool reset){ | |||||||
| 
 | 
 | ||||||
|   auto frames = buildMessageFrames(text); |   auto frames = buildMessageFrames(text); | ||||||
| 
 | 
 | ||||||
|   m_txFrameQueue.append(frames); |  | ||||||
|   m_txFrameCount = frames.length(); |  | ||||||
| 
 |  | ||||||
|   int freq = currentFreqOffset(); |  | ||||||
|   qDebug() << "creating message for freq" << freq; |  | ||||||
| 
 |  | ||||||
|   QStringList lines; |   QStringList lines; | ||||||
|   foreach(auto frame, frames){ |   foreach(auto frame, frames){ | ||||||
|       auto dt = DecodedText(frame.first, frame.second, m_nSubMode); |       auto dt = DecodedText(frame.first, frame.second, m_nSubMode); | ||||||
|       lines.append(dt.message()); |       lines.append(dt.message()); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  |   m_txFrameQueue.append(frames); | ||||||
|  |   m_txFrameCount = frames.length(); | ||||||
|  | 
 | ||||||
|  |   int freq = currentFreqOffset(); | ||||||
|  |   qDebug() << "creating message for freq" << freq; | ||||||
|  | 
 | ||||||
|   // TODO: jsherer - parse outgoing message so we can add it to the inbox as an outgoing message
 |   // TODO: jsherer - parse outgoing message so we can add it to the inbox as an outgoing message
 | ||||||
| 
 | 
 | ||||||
|   auto joined = Varicode::rstrip(lines.join("")); |   auto joined = Varicode::rstrip(lines.join("")); | ||||||
| @ -6265,6 +6277,9 @@ void MainWindow::resetMessageTransmitQueue(){ | |||||||
|   m_txFrameCount = 0; |   m_txFrameCount = 0; | ||||||
|   m_txFrameQueue.clear(); |   m_txFrameQueue.clear(); | ||||||
|   m_txMessageQueue.clear(); |   m_txMessageQueue.clear(); | ||||||
|  | 
 | ||||||
|  |   // reset the total message sent
 | ||||||
|  |   m_totalTxMessage.clear(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| QPair<QString, int> MainWindow::popMessageFrame(){ | QPair<QString, int> MainWindow::popMessageFrame(){ | ||||||
| @ -6382,6 +6397,11 @@ bool MainWindow::prepareNextMessageFrame() | |||||||
|   auto frame = f.first; |   auto frame = f.first; | ||||||
|   auto bits = f.second; |   auto bits = f.second; | ||||||
| 
 | 
 | ||||||
|  |   // append this frame to the total message sent so far
 | ||||||
|  |   // auto dt = DecodedText(frame, bits, m_nSubMode);
 | ||||||
|  |   // m_totalTxMessage.append(dt.message());
 | ||||||
|  |   // qDebug() << "total sent" << m_totalTxMessage;
 | ||||||
|  | 
 | ||||||
|   if(frame.isEmpty()){ |   if(frame.isEmpty()){ | ||||||
|     ui->nextFreeTextMsg->clear(); |     ui->nextFreeTextMsg->clear(); | ||||||
|     updateTxButtonDisplay(); |     updateTxButtonDisplay(); | ||||||
|  | |||||||
| @ -795,6 +795,7 @@ private: | |||||||
|   QString m_txTextDirtyLastText; |   QString m_txTextDirtyLastText; | ||||||
|   QString m_txTextDirtyLastSelectedCall; |   QString m_txTextDirtyLastSelectedCall; | ||||||
|   QString m_lastTxMessage; |   QString m_lastTxMessage; | ||||||
|  |   QString m_totalTxMessage; | ||||||
|   QDateTime m_lastTxTime; |   QDateTime m_lastTxTime; | ||||||
|   int m_timeDeltaMsMMA; |   int m_timeDeltaMsMMA; | ||||||
|   int m_timeDeltaMsMMA_N; |   int m_timeDeltaMsMMA_N; | ||||||
|  | |||||||
| @ -1133,7 +1133,7 @@ background-color:#6699ff; | |||||||
|           <string>Incoming and outgoing messages will appear here.</string> |           <string>Incoming and outgoing messages will appear here.</string> | ||||||
|          </property> |          </property> | ||||||
|         </widget> |         </widget> | ||||||
|         <widget class="QTextEdit" name="extFreeTextMsgEdit"> |         <widget class="TransmitTextEdit" name="extFreeTextMsgEdit"> | ||||||
|          <property name="sizePolicy"> |          <property name="sizePolicy"> | ||||||
|           <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> |           <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> | ||||||
|            <horstretch>4</horstretch> |            <horstretch>4</horstretch> | ||||||
| @ -5848,6 +5848,11 @@ list. The list can be maintained in Settings (F2).</string> | |||||||
|    <extends>QPushButton</extends> |    <extends>QPushButton</extends> | ||||||
|    <header>DoubleClickablePushButton.hpp</header> |    <header>DoubleClickablePushButton.hpp</header> | ||||||
|   </customwidget> |   </customwidget> | ||||||
|  |   <customwidget> | ||||||
|  |    <class>TransmitTextEdit</class> | ||||||
|  |    <extends>QTextEdit</extends> | ||||||
|  |    <header>TransmitTextEdit.h</header> | ||||||
|  |   </customwidget> | ||||||
|  </customwidgets> |  </customwidgets> | ||||||
|  <tabstops> |  <tabstops> | ||||||
|   <tabstop>extFreeTextMsgEdit</tabstop> |   <tabstop>extFreeTextMsgEdit</tabstop> | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Jordan Sherer
						Jordan Sherer