Skip to content

Commit

Permalink
Use ctrl key to set/unset flag for poll feature
Browse files Browse the repository at this point in the history
Ctrl key also changes the text of the button to "Poll"
  • Loading branch information
shiftee committed Dec 11, 2017
1 parent bafedba commit 42fd8f2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
25 changes: 24 additions & 1 deletion src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ extern MainWindow * globalMainWin;
MainWindow::MainWindow( QWidget * _parent ) :
QMainWindow( _parent ),
ui( new Ui::MainWindowClass ),
m_modbus( NULL )
m_modbus( NULL ),
m_poll(false)
{
ui->setupUi(this);

Expand Down Expand Up @@ -112,6 +113,28 @@ MainWindow::~MainWindow()
delete ui;
}

void MainWindow::keyPressEvent(QKeyEvent* event)
{
if( event->key() == Qt::Key_Control )
{
//set flag to request polling
if( m_modbus != NULL )
m_poll = true;

ui->sendBtn->setText( tr("Poll") );
}
}

void MainWindow::keyReleaseEvent(QKeyEvent* event)
{
if( event->key() == Qt::Key_Control )
{
m_poll = false;

ui->sendBtn->setText( tr("Send") );
}
}

void MainWindow::busMonitorAddItem( bool isRequest,
uint8_t slave,
uint8_t func,
Expand Down
5 changes: 4 additions & 1 deletion src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,14 @@ private slots:
void setStatusError(const QString &msg);

private:
void keyPressEvent(QKeyEvent* event);
void keyReleaseEvent(QKeyEvent* event);

Ui::MainWindowClass * ui;
modbus_t * m_modbus;
QWidget * m_statusInd;
QLabel * m_statusText;

bool m_poll;
};

#endif // MAINWINDOW_H

0 comments on commit 42fd8f2

Please sign in to comment.