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.
20 #include "conditions.h"
22 #include <KDE/KConfigGroup>
27 Existing_window_condition::Existing_window_condition( KConfigGroup
& cfg_P
, Condition_list_base
* parent_P
)
28 : Condition( cfg_P
, parent_P
)
30 KConfigGroup
windowConfig( cfg_P
.config(), cfg_P
.name() + "Window" );
31 _window
= new Windowdef_list( windowConfig
);
36 void Existing_window_condition::init()
38 connect( windows_handler
, SIGNAL( window_added( WId
)), this, SLOT( window_added( WId
)));
39 connect( windows_handler
, SIGNAL( window_removed( WId
)), this, SLOT( window_removed( WId
)));
42 bool Existing_window_condition::match() const
47 void Existing_window_condition::set_match( WId w_P
)
49 if( w_P
!= None
&& !is_match
)
50 is_match
= window()->match( Window_data( w_P
));
52 is_match
= windows_handler
->find_window( window()) != None
;
53 kDebug() << "Existing_window_condition::set_match :" << is_match
;
57 void Existing_window_condition::cfg_write( KConfigGroup
& cfg_P
) const
59 base::cfg_write( cfg_P
);
60 KConfigGroup
windowConfig( cfg_P
.config(), cfg_P
.name() + "Window" );
61 window()->cfg_write( windowConfig
);
62 cfg_P
.writeEntry( "Type", "EXISTING_WINDOW" ); // overwrites value set in base::cfg_write()
65 Existing_window_condition
* Existing_window_condition::copy( Condition_list_base
* parent_P
) const
67 return new Existing_window_condition( window()->copy(), parent_P
);
70 const QString
Existing_window_condition::description() const
72 return i18n( "Existing window: " ) + window()->comment();
75 void Existing_window_condition::window_added( WId w_P
)
80 void Existing_window_condition::window_removed( WId
)
85 Existing_window_condition::~Existing_window_condition()
87 disconnect( windows_handler
, NULL
, this, NULL
);
91 } // namespace KHotKeys