mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Added enabled state and button to be able to execute a command object
p4#: 22397
This commit is contained in:
@@ -51,6 +51,7 @@ RimCommandExecuteScript::RimCommandExecuteScript()
|
|||||||
{
|
{
|
||||||
CAF_PDM_InitField(&scriptText, "ScriptText", QString(), "ScriptText", "", "" ,"");
|
CAF_PDM_InitField(&scriptText, "ScriptText", QString(), "ScriptText", "", "" ,"");
|
||||||
scriptText.setUiEditorTypeName(caf::PdmUiTextEditor::uiEditorTypeName());
|
scriptText.setUiEditorTypeName(caf::PdmUiTextEditor::uiEditorTypeName());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@@ -93,6 +94,18 @@ void RimCommandExecuteScript::undo()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RimCommandExecuteScript::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute)
|
||||||
|
{
|
||||||
|
caf::PdmUiTextEditorAttribute* myAttr = dynamic_cast<caf::PdmUiTextEditorAttribute*>(attribute);
|
||||||
|
if (myAttr)
|
||||||
|
{
|
||||||
|
myAttr->showSaveButton = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,8 @@ public:
|
|||||||
|
|
||||||
virtual void redo();
|
virtual void redo();
|
||||||
virtual void undo();
|
virtual void undo();
|
||||||
|
|
||||||
|
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -139,6 +139,8 @@ void RiuMainWindow::initializeGuiNewProjectLoaded()
|
|||||||
slotRefreshViewActions();
|
slotRefreshViewActions();
|
||||||
refreshAnimationActions();
|
refreshAnimationActions();
|
||||||
refreshDrawStyleActions();
|
refreshDrawStyleActions();
|
||||||
|
|
||||||
|
m_processMonitor->slotClearTextEdit();
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QIntValidator>
|
#include <QIntValidator>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "cafFactory.h"
|
#include "cafFactory.h"
|
||||||
@@ -69,6 +70,17 @@ void PdmUiTextEditor::configureAndUpdateUi(const QString& uiConfigName)
|
|||||||
field()->ownerObject()->editorAttribute(field(), uiConfigName, &leab);
|
field()->ownerObject()->editorAttribute(field(), uiConfigName, &leab);
|
||||||
m_textMode = leab.textMode;
|
m_textMode = leab.textMode;
|
||||||
|
|
||||||
|
if (leab.showSaveButton)
|
||||||
|
{
|
||||||
|
disconnect(m_textEdit, SIGNAL(textChanged()), this, SLOT(slotTextChanged()));
|
||||||
|
m_saveButton->show();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
connect(m_textEdit, SIGNAL(textChanged()), this, SLOT(slotTextChanged()));
|
||||||
|
m_saveButton->hide();
|
||||||
|
}
|
||||||
|
|
||||||
m_textEdit->blockSignals(true);
|
m_textEdit->blockSignals(true);
|
||||||
switch (leab.textMode)
|
switch (leab.textMode)
|
||||||
{
|
{
|
||||||
@@ -89,9 +101,25 @@ void PdmUiTextEditor::configureAndUpdateUi(const QString& uiConfigName)
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
QWidget* PdmUiTextEditor::createEditorWidget(QWidget * parent)
|
QWidget* PdmUiTextEditor::createEditorWidget(QWidget * parent)
|
||||||
{
|
{
|
||||||
m_textEdit = new QTextEdit(parent);
|
QWidget* containerWidget = new QWidget(parent);
|
||||||
|
|
||||||
|
m_textEdit = new QTextEdit(containerWidget);
|
||||||
connect(m_textEdit, SIGNAL(textChanged()), this, SLOT(slotTextChanged()));
|
connect(m_textEdit, SIGNAL(textChanged()), this, SLOT(slotTextChanged()));
|
||||||
return m_textEdit;
|
|
||||||
|
m_saveButton = new QPushButton("Save changes", containerWidget);
|
||||||
|
connect(m_saveButton, SIGNAL(clicked()), this, SLOT(slotSaveButtonClicked()));
|
||||||
|
|
||||||
|
QVBoxLayout* layout = new QVBoxLayout;
|
||||||
|
layout->addWidget(m_textEdit);
|
||||||
|
|
||||||
|
QHBoxLayout* buttonLayout = new QHBoxLayout;
|
||||||
|
buttonLayout->insertStretch(0, 10);
|
||||||
|
buttonLayout->addWidget(m_saveButton);
|
||||||
|
|
||||||
|
layout->addLayout(buttonLayout);
|
||||||
|
containerWidget->setLayout(layout);
|
||||||
|
|
||||||
|
return containerWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@@ -126,5 +154,13 @@ void PdmUiTextEditor::slotTextChanged()
|
|||||||
this->setValueToField(v);
|
this->setValueToField(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void PdmUiTextEditor::slotSaveButtonClicked()
|
||||||
|
{
|
||||||
|
slotTextChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // end namespace caf
|
} // end namespace caf
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
#include <QPushButton>
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
|
||||||
@@ -40,6 +41,7 @@ public:
|
|||||||
PdmUiTextEditorAttribute()
|
PdmUiTextEditorAttribute()
|
||||||
{
|
{
|
||||||
textMode = PLAIN;
|
textMode = PLAIN;
|
||||||
|
showSaveButton = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum TextMode
|
enum TextMode
|
||||||
@@ -49,7 +51,8 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TextMode textMode;
|
TextMode textMode;
|
||||||
|
bool showSaveButton;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -69,10 +72,12 @@ protected:
|
|||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void slotTextChanged();
|
void slotTextChanged();
|
||||||
|
void slotSaveButtonClicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer<QTextEdit> m_textEdit;
|
QPointer<QTextEdit> m_textEdit;
|
||||||
QPointer<QLabel> m_label;
|
QPointer<QPushButton> m_saveButton;
|
||||||
|
QPointer<QLabel> m_label;
|
||||||
|
|
||||||
PdmUiTextEditorAttribute::TextMode m_textMode;
|
PdmUiTextEditorAttribute::TextMode m_textMode;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user