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 <kapplication.h>
27 #include <QVBoxLayout>
28 #include <QGridLayout>
35 KDE_EXPORT QObject
* allocate_config(KConfig
* conf
, QWidget
* parent
)
37 return(new ModernSysConfig(conf
, parent
));
42 // 'conf' is a pointer to the kwindecoration modules open kwin config,
43 // and is by default set to the "Style" group.
45 // 'parent' is the parent of the QObject, which is a VBox inside the
46 // Configure tab in kwindecoration
48 ModernSysConfig::ModernSysConfig(KConfig
* conf
, QWidget
* parent
) : QObject(parent
)
50 clientrc
= new KConfig("kwinmodernsysrc");
51 KGlobal::locale()->insertCatalog("kwin_clients");
52 mainw
= new QWidget(parent
);
53 vbox
= new QVBoxLayout(mainw
);
57 handleBox
= new QWidget(mainw
);
58 QGridLayout
* layout
= new QGridLayout(handleBox
);
59 layout
->setSpacing( KDialog::spacingHint() );
61 cbShowHandle
= new QCheckBox(i18n("&Show window resize handle"), handleBox
);
62 cbShowHandle
->setWhatsThis(
63 i18n("When selected, all windows are drawn with a resize "
64 "handle at the lower right corner. This makes window resizing "
65 "easier, especially for trackballs and other mouse replacements "
67 layout
->addWidget(cbShowHandle
, 0, 0, 1, 2 );
68 connect(cbShowHandle
, SIGNAL(clicked()), this, SLOT(slotSelectionChanged()));
70 sliderBox
= new KVBox(handleBox
);
71 //handleSizeSlider = new QSlider(0, 4, 1, 0, Qt::Horizontal, sliderBox);
72 handleSizeSlider
= new QSlider(Qt::Horizontal
, sliderBox
);
73 handleSizeSlider
->setMinimum(0);
74 handleSizeSlider
->setMaximum(4);
75 handleSizeSlider
->setPageStep(1);
76 handleSizeSlider
->setWhatsThis(
77 i18n("Here you can change the size of the resize handle."));
78 handleSizeSlider
->setTickInterval(1);
79 handleSizeSlider
->setTickPosition(QSlider::TicksBelow
);
80 connect(handleSizeSlider
, SIGNAL(valueChanged(int)), this, SLOT(slotSelectionChanged()));
82 hbox
= new KHBox(sliderBox
);
85 bool rtl
= kapp
->layoutDirection() == Qt::RightToLeft
;
86 label1
= new QLabel(i18n("Small"), hbox
);
87 label1
->setAlignment(rtl
? Qt::AlignRight
: Qt::AlignLeft
);
88 label2
= new QLabel(i18n("Medium"), hbox
);
89 label2
->setAlignment( Qt::AlignHCenter
);
90 label3
= new QLabel(i18n("Large"), hbox
);
91 label3
->setAlignment(rtl
? Qt::AlignLeft
: Qt::AlignRight
);
93 vbox
->addWidget(handleBox
);
96 // layout->setColumnMinimumWidth(0, 30);
97 layout
->addItem(new QSpacerItem(30, 10, QSizePolicy::Fixed
, QSizePolicy::Fixed
), 1, 0);
98 layout
->addWidget(sliderBox
, 1, 1);
100 KConfigGroup
group(conf
,"General");
106 ModernSysConfig::~ModernSysConfig()
113 void ModernSysConfig::slotSelectionChanged()
115 bool i
= cbShowHandle
->isChecked();
116 if (i
!= hbox
->isEnabled()) {
118 handleSizeSlider
->setEnabled(i
);
124 void ModernSysConfig::load(const KConfigGroup
& /*conf*/)
126 KConfigGroup
cg(clientrc
, "General");
127 bool i
= cg
.readEntry("ShowHandle", true);
128 cbShowHandle
->setChecked(i
);
130 handleSizeSlider
->setEnabled(i
);
131 handleWidth
= cg
.readEntry("HandleWidth", 6);
132 handleSize
= cg
.readEntry("HandleSize", 30);
133 handleSizeSlider
->setValue(qMin((handleWidth
- 6) / 2, (uint
)4));
138 void ModernSysConfig::save(KConfigGroup
& /*conf*/)
140 KConfigGroup
cg(clientrc
, "General");
141 cg
.writeEntry("ShowHandle", cbShowHandle
->isChecked());
142 cg
.writeEntry("HandleWidth", 6 + 2 * handleSizeSlider
->value());
143 cg
.writeEntry("HandleSize", 30 + 4 * handleSizeSlider
->value());
148 void ModernSysConfig::defaults()
150 cbShowHandle
->setChecked(true);
151 hbox
->setEnabled(true);
152 handleSizeSlider
->setEnabled(true);
153 handleSizeSlider
->setValue(0);
156 #include "config.moc"