summarylogtreecommitdiffstats
path: root/01-add-ctrl_c-button.diff
blob: eddebb329ed3c25e4d5d88ee0db6ac392fa2d8b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
--- cutecom-0.22.0/qcppdialogimpl.cpp
+++ cutecom-0.22.0/qcppdialogimpl.cpp
@@ -101,6 +101,7 @@
 
    connect(m_sendPb, SIGNAL(clicked()), this, SLOT(sendFile()));
    connect(m_sendBreakPb, SIGNAL(clicked()), this, SLOT(sendBreak()));
+   connect(m_ctrlc, SIGNAL(clicked()), this, SLOT(sendCtrlc()));
    connect(m_aboutPb, SIGNAL(clicked()), this, SLOT(showAboutMsg()));
    connect(m_quitPb, SIGNAL(clicked()), this, SLOT(close()));
 
@@ -597,6 +598,15 @@
     }
 }
 
+void QCPPDialogImpl::sendCtrlc()
+{
+    QKeyEvent keyEvent(QEvent::KeyPress,Qt::Key_C, Qt::ControlModifier);
+    QApplication::sendEvent(m_cmdLe, &keyEvent);
+
+    QKeyEvent key_release(QKeyEvent::KeyRelease, Qt::Key_C, Qt::ControlModifier);
+    QApplication::sendEvent(m_cmdLe, &key_release);
+}
+
 void QCPPDialogImpl::killSz()
 {
    if (m_sz==0)
@@ -1008,6 +1018,7 @@
    m_protoPb->setEnabled(true);
    m_closePb->setEnabled(true);
    m_sendBreakPb->setEnabled(true);
+   m_ctrlc->setEnabled(true);
 
    m_cmdLe->setFocus();
 
@@ -1063,6 +1074,7 @@
    m_protoPb->setEnabled(false);
    m_closePb->setEnabled(false);
    m_sendBreakPb->setEnabled(false);
+   m_ctrlc->setEnabled(false);
 
    m_connectPb->setFocus();
 
--- cutecom-0.22.0/cutecommdlg.ui
+++ cutecom-0.22.0/cutecommdlg.ui
@@ -561,6 +561,13 @@
           </widget>
          </item>
          <item>
+          <widget class="QPushButton" name="m_ctrlc">
+           <property name="text">
+            <string>Ctrl+C</string>
+           </property>
+          </widget>
+         </item>
+         <item>
           <spacer>
            <property name="orientation">
             <enum>Qt::Horizontal</enum>
--- cutecom-0.22.0/qcppdialogimpl.h
+++ cutecom-0.22.0/qcppdialogimpl.h
@@ -51,6 +51,7 @@
       void readData(int fd);
       void sendFile();
       void sendBreak();
+      void sendCtrlc();
       void showAboutMsg();
 
       void oldCmdClicked(QListWidgetItem* item);