Fix debian/rules to build in BUILD/ dir.
[tagua/yd.git] / src / option_p.cpp
bloba7a6ad6ce584f030078b422f7a9ef6267632049f
1 /*
2 Copyright (c) 2007 Paolo Capriotti <p.capriotti@gmail.com>
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.
9 */
11 #include "option_p.h"
14 OptCheckBox::OptCheckBox(BoolOptPtr opt, OptionWidget *owner, QWidget *parent)
15 : QCheckBox(opt->label(), parent)
16 , m_owner(owner)
17 , m_opt(opt) {
18 setChecked(m_opt->value());
19 connect(this, SIGNAL(toggled(bool)), this, SLOT(setOpt(bool)));
22 void OptCheckBox::setOpt(bool b) {
23 m_opt->setValue(b);
24 m_owner->notifyChange();
27 OptRadioButton::OptRadioButton(SelectOptPtr opt, int i, OptionWidget *owner, QWidget *parent)
28 : QRadioButton(opt->options()[i]->label(), parent)
29 , m_owner(owner)
30 , m_opt(opt)
31 , m_index(i) {
32 setChecked(m_opt->options()[i]->value());
33 connect(this, SIGNAL(toggled(bool)), this, SLOT(setOpt(bool)));
36 void OptRadioButton::setOpt(bool b) {
37 if(b) {
38 m_opt->setSelected(m_index);
39 m_owner->notifyChange();
43 OptSpinBox::OptSpinBox(IntOptPtr opt, OptionWidget *owner, QWidget *parent)
44 : QSpinBox(parent)
45 , m_owner(owner)
46 , m_opt(opt) {
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) {
54 m_opt->setValue(i);
55 m_owner->notifyChange();
58 OptSlider::OptSlider(IntOptPtr opt, OptionWidget *owner, QWidget *parent)
59 : QSlider(parent)
60 , m_owner(owner)
61 , m_opt(opt) {
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) {
70 m_opt->setValue(i);
71 m_owner->notifyChange();
74 OptLineEdit::OptLineEdit(StringOptPtr opt, OptionWidget *owner, QWidget *parent)
75 : QLineEdit(parent)
76 , m_owner(owner)
77 , m_opt(opt) {
78 setText(m_opt->value());
79 connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(setOpt(const QString&)));
82 void OptLineEdit::setOpt(const QString& s) {
83 m_opt->setValue(s);
84 m_owner->notifyChange();
87 OptUrlRequester::OptUrlRequester(UrlOptPtr opt, OptionWidget *owner, QWidget *parent)
88 : KUrlRequester(parent)
89 , m_owner(owner)
90 , m_opt(opt) {
91 setUrl(m_opt->value());
92 connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(setOpt(const QString&)));
95 void OptUrlRequester::setOpt(const QString& s) {
96 m_opt->setValue(s);
97 m_owner->notifyChange();
100 OptComboBox::OptComboBox(ComboOptPtr opt, OptionWidget *owner, QWidget *parent)
101 : QComboBox(parent)
102 , m_owner(owner)
103 , m_opt(opt) {
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)
116 , m_owner(owner)
117 , m_opt(opt) {
118 setColor(m_opt->value());
119 connect(this, SIGNAL(changed(const QColor&)), this, SLOT(setOpt(const QColor&)));
122 void OptColorButton::setOpt(const QColor& c) {
123 m_opt->setValue(c);
124 m_owner->notifyChange();
127 OptFontRequester::OptFontRequester(FontOptPtr opt, OptionWidget *owner, QWidget *parent)
128 : KFontRequester(parent)
129 , m_owner(owner)
130 , m_opt(opt) {
131 setFont(m_opt->value());
132 connect(this, SIGNAL(fontSelected(const QFont&)), this, SLOT(setOpt(const QFont&)));
135 void OptFontRequester::setOpt(const QFont& f) {
136 m_opt->setValue(f);
137 m_owner->notifyChange();