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

@@ -2,8 +2,8 @@ cmake_minimum_required(VERSION 3.0)
cmake_policy(SET CMP0017 NEW) # need include() with .cmake
project(qad)
set(qad_MAJOR 1)
set(qad_MINOR 12)
set(qad_REVISION 1)
set(qad_MINOR 13)
set(qad_REVISION 0)
set(qad_SUFFIX )
set(qad_COMPANY SHS)
set(qad_DOMAIN org.SHS)

View File

@@ -647,6 +647,11 @@ void Graphic::setGraphicsDataRaw(const QByteArray & ba) {
}
void Graphic::setFloatingAxisEnabled(bool on) {
ui->checkGuides->setChecked(on);
}
void Graphic::setButtons(Graphic::Buttons b) {
buttons_ = b;
ui->buttonAutofit->setVisible(b.testFlag(Autofit));

View File

@@ -297,6 +297,7 @@ public slots:
void setGraduationSteps(double sx, double sy) {gridx = sx; gridy = sy; if (aupdate) update();}
void setAxisType(AxisType t) {axis_type_x = t; if (aupdate) update();}
void setFloatingAxisType(FloatingAxisType t) {floating_axis_type = t; setGuidesCursor(); if (aupdate) update();}
void setFloatingAxisEnabled(bool on);
void addPoint(const QPointF & p, int graphic, bool update_ = true);
void addPoint(const QPointF & p, bool update = true) {addPoint(p, curGraphic, update);}

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);
}

View File

@@ -58,10 +58,16 @@ public:
ACEntry(const QString & t = QString(), const QString & n = QString(), const QString & h = QString()):
type(t), name(n), hint(h) {declaration_pos = -1;}
bool isNull() const {return type.isEmpty() && name.isEmpty();}
QString declaration() const;
ACEntry & addHint(QString h) {hint = h; return *this;}
ACEntry & addHelpHRef(QUrl h) {help_href = h; return *this;}
ACEntry & addCustomData(QVariant d) {custom_data = d; return *this;}
QString type;
QString name;
QString hint;
int declaration_pos;
QString declaration_file;
QUrl help_href;
QVariant custom_data;
};
@@ -80,6 +86,7 @@ public:
bool showSpaces() const {return spaces_;}
bool showLineNumbers() const;
void setHelpHintVisible(bool on);
bool isHelpHintVisible() const;
void setEditorFont(QFont f);
QFont editorFont() const;
@@ -88,7 +95,7 @@ public:
void registerAutoCompletitionClass(int id, ACClassType ac_class, const QString & name, const QIcon & icon = QIcon());
bool wordCompletitionEnabled() const {return word_complet;}
bool wordCompletitionEnabled() const {return word_complete;}
protected:
typedef QPair<QString, QString> StringsPair;
@@ -136,10 +143,10 @@ private:
QList<QTextEdit::ExtraSelection> es_selected, es_custom, es_brackets, es_search_list;
QMap<int, ACClass> ac_classes;
QStringList cursor_scope;
ACEntry link_entry;
ACEntry link_entry, help_entry;
int prev_lc, auto_comp_pl, timer, cur_search_ind, pos_press, pos_el_press;
bool spaces_, _ignore_focus_out, _first, _destructor, _replacing;
bool word_complet;
bool word_complete, help_visible;
bool eventFilter(QObject * o, QEvent * e) override;
void showEvent(QShowEvent * ) override;
@@ -155,6 +162,7 @@ private:
private slots:
void _activateLink(QCodeEdit::ACEntry e) {linkClicked(e);}
void gotoHelpHRef(QCodeEdit::ACEntry e);
void syncScrolls();
void scrollUp();
void scrollDown();
@@ -195,7 +203,7 @@ public slots:
void searchNext(bool next = true);
void searchPrevious();
void hideSearch();
void setWordCompletitionEnabled(bool on) {word_complet = on;}
void setWordCompletitionEnabled(bool on) {word_complete = on;}
signals:
void textChanged();

View File

@@ -65,6 +65,7 @@ void QCodeEditCompleter::addItems(QFont f, const QCodeEdit::ACClass & cl, const
ni->setIcon(0, cl.icon);
ni->setText(0, s.type);
ni->setText(1, s.name);
ni->setData(0, Qt::UserRole, s.help_href);
addTopLevelItem(ni);
}
}
@@ -95,6 +96,26 @@ QString QCodeEditCompleter::currentValue() const {
}
void QCodeEditCompleter::keyPressEvent(QKeyEvent * e) {
switch (e->key()) {
case Qt::Key_Escape:
hide();
break;
case Qt::Key_Return:
emit commit();
break;
case Qt::Key_F1:
if (currentItem()) {
QString href = currentItem()->data(0, Qt::UserRole).toString();
emit gotoHRef(QCodeEdit::ACEntry().addHelpHRef(href));
}
break;
default: break;
}
QTreeWidget::keyPressEvent(e);
}
void QCodeEditCompleter::adjust() {
int sz = sizeHint().width();
resize(sz, fontHeight() * 16);

View File

@@ -40,11 +40,14 @@ public:
QString currentValue() const;
private:
void keyPressEvent(QKeyEvent * e) override;
private slots:
void adjust();
signals:
void commit();
void gotoHRef(QCodeEdit::ACEntry e);
};