Commit 47747630 authored by hjk's avatar hjk Committed by hjk
Browse files

Enable SavedAction with QTextEdit



Change-Id: Ica5e65124926eeb911ffc6fd5fa8105d6075c18f
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 912cd548
...@@ -42,10 +42,11 @@ ...@@ -42,10 +42,11 @@
#include <QtGui/QAction> #include <QtGui/QAction>
#include <QtGui/QActionGroup> #include <QtGui/QActionGroup>
#include <QtGui/QCheckBox> #include <QtGui/QCheckBox>
#include <QtGui/QGroupBox>
#include <QtGui/QLineEdit> #include <QtGui/QLineEdit>
#include <QtGui/QRadioButton> #include <QtGui/QRadioButton>
#include <QtGui/QSpinBox> #include <QtGui/QSpinBox>
#include <QtGui/QGroupBox> #include <QtGui/QTextEdit>
using namespace Utils; using namespace Utils;
...@@ -316,6 +317,9 @@ void SavedAction::connectWidget(QWidget *widget, ApplyMode applyMode) ...@@ -316,6 +317,9 @@ void SavedAction::connectWidget(QWidget *widget, ApplyMode applyMode)
qDebug() << "connectWidget to non-checkable group box" << widget << toString(); qDebug() << "connectWidget to non-checkable group box" << widget << toString();
groupBox->setChecked(m_value.toBool()); groupBox->setChecked(m_value.toBool());
connect(groupBox, SIGNAL(toggled(bool)), this, SLOT(groupBoxToggled(bool))); connect(groupBox, SIGNAL(toggled(bool)), this, SLOT(groupBoxToggled(bool)));
} else if (QTextEdit *textEdit = qobject_cast<QTextEdit *>(widget)) {
textEdit->setPlainText(m_value.toString());
connect(textEdit, SIGNAL(textChanged()), this, SLOT(textEditTextChanged()));
} else { } else {
qDebug() << "Cannot connect widget " << widget << toString(); qDebug() << "Cannot connect widget " << widget << toString();
} }
...@@ -343,6 +347,8 @@ void SavedAction::apply(QSettings *s) ...@@ -343,6 +347,8 @@ void SavedAction::apply(QSettings *s)
setValue(pathChooser->path()); setValue(pathChooser->path());
else if (const QGroupBox *groupBox = qobject_cast<QGroupBox *>(m_widget)) else if (const QGroupBox *groupBox = qobject_cast<QGroupBox *>(m_widget))
setValue(groupBox->isChecked()); setValue(groupBox->isChecked());
else if (const QTextEdit *textEdit = qobject_cast<QTextEdit *>(m_widget))
setValue(textEdit->toPlainText());
if (s) if (s)
writeSettings(s); writeSettings(s);
} }
...@@ -396,6 +402,14 @@ void SavedAction::pathChooserEditingFinished() ...@@ -396,6 +402,14 @@ void SavedAction::pathChooserEditingFinished()
setValue(pathChooser->path()); setValue(pathChooser->path());
} }
void SavedAction::textEditTextChanged()
{
QTextEdit *textEdit = qobject_cast<QTextEdit *>(sender());
QTC_ASSERT(textEdit, return);
if (m_applyMode == ImmediateApply)
setValue(textEdit->toPlainText());
}
void SavedAction::groupBoxToggled(bool checked) void SavedAction::groupBoxToggled(bool checked)
{ {
if (m_applyMode == ImmediateApply) if (m_applyMode == ImmediateApply)
......
...@@ -97,6 +97,7 @@ private: ...@@ -97,6 +97,7 @@ private:
Q_SLOT void spinBoxValueChanged(int); Q_SLOT void spinBoxValueChanged(int);
Q_SLOT void spinBoxValueChanged(QString); Q_SLOT void spinBoxValueChanged(QString);
Q_SLOT void groupBoxToggled(bool checked); Q_SLOT void groupBoxToggled(bool checked);
Q_SLOT void textEditTextChanged();
QVariant m_value; QVariant m_value;
QVariant m_defaultValue; QVariant m_defaultValue;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment