28 #include <QVBoxLayout>
30 using namespace MailCommon;
33 QMap<QString, QString> *variables,
35 :
KDialog( parent ), mVariableName( variableName ), mVariables( variables )
37 setWindowTitle( i18n(
"Enter Values for Variables" ) );
38 setButtons( Ok | Cancel );
40 QVBoxLayout *layout =
new QVBoxLayout( mainWidget() );
42 QLabel *label =
new QLabel;
43 label->setText( i18n(
"Enter the replacement values for '%1':", variableName ) );
44 layout->addWidget( label );
46 mVariableValueText =
new KTextEdit;
47 mVariableValueText->setAcceptRichText(
false);
48 layout->addWidget( mVariableValueText );
50 mSaveVariable =
new QCheckBox;
51 mSaveVariable->setChecked(
false );
52 mSaveVariable->setText( i18n(
"Make value &default" ) );
53 mSaveVariable->setToolTip(
54 i18nc(
"@info:tooltip",
55 "Enable this to save the value entered to the right "
56 "as the default value for this variable" ) );
57 mSaveVariable->setWhatsThis(
58 i18nc(
"@info:whatsthis",
59 "If you enable this option, the value entered to the right will be saved. "
60 "If you use the same variable later, even in another snippet, the value entered "
61 "to the right will be the default value for that variable." ) );
62 layout->addWidget( mSaveVariable );
64 if ( mVariables->contains( variableName ) ) {
65 mSaveVariable->setChecked(
true );
66 mVariableValueText->setText( mVariables->value( variableName ) );
69 mVariableValueText->setFocus();
74 return mVariableValueText->toPlainText();
79 return mSaveVariable->isChecked();
84 if ( button == KDialog::Ok ) {
85 if ( mSaveVariable->isChecked() ) {
86 mVariables->insert( mVariableName, mVariableValueText->toPlainText() );
88 mVariables->remove( mVariableName );
95 KDialog::slotButtonClicked( button );
98 #include "snippetvariabledialog_p.moc"
bool saveVariableIsChecked() const
virtual void slotButtonClicked(int button)
QString variableValue() const
SnippetVariableDialog(const QString &variableName, QMap< QString, QString > *variables, QWidget *parent=0)