1
/********************************************************************
2
KWin - the KDE window manager
3
This file is part of the KDE project.
5
Copyright (C) 2005 Lubos Lunak <l.lunak@kde.org>
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2 of the License, or
10
(at your option) any later version.
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
17
You should have received a copy of the GNU General Public License
18
along with this program. If not, see <http://www.gnu.org/licenses/>.
19
*********************************************************************/
21
// read additional window rules and add them to kwinrulesrc
24
#include <kconfiggroup.h>
26
#include <kcomponentdata.h>
27
#include <kstandarddirs.h>
28
#include <kaboutdata.h>
29
#include <kcmdlineargs.h>
31
#include <QtDBus/QtDBus>
33
int main( int argc, char* argv[] )
37
KAboutData about( "kwin_update_default_rules", "kwin", KLocalizedString(), 0 );
38
KCmdLineArgs::init( argc, argv, &about );
39
KComponentData inst( &about );
40
Q_UNUSED( KGlobal::locale() ); // jump-start locales to get to translated descriptions
41
QString file = KStandardDirs::locate( "data", QString( "kwin/default_rules/%1" ).arg(argv[ 1 ] ));
44
kWarning(1212) << "File " << argv[ 1 ] << " not found!" ;
47
KConfig src_cfg( file );
48
KConfig dest_cfg( "kwinrulesrc" );
49
KConfigGroup scg(&src_cfg, "General");
50
KConfigGroup dcg(&dest_cfg, "General");
51
int count = scg.readEntry( "count", 0 );
52
int pos = dcg.readEntry( "count", 0 );
57
QMap< QString, QString > entries = src_cfg.entryMap( QString::number( group ));
59
dest_cfg.deleteGroup( QString::number( pos ));
60
KConfigGroup dcg2 (&dest_cfg, QString::number( pos ));
61
for( QMap< QString, QString >::ConstIterator it = entries.constBegin();
62
it != entries.constEnd();
64
dcg2.writeEntry( it.key(), *it );
66
dcg.writeEntry( "count", pos );
69
// Send signal to all kwin instances
70
QDBusMessage message =
71
QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig");
72
QDBusConnection::sessionBus().send(message);