diff options
author | hjk <qtc-committer@nokia.com> | 2009-04-02 14:49:49 +0200 |
---|---|---|
committer | hjk <qtc-committer@nokia.com> | 2009-04-02 16:26:10 +0200 |
commit | 4198ffa193910461fa87e84723255640f0450994 (patch) | |
tree | 9a96b8fd96e1f617a9c25b8a3f5053890aa6c657 /src/libs/utils/savedaction.cpp | |
parent | 4fec64a2339b600634323b7b2e63713308b5811e (diff) |
utils: make QSpinBox useable for SavedAction
Diffstat (limited to 'src/libs/utils/savedaction.cpp')
-rw-r--r-- | src/libs/utils/savedaction.cpp | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/src/libs/utils/savedaction.cpp b/src/libs/utils/savedaction.cpp index af6f6469e27..0a405e5c7e7 100644 --- a/src/libs/utils/savedaction.cpp +++ b/src/libs/utils/savedaction.cpp @@ -35,12 +35,13 @@ #include <QtCore/QDebug> #include <QtCore/QSettings> +#include <QtGui/QAbstractButton> #include <QtGui/QAction> #include <QtGui/QActionGroup> -#include <QtGui/QAbstractButton> -#include <QtGui/QRadioButton> #include <QtGui/QCheckBox> #include <QtGui/QLineEdit> +#include <QtGui/QRadioButton> +#include <QtGui/QSpinBox> using namespace Core::Utils; @@ -289,6 +290,13 @@ void SavedAction::connectWidget(QWidget *widget, ApplyMode applyMode) connect(button, SIGNAL(clicked()), this, SLOT(uncheckableButtonClicked())); } + } else if (QSpinBox *spinBox = qobject_cast<QSpinBox *>(widget)) { + spinBox->setValue(m_value.toInt()); + //qDebug() << "SETTING VALUE" << spinBox->value(); + connect(spinBox, SIGNAL(valueChanged(int)), + this, SLOT(spinBoxValueChanged(int))); + connect(spinBox, SIGNAL(valueChanged(QString)), + this, SLOT(spinBoxValueChanged(QString))); } else if (QLineEdit *lineEdit = qobject_cast<QLineEdit *>(widget)) { lineEdit->setText(m_value.toString()); //qDebug() << "SETTING TEXT" << lineEdit->text(); @@ -322,6 +330,8 @@ void SavedAction::apply(QSettings *s) setValue(button->isChecked()); else if (QLineEdit *lineEdit = qobject_cast<QLineEdit *>(m_widget)) setValue(lineEdit->text()); + else if (QSpinBox *spinBox = qobject_cast<QSpinBox *>(m_widget)) + setValue(spinBox->value()); else if (PathChooser *pathChooser = qobject_cast<PathChooser *>(m_widget)) setValue(pathChooser->path()); if (s) @@ -353,6 +363,22 @@ void SavedAction::lineEditEditingFinished() setValue(lineEdit->text()); } +void SavedAction::spinBoxValueChanged(int value) +{ + QSpinBox *spinBox = qobject_cast<QSpinBox *>(sender()); + QTC_ASSERT(spinBox, return); + if (m_applyMode == ImmediateApply) + setValue(value); +} + +void SavedAction::spinBoxValueChanged(QString value) +{ + QSpinBox *spinBox = qobject_cast<QSpinBox *>(sender()); + QTC_ASSERT(spinBox, return); + if (m_applyMode == ImmediateApply) + setValue(value); +} + void SavedAction::pathChooserEditingFinished() { PathChooser *pathChooser = qobject_cast<PathChooser *>(sender()); |