From 596ec969c6a10334ca1d4e925e5a246c8d38175b Mon Sep 17 00:00:00 2001 From: andrey Date: Mon, 14 Sep 2020 14:47:42 +0300 Subject: [PATCH] QCodeEdit hide f1 --- libs/widgets/qcodeedit.cpp | 8 +++++++- libs/widgets/qcodeedit.h | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/libs/widgets/qcodeedit.cpp b/libs/widgets/qcodeedit.cpp index 970d5b5..6c4a879 100644 --- a/libs/widgets/qcodeedit.cpp +++ b/libs/widgets/qcodeedit.cpp @@ -49,7 +49,7 @@ QCodeEdit::QCodeEdit(QWidget * parent): QWidget(parent) { widget_help->setFrameShape(QFrame::StyledPanel); widget_help->setLayout(new QBoxLayout(QBoxLayout::TopToBottom)); widget_help->layout()->setContentsMargins(0, 0, 0, 0); - for (int i = 0; i < 3; ++i) { + for (int i = 0; i < lh_last; ++i) { lbl_help[i] = new IconedLabel(); lbl_help[i]->setFrameShadow(QFrame::Plain); lbl_help[i]->setFrameShape(QFrame::NoFrame); @@ -58,6 +58,7 @@ QCodeEdit::QCodeEdit(QWidget * parent): QWidget(parent) { } lbl_help[lhF1]->setIcon(QIcon(":/icons/f1.png")); lbl_help[lhF1]->setText(tr("Press F1 for details")); + lbl_help[lhF1]->setVisible(false); completer = new QCodeEditCompleter(); ui->textCode->setCursorWidth(qMax(qRound(fontHeight() / 10.), 1)); @@ -235,6 +236,11 @@ bool QCodeEdit::showLineNumbers() const { } +void QCodeEdit::setHelpHintVisible(bool on) { + lbl_help[lhF1]->setVisible(on); +} + + void QCodeEdit::setEditorFont(QFont f) { ui->textCode->setFont(f); ui->textLines->setFont(f); diff --git a/libs/widgets/qcodeedit.h b/libs/widgets/qcodeedit.h index 12c993e..67a6fc3 100644 --- a/libs/widgets/qcodeedit.h +++ b/libs/widgets/qcodeedit.h @@ -79,6 +79,7 @@ public: QStringList cursorScope() const; bool showSpaces() const {return spaces_;} bool showLineNumbers() const; + void setHelpHintVisible(bool on); void setEditorFont(QFont f); QFont editorFont() const; @@ -124,7 +125,8 @@ private: enum LabelHelpType { lhMain, lhHint, - lhF1 + lhF1, + lh_last }; QCodeEditCompleter * completer;