GithubHelp home page GithubHelp logo

Comments (16)

feragon avatar feragon commented on August 24, 2024

It doesn't support RTF out of the box.
I tested this and it worked: https://stackoverflow.com/questions/1956542/how-to-make-item-view-render-rich-html-text-in-qt

If you need it, add the delegate to ui->history in lcUI/widgets/clicommand.cpp

from librecad_3.

Guruprasad-Rane avatar Guruprasad-Rane commented on August 24, 2024

I will try this.

from librecad_3.

Guruprasad-Rane avatar Guruprasad-Rane commented on August 24, 2024

By the way I could not achieve this. I was looking for such option so that when command line gives options to the user, it highlights using bold or underline font, the short cut options and the currently active option.
Example:
Options: < Radius >, Diameter
Is there already any function to do this?

from librecad_3.

feragon avatar feragon commented on August 24, 2024

Use this file for lcUI/widgets/clicommand.cpp: https://gist.github.com/feragon/0790b191c3cc400ba5c4ad2fba54d905

Try to enter some HTML command to test it (like <b>command</b>)

from librecad_3.

Guruprasad-Rane avatar Guruprasad-Rane commented on August 24, 2024

Yes. It worked perfectly :-)

from librecad_3.

Guruprasad-Rane avatar Guruprasad-Rane commented on August 24, 2024

Couple of issues noticed.

  • Line spacing between messages has increased considerably. Tried doc.setDefaultStyleSheet but didn't work. Also tried doc.setDocumentMargin(0); but no sucess.

  • Scrollbar get added after few messages and it does not auto scroll. I guess this is because of increased line spacing only.

from librecad_3.

feragon avatar feragon commented on August 24, 2024

The auto scroll wasn't properly before. You have to scroll down one or two times to enable it.

Can you try to replace the HTMLDelegate sizeHint method with this :

QSize HTMLDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const {
    QTextDocument doc;
    doc.setHtml(option.text);
    doc.setTextWidth(option.rect.width());
    return {(int) doc.textWidth(), (int) doc.size().height()};
}

from librecad_3.

Guruprasad-Rane avatar Guruprasad-Rane commented on August 24, 2024

Before changing QSize HTMLDelegate::sizeHint
before

After changing QSize HTMLDelegate::sizeHint "Provide Center Point" is almost hidden because of overlap.
after

To reduce the line spacing I have tried

message("<b>CIRCLE</b><br>Provide Center Point:", self.target_widget)

from librecad_3.

feragon avatar feragon commented on August 24, 2024

Did you tried without the <br> ? You can call message two times (one call per line)

I'll look at changing sizeHint method to support multi-lines items.

from librecad_3.

Guruprasad-Rane avatar Guruprasad-Rane commented on August 24, 2024

With out
with separate message calls
screenshot from 2018-12-13 23-45-33

from librecad_3.

Guruprasad-Rane avatar Guruprasad-Rane commented on August 24, 2024

I tried changing ui->history from QListWidget to QTextEdit in readonly mode and I think it works better. Scrollbar appears but it can be made to autoscroll to the last line. Also history need not be trimmed.
screenshot from 2018-12-15 01-12-56

from librecad_3.

Guruprasad-Rane avatar Guruprasad-Rane commented on August 24, 2024

history = new QTextEdit(dockWidgetContents);

void CliCommand::write(const QString& message) {
    ui->history->setHtml(ui->history->toHtml() + message);
    ui->history->verticalScrollBar()->setValue(ui->history->verticalScrollBar()->maximum());
}

from librecad_3.

feragon avatar feragon commented on August 24, 2024

It looks exactly the same. Do you need the HTML delegate with the QTextEdit ?

You can use the QTextEdit, I don't see any problem with it.

from librecad_3.

Guruprasad-Rane avatar Guruprasad-Rane commented on August 24, 2024

No need for HTML delegate with QTextEdit, it can use toHtml()

from librecad_3.

Guruprasad-Rane avatar Guruprasad-Rane commented on August 24, 2024

Key Up and Key Down event for CliCommand::onKeyPressed(QKeyEvent *event) not working.
It has a condition if(_historyIndex + 1 < _history.size()) but _historyIndex is always -1 and _history.size() is always 0
What is _historyIndex and _history.size() ? And why this condition?

from librecad_3.

feragon avatar feragon commented on August 24, 2024

The up and down keys allow to move into the last typed commands.
_history should contains every typed command, and _historyIndex is the current position in the history.
If _history.size() is always 0, that means the commands are not added to the history anymore.

from librecad_3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.