summaryrefslogtreecommitdiffstats
path: root/twin/clients/modernsystem/config/config.cpp
blob: 4512203c4011bb0e030a4122841e5dc1c48cb830 (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
// Melchior FRANZ  <mfranz@kde.org>	-- 2001-04-22

#include <tdeapplication.h>
#include <tdeconfig.h>
#include <kdialog.h>
#include <tdelocale.h>
#include <tdeglobal.h>
#include <tqlayout.h>
#include <tqwhatsthis.h>
#include "config.h"


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


// '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

ModernSysConfig::ModernSysConfig(TDEConfig* conf, TQWidget* parent) : TQObject(parent)
{	
	clientrc = new TDEConfig("twinmodernsysrc");
	TDEGlobal::locale()->insertCatalogue("twin_clients");
	mainw = new TQWidget(parent);
	vbox = new TQVBoxLayout(mainw);
	vbox->setSpacing(6);
	vbox->setMargin(0);

	handleBox = new TQWidget(mainw);
        TQGridLayout* layout = new TQGridLayout(handleBox, 0, KDialog::spacingHint());

	cbShowHandle = new TQCheckBox(i18n("&Show window resize handle"), handleBox);
	TQWhatsThis::add(cbShowHandle,
			i18n("When selected, all windows are drawn with a resize "
			"handle at the lower right corner. This makes window resizing "
			"easier, especially for trackballs and other mouse replacements "
			"on laptops."));
        layout->addMultiCellWidget(cbShowHandle, 0, 0, 0, 1);
	connect(cbShowHandle, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotSelectionChanged()));

	sliderBox = new TQVBox(handleBox);
	handleSizeSlider = new TQSlider(0, 4, 1, 0, TQt::Horizontal, sliderBox);
	TQWhatsThis::add(handleSizeSlider,
			i18n("Here you can change the size of the resize handle."));
	handleSizeSlider->setTickInterval(1);
	handleSizeSlider->setTickmarks(TQSlider::Below);
	connect(handleSizeSlider, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(slotSelectionChanged()));

	hbox = new TQHBox(sliderBox);
	hbox->setSpacing(6);

	bool rtl = kapp->reverseLayout();
	label1 = new TQLabel(i18n("Small"), hbox);
	label1->setAlignment(rtl ? AlignRight : AlignLeft);
	label2 = new TQLabel(i18n("Medium"), hbox);
	label2->setAlignment(AlignHCenter);
	label3 = new TQLabel(i18n("Large"), hbox);
	label3->setAlignment(rtl ? AlignLeft : AlignRight);
	
	vbox->addWidget(handleBox);
	vbox->addStretch(1);

//        layout->setColSpacing(0, 30);
        layout->addItem(new TQSpacerItem(30, 10, TQSizePolicy::Fixed, TQSizePolicy::Fixed), 1, 0);
        layout->addWidget(sliderBox, 1, 1);
	
	load(conf);
	mainw->show();
}


ModernSysConfig::~ModernSysConfig()
{
	delete mainw;
	delete clientrc;
}


void ModernSysConfig::slotSelectionChanged()
{
	bool i = cbShowHandle->isChecked();
	if (i != hbox->isEnabled()) {
		hbox->setEnabled(i);
		handleSizeSlider->setEnabled(i);
	}
	emit changed();
}


void ModernSysConfig::load(TDEConfig* /*conf*/)
{
	clientrc->setGroup("General");
	bool i = clientrc->readBoolEntry("ShowHandle", true );
	cbShowHandle->setChecked(i);
	hbox->setEnabled(i);
	handleSizeSlider->setEnabled(i);
	handleWidth = clientrc->readUnsignedNumEntry("HandleWidth", 6);
	handleSize = clientrc->readUnsignedNumEntry("HandleSize", 30);
	handleSizeSlider->setValue(TQMIN((handleWidth - 6) / 2, 4));
	
}


void ModernSysConfig::save(TDEConfig* /*conf*/)
{
	clientrc->setGroup("General");
	clientrc->writeEntry("ShowHandle", cbShowHandle->isChecked());
	clientrc->writeEntry("HandleWidth", 6 + 2 * handleSizeSlider->value());
	clientrc->writeEntry("HandleSize", 30 + 4 * handleSizeSlider->value());
	clientrc->sync();
}


void ModernSysConfig::defaults()
{
	cbShowHandle->setChecked(true);
	hbox->setEnabled(true);
	handleSizeSlider->setEnabled(true);
	handleSizeSlider->setValue(0);
}

#include "config.moc"