MCPcopy Create free account
hub / github.com/PlotJuggler/PlotJuggler / setName

Function setName

pj_plotting/widget/src/TabbedPlotWidget.cpp:91–129  ·  view source on GitHub ↗

Small private widget for one tab in the strip. Holds a name label plus a close button. Double-clicking flips the label out for an in-place QLineEdit; pressing Enter commits the rename, Escape or loss of focus reverts to the previous name.

Source from the content-addressed store, hash-verified

89// in-place QLineEdit; pressing Enter commits the rename, Escape or
90// loss of focus reverts to the previous name.
91class PlotTabFrame : public QFrame {
92 Q_OBJECT
93 public:
94 explicit PlotTabFrame(const QString& tab_name, QWidget* parent = nullptr) : QFrame(parent) {
95 setObjectName("plotTabFrame");
96 setProperty("selected", false);
97 setAttribute(Qt::WA_StyledBackground, true);
98 setCursor(Qt::PointingHandCursor);
99 // Fill the bar height exactly — tabs have a colored background, so
100 // any breathing room above or below would render as a visible
101 // 1-px stripe of bar-background flanking the tab.
102 setFixedHeight(kTabBarButtonSize);
103
104 auto* layout = new QHBoxLayout(this);
105 layout->setContentsMargins(8, 0, 4, 0);
106 layout->setSpacing(6);
107
108 label_ = new QLabel(tab_name, this);
109 label_->setAttribute(Qt::WA_TransparentForMouseEvents);
110 layout->addWidget(label_);
111
112 edit_ = new QLineEdit(this);
113 edit_->setObjectName("plotTabRenameEdit");
114 edit_->hide();
115 edit_->installEventFilter(this);
116 connect(edit_, &QLineEdit::returnPressed, this, &PlotTabFrame::commitEdit);
117 layout->addWidget(edit_);
118
119 close_button_ = new QPushButton(this);
120 close_button_->setFlat(true);
121 close_button_->setFixedSize(QSize(16, 16));
122 close_button_->setFocusPolicy(Qt::NoFocus);
123 layout->addWidget(close_button_);
124 connect(close_button_, &QPushButton::clicked, this, &PlotTabFrame::closeRequested);
125 }
126
127 void setName(const QString& tab_name) {
128 label_->setText(tab_name);
129 }
130
131 [[nodiscard]] QString name() const {
132 return label_->text();

Callers 5

setPlaceholderWidgetMethod · 0.85
adoptObjectWidgetMethod · 0.85
ensurePlotWidgetMethod · 0.85
xmlLoadStateMethod · 0.85

Calls 1

setTextMethod · 0.45

Tested by

no test coverage detected