summaryrefslogtreecommitdiffstats
path: root/kwin/clients/quartz/config/config.cpp
blob: c4c8e5cbab7e303bd8d501af6f35cfd5f80c81fb (plain)
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
/* 	
 *
 *	This file contains the quartz configuration widget
 *
 *	Copyright (c) 2001
 *		Karol Szwed <[email protected]>
 *		http://gallium.n3.net/
 */

#include "config.h"
#include <kglobal.h>
#include <tqwhatsthis.h>
#include <klocale.h>


extern "C"
{
	KDE_EXPORT TQObject* allocate_config( KConfig* conf, TQWidget* parent )
	{
		return(new QuartzConfig(conf, parent));
	}
}


/* NOTE: 
 * 'conf' 	is a pointer to the twindecoration modules open twin config,
 *			and is by default set to the "Style" group.
 *
 * 'parent'	is the parent of the TQObject, which is a VBox inside the
 *			Configure tab in twindecoration
 */

QuartzConfig::QuartzConfig( KConfig* conf, TQWidget* parent )
	: TQObject( parent )
{
	quartzConfig = new KConfig("twinquartzrc");
	KGlobal::locale()->insertCatalogue("twin_clients");
	gb = new TQVBox( parent );
	cbColorBorder = new TQCheckBox( 
						i18n("Draw window frames using &titlebar colors"), gb );
	TQWhatsThis::add( cbColorBorder, 
						i18n("When selected, the window decoration borders "
						"are drawn using the titlebar colors; otherwise, they are "
						"drawn using normal border colors instead.") );
	cbExtraSmall = new TQCheckBox( i18n("Quartz &extra slim"), gb );
	TQWhatsThis::add( cbExtraSmall,
		i18n("Quartz window decorations with extra-small title bar.") );
	// Load configuration options
	load( conf );

	// Ensure we track user changes properly
	connect( cbColorBorder, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotSelectionChanged()) );
	connect( cbExtraSmall,  TQT_SIGNAL(clicked()), this, TQT_SLOT(slotSelectionChanged()) );

	// Make the widgets visible in twindecoration
	gb->show();
}


QuartzConfig::~QuartzConfig()
{
	delete gb;
	delete quartzConfig;
}


void QuartzConfig::slotSelectionChanged()
{
	emit changed();
}


// Loads the configurable options from the twinrc config file
// It is passed the open config from twindecoration to improve efficiency
void QuartzConfig::load( KConfig* /*conf*/ )
{
	quartzConfig->setGroup("General");
	bool override = quartzConfig->readBoolEntry( "UseTitleBarBorderColors", true );
	cbColorBorder->setChecked( override );
	override = quartzConfig->readBoolEntry( "UseQuartzExtraSlim", false );
	cbExtraSmall->setChecked( override );
}


// Saves the configurable options to the twinrc config file
void QuartzConfig::save( KConfig* /*conf*/ )
{
	quartzConfig->setGroup("General");
	quartzConfig->writeEntry( "UseTitleBarBorderColors", cbColorBorder->isChecked() );
	quartzConfig->writeEntry( "UseQuartzExtraSlim", cbExtraSmall->isChecked() );
	// Ensure others trying to read this config get updated
	quartzConfig->sync();
}


// Sets UI widget defaults which must correspond to style defaults
void QuartzConfig::defaults()
{
	cbColorBorder->setChecked( true );
	cbExtraSmall->setChecked( false );
}

#include "config.moc"
// vim: ts=4