File tree 1 file changed +24
-0
lines changed
1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 5
5
6
6
#include < QScrollBar>
7
7
8
+ #include < QClipboard>
9
+ #include < QGuiApplication>
10
+
8
11
namespace Ripes {
9
12
10
13
Console::Console (QWidget *parent) : QPlainTextEdit(parent) {
@@ -70,6 +73,27 @@ void Console::backspace() {
70
73
}
71
74
72
75
void Console::keyPressEvent (QKeyEvent *e) {
76
+ QClipboard *clipboard = QGuiApplication::clipboard ();
77
+
78
+ if (e->modifiers () & Qt::ControlModifier) {
79
+ switch (e->key ()) {
80
+ case Qt::Key_C:
81
+ if (textCursor ().hasSelection ()) {
82
+ clipboard->setText (textCursor ().selectedText ());
83
+ }
84
+ return ;
85
+
86
+ case Qt::Key_V:
87
+ QString clipboardText = clipboard->text ();
88
+ if (!clipboardText.isEmpty ()) {
89
+ m_buffer += clipboardText;
90
+ if (m_localEchoEnabled)
91
+ putData (clipboardText.toUtf8 ());
92
+ }
93
+ return ;
94
+ }
95
+ }
96
+
73
97
switch (e->key ()) {
74
98
case Qt::Key_Left:
75
99
case Qt::Key_Right:
You can’t perform that action at this time.
0 commit comments