MCPcopy Create free account
hub / github.com/Linloir/GraphBuilder / textInputItem

Method textInputItem

customWidgets.cpp:554–608  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

552}
553
554textInputItem::textInputItem(const QString &name, QWidget *parent) :
555 QWidget(parent)
556{
557 QFont nameFont = QFont("Corbel", 12);
558 QFontMetrics fm(nameFont);
559 qreal height = fm.lineSpacing();
560 itemName = new QLabel(this);
561 itemName->setText(name);
562 itemName->setFont(nameFont);
563 itemName->setFixedHeight(height);
564 itemName->setStyleSheet("color:#1c1c1c");
565
566 QFont textFont = QFont("Corbel", 12);
567 fm = QFontMetrics(textFont);
568 editor = new QLineEdit(this);
569 editor->setText("");
570 editor->setFixedHeight(fm.lineSpacing());
571 editor->setStyleSheet("color:#5c5c5c;background-color:#00000000;border-style:none;");
572 editor->setReadOnly(true);
573 editor->setFont(textFont);
574
575 bgWidget = new QWidget(this);
576 bgWidget->setStyleSheet("background-color:#00000000;border-radius:5px;");
577 bgWidget->lower();
578 bgWidget->show();
579
580 indicator = new QWidget(this);
581 indicator->setFixedHeight(4);
582 indicator->setStyleSheet("background-color:#0078d4;border-radius:2px");
583
584 opac = new QGraphicsOpacityEffect(this);
585 opac->setOpacity(0);
586 indicator->setGraphicsEffect(opac);
587
588 this->setFixedHeight(itemName->height() + 10);
589
590 connect(editor, &QLineEdit::returnPressed, this, [=](){
591 leaveEditEffect();
592 onEditing = false;
593 editor->setReadOnly(true);
594 curText = editor->text();
595 });
596 connect(editor, &QLineEdit::editingFinished, this, [=](){
597 leaveEditEffect();
598 onEditing = false;
599 editor->setReadOnly(true);
600 curText = editor->text();
601 QTimer *delay = new QTimer(this);
602 connect(delay, &QTimer::timeout, this, [=](){mousePressed = false;});
603 delay->setSingleShot(true);
604 delay->start(10);
605 mousePressed = false;
606 emit textEdited(curText);
607 });
608}
609
610void textInputItem::resizeEvent(QResizeEvent *event){
611 itemName->move(margin, this->height() / 2 - itemName->height() / 2);

Callers

nothing calls this directly

Calls 1

setTextMethod · 0.45

Tested by

no test coverage detected