Mercurial > hg > easyhg-kdiff3
comparison kdiff3/src-QT4/guiutils.h @ 82:e10fc1ab21a2
(none)
author | joachim99 |
---|---|
date | Tue, 06 Jan 2009 18:07:30 +0000 |
parents | |
children | 6f42f5bd218e |
comparison
equal
deleted
inserted
replaced
81:5d7e91c44e6d | 82:e10fc1ab21a2 |
---|---|
1 /*************************************************************************** | |
2 kdiff3.h - description | |
3 ------------------- | |
4 begin : March 26 17:44 CEST 2002 | |
5 copyright : (c) 2008 by Valentin Rusu | |
6 email : kde at rusu.info | |
7 ***************************************************************************/ | |
8 | |
9 /*************************************************************************** | |
10 * * | |
11 * This program is free software; you can redistribute it and/or modify * | |
12 * it under the terms of the GNU General Public License as published by * | |
13 * the Free Software Foundation; either version 3 of the License, or * | |
14 * (at your option) any later version. * | |
15 * * | |
16 ***************************************************************************/ | |
17 | |
18 #include <qobject.h> | |
19 #include <kactioncollection.h> | |
20 | |
21 namespace KDiff3 { | |
22 | |
23 template <class T> | |
24 T* createAction( | |
25 const QString& text, | |
26 const QObject* receiver, | |
27 const char* slot, | |
28 KActionCollection* ac, | |
29 const char* actionName); | |
30 | |
31 template <> | |
32 inline KAction* createAction<KAction>( | |
33 const QString& text, | |
34 const QObject* receiver, | |
35 const char* slot, | |
36 KActionCollection* ac, | |
37 const char* actionName) { | |
38 assert( ac != 0 ); | |
39 KAction* theAction = ac->addAction( actionName ); | |
40 theAction->setText( text ); | |
41 QObject::connect( theAction, SIGNAL( triggered() ), receiver, slot ); | |
42 return theAction; | |
43 } | |
44 template <> | |
45 inline KToggleAction* createAction<KToggleAction>( | |
46 const QString& text, | |
47 const QObject* receiver, | |
48 const char* slot, | |
49 KActionCollection* ac, | |
50 const char* actionName) { | |
51 assert( ac != 0 ); | |
52 KToggleAction* theAction = new KToggleAction(ac); | |
53 ac->addAction( actionName, theAction ); | |
54 theAction->setText( text ); | |
55 QObject::connect( theAction, SIGNAL( toggled(bool) ), receiver, slot ); | |
56 return theAction; | |
57 } | |
58 | |
59 template <class T> | |
60 T* createAction( | |
61 const QString& text, | |
62 const KShortcut& shortcut, | |
63 const QObject* receiver, | |
64 const char* slot, | |
65 KActionCollection* ac, | |
66 const char* actionName) | |
67 { | |
68 T* theAction = createAction<T>( text, receiver, slot, ac, actionName ); | |
69 theAction->setShortcut( shortcut ); | |
70 return theAction; | |
71 } | |
72 template <class T> | |
73 T* createAction( | |
74 const QString& text, | |
75 const QIcon& icon, | |
76 const QObject* receiver, | |
77 const char* slot, | |
78 KActionCollection* ac, | |
79 const char* actionName) | |
80 { | |
81 T* theAction = createAction<T>( text, receiver, slot, ac, actionName ); | |
82 theAction->setIcon( icon ); | |
83 return theAction; | |
84 } | |
85 template <class T> | |
86 T* createAction( | |
87 const QString& text, | |
88 const QIcon& icon, | |
89 const QString& iconText, | |
90 const QObject* receiver, | |
91 const char* slot, | |
92 KActionCollection* ac, | |
93 const char* actionName) | |
94 { | |
95 T* theAction = createAction<T>( text, receiver, slot, ac, actionName ); | |
96 theAction->setIcon( icon ); | |
97 theAction->setIconText( iconText ); | |
98 return theAction; | |
99 } | |
100 template <class T> | |
101 T* createAction( | |
102 const QString& text, | |
103 const QIcon& icon, | |
104 const KShortcut& shortcut, | |
105 const QObject* receiver, | |
106 const char* slot, | |
107 KActionCollection* ac, | |
108 const char* actionName) | |
109 { | |
110 T* theAction = createAction<T>( text, shortcut, receiver, slot, ac, actionName ); | |
111 theAction->setIcon( icon ); | |
112 return theAction; | |
113 } | |
114 template <class T> | |
115 T* createAction( | |
116 const QString& text, | |
117 const QIcon& icon, | |
118 const QString& iconText, | |
119 const KShortcut& shortcut, | |
120 const QObject* receiver, | |
121 const char* slot, | |
122 KActionCollection* ac, | |
123 const char* actionName) | |
124 { | |
125 T* theAction = createAction<T>( text, shortcut, receiver, slot, ac, actionName ); | |
126 theAction->setIcon( icon ); | |
127 theAction->setIconText( iconText ); | |
128 return theAction; | |
129 } | |
130 } |