src/gui_editactions.cpp

changeset 368
436ceec98c4f
parent 360
77f08db90249
child 369
0060d11e4991
equal deleted inserted replaced
367:3745caa5d87d 368:436ceec98c4f
17 */ 17 */
18 18
19 #include <QSpinBox> 19 #include <QSpinBox>
20 #include <QCheckBox> 20 #include <QCheckBox>
21 #include <QBoxLayout> 21 #include <QBoxLayout>
22 #include <QClipboard>
22 23
23 #include "gui.h" 24 #include "gui.h"
24 #include "common.h" 25 #include "common.h"
25 #include "file.h" 26 #include "file.h"
26 #include "colorSelectDialog.h" 27 #include "colorSelectDialog.h"
32 #include "colors.h" 33 #include "colors.h"
33 #include "ui_replcoords.h" 34 #include "ui_replcoords.h"
34 #include "ui_editraw.h" 35 #include "ui_editraw.h"
35 #include "ui_flip.h" 36 #include "ui_flip.h"
36 37
37 vector<str> g_Clipboard;
38
39 cfg (bool, edit_schemanticinline, false); 38 cfg (bool, edit_schemanticinline, false);
40 39
41 // ============================================================================= 40 // =============================================================================
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
43 // ============================================================================= 42 // =============================================================================
44 static int copyToClipboard () { 43 static int copyToClipboard () {
45 vector<LDObject*> objs = g_win->sel (); 44 vector<LDObject*> objs = g_win->sel ();
46 int num = 0; 45 int num = 0;
47 46
48 // Clear the clipboard first. 47 // Clear the clipboard first.
49 g_Clipboard.clear (); 48 qApp->clipboard()->clear();
50 49
51 // Now, copy the contents into the clipboard. 50 // Now, copy the contents into the clipboard.
52 for (LDObject* obj : objs) 51 str data;
53 { 52 for (LDObject* obj : objs) {
54 g_Clipboard << obj->raw (); 53 data += ( obj->raw () + "\n" );
55 ++num; 54 ++num;
56 } 55 }
56
57 qApp->clipboard()->setText( data );
57 58
58 return num; 59 return num;
59 } 60 }
60 61
61 // ============================================================================= 62 // =============================================================================
78 79
79 // ============================================================================= 80 // =============================================================================
80 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 81 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
81 // ============================================================================= 82 // =============================================================================
82 MAKE_ACTION (paste, "Paste", "paste", "Paste clipboard contents.", CTRL (V)) { 83 MAKE_ACTION (paste, "Paste", "paste", "Paste clipboard contents.", CTRL (V)) {
84 const str clipboardText = qApp->clipboard()->text();
83 ulong idx = g_win->getInsertionPoint (); 85 ulong idx = g_win->getInsertionPoint ();
84 g_win->sel ().clear (); 86 g_win->sel ().clear ();
85 int num = 0; 87 int num = 0;
86 88
87 for (str line : g_Clipboard) { 89 for( str line : clipboardText.split( "\n", QString::SkipEmptyParts ))
90 {
88 LDObject* pasted = parseLine (line); 91 LDObject* pasted = parseLine (line);
89 g_curfile->insertObj (idx++, pasted); 92 g_curfile->insertObj (idx++, pasted);
90 g_win->sel () << pasted; 93 g_win->sel () << pasted;
91 g_win->R ()->compileObject (pasted); 94 g_win->R ()->compileObject (pasted);
92 ++num; 95 ++num;

mercurial