-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcase3-guiutils.h
More file actions
130 lines (124 loc) · 4.22 KB
/
case3-guiutils.h
File metadata and controls
130 lines (124 loc) · 4.22 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/***************************************************************************
kdiff3.h - description
-------------------
begin : March 26 17:44 CEST 2002
copyright : (c) 2008 by Valentin Rusu
email : kde at rusu.info
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <QObject>
#include <kactioncollection.h>
namespace KDiff3 {
template <class T>
T* createAction(
const QString& text,
const QObject* receiver,
const char* slot,
KActionCollection* ac,
const char* actionName);
template <>
inline KAction* createAction<KAction>(
const QString& text,
const QObject* receiver,
const char* slot,
KActionCollection* ac,
const char* actionName) {
assert( ac != 0 );
KAction* theAction = ac->addAction( actionName );
theAction->setText( text );
QObject::connect( theAction, SIGNAL( triggered() ), receiver, slot );
return theAction;
}
template <>
inline KToggleAction* createAction<KToggleAction>(
const QString& text,
const QObject* receiver,
const char* slot,
KActionCollection* ac,
const char* actionName) {
assert( ac != 0 );
KToggleAction* theAction = new KToggleAction(ac);
ac->addAction( actionName, theAction );
theAction->setText( text );
QObject::connect( theAction, SIGNAL( triggered(bool) ), receiver, slot );
return theAction;
}
template <class T>
T* createAction(
const QString& text,
const KShortcut& shortcut,
const QObject* receiver,
const char* slot,
KActionCollection* ac,
const char* actionName)
{
T* theAction = createAction<T>( text, receiver, slot, ac, actionName );
theAction->setShortcut( shortcut );
return theAction;
}
template <class T>
T* createAction(
const QString& text,
const QIcon& icon,
const QObject* receiver,
const char* slot,
KActionCollection* ac,
const char* actionName)
{
T* theAction = createAction<T>( text, receiver, slot, ac, actionName );
theAction->setIcon( icon );
return theAction;
}
template <class T>
T* createAction(
const QString& text,
const QIcon& icon,
const QString& iconText,
const QObject* receiver,
const char* slot,
KActionCollection* ac,
const char* actionName)
{
T* theAction = createAction<T>( text, receiver, slot, ac, actionName );
theAction->setIcon( icon );
theAction->setIconText( iconText );
return theAction;
}
template <class T>
T* createAction(
const QString& text,
const QIcon& icon,
const KShortcut& shortcut,
const QObject* receiver,
const char* slot,
KActionCollection* ac,
const char* actionName)
{
T* theAction = createAction<T>( text, shortcut, receiver, slot, ac, actionName );
theAction->setIcon( icon );
return theAction;
}
template <class T>
T* createAction(
const QString& text,
const QIcon& icon,
const QString& iconText,
const KShortcut& shortcut,
const QObject* receiver,
const char* slot,
KActionCollection* ac,
const char* actionName)
{
T* theAction = createAction<T>( text, shortcut, receiver, slot, ac, actionName );
theAction->setIcon( icon );
theAction->setIconText( iconText );
return theAction;
}
}