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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
/****************************************************************************
KHotKeys
Copyright (C) 1999-2002 Lubos Lunak <l.lunak@kde.org>
Distributed under the terms of the GNU General Public License version 2.
****************************************************************************/
#define _GESTURE_TRIGGERS_TAB_CPP_
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "gesture_triggers_tab.h"
#include <tqpushbutton.h>
#include <tqlineedit.h>
#include <triggers.h>
#include <actions.h>
#include <action_data.h>
#include "kcmkhotkeys.h"
#include "gesturedrawer.h"
#include "gesturerecordpage.h"
namespace KHotKeys
{
Gesture_triggers_tab::Gesture_triggers_tab( TQWidget* parent_P, const char* name_P )
: Gesture_triggers_tab_ui( parent_P, name_P )
{
clear_data();
// KHotKeys::Module::changed()
connect( gesture_edit_button1, TQT_SIGNAL( clicked()),
module, TQT_SLOT( changed()));
connect( gesture_edit_button2, TQT_SIGNAL( clicked()),
module, TQT_SLOT( changed()));
connect( gesture_edit_button3, TQT_SIGNAL( clicked()),
module, TQT_SLOT( changed()));
}
void Gesture_triggers_tab::clear_data()
{
gesture1 = gesture2 = gesture3 = TQString::null;
gesture_lineedit1->clear();
gesture_lineedit2->clear();
gesture_lineedit3->clear();
gesture_drawer1->setData( TQString::null );
gesture_drawer2->setData( TQString::null );
gesture_drawer3->setData( TQString::null );
}
void Gesture_triggers_tab::set_data( const Trigger_list* triggers_P )
{
if( triggers_P == NULL )
{
clear_data();
return;
}
Gesture_trigger* trig = NULL;
Trigger_list::Iterator it( *triggers_P );
if( it )
{
assert( dynamic_cast< Gesture_trigger* >( *it ));
trig = static_cast< Gesture_trigger* >( *it );
}
else
trig = NULL;
gesture1 = trig ? trig->gesturecode() : TQString::null;
gesture_lineedit1->setText( gesture1 );
gesture_drawer1->setData( gesture1 );
++it;
if( it )
{
assert( dynamic_cast< Gesture_trigger* >( *it ));
trig = static_cast< Gesture_trigger* >( *it );
}
else
trig = NULL;
gesture2 = trig ? trig->gesturecode() : TQString::null;
gesture_lineedit2->setText( gesture2 );
gesture_drawer2->setData( gesture2 );
++it;
if( it )
{
assert( dynamic_cast< Gesture_trigger* >( *it ));
trig = static_cast< Gesture_trigger* >( *it );
}
else
trig = NULL;
gesture3 = trig ? trig->gesturecode() : TQString::null;
gesture_lineedit3->setText( gesture3 );
gesture_drawer3->setData( gesture3 );
}
Trigger_list* Gesture_triggers_tab::get_data( Action_data* data_P ) const
{
Trigger_list* ret = new Trigger_list( "Gesture_triggers" );
if( !gesture1.isEmpty())
ret->append( new Gesture_trigger( data_P, gesture1 ));
if( !gesture2.isEmpty())
ret->append( new Gesture_trigger( data_P, gesture2 ));
if( !gesture3.isEmpty())
ret->append( new Gesture_trigger( data_P, gesture3 ));
return ret;
}
void Gesture_triggers_tab::edit_gesture_pressed1()
{
Gesture_edit_dialog dlg( gesture1 );
gesture1 = dlg.edit_gesture();
gesture_lineedit1->setText( gesture1 );
gesture_drawer1->setData( gesture1 );
}
void Gesture_triggers_tab::edit_gesture_pressed2()
{
Gesture_edit_dialog dlg( gesture2 );
gesture2 = dlg.edit_gesture();
gesture_lineedit2->setText( gesture2 );
gesture_drawer2->setData( gesture2 );
}
void Gesture_triggers_tab::edit_gesture_pressed3()
{
Gesture_edit_dialog dlg( gesture3 );
gesture3 = dlg.edit_gesture();
gesture_lineedit3->setText( gesture3 );
gesture_drawer3->setData( gesture3 );
}
// Gesture_edit_dialog
Gesture_edit_dialog::Gesture_edit_dialog( const TQString& gesture_P )
: KDialogBase( NULL, NULL, true, "", Ok | Cancel ), // CHECKME caption
_gesture( gesture_P ), _page( NULL )
{
_page = new GestureRecordPage( _gesture,
this, "GestureRecordPage");
// connect(_page, TQT_SIGNAL(gestureRecorded(bool)), // allow clearing the gesture
// this, TQT_SLOT(enableButtonOK(bool)));
setMainWidget( _page );
}
TQString Gesture_edit_dialog::edit_gesture()
{
if( exec())
return _page->getGesture();
else
return _gesture;
}
} // namespace KHotKeys
#include "gesture_triggers_tab.moc"
|