Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command line fixes and improvements #138

Merged
merged 8 commits into from
Jun 21, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Easier command line keyboard input
Make command line window take strong focus
Give command line widget a flashing cursor when active
  • Loading branch information
marcusbirkin committed Jun 11, 2018
commit fbc848e79b0e29818836221f97da855748b8132a
25 changes: 24 additions & 1 deletion src/commandline.cpp
Original file line number Diff line number Diff line change
@@ -311,11 +311,34 @@ QString CommandLine::text()

/************************ CommandLineWidget ******************************/

CommandLineWidget::CommandLineWidget(QWidget *parent) : QTextEdit(parent)
CommandLineWidget::CommandLineWidget(QWidget *parent) : QTextEdit(parent),
m_cursorTimer(new QTimer(this)),
m_cursorState(true)
{
this->setReadOnly(true);
setStyleSheet("color: rgb(127, 255, 23);background: black;font: 75 12pt \"Courier\";");
clear();

// Cursor blinker
connect(m_cursorTimer, SIGNAL(timeout()), this, SLOT(flashCursor()));
m_cursorTimer->setInterval(300);
m_cursorTimer->setSingleShot(false);
m_cursorTimer->start();
}

void CommandLineWidget::flashCursor()
{
if (this->hasFocus())
{
auto cursor = (m_cursorState == true) ? "_" : "";
this->setText(QString("%1%2")
.arg(m_commandLine.text())
.arg(cursor));

m_cursorState = !m_cursorState;
} else {
this->setText(m_commandLine.text());
}
}

void CommandLineWidget::displayText()
4 changes: 4 additions & 0 deletions src/commandline.h
Original file line number Diff line number Diff line change
@@ -91,9 +91,13 @@ public slots:
void setLevels(QSet<int> addreses, int level);
protected:
virtual void keyPressEvent(QKeyEvent *e);
private slots:
void flashCursor();
private:
CommandLine m_commandLine;
void displayText();
QTimer *m_cursorTimer;
bool m_cursorState;
};

class EditableLCDNumber : public QLCDNumber
6 changes: 5 additions & 1 deletion src/transmitwindow.cpp
Original file line number Diff line number Diff line change
@@ -77,6 +77,7 @@ transmitwindow::transmitwindow(int universe, QWidget *parent) :
QToolButton *button = new QToolButton(this);
button->setText(QString::number(i+1));
button->setMinimumSize(16, 16);
button->setFocusPolicy(Qt::FocusPolicy::NoFocus);
layout->addWidget(button);
m_presetButtons << button;
connect(button, SIGNAL(pressed()), this, SLOT(presetButtonPressed()));
@@ -85,6 +86,7 @@ transmitwindow::transmitwindow(int universe, QWidget *parent) :
m_presetButtons << recordButton;
recordButton->setCheckable(true);
recordButton->setIcon(QIcon(":/icons/record.png"));
recordButton->setFocusPolicy(Qt::FocusPolicy::NoFocus);
layout->addWidget(recordButton);
ui->gbPresets->setLayout(layout);
connect(recordButton, SIGNAL(toggled(bool)), this, SLOT(recordButtonPressed(bool)));
@@ -271,7 +273,7 @@ void transmitwindow::setUniverseOptsEnabled(bool enabled)
ui->gbProtocolVersion->setEnabled(enabled);
ui->cbBlind->setEnabled(enabled ? ui->rbRatified->isChecked() : false);
ui->tabWidget->setEnabled(!enabled);

on_tabWidget_currentChanged(ui->tabWidget->currentIndex());

if(enabled)
{
@@ -528,6 +530,8 @@ void transmitwindow::on_tabWidget_currentChanged(int index)
m_sender->setLevelRange(0, MAX_DMX_ADDRESS-1, 0);
QMetaObject::invokeMethod(
m_fxEngine,"pause");

ui->teCommandline->setFocus();
}

if(index==tabEffects)
Loading