Changeset - c65e4fbe5d6d
[Not reviewed]
default
0 3 0
Hasan Yavuz Ă–ZDERYA - 10 years ago 2016-02-28 11:51:24
hy@ozderya.net
added menu items to send command
3 files changed with 17 insertions and 1 deletions:
0 comments (0 inline, 0 general)
commandpanel.cpp
Show inline comments
 
@@ -41,6 +41,7 @@ CommandPanel::CommandPanel(QSerialPort* 
 
    connect(&_newCommandAction, &QAction::triggered, this, &CommandPanel::newCommand);
 

	
 
    _menu.addAction(&_newCommandAction);
 
    _menu.addSeparator();
 

	
 
    command_name_counter = 0;
 
    newCommand(); // add an empty slot by default
 
@@ -59,6 +60,7 @@ void CommandPanel::newCommand()
 
    ui->scrollAreaWidgetContents->layout()->addWidget(command);
 
    command->setFocusToEdit();
 
    connect(command, &CommandWidget::sendCommand, this, &CommandPanel::sendCommand);
 
    _menu.addAction(command->sendAction());
 
}
 

	
 
void CommandPanel::sendCommand(QByteArray command)
commandwidget.cpp
Show inline comments
 
@@ -27,7 +27,8 @@
 

	
 
CommandWidget::CommandWidget(QWidget *parent) :
 
    QWidget(parent),
 
    ui(new Ui::CommandWidget)
 
    ui(new Ui::CommandWidget),
 
    _sendAction(this)
 
{
 
    ui->setupUi(this);
 

	
 
@@ -38,6 +39,11 @@ CommandWidget::CommandWidget(QWidget *pa
 
    connect(ui->pbDelete, &QPushButton::clicked, this, &CommandWidget::onDeleteClicked);
 
    connect(ui->pbSend, &QPushButton::clicked, this, &CommandWidget::onSendClicked);
 
    connect(ui->pbASCII, &QPushButton::toggled, this, &CommandWidget::onASCIIToggled);
 
    connect(ui->leName, &QLineEdit::textChanged, [this](QString text)
 
            {
 
                this->_sendAction.setText(text);
 
            });
 
    connect(&_sendAction, &QAction::triggered, this, &CommandWidget::onSendClicked);
 
}
 

	
 
CommandWidget::~CommandWidget()
 
@@ -108,3 +114,8 @@ void CommandWidget::setFocusToEdit()
 
{
 
    ui->leCommand->setFocus(Qt::OtherFocusReason);
 
}
 

	
 
QAction* CommandWidget::sendAction()
 
{
 
    return &_sendAction;
 
}
commandwidget.h
Show inline comments
 
@@ -22,6 +22,7 @@
 

	
 
#include <QWidget>
 
#include <QByteArray>
 
#include <QAction>
 

	
 
namespace Ui {
 
class CommandWidget;
 
@@ -38,6 +39,7 @@ public:
 
    void setName(QString name);
 
    QString name();
 
    void setFocusToEdit();
 
    QAction* sendAction();
 

	
 
signals:
 
    void deleteRequested(CommandWidget* thisWidget); // emitted when delete button is clicked
 
@@ -50,6 +52,7 @@ signals:
 

	
 
private:
 
    Ui::CommandWidget *ui;
 
    QAction _sendAction;
 

	
 
    bool isASCIIMode(); // true: ascii mode, false hex mode
 

	
0 comments (0 inline, 0 general)