add more spacing
[personal-kdebase.git] / workspace / kwin / clients / modernsystem / config / config.cpp
blob6a61def8fd1489664ca1948afa123577261b472f
1 /********************************************************************
2 This program is free software; you can redistribute it and/or modify
3 it under the terms of the GNU General Public License as published by
4 the Free Software Foundation; either version 2 of the License, or
5 (at your option) any later version.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with this program. If not, see <http://www.gnu.org/licenses/>.
14 *********************************************************************/
16 // Melchior FRANZ <mfranz@kde.org> -- 2001-04-22
18 #include "config.h"
20 #include <kapplication.h>
21 #include <kconfig.h>
22 #include <kdialog.h>
23 #include <klocale.h>
24 #include <kglobal.h>
25 #include <QLayout>
27 //Added by qt3to4:
28 #include <QLabel>
29 #include <QVBoxLayout>
30 #include <QGridLayout>
31 #include <kvbox.h>
34 extern "C"
36 KDE_EXPORT QObject* allocate_config(KConfig* conf, QWidget* parent)
38 return(new ModernSysConfig(conf, parent));
43 // 'conf' is a pointer to the kwindecoration modules open kwin config,
44 // and is by default set to the "Style" group.
46 // 'parent' is the parent of the QObject, which is a VBox inside the
47 // Configure tab in kwindecoration
49 ModernSysConfig::ModernSysConfig(KConfig* conf, QWidget* parent) : QObject(parent)
51 clientrc = new KConfig("kwinmodernsysrc");
52 KGlobal::locale()->insertCatalog("kwin_clients");
53 mainw = new QWidget(parent);
54 vbox = new QVBoxLayout(mainw);
55 vbox->setSpacing(6);
56 vbox->setMargin(0);
58 handleBox = new QWidget(mainw);
59 QGridLayout* layout = new QGridLayout(handleBox );
60 layout->setSpacing( KDialog::spacingHint() );
62 cbShowHandle = new QCheckBox(i18n("&Show window resize handle"), handleBox);
63 cbShowHandle->setWhatsThis(
64 i18n("When selected, all windows are drawn with a resize "
65 "handle at the lower right corner. This makes window resizing "
66 "easier, especially for trackballs and other mouse replacements "
67 "on laptops."));
68 layout->addWidget(cbShowHandle, 0, 0, 1, 2 );
69 connect(cbShowHandle, SIGNAL(clicked()), this, SLOT(slotSelectionChanged()));
71 sliderBox = new KVBox(handleBox);
72 //handleSizeSlider = new QSlider(0, 4, 1, 0, Qt::Horizontal, sliderBox);
73 handleSizeSlider = new QSlider(Qt::Horizontal, sliderBox);
74 handleSizeSlider->setMinimum(0);
75 handleSizeSlider->setMaximum(4);
76 handleSizeSlider->setPageStep(1);
77 handleSizeSlider->setWhatsThis(
78 i18n("Here you can change the size of the resize handle."));
79 handleSizeSlider->setTickInterval(1);
80 handleSizeSlider->setTickPosition(QSlider::TicksBelow);
81 connect(handleSizeSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSelectionChanged()));
83 hbox = new KHBox(sliderBox);
84 hbox->setSpacing(6);
86 bool rtl = kapp->layoutDirection() == Qt::RightToLeft;
87 label1 = new QLabel(i18n("Small"), hbox);
88 label1->setAlignment(rtl ? Qt::AlignRight : Qt::AlignLeft);
89 label2 = new QLabel(i18n("Medium"), hbox);
90 label2->setAlignment( Qt::AlignHCenter );
91 label3 = new QLabel(i18n("Large"), hbox);
92 label3->setAlignment(rtl ? Qt::AlignLeft : Qt::AlignRight);
94 vbox->addWidget(handleBox);
95 vbox->addStretch(1);
97 // layout->setColumnMinimumWidth(0, 30);
98 layout->addItem(new QSpacerItem(30, 10, QSizePolicy::Fixed, QSizePolicy::Fixed), 1, 0);
99 layout->addWidget(sliderBox, 1, 1);
101 KConfigGroup group(conf,"General");
102 load(group);
103 mainw->show();
107 ModernSysConfig::~ModernSysConfig()
109 delete mainw;
110 delete clientrc;
114 void ModernSysConfig::slotSelectionChanged()
116 bool i = cbShowHandle->isChecked();
117 if (i != hbox->isEnabled()) {
118 hbox->setEnabled(i);
119 handleSizeSlider->setEnabled(i);
121 emit changed();
125 void ModernSysConfig::load(const KConfigGroup& /*conf*/)
127 KConfigGroup cg(clientrc, "General");
128 bool i = cg.readEntry("ShowHandle", true);
129 cbShowHandle->setChecked(i);
130 hbox->setEnabled(i);
131 handleSizeSlider->setEnabled(i);
132 handleWidth = cg.readEntry("HandleWidth", 6);
133 handleSize = cg.readEntry("HandleSize", 30);
134 handleSizeSlider->setValue(qMin((handleWidth - 6) / 2, (uint)4));
139 void ModernSysConfig::save(KConfigGroup& /*conf*/)
141 KConfigGroup cg(clientrc, "General");
142 cg.writeEntry("ShowHandle", cbShowHandle->isChecked());
143 cg.writeEntry("HandleWidth", 6 + 2 * handleSizeSlider->value());
144 cg.writeEntry("HandleSize", 30 + 4 * handleSizeSlider->value());
145 clientrc->sync();
149 void ModernSysConfig::defaults()
151 cbShowHandle->setChecked(true);
152 hbox->setEnabled(true);
153 handleSizeSlider->setEnabled(true);
154 handleSizeSlider->setValue(0);
157 #include "config.moc"