| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | #include "qg_commandhistory.h" |
| |
|
| | #include <QMouseEvent> |
| | |
| | QG_CommandHistory::QG_CommandHistory(QWidget* parent) : |
| | QTextEdit(parent){ |
| | setContextMenuPolicy(Qt::ActionsContextMenu); |
| |
|
| | m_pCopy = new QAction(tr("&Copy"), this); |
| | connect(m_pCopy, &QAction::triggered, this, &QG_CommandHistory::copy); |
| | addAction(m_pCopy); |
| | m_pCopy->setVisible(false); |
| | |
| | connect(this, &QG_CommandHistory::copyAvailable, m_pCopy, &QAction::setVisible); |
| |
|
| | m_pSelectAll = new QAction(tr("Select &All"), this); |
| | connect(m_pSelectAll, &QAction::triggered, this, &QG_CommandHistory::selectAll); |
| | addAction(m_pSelectAll); |
| | connect(this, &QG_CommandHistory::textChanged, this, &QG_CommandHistory::slotTextChanged); |
| |
|
| | QAction* clear = new QAction(tr("Clear"), this); |
| | connect(clear, &QAction::triggered, this, &QG_CommandHistory::clear); |
| | addAction(clear); |
| |
|
| | #ifndef DONT_FORCE_WIDGETS_CSS |
| | setStyleSheet("selection-color: white; selection-background-color: green;"); |
| | #endif |
| | } |
| |
|
| | void QG_CommandHistory::mouseReleaseEvent(QMouseEvent* event){ |
| | QTextEdit::mouseReleaseEvent(event); |
| | if (event->button() == Qt::LeftButton && m_pCopy->isVisible()) { |
| | copy(); |
| | } |
| | } |
| |
|
| | void QG_CommandHistory::slotTextChanged(){ |
| | |
| | m_pSelectAll->setVisible(! toPlainText().isEmpty()); |
| | } |
| |
|