2
Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org>
3
Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
5
This library is free software; you can redistribute it and/or
6
modify it under the terms of the GNU Library General Public
7
License version 2 as published by the Free Software Foundation.
9
This library is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
Library General Public License for more details.
14
You should have received a copy of the GNU Library General Public License
15
along with this library; see the file COPYING.LIB. If not, write to
16
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
Boston, MA 02110-1301, USA.
19
#include "conditions/existing_window_condition.h"
21
#include "windows_helper/window_selection_list.h"
23
#include "windows_handler.h"
24
#include "khotkeysglobal.h"
29
Existing_window_condition::Existing_window_condition( KConfigGroup& cfg_P, Condition_list_base* parent_P )
30
: Condition( cfg_P, parent_P )
32
KConfigGroup windowConfig( cfg_P.config(), cfg_P.name() + "Window" );
33
_window = new Windowdef_list( windowConfig );
39
Existing_window_condition::Existing_window_condition( Windowdef_list* window_P,
40
Condition_list_base* parent_P )
41
: Condition( parent_P ), _window( window_P ), is_match( false )
48
Existing_window_condition::~Existing_window_condition()
50
disconnect( windows_handler, NULL, this, NULL );
55
void Existing_window_condition::cfg_write( KConfigGroup& cfg_P ) const
57
base::cfg_write( cfg_P );
58
KConfigGroup windowConfig( cfg_P.config(), cfg_P.name() + "Window" );
59
window()->cfg_write( windowConfig );
60
cfg_P.writeEntry( "Type", "EXISTING_WINDOW" ); // overwrites value set in base::cfg_write()
64
Existing_window_condition* Existing_window_condition::copy() const
66
return new Existing_window_condition(window()->copy());
70
const QString Existing_window_condition::description() const
72
return i18n( "Existing window: " ) + window()->comment();
76
void Existing_window_condition::init()
78
connect( windows_handler, SIGNAL( window_added( WId )), this, SLOT( window_added( WId )));
79
connect( windows_handler, SIGNAL( window_removed( WId )), this, SLOT( window_removed( WId )));
83
bool Existing_window_condition::match() const
89
void Existing_window_condition::set_match( WId w_P )
91
if( w_P != None && !is_match )
92
is_match = window()->match( Window_data( w_P ));
94
is_match = windows_handler->find_window( window()) != None;
99
const Windowdef_list* Existing_window_condition::window() const
105
Windowdef_list* Existing_window_condition::window()
111
void Existing_window_condition::window_added( WId w_P )
117
void Existing_window_condition::window_removed( WId )
123
} // namespace KHotKeys