Changeset - cd8c3e8601e0
[Not reviewed]
default
0 5 0
Hasan Yavuz Ă–ZDERYA - 9 years ago 2016-06-14 22:11:39
hy@ozderya.net
focus on command panel when user tries to send an empty command from the menu
5 files changed with 14 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/commandpanel.cpp
Show inline comments
 
@@ -62,6 +62,7 @@ void CommandPanel::newCommand()
 
    ui->scrollAreaWidgetContents->layout()->addWidget(command);
 
    command->setFocusToEdit();
 
    connect(command, &CommandWidget::sendCommand, this, &CommandPanel::sendCommand);
 
    connect(command, &CommandWidget::focusRequested, this, &CommandPanel::focusRequested);
 
    _menu.addAction(command->sendAction());
 
}
 

	
src/commandpanel.h
Show inline comments
 
@@ -43,6 +43,10 @@ public:
 
    QMenu* menu();
 
    QAction* newCommandAction();
 

	
 
signals:
 
    // emitted when user tries to send an empty command
 
    void focusRequested();
 

	
 
private:
 
    Ui::CommandPanel *ui;
 
    QSerialPort* serialPort;
src/commandwidget.cpp
Show inline comments
 
@@ -64,6 +64,7 @@ void CommandWidget::onSendClicked()
 
    {
 
        qWarning() << "Enter a command to send!";
 
        ui->leCommand->setFocus(Qt::OtherFocusReason);
 
        emit focusRequested();
 
        return;
 
    }
 

	
src/commandwidget.h
Show inline comments
 
@@ -50,6 +50,9 @@ signals:
 
    // string containing hexadecimal characters only (not even spaces)
 
    void sendCommand(QByteArray command);
 

	
 
    // emitted when user tries to send an empty command
 
    void focusRequested();
 

	
 
private:
 
    Ui::CommandWidget *ui;
 
    QAction _sendAction;
src/mainwindow.cpp
Show inline comments
 
@@ -70,6 +70,11 @@ MainWindow::MainWindow(QWidget *parent) 
 
                this->ui->tabWidget->setCurrentWidget(&commandPanel);
 
            });
 

	
 
    connect(&commandPanel, &CommandPanel::focusRequested, [this]()
 
            {
 
                this->ui->tabWidget->setCurrentWidget(&commandPanel);
 
            });
 

	
 
    setupAboutDialog();
 

	
 
    // init view menu
0 comments (0 inline, 0 general)