summaryrefslogtreecommitdiffstats
path: root/twin-styles/cde/config/config.cpp
blob: 41631d57ef2f4406295254240fdc50e71122baf8 (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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// $Id$
#include "config.h"
#include <kapplication.h>
#include <kglobal.h>
#include <tqwhatsthis.h>
#include <tqvbox.h>
#include <klocale.h>

extern "C" KDE_EXPORT TQObject* allocate_config( KConfig* conf, TQWidget* parent )
{
	return new CdeConfig(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
 */

CdeConfig::CdeConfig( KConfig* conf, TQWidget* parent )
	: TQObject( parent )
{
	cdeConfig = new KConfig("twincderc");
	KGlobal::locale()->insertCatalogue("twin_art_clients");
	
	groupBox = new TQVBox( parent );
	
	bgAlign = new TQButtonGroup( 3, Qt::Horizontal, i18n("Text &Alignment"), groupBox );
	bgAlign->setExclusive( true );
	TQWhatsThis::add( bgAlign, i18n("Use these buttons to set the alignment of the titlebar caption text.") );
	new TQRadioButton( i18n("Left"), bgAlign, "AlignLeft" );
	TQRadioButton *radio2 = new TQRadioButton( i18n("Centered"), bgAlign, "AlignHCenter" );
	radio2->setChecked( true );
	new TQRadioButton( i18n("Right"), bgAlign, "AlignRight" );
	
	cbColorBorder = new TQCheckBox( i18n("Draw window frames using &titlebar colors"), groupBox );
	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.") );
	
//	cbTitlebarButton = new TQCheckBox( i18n("Titlebar acts like a &pushbutton when clicked"), groupBox );
//	TQWhatsThis::add( cbTitlebarButton, i18n("When selected, this option causes the window titlebar to behave "
//						"as if it was a pushbutton when you click it to move the window.") );
	
	(void) new TQLabel( i18n("Tip: If you want the look of the original Motif(tm) Window Manager,\n"
				"click the \"Buttons\" tab above and remove the help\n"
				"and close buttons from the titlebar."), groupBox );
	
	// Load configuration options
	load( conf );

	// Ensure we track user changes properly
	connect( cbColorBorder, TQT_SIGNAL(clicked()), TQT_SLOT(slotSelectionChanged()) );
//	connect( cbTitlebarButton, TQT_SIGNAL(clicked()), TQT_SLOT(slotSelectionChanged()) );
	connect( bgAlign, TQT_SIGNAL(clicked(int)), TQT_SLOT(slotSelectionChanged(int)) );

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


CdeConfig::~CdeConfig()
{
	delete bgAlign;
	delete groupBox;
	delete cdeConfig;
}


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

void CdeConfig::slotSelectionChanged( int )
{
	emit changed();
}

// Loads the configurable options from the twinrc config file
// It is passed the open config from twindecoration to improve efficiency
void CdeConfig::load( KConfig* /*conf*/ )
{
	cdeConfig->setGroup("General");

	TQString value = cdeConfig->readEntry( "TextAlignment", "AlignHCenter" );
	TQRadioButton *button = (TQRadioButton*)bgAlign->child( (const char *)value.latin1() );
	if ( button )
	    button->setChecked( true );

	bool coloredFrame = cdeConfig->readBoolEntry( "UseTitleBarBorderColors", true );
	cbColorBorder->setChecked( coloredFrame );

//	bool titlebarButton = cdeConfig->readBoolEntry( "TitlebarButtonMode", true );
//	cbTitlebarButton->setChecked( titlebarButton );
}


// Saves the configurable options to the twinrc config file
void CdeConfig::save( KConfig* /*conf*/ )
{
	cdeConfig->setGroup("General");

	TQRadioButton *button = (TQRadioButton*)bgAlign->selected();
	if ( button )
	    cdeConfig->writeEntry( "TextAlignment", TQString(button->name()) );

	cdeConfig->writeEntry( "UseTitleBarBorderColors", cbColorBorder->isChecked() );
//	cdeConfig->writeEntry( "TitlebarButtonMode", cbTitlebarButton->isChecked() );
	
	// Ensure others trying to read this config get updated
	cdeConfig->sync();
}


// Sets UI widget defaults which must correspond to style defaults
void CdeConfig::defaults()
{
	TQRadioButton *button = (TQRadioButton*)bgAlign->child( "AlignHCenter" );
	if ( button )
	    button->setChecked( true );

	cbColorBorder->setChecked( true );
//	cbTitlebarButton->setChecked( true );
}

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