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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
/****************************************************************************
KHotKeys
Copyright (C) 1999-2001 Lubos Lunak <[email protected]>
Distributed under the terms of the GNU General Public License version 2.
****************************************************************************/
#define _WINDOWDEF_SIMPLE_WIDGET_CPP_
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "windowdef_simple_widget.h"
#include <tqlineedit.h>
#include <tqcombobox.h>
#include <tqcheckbox.h>
#include <tqpushbutton.h>
#include <kdebug.h>
#include <windows.h>
#include "windowdef_list_widget.h"
#include "kcmkhotkeys.h"
#include "windowselector.h"
namespace KHotKeys
{
Windowdef_simple_widget::Windowdef_simple_widget( TQWidget* parent_P, const char* name_P )
: Windowdef_simple_widget_ui( parent_P, name_P )
{
window_title_lineedit->setEnabled( false );
window_class_lineedit->setEnabled( false );
window_role_lineedit->setEnabled( false );
connect( autodetect_button, TQ_SIGNAL( clicked()), TQ_SLOT( autodetect_clicked()));
clear_data();
// KHotKeys::Module::changed()
connect( window_title_combo, TQ_SIGNAL( activated( int )),
module, TQ_SLOT( changed()));
connect( window_title_lineedit, TQ_SIGNAL( textChanged( const TQString& )),
module, TQ_SLOT( changed()));
connect( window_class_combo, TQ_SIGNAL( activated( int )),
module, TQ_SLOT( changed()));
connect( window_class_lineedit, TQ_SIGNAL( textChanged( const TQString& )),
module, TQ_SLOT( changed()));
connect( window_role_combo, TQ_SIGNAL( activated( int )),
module, TQ_SLOT( changed()));
connect( window_role_lineedit, TQ_SIGNAL( textChanged( const TQString& )),
module, TQ_SLOT( changed()));
connect( type_normal_checkbox, TQ_SIGNAL( clicked()),
module, TQ_SLOT( changed()));
connect( type_dialog_checkbox, TQ_SIGNAL( clicked()),
module, TQ_SLOT( changed()));
connect( type_dock_checkbox, TQ_SIGNAL( clicked()),
module, TQ_SLOT( changed()));
connect( type_desktop_checkbox, TQ_SIGNAL( clicked()),
module, TQ_SLOT( changed()));
connect( comment_lineedit, TQ_SIGNAL( textChanged( const TQString& )),
module, TQ_SLOT( changed()));
}
void Windowdef_simple_widget::clear_data()
{
comment_lineedit->clear();
window_title_combo->setCurrentItem( 0 );
window_title_lineedit->clear();
window_title_lineedit->setEnabled( false );
window_class_combo->setCurrentItem( 0 );
window_class_lineedit->clear();
window_class_lineedit->setEnabled( false );
window_role_combo->setCurrentItem( 0 );
window_role_lineedit->clear();
window_role_lineedit->setEnabled( false );
type_normal_checkbox->setChecked( true );
type_dialog_checkbox->setChecked( true );
type_dock_checkbox->setChecked( false );
// type_tool_checkbox->setChecked( false );
// type_menu_checkbox->setChecked( false );
type_desktop_checkbox->setChecked( false );
}
void Windowdef_simple_widget::set_data( const Windowdef_simple* data_P )
{
if( data_P == NULL )
{
clear_data();
return;
}
comment_lineedit->setText( data_P->comment());
window_title_combo->setCurrentItem( data_P->title_match_type());
window_title_lineedit->setText( data_P->title());
window_title_lineedit->setEnabled( window_title_combo->currentItem() != 0 );
window_class_combo->setCurrentItem( data_P->wclass_match_type());
window_class_lineedit->setText( data_P->wclass());
window_class_lineedit->setEnabled( window_class_combo->currentItem() != 0 );
window_role_combo->setCurrentItem( data_P->role_match_type());
window_role_lineedit->setText( data_P->role());
window_role_lineedit->setEnabled( window_role_combo->currentItem() != 0 );
type_normal_checkbox->setChecked( data_P->type_match( Windowdef_simple::WINDOW_TYPE_NORMAL ));
type_dialog_checkbox->setChecked( data_P->type_match( Windowdef_simple::WINDOW_TYPE_DIALOG ));
type_dock_checkbox->setChecked( data_P->type_match( Windowdef_simple::WINDOW_TYPE_DOCK ));
// type_tool_checkbox->setChecked( data_P->type_match( Windowdef_simple::WINDOW_TYPE_TOOL ));
// type_menu_checkbox->setChecked( data_P->type_match( Windowdef_simple::WINDOW_TYPE_MENU ));
type_desktop_checkbox->setChecked(
data_P->type_match( Windowdef_simple::WINDOW_TYPE_DESKTOP ));
}
Windowdef_simple* Windowdef_simple_widget::get_data() const
{
return new Windowdef_simple( comment_lineedit->text(), window_title_lineedit->text(),
static_cast< Windowdef_simple::substr_type_t >( window_title_combo->currentItem()),
window_class_lineedit->text(),
static_cast< Windowdef_simple::substr_type_t >( window_class_combo->currentItem()),
window_role_lineedit->text(),
static_cast< Windowdef_simple::substr_type_t >( window_role_combo->currentItem()),
( type_normal_checkbox->isChecked() ? Windowdef_simple::WINDOW_TYPE_NORMAL : 0 )
| ( type_dialog_checkbox->isChecked() ? Windowdef_simple::WINDOW_TYPE_DIALOG : 0 )
| ( type_dock_checkbox->isChecked() ? Windowdef_simple::WINDOW_TYPE_DOCK : 0 )
// | ( type_tool_checkbox->isChecked() ? Windowdef_simple::WINDOW_TYPE_TOOL : 0 )
// | ( type_menu_checkbox->isChecked() ? Windowdef_simple::WINDOW_TYPE_MENU : 0 )
| ( type_desktop_checkbox->isChecked() ? Windowdef_simple::WINDOW_TYPE_DESKTOP : 0 )
);
}
void Windowdef_simple_widget::window_role_combo_changed( int item_P )
{ // CHECKME nebo je connect() na highlighted() ?
window_role_lineedit->setEnabled( item_P != 0 );
}
void Windowdef_simple_widget::window_class_combo_changed( int item_P )
{
window_class_lineedit->setEnabled( item_P != 0 );
}
void Windowdef_simple_widget::window_title_combo_changed( int item_P )
{
window_title_lineedit->setEnabled( item_P != 0 );
}
void Windowdef_simple_widget::set_autodetect( TQObject* obj_P, const char* slot_P )
{
disconnect( TQ_SIGNAL( autodetect_signal()));
if( obj_P != NULL )
connect( this, TQ_SIGNAL( autodetect_signal()), obj_P, slot_P );
}
void Windowdef_simple_widget::autodetect_clicked()
{
emit autodetect_signal();
autodetect();
}
void Windowdef_simple_widget::autodetect()
{
WindowSelector* sel = new WindowSelector( this, TQ_SLOT( autodetect_window_selected( WId )));
sel->select();
}
void Windowdef_simple_widget::autodetect_window_selected( WId window )
{
if( window )
{
Window_data data( window );
window_title_lineedit->setText( data.title );
window_role_lineedit->setText( data.role );
window_class_lineedit->setText( data.wclass );
type_normal_checkbox->setChecked( data.type == NET::Normal );
type_dialog_checkbox->setChecked( data.type == NET::Dialog );
type_dock_checkbox->setChecked( data.type == NET::Dock );
// type_tool_checkbox->setChecked( data_P->type_match( Windowdef_simple::WINDOW_TYPE_TOOL ));
// type_menu_checkbox->setChecked( data_P->type_match( Windowdef_simple::WINDOW_TYPE_MENU ));
type_desktop_checkbox->setChecked( data.type == NET::Desktop );
}
}
} // namespace KHotKeys
#include "windowdef_simple_widget.moc"
|