Version 1.13.0

This commit is contained in:
2020-09-16 01:28:37 +03:00
parent 1bcef63d3d
commit 22b9abfcb4
7 changed files with 81 additions and 13 deletions

View File

@@ -10,6 +10,7 @@
#include <QTextBlock>
#include <QAction>
#include <QApplication>
#include <QDesktopServices>
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
# include <QWindow>
#endif
@@ -58,7 +59,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);
help_visible = true;
completer = new QCodeEditCompleter();
ui->textCode->setCursorWidth(qMax<int>(qRound(fontHeight() / 10.), 1));
@@ -117,6 +118,8 @@ QCodeEdit::QCodeEdit(QWidget * parent): QWidget(parent) {
addAction(a);*/
connect(completer, SIGNAL(itemDoubleClicked(QTreeWidgetItem * ,int)), this, SLOT(commitCompletition()));
connect(completer, SIGNAL(commit()), this, SLOT(commitCompletition()));
connect(completer, SIGNAL(gotoHRef(QCodeEdit::ACEntry)), this, SLOT(gotoHelpHRef(QCodeEdit::ACEntry)));
connect(ui->textCode->verticalScrollBar(), SIGNAL(valueChanged(int)), ui->textLines->verticalScrollBar(), SLOT(setValue(int)));
connect(ui->textCode->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(hideHelp()));
connect(ui->textCode, SIGNAL(textChanged()), this, SLOT(textEdit_textChanged()));
@@ -237,7 +240,12 @@ bool QCodeEdit::showLineNumbers() const {
void QCodeEdit::setHelpHintVisible(bool on) {
lbl_help[lhF1]->setVisible(on);
help_visible = on;
}
bool QCodeEdit::isHelpHintVisible() const {
return help_visible;
}
@@ -436,10 +444,11 @@ bool QCodeEdit::eventFilter(QObject * o, QEvent * e) {
QKeyEvent * ke;
QChar kc(0);
switch (e->type()) {
case QEvent::ToolTip: {
QTextCursor tc = ui->textCode->cursorForPosition(((QHelpEvent*)e)->pos());
tc.select(QTextCursor::WordUnderCursor);
raiseHelp(tc);
case QEvent::ToolTip:
if (completer->isHidden()) {
QTextCursor tc = ui->textCode->cursorForPosition(((QHelpEvent*)e)->pos());
tc.select(QTextCursor::WordUnderCursor);
raiseHelp(tc);
}
break;
case QEvent::KeyPress:
@@ -534,6 +543,10 @@ bool QCodeEdit::eventFilter(QObject * o, QEvent * e) {
case Qt::Key_Control:
showLink();
break;
case Qt::Key_F1:
if (widget_help->isVisible())
gotoHelpHRef(help_entry);
break;
default: break;
}
if (!ke->text().isEmpty())
@@ -1161,6 +1174,7 @@ void QCodeEdit::raiseHelp(QTextCursor tc, int arg) {
applyExtraSelection();
//tc.movePosition(QTextCursor::StartOfWord, QTextCursor::MoveAnchor);
lbl_help[lhMain]->setFont(font());
lbl_help[lhF1]->setVisible(!e.help_href.isEmpty() && help_visible);
qApp->processEvents();
widget_help->adjustSize();
widget_help->resize(widget_help->sizeHint());
@@ -1178,13 +1192,21 @@ void QCodeEdit::raiseHelp(QTextCursor tc, int arg) {
widget_help->move(ui->textCode->viewport()->mapToGlobal(whp));
widget_help->show();
widget_help->raise();
help_entry = e;
cursor_scope = scope.first;
cursor_scope << scope.second;
//qDebug() << "tooltip" << st;
}
void QCodeEdit::gotoHelpHRef(QCodeEdit::ACEntry e) {
if (e.help_href.isEmpty()) return;
QDesktopServices::openUrl(e.help_href);
}
void QCodeEdit::hideHelp() {
help_entry = ACEntry();
widget_help->hide();
es_cursor.cursor = QTextCursor();
cursor_scope.clear();
@@ -1313,7 +1335,7 @@ void QCodeEdit::invokeAutoCompletition(bool force) {
hideHelp();
return;
}
if (word_complet) acl << wordsCompletitionList(scope.second);
if (word_complete) acl << wordsCompletitionList(scope.second);
QFont bf(font());
bf.setBold(true);
foreach (const ACSection & ac, acl) {
@@ -1498,3 +1520,11 @@ void QCodeEdit::on_buttonReplaceAll_clicked() {
_replacing = false;
textEdit_textChanged();
}
QString QCodeEdit::ACEntry::declaration() const {
if (declaration_pos < 0 || declaration_file.isEmpty()) return QString();
return (declaration_file + ": %1").arg(declaration_pos);
}