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

Method selectionItem

customWidgets.cpp:80–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78//*********************************************************//
79
80selectionItem::selectionItem(QString name, QString info, QWidget *parent) :
81 QWidget(parent){
82 /* set labels */
83 QFont titleFont = QFont("Corbel", 13);
84 QFontMetrics fm(titleFont);
85 qreal height = fm.lineSpacing();
86 title = new QLabel(this);
87 title->setText(name);
88 title->setFont(titleFont);
89 title->setMinimumHeight(height);
90 title->setStyleSheet("color:#2c2c2c");
91 title->setAlignment(Qt::AlignLeft | Qt::AlignBottom);
92 QFont descFont = QFont("Corbel Light", 11);
93 fm = QFontMetrics(descFont);
94 height = fm.lineSpacing();
95 description = new QLabel(this);
96 description->setText(info);
97 description->setFont(descFont);
98 description->setMinimumHeight(height);
99 description->setAlignment(Qt::AlignLeft | Qt::AlignTop);
100 description->setStyleSheet("color:#707070");
101
102 indicator = new QWidget(this);
103
104 /* set minimum height and layout */
105 setFixedHeight(title->height() + (info == "" ? 0 : description->height() + 5));
106 indicator->resize(6, 0.4 * this->height());
107 indicator->move(4, 0.3 * this->height());
108 indicator->setStyleSheet("border-radius:3px;background-color:#0078D4");
109 opac = new QGraphicsOpacityEffect(indicator);
110 opac->setOpacity(0);
111 indicator->setGraphicsEffect(opac);
112
113 QVBoxLayout *contentLayout = new QVBoxLayout(this);
114 contentLayout->setContentsMargins(20, 0, 0, 0);
115 contentLayout->setSpacing(2);
116 this->setLayout(contentLayout);
117 contentLayout->addWidget(title);
118 if(info != "")
119 contentLayout->addWidget(description);
120 contentLayout->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
121
122 /* set background widget */
123 bgWidget = new QWidget(this);
124 bgWidget->resize(this->size());
125 bgWidget->setStyleSheet("border-radius:5px;background-color:#00000000");
126 bgWidget->lower();
127 bgWidget->show();
128
129 this->setMouseTracking(true);
130}
131
132void selectionItem::enterEvent(QEnterEvent *event){
133 bgWidget->setStyleSheet("border-radius:5px;background-color:#0a000000");

Callers

nothing calls this directly

Calls 3

moveMethod · 0.80
addWidgetMethod · 0.80
setTextMethod · 0.45

Tested by

no test coverage detected