0000826: reading from the python console for using pdb -- code cleanup
This commit is contained in:
parent
941dcbf6fc
commit
81045486fd
|
@ -1417,70 +1417,4 @@ void ConsoleHistory::doScratch( void )
|
|||
|
||||
// -----------------------------------------------------
|
||||
|
||||
/* TRANSLATOR Gui::PythonInputField */
|
||||
|
||||
PythonInputField::PythonInputField(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
QGridLayout* gridLayout = new QGridLayout(this);
|
||||
gridLayout->setSpacing(6);
|
||||
gridLayout->setMargin(9);
|
||||
|
||||
editField = new PythonEditor(this);
|
||||
gridLayout->addWidget(editField, 0, 0, 1, 1);
|
||||
setFocusProxy(editField);
|
||||
|
||||
QHBoxLayout* hboxLayout = new QHBoxLayout();
|
||||
hboxLayout->setSpacing(6);
|
||||
hboxLayout->setMargin(0);
|
||||
|
||||
QSpacerItem* spacerItem = new QSpacerItem(131, 31, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
hboxLayout->addItem(spacerItem);
|
||||
|
||||
okButton = new QPushButton(this);
|
||||
hboxLayout->addWidget(okButton);
|
||||
clearButton = new QPushButton(this);
|
||||
hboxLayout->addWidget(clearButton);
|
||||
gridLayout->addLayout(hboxLayout, 1, 0, 1, 1);
|
||||
|
||||
|
||||
this->setWindowTitle(Gui::PythonConsole::tr("Python Input Dialog"));
|
||||
okButton->setText(tr("OK"));
|
||||
clearButton->setText(tr("Clear"));
|
||||
|
||||
QObject::connect(okButton, SIGNAL(clicked()), this, SIGNAL(textEntered()));
|
||||
QObject::connect(clearButton, SIGNAL(clicked()), editField, SLOT(clear()));
|
||||
}
|
||||
|
||||
PythonInputField::~PythonInputField()
|
||||
{
|
||||
}
|
||||
|
||||
QString PythonInputField::getText() const
|
||||
{
|
||||
return editField->toPlainText();
|
||||
}
|
||||
|
||||
void PythonInputField::clear()
|
||||
{
|
||||
return editField->clear();
|
||||
}
|
||||
|
||||
void PythonInputField::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
this->setWindowTitle(Gui::PythonConsole::tr("Python Input Dialog"));
|
||||
okButton->setText(tr("OK"));
|
||||
clearButton->setText(tr("Clear"));
|
||||
}
|
||||
else {
|
||||
QWidget::changeEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
void PythonInputField::showEvent(QShowEvent* e)
|
||||
{
|
||||
editField->setFocus();
|
||||
}
|
||||
|
||||
#include "moc_PythonConsole.cpp"
|
||||
|
|
|
@ -181,29 +181,6 @@ protected:
|
|||
void colorChanged(const QString& type, const QColor& col);
|
||||
};
|
||||
|
||||
class GuiExport PythonInputField : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PythonInputField(QWidget* parent=0);
|
||||
~PythonInputField();
|
||||
QString getText() const;
|
||||
void clear();
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
void showEvent(QShowEvent* e);
|
||||
|
||||
Q_SIGNALS:
|
||||
void textEntered();
|
||||
|
||||
private:
|
||||
QPushButton* okButton;
|
||||
QPushButton* clearButton;
|
||||
QPlainTextEdit* editField;
|
||||
};
|
||||
|
||||
} // namespace Gui
|
||||
|
||||
#endif // GUI_PYTHONCONSOLE_H
|
||||
|
|
|
@ -292,19 +292,11 @@ void PythonStdin::init_type()
|
|||
PythonStdin::PythonStdin(PythonConsole *pc)
|
||||
: pyConsole(pc)
|
||||
{
|
||||
editField = new PythonInputField(/*getMainWindow()*/);
|
||||
timer = new QTimer();
|
||||
timer->setInterval(250);
|
||||
QObject::connect(timer, SIGNAL(timeout()),
|
||||
editField, SLOT(hide()));
|
||||
console = getMainWindow()->findChild<PythonConsole*>();
|
||||
}
|
||||
|
||||
PythonStdin::~PythonStdin()
|
||||
{
|
||||
// call deleteLater() because deleting immediately causes problems
|
||||
editField->deleteLater();
|
||||
timer->deleteLater();
|
||||
}
|
||||
|
||||
Py::Object PythonStdin::repr()
|
||||
|
|
|
@ -30,7 +30,6 @@ class QTimer;
|
|||
|
||||
namespace Gui {
|
||||
class PythonConsole;
|
||||
class PythonInputField;
|
||||
|
||||
/**
|
||||
* Python class for redirection of stdout to FreeCAD's Python
|
||||
|
@ -141,9 +140,7 @@ public:
|
|||
Py::Object readline(const Py::Tuple&);
|
||||
|
||||
private:
|
||||
PythonInputField* editField;
|
||||
PythonConsole* console;
|
||||
QTimer* timer;
|
||||
};
|
||||
|
||||
} // namespace Gui
|
||||
|
|
Loading…
Reference in New Issue
Block a user