Skip to content
This repository was archived by the owner on Sep 28, 2020. It is now read-only.

Commit 33d4641

Browse files
first version
1 parent 32578a5 commit 33d4641

8 files changed

Lines changed: 361 additions & 0 deletions

CMakeLists.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
project(ktexteditor_pasteselection)
2+
3+
find_package(KDE4 REQUIRED)
4+
include(KDE4Defaults)
5+
include_directories(${KDE4_INCLUDES} ${QT_INCLUDES})
6+
add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
7+
8+
set(ktexteditor_pasteselection_SRCS pasteselectionplugin.cpp)
9+
10+
kde4_add_plugin(ktexteditor_pasteselection ${ktexteditor_pasteselection_SRCS})
11+
12+
target_link_libraries(ktexteditor_pasteselection ${KDE4_KDEUI_LIBS} ${KDE4_KTEXTEDITOR_LIBS})
13+
14+
install(TARGETS ktexteditor_pasteselection DESTINATION ${PLUGIN_INSTALL_DIR})
15+
16+
install(FILES pasteselectionui.rc DESTINATION ${DATA_INSTALL_DIR}/ktexteditor_pasteselection)
17+
18+
install(FILES ktexteditor_pasteselection.desktop DESTINATION ${SERVICES_INSTALL_DIR})
19+

PasteSelection.kdev4

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[Project]
2+
Manager=KDevCMakeManager
3+
Name=ktexteditor-paste-selection

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
ktexteditor-paste-selection
2+
===========================
3+
4+
Katepart plugin (Kwrite, Kate, Kdevelop, ...) that adds keyboard shortcut for paste selection
5+
6+
7+
Dependencies
8+
------------
9+
10+
Debian and derived:
11+
- kdelibs5-dev
12+
13+
Other distros:
14+
- kdelibs5-devel
15+
16+
17+
Install
18+
-------
19+
20+
```sh
21+
mkdir build
22+
cd build
23+
cmake .. -DCMAKE_INSTALL_PREFIX=$(kde4-config --prefix) -DQT_QMAKE_EXECUTABLE=/usr/bin/qmake-qt4
24+
make
25+
sudo make install
26+
```
27+
28+
or
29+
30+
```sh
31+
mkdir build
32+
cd build
33+
cmake .. -DCMAKE_INSTALL_PREFIX=$(kde4-config --localprefix) -DQT_QMAKE_EXECUTABLE=/usr/bin/qmake-qt4
34+
make
35+
make install
36+
```

ktexteditor_pasteselection.desktop

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
[Desktop Entry]
2+
Type=Service
3+
Comment=PasteSelection
4+
Comment[ast]=PasteSelection
5+
Comment[bg]=PasteSelection
6+
Comment[bs]=PasteSelection
7+
Comment[ca]=PasteSelection
8+
Comment[ca@valencia]=PasteSelection
9+
Comment[cs]=PasteSelection
10+
Comment[da]=PasteSelection
11+
Comment[de]=PasteSelection
12+
Comment[el]=PasteSelection
13+
Comment[en_GB]=PasteSelection
14+
Comment[es]=PasteSelection
15+
Comment[et]=PasteSelection
16+
Comment[fi]=PasteSelection
17+
Comment[fr]=PasteSelection
18+
Comment[ga]=PasteSelection
19+
Comment[gl]=PasteSelection
20+
Comment[hu]=PasteSelection
21+
Comment[it]=PasteSelection
22+
Comment[kk]=PasteSelection
23+
Comment[km]=PasteSelection
24+
Comment[ko]=PasteSelection
25+
Comment[lt]=PasteSelection
26+
Comment[lv]=PasteSelection
27+
Comment[nb]=PasteSelection
28+
Comment[nds]=PasteSelection
29+
Comment[nl]=PasteSelection
30+
Comment[nn]=PasteSelection
31+
Comment[pa]=PasteSelection
32+
Comment[pl]=PasteSelection
33+
Comment[pt]=PasteSelection
34+
Comment[pt_BR]=PasteSelection
35+
Comment[ru]=PasteSelection
36+
Comment[sk]=PasteSelection
37+
Comment[sl]=PasteSelection
38+
Comment[sr]=PasteSelection
39+
Comment[sr@ijekavian]=PasteSelection
40+
Comment[sr@ijekavianlatin]=PasteSelection
41+
Comment[sr@latin]=PasteSelection
42+
Comment[sv]=PasteSelection
43+
Comment[tr]=PasteSelection
44+
Comment[ug]=PasteSelection
45+
Comment[uk]=PasteSelection
46+
Comment[x-test]=xxPasteSelectionxx
47+
Comment[zh_CN]=PasteSelection
48+
Comment[zh_TW]=PasteSelection
49+
Name=PasteSelection
50+
Name[ast]=PasteSelection
51+
Name[bg]=PasteSelection
52+
Name[bs]=PasteSelection
53+
Name[ca]=PasteSelection
54+
Name[ca@valencia]=PasteSelection
55+
Name[cs]=PasteSelection
56+
Name[da]=PasteSelection
57+
Name[de]=PasteSelection
58+
Name[el]=PasteSelection
59+
Name[en_GB]=PasteSelection
60+
Name[eo]=PasteSelection
61+
Name[es]=PasteSelection
62+
Name[et]=PasteSelection
63+
Name[fi]=PasteSelection
64+
Name[fr]=PasteSelection
65+
Name[ga]=PasteSelection
66+
Name[gl]=PasteSelection
67+
Name[hu]=PasteSelection
68+
Name[it]=PasteSelection
69+
Name[ja]=PasteSelection
70+
Name[kk]=PasteSelection
71+
Name[km]=PasteSelection
72+
Name[ko]=PasteSelection
73+
Name[lt]=PasteSelection
74+
Name[lv]=PasteSelection
75+
Name[nb]=PasteSelection
76+
Name[nds]=PasteSelection
77+
Name[nl]=PasteSelection
78+
Name[nn]=PasteSelection
79+
Name[pa]=PasteSelection
80+
Name[pl]=PasteSelection
81+
Name[pt]=PasteSelection
82+
Name[pt_BR]=PasteSelection
83+
Name[ro]=PasteSelection
84+
Name[ru]=PasteSelection
85+
Name[sk]=PasteSelection
86+
Name[sl]=PasteSelection
87+
Name[sq]=PasteSelection
88+
Name[sr]=PasteSelection
89+
Name[sr@ijekavian]=PasteSelection
90+
Name[sr@ijekavianlatin]=PasteSelection
91+
Name[sr@latin]=PasteSelection
92+
Name[sv]=PasteSelection
93+
Name[tr]=PasteSelection
94+
Name[ug]=PasteSelection
95+
Name[uk]=PasteSelection
96+
Name[x-test]=xxPasteSelectionxx
97+
Name[zh_CN]=PasteSelection
98+
Name[zh_TW]=PasteSelection
99+
GenericName=PasteSelection
100+
GenericName[ast]=PasteSelection
101+
GenericName[bg]=PasteSelection
102+
GenericName[bs]=PasteSelection
103+
GenericName[ca]=PasteSelection
104+
GenericName[ca@valencia]=PasteSelection
105+
GenericName[cs]=PasteSelection
106+
GenericName[da]=PasteSelection
107+
GenericName[de]=PasteSelection
108+
GenericName[el]=PasteSelection
109+
GenericName[en_GB]=PasteSelection
110+
GenericName[es]=PasteSelection
111+
GenericName[et]=PasteSelection
112+
GenericName[fi]=PasteSelection
113+
GenericName[fr]=PasteSelection
114+
GenericName[ga]=PasteSelection
115+
GenericName[gl]=PasteSelection
116+
GenericName[hu]=PasteSelection
117+
GenericName[it]=PasteSelection
118+
GenericName[kk]=PasteSelection
119+
GenericName[km]=PasteSelection
120+
GenericName[ko]=PasteSelection
121+
GenericName[lt]=PasteSelection
122+
GenericName[lv]=PasteSelection
123+
GenericName[nb]=PasteSelection
124+
GenericName[nds]=PasteSelection
125+
GenericName[nl]=PasteSelection
126+
GenericName[nn]=PasteSelection
127+
GenericName[pa]=PasteSelection
128+
GenericName[pl]=PasteSelection
129+
GenericName[pt]=PasteSelection
130+
GenericName[pt_BR]=PasteSelection
131+
GenericName[ru]=PasteSelection
132+
GenericName[sk]=PasteSelection
133+
GenericName[sl]=PasteSelection
134+
GenericName[sr]=PasteSelection
135+
GenericName[sr@ijekavian]=PasteSelection
136+
GenericName[sr@ijekavianlatin]=PasteSelection
137+
GenericName[sr@latin]=PasteSelection
138+
GenericName[sv]=PasteSelection
139+
GenericName[tr]=PasteSelection
140+
GenericName[ug]=PasteSelection
141+
GenericName[uk]=PasteSelection
142+
GenericName[x-test]=xxPasteSelectionxx
143+
GenericName[zh_CN]=PasteSelection
144+
GenericName[zh_TW]=PasteSelection
145+
Icon=kate
146+
ServiceTypes=KTextEditor/Plugin
147+
X-KDE-ServiceTypes=KTextEditor/Plugin
148+
X-KDE-Library=ktexteditor_pasteselection
149+
X-KDE-PluginKeyword=ktexteditor_pasteselection
150+
X-KDE-PluginInfo-Name=ktexteditor_pasteselection
151+
X-KDE-PluginInfo-Author=Jonathan Poelen
152+
X-KDE-PluginInfo-Email[email protected]
153+
X-KDE-PluginInfo-Website=https://github.com/jonathanpoelen/ktexteditor-pasteselection
154+
X-KDE-PluginInfo-Version=1.0
155+
X-KDE-PluginInfo-License=GPL
156+
X-KDE-PluginInfo-Depends=
157+
X-KDE-PluginInfo-EnabledByDefault=false
158+
X-KDE-PluginInfo-Category=Editor
159+
X-KDE-ParentApp=kate
160+
X-KDE-Version=4.0

pasteselectionplugin.cpp

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#include "pasteselectionplugin.h"
2+
#include "pasteselectionview.h"
3+
4+
#include <KTextEditor/Document>
5+
#include <KTextEditor/View>
6+
7+
#include <KPluginFactory>
8+
#include <KPluginLoader>
9+
#include <KLocale>
10+
#include <KAction>
11+
#include <KActionCollection>
12+
13+
#include <QApplication>
14+
#include <QClipboard>
15+
16+
K_PLUGIN_FACTORY(PasteSelectionPluginFactory, registerPlugin<PasteSelectionPlugin>("ktexteditor_pasteselection");)
17+
K_EXPORT_PLUGIN(PasteSelectionPluginFactory("ktexteditor_pasteselection", "ktexteditor_plugins"))
18+
19+
PasteSelectionPlugin::PasteSelectionPlugin(QObject *parent, const QVariantList &args)
20+
: KTextEditor::Plugin(parent)
21+
{
22+
Q_UNUSED(args);
23+
}
24+
25+
PasteSelectionPlugin::~PasteSelectionPlugin()
26+
{
27+
}
28+
29+
void PasteSelectionPlugin::addView(KTextEditor::View *view)
30+
{
31+
PasteSelectionView *nview = new PasteSelectionView(view);
32+
m_views.append(nview);
33+
}
34+
35+
void PasteSelectionPlugin::removeView(KTextEditor::View *view)
36+
{
37+
for(int z = 0; z < m_views.size(); z++)
38+
{
39+
if(m_views.at(z)->parentClient() == view)
40+
{
41+
PasteSelectionView *nview = m_views.at(z);
42+
m_views.removeAll(nview);
43+
delete nview;
44+
}
45+
}
46+
}
47+
48+
void PasteSelectionPlugin::readConfig()
49+
{
50+
}
51+
52+
void PasteSelectionPlugin::writeConfig()
53+
{
54+
}
55+
56+
PasteSelectionView::PasteSelectionView(KTextEditor::View *view)
57+
: QObject(view)
58+
, KXMLGUIClient(view)
59+
, m_view(view)
60+
{
61+
setComponentData(PasteSelectionPluginFactory::componentData());
62+
63+
KAction *action = new KAction(i18n("Paste selection"), this);
64+
actionCollection()->addAction("tools_pasteselection", action);
65+
action->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_Insert);
66+
connect(action, SIGNAL(triggered()), this, SLOT(insertPasteSelection()));
67+
68+
setXMLFile("pasteselectionui.rc");
69+
}
70+
71+
PasteSelectionView::~PasteSelectionView()
72+
{
73+
}
74+
75+
void PasteSelectionView::insertPasteSelection()
76+
{
77+
m_view->document()->insertText(m_view->cursorPosition(), QApplication::clipboard()->text(QClipboard::QClipboard::Selection));
78+
}
79+
80+
#include "pasteselectionview.moc"

pasteselectionplugin.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#ifndef PASTESELECTIONPLUGIN_H
2+
#define PASTESELECTIONPLUGIN_H
3+
4+
#include <KTextEditor/Plugin>
5+
6+
namespace KTextEditor
7+
{
8+
class View;
9+
}
10+
11+
class PasteSelectionView;
12+
13+
class PasteSelectionPlugin
14+
: public KTextEditor::Plugin
15+
{
16+
public:
17+
// Constructor
18+
explicit PasteSelectionPlugin(QObject *parent = 0, const QVariantList &args = QVariantList());
19+
// Destructor
20+
virtual ~PasteSelectionPlugin();
21+
22+
void addView (KTextEditor::View *view);
23+
void removeView (KTextEditor::View *view);
24+
25+
void readConfig();
26+
void writeConfig();
27+
28+
// void readConfig (KConfig *);
29+
// void writeConfig (KConfig *);
30+
31+
private:
32+
QList<class PasteSelectionView*> m_views;
33+
};
34+
35+
#endif

pasteselectionui.rc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!DOCTYPE kpartgui>
2+
<kpartplugin name="ktexteditor_pasteselection" library="ktexteditor_pasteselection" version="2">
3+
<MenuBar>
4+
<Menu name="tools"><Text>&amp;Edit</Text>
5+
<separator group="tools_operations" />
6+
<Action name="tools_pasteselection" group="tools_operations"/>
7+
</Menu>
8+
</MenuBar>
9+
</kpartplugin>

pasteselectionview.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#ifndef PASTESELECTIONVIEW_H
2+
#define PASTESELECTIONVIEW_H
3+
4+
#include <QObject>
5+
#include <KXMLGUIClient>
6+
7+
class PasteSelectionView : public QObject, public KXMLGUIClient
8+
{
9+
Q_OBJECT
10+
public:
11+
explicit PasteSelectionView(KTextEditor::View *view = 0);
12+
~PasteSelectionView();
13+
private slots:
14+
void insertPasteSelection();
15+
private:
16+
KTextEditor::View *m_view;
17+
};
18+
19+
#endif

0 commit comments

Comments
 (0)