Skip to content

Commit

Permalink
Merge pull request vedderb#54 from ddosoff/master
Browse files Browse the repository at this point in the history
Set focus to command line
  • Loading branch information
vedderb authored Dec 9, 2019
2 parents 5746b4c + 5f16d30 commit 9e22edc
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
19 changes: 15 additions & 4 deletions pages/pageterminal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ PageTerminal::~PageTerminal()
void PageTerminal::clearTerminal()
{
ui->terminalBrowser->clear();
ui->terminalEdit->setFocus();
}

VescInterface *PageTerminal::vesc() const
Expand All @@ -61,15 +62,25 @@ void PageTerminal::printReceived(QString str)

void PageTerminal::on_sendButton_clicked()
{
if (mVesc) {
if (mVesc && mVesc->isPortConnected()) {
mVesc->commands()->sendTerminalCmd(ui->terminalEdit->text());
ui->terminalEdit->clear();
}
else {
ui->terminalBrowser->append("VESC not connected");
}

ui->terminalEdit->setFocus();
}

void PageTerminal::on_helpButton_clicked()
{
if (mVesc) {
mVesc->commands()->sendTerminalCmd("help");
}
ui->terminalEdit->setText("help");
on_sendButton_clicked();
}

void PageTerminal::showEvent(QShowEvent *event)
{
QWidget::showEvent( event );
ui->terminalEdit->setFocus();
}
6 changes: 5 additions & 1 deletion pages/pageterminal.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,21 @@ class PageTerminal : public QWidget
public:
explicit PageTerminal(QWidget *parent = 0);
~PageTerminal();
void clearTerminal();

VescInterface *vesc() const;
void setVesc(VescInterface *vesc);

public slots:
void clearTerminal();

private slots:
void printReceived(QString str);

void on_sendButton_clicked();
void on_helpButton_clicked();

protected:
virtual void showEvent(QShowEvent *event);
private:
Ui::PageTerminal *ui;
VescInterface *mVesc;
Expand Down
11 changes: 7 additions & 4 deletions pages/pageterminal.ui
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,16 @@
<connection>
<sender>clearButton</sender>
<signal>clicked()</signal>
<receiver>terminalBrowser</receiver>
<slot>clear()</slot>
<receiver>PageTerminal</receiver>
<slot>clearTerminal()</slot>
<hints>
<hint type="sourcelabel">
<x>599</x>
<y>423</y>
</hint>
<hint type="destinationlabel">
<x>577</x>
<y>368</y>
<x>315</x>
<y>225</y>
</hint>
</hints>
</connection>
Expand All @@ -139,4 +139,7 @@
</hints>
</connection>
</connections>
<slots>
<slot>clearTerminal()</slot>
</slots>
</ui>

0 comments on commit 9e22edc

Please sign in to comment.