1 /****************************************************************************
5 Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org>
7 Distributed under the terms of the GNU General Public License version 2.
9 ****************************************************************************/
11 #define _WINDOWDEF_SIMPLE_WIDGET_CPP_
15 #include "windowdef_simple_widget.h"
20 #include <QPushButton>
25 #include "windowdef_list_widget.h"
26 #include "kcmkhotkeys.h"
27 #include "windowselector.h"
32 Windowdef_simple_widget::Windowdef_simple_widget( QWidget
* parent_P
, const char* name_P
)
33 : Windowdef_simple_widget_ui( parent_P
)
35 setObjectName(name_P
);
36 window_title_lineedit
->setEnabled( false );
37 window_class_lineedit
->setEnabled( false );
38 window_role_lineedit
->setEnabled( false );
39 connect( autodetect_button
, SIGNAL( clicked()), SLOT( autodetect_clicked()));
40 connect(window_class_combo
,SIGNAL(activated(int)),this,SLOT(window_class_combo_changed(int)));
41 connect(window_role_combo
,SIGNAL(activated(int)),this,SLOT(window_role_combo_changed(int)));
42 connect(window_title_combo
,SIGNAL(activated(int)),this,SLOT(window_title_combo_changed(int)));
45 // KHotKeys::Module::changed()
46 connect( window_title_combo
, SIGNAL( activated( int )),
47 module
, SLOT( changed()));
48 connect( window_title_lineedit
, SIGNAL( textChanged( const QString
& )),
49 module
, SLOT( changed()));
50 connect( window_class_combo
, SIGNAL( activated( int )),
51 module
, SLOT( changed()));
52 connect( window_class_lineedit
, SIGNAL( textChanged( const QString
& )),
53 module
, SLOT( changed()));
54 connect( window_role_combo
, SIGNAL( activated( int )),
55 module
, SLOT( changed()));
56 connect( window_role_lineedit
, SIGNAL( textChanged( const QString
& )),
57 module
, SLOT( changed()));
58 connect( type_normal_checkbox
, SIGNAL( clicked()),
59 module
, SLOT( changed()));
60 connect( type_dialog_checkbox
, SIGNAL( clicked()),
61 module
, SLOT( changed()));
62 connect( type_dock_checkbox
, SIGNAL( clicked()),
63 module
, SLOT( changed()));
64 connect( type_desktop_checkbox
, SIGNAL( clicked()),
65 module
, SLOT( changed()));
66 connect( comment_lineedit
, SIGNAL( textChanged( const QString
& )),
67 module
, SLOT( changed()));
70 void Windowdef_simple_widget::clear_data()
72 comment_lineedit
->clear();
73 window_title_combo
->setCurrentIndex( 0 );
74 window_title_lineedit
->clear();
75 window_title_lineedit
->setEnabled( false );
76 window_class_combo
->setCurrentIndex( 0 );
77 window_class_lineedit
->clear();
78 window_class_lineedit
->setEnabled( false );
79 window_role_combo
->setCurrentIndex( 0 );
80 window_role_lineedit
->clear();
81 window_role_lineedit
->setEnabled( false );
82 type_normal_checkbox
->setChecked( true );
83 type_dialog_checkbox
->setChecked( true );
84 type_dock_checkbox
->setChecked( false );
85 // type_tool_checkbox->setChecked( false );
86 // type_menu_checkbox->setChecked( false );
87 type_desktop_checkbox
->setChecked( false );
90 void Windowdef_simple_widget::set_data( const Windowdef_simple
* data_P
)
97 comment_lineedit
->setText( data_P
->comment());
98 window_title_combo
->setCurrentIndex( data_P
->title_match_type());
99 window_title_lineedit
->setText( data_P
->title());
100 window_title_lineedit
->setEnabled( window_title_combo
->currentIndex() != 0 );
101 window_class_combo
->setCurrentIndex( data_P
->wclass_match_type());
102 window_class_lineedit
->setText( data_P
->wclass());
103 window_class_lineedit
->setEnabled( window_class_combo
->currentIndex() != 0 );
104 window_role_combo
->setCurrentIndex( data_P
->role_match_type());
105 window_role_lineedit
->setText( data_P
->role());
106 window_role_lineedit
->setEnabled( window_role_combo
->currentIndex() != 0 );
107 type_normal_checkbox
->setChecked( data_P
->type_match( Windowdef_simple::WINDOW_TYPE_NORMAL
));
108 type_dialog_checkbox
->setChecked( data_P
->type_match( Windowdef_simple::WINDOW_TYPE_DIALOG
));
109 type_dock_checkbox
->setChecked( data_P
->type_match( Windowdef_simple::WINDOW_TYPE_DOCK
));
110 // type_tool_checkbox->setChecked( data_P->type_match( Windowdef_simple::WINDOW_TYPE_TOOL ));
111 // type_menu_checkbox->setChecked( data_P->type_match( Windowdef_simple::WINDOW_TYPE_MENU ));
112 type_desktop_checkbox
->setChecked(
113 data_P
->type_match( Windowdef_simple::WINDOW_TYPE_DESKTOP
));
116 Windowdef_simple
* Windowdef_simple_widget::get_data() const
118 return new Windowdef_simple( comment_lineedit
->text(), window_title_lineedit
->text(),
119 static_cast< Windowdef_simple::substr_type_t
>( window_title_combo
->currentIndex()),
120 window_class_lineedit
->text(),
121 static_cast< Windowdef_simple::substr_type_t
>( window_class_combo
->currentIndex()),
122 window_role_lineedit
->text(),
123 static_cast< Windowdef_simple::substr_type_t
>( window_role_combo
->currentIndex()),
124 ( type_normal_checkbox
->isChecked() ? Windowdef_simple::WINDOW_TYPE_NORMAL
: 0 )
125 | ( type_dialog_checkbox
->isChecked() ? Windowdef_simple::WINDOW_TYPE_DIALOG
: 0 )
126 | ( type_dock_checkbox
->isChecked() ? Windowdef_simple::WINDOW_TYPE_DOCK
: 0 )
127 // | ( type_tool_checkbox->isChecked() ? Windowdef_simple::WINDOW_TYPE_TOOL : 0 )
128 // | ( type_menu_checkbox->isChecked() ? Windowdef_simple::WINDOW_TYPE_MENU : 0 )
129 | ( type_desktop_checkbox
->isChecked() ? Windowdef_simple::WINDOW_TYPE_DESKTOP
: 0 )
133 void Windowdef_simple_widget::window_role_combo_changed( int item_P
)
134 { // CHECKME nebo je connect() na highlighted() ?
135 window_role_lineedit
->setEnabled( item_P
!= 0 );
138 void Windowdef_simple_widget::window_class_combo_changed( int item_P
)
140 window_class_lineedit
->setEnabled( item_P
!= 0 );
143 void Windowdef_simple_widget::window_title_combo_changed( int item_P
)
145 window_title_lineedit
->setEnabled( item_P
!= 0 );
148 void Windowdef_simple_widget::set_autodetect( QObject
* obj_P
, const char* slot_P
)
150 disconnect( SIGNAL( autodetect_signal()));
152 connect( this, SIGNAL( autodetect_signal()), obj_P
, slot_P
);
155 void Windowdef_simple_widget::autodetect_clicked()
157 emit
autodetect_signal();
161 void Windowdef_simple_widget::autodetect()
163 WindowSelector
* sel
= new WindowSelector( this, SLOT( autodetect_window_selected( WId
)));
167 void Windowdef_simple_widget::autodetect_window_selected( WId window
)
171 Window_data
data( window
);
172 window_title_lineedit
->setText( data
.title
);
173 window_role_lineedit
->setText( data
.role
);
174 window_class_lineedit
->setText( data
.wclass
);
175 type_normal_checkbox
->setChecked( data
.type
== NET::Normal
);
176 type_dialog_checkbox
->setChecked( data
.type
== NET::Dialog
);
177 type_dock_checkbox
->setChecked( data
.type
== NET::Dock
);
178 // type_tool_checkbox->setChecked( data_P->type_match( Windowdef_simple::WINDOW_TYPE_TOOL ));
179 // type_menu_checkbox->setChecked( data_P->type_match( Windowdef_simple::WINDOW_TYPE_MENU ));
180 type_desktop_checkbox
->setChecked( data
.type
== NET::Desktop
);
184 } // namespace KHotKeys
186 #include "windowdef_simple_widget.moc"