MCPcopy Create free account
hub / github.com/KDE/kdevelop / askNewProfileName

Method askNewProfileName

kdevplatform/shell/settings/environmentwidget.cpp:166–205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164}
165
166QString EnvironmentWidget::askNewProfileName(const QString& defaultName)
167{
168 ScopedDialog<QDialog> dialog(this);
169 dialog->setWindowTitle(i18nc("@title:window", "Enter Name of New Environment Profile"));
170
171 auto *layout = new QVBoxLayout(dialog);
172
173 auto editLayout = new QHBoxLayout;
174
175 auto label = new QLabel(i18nc("@label:textbox", "Name:"));
176 editLayout->addWidget(label);
177 auto edit = new QLineEdit;
178 editLayout->addWidget(edit);
179 layout->addLayout(editLayout);
180
181 auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
182 auto okButton = buttonBox->button(QDialogButtonBox::Ok);
183 okButton->setEnabled(false);
184 okButton->setDefault(true);
185 dialog->connect(buttonBox, &QDialogButtonBox::accepted, dialog.data(), &QDialog::accept);
186 dialog->connect(buttonBox, &QDialogButtonBox::rejected, dialog.data(), &QDialog::reject);
187 layout->addWidget(buttonBox);
188
189 auto validator = new ProfileNameValidator(m_environmentProfileListModel, dialog);
190 connect(edit, &QLineEdit::textChanged, validator, [validator, okButton](const QString& text) {
191 int pos;
192 QString t(text);
193 const bool isValidProfileName = (validator->validate(t, pos) == QValidator::Acceptable);
194 okButton->setEnabled(isValidProfileName);
195 });
196
197 edit->setText(defaultName);
198 edit->selectAll();
199
200 if (dialog->exec() != QDialog::Accepted) {
201 return {};
202 }
203
204 return edit->text();
205}
206
207void EnvironmentWidget::removeSelectedVariables()
208{

Callers

nothing calls this directly

Calls 9

buttonMethod · 0.80
execMethod · 0.80
addWidgetMethod · 0.45
setEnabledMethod · 0.45
dataMethod · 0.45
validateMethod · 0.45
setTextMethod · 0.45
selectAllMethod · 0.45
textMethod · 0.45

Tested by

no test coverage detected