2 Copyright (c) 2007 Paolo Capriotti <p.capriotti@sns.it>
3 (c) 2007 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
14 OptCheckBox::OptCheckBox(BoolOptPtr opt
, OptionWidget
*owner
, QWidget
*parent
)
15 : QCheckBox(opt
->label(), parent
)
18 setChecked(m_opt
->value());
19 connect(this, SIGNAL(toggled(bool)), this, SLOT(setOpt(bool)));
22 void OptCheckBox::setOpt(bool b
) {
24 m_owner
->notifyChange();
27 OptRadioButton::OptRadioButton(SelectOptPtr opt
, int i
, OptionWidget
*owner
, QWidget
*parent
)
28 : QRadioButton(opt
->options()[i
]->label(), parent
)
32 setChecked(m_opt
->options()[i
]->value());
33 connect(this, SIGNAL(toggled(bool)), this, SLOT(setOpt(bool)));
36 void OptRadioButton::setOpt(bool b
) {
38 m_opt
->setSelected(m_index
);
39 m_owner
->notifyChange();
43 OptSpinBox::OptSpinBox(IntOptPtr opt
, OptionWidget
*owner
, QWidget
*parent
)
47 setMinimum(m_opt
->min());
48 setMaximum(m_opt
->max());
49 setValue(m_opt
->value());
50 connect(this, SIGNAL(valueChanged(int)), this, SLOT(setOpt(int)));
53 void OptSpinBox::setOpt(int i
) {
55 m_owner
->notifyChange();
58 OptSlider::OptSlider(IntOptPtr opt
, OptionWidget
*owner
, QWidget
*parent
)
62 setOrientation(Qt::Horizontal
);
63 setMinimum(m_opt
->min());
64 setMaximum(m_opt
->max());
65 setValue(m_opt
->value());
66 connect(this, SIGNAL(valueChanged(int)), this, SLOT(setOpt(int)));
69 void OptSlider::setOpt(int i
) {
71 m_owner
->notifyChange();
74 OptLineEdit::OptLineEdit(StringOptPtr opt
, OptionWidget
*owner
, QWidget
*parent
)
78 setText(m_opt
->value());
79 connect(this, SIGNAL(textChanged(const QString
&)), this, SLOT(setOpt(const QString
&)));
82 void OptLineEdit::setOpt(const QString
& s
) {
84 m_owner
->notifyChange();
87 OptUrlRequester::OptUrlRequester(UrlOptPtr opt
, OptionWidget
*owner
, QWidget
*parent
)
88 : KUrlRequester(parent
)
91 setUrl(m_opt
->value());
92 connect(this, SIGNAL(textChanged(const QString
&)), this, SLOT(setOpt(const QString
&)));
95 void OptUrlRequester::setOpt(const QString
& s
) {
97 m_owner
->notifyChange();
100 OptComboBox::OptComboBox(ComboOptPtr opt
, OptionWidget
*owner
, QWidget
*parent
)
104 addItems(m_opt
->values());
105 setCurrentIndex(m_opt
->selected());
106 connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(setOpt(int)));
109 void OptComboBox::setOpt(int c
) {
110 m_opt
->setSelected(c
);
111 m_owner
->notifyChange();
114 OptColorButton::OptColorButton(ColorOptPtr opt
, OptionWidget
*owner
, QWidget
*parent
)
115 : KColorButton(parent
)
118 setColor(m_opt
->value());
119 connect(this, SIGNAL(changed(const QColor
&)), this, SLOT(setOpt(const QColor
&)));
122 void OptColorButton::setOpt(const QColor
& c
) {
124 m_owner
->notifyChange();
127 OptFontRequester::OptFontRequester(FontOptPtr opt
, OptionWidget
*owner
, QWidget
*parent
)
128 : KFontRequester(parent
)
131 setFont(m_opt
->value());
132 connect(this, SIGNAL(fontSelected(const QFont
&)), this, SLOT(setOpt(const QFont
&)));
135 void OptFontRequester::setOpt(const QFont
& f
) {
137 m_owner
->notifyChange();