27#include <RobotAPI/gui-plugins/ui_SkillDashboardConfig.h>
32#include <QStylePlugin>
34#include <QDesktopServices>
42 QDialog(parent), ui(new
Ui::SkillDashboardConfig)
45 this->setWindowTitle(
"Configure Skill");
46 connect(ui->dialogButtons, &QDialogButtonBox::accepted,
this, &QDialog::accept);
47 connect(ui->dialogButtons, &QDialogButtonBox::rejected,
this, &QDialog::reject);
48 connect(ui->linkButton, &QPushButton::clicked,
this, &SkillDashboardConfigWindow::openNerdFontSearch);
49 connect(ui->buttonName,
50 &QLineEdit::textChanged,
52 &SkillDashboardConfigWindow::onShortcutNameChanged);
56 SkillDashboardConfigWindow::onShortcutNameChanged()
64 return ui->buttonName->text();
70 return ui->iconName->text();
74 SkillDashboardConfigWindow::openNerdFontSearch()
76 QDesktopServices::openUrl(QUrl(
"https://www.nerdfonts.com/cheat-sheet"));
83 return ui->skillName->text();
89 return ui->skillArgs->toPlainText();
95 ui->buttonName->setText(QString::fromStdString(name));
101 ui->skillName->setText(QString::fromStdString(
id));
107 ui->iconName->setText(QString::fromStdString(iconName));
113 ui->skillArgs->setPlainText(QString::fromStdString(config));
119 ui->infoText->setText(QString::fromStdString(info));
120 ui->infoText->setStyleSheet(
"color: red;");
130 this->hboxLayout =
new QHBoxLayout(
this);
131 this->hboxLayout->setContentsMargins(6, 2, 6, 2);
132 this->hboxLayout->setSpacing(4);
134 this->label =
new QLabel(
this);
135 this->label->setWordWrap(
true);
136 this->label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
137 this->label->setStyleSheet(
"color: red;");
138 this->hboxLayout->addWidget(label);
143 this->closeButton =
new QPushButton(
"✕",
this);
144 this->closeButton->setFixedSize(18, 18);
145 this->closeButton->setStyleSheet(R
"(
156 this->showAllButton = new QPushButton(
this);
157 this->showAllButton->setFixedSize(20, 20);
159 this->showAllButton->setIcon(
160 parentWidget()->style()->standardIcon(QStyle::SP_ToolBarVerticalExtensionButton));
161 this->hboxLayout->addWidget(showAllButton);
163 showAllButton, &QPushButton::clicked,
this, &MessageWidget::showAllButtonClicked);
164 this->hboxLayout->addWidget(closeButton);
165 connect(closeButton, &QPushButton::clicked,
this, &MessageWidget::closeButtonClicked);
172 MessageWidget::closeButtonClicked()
174 this->messages.pop();
175 if (this->messages.empty())
181 this->label->setText(messages.top());
186 MessageWidget::showAllButtonClicked()
188 QLayout* mainLayout =
nullptr;
190 mainLayout = parentWidget()->layout();
194 if (not this->closeAllButton)
196 QPushButton* closeAll =
new QPushButton(
"Close all", parentWidget());
197 connect(closeAll, &QPushButton::clicked,
this, &MessageWidget::closeAllButtonClicked);
198 mainLayout->addWidget(closeAll);
199 this->closeAllButton =
true;
202 while (!messages.empty())
204 const QString& text = messages.top();
206 w->newErrorMessage(text);
207 mainLayout->addWidget(w);
208 allMessageWidgets.push_back(w);
216 MessageWidget::closeAllButtonClicked()
218 QLayout* mainLayout =
nullptr;
220 mainLayout = parentWidget()->layout();
227 mainLayout->removeWidget(w);
231 allMessageWidgets.clear();
233 QPushButton* button = qobject_cast<QPushButton*>(sender());
236 mainLayout->removeWidget(button);
238 button->deleteLater();
240 this->closeAllButton =
false;
246 this->messages.push(text);
247 this->label->setText(text);
248 if (not QWidget::isVisible())
~SkillDashboardConfigWindow()
void shortcutNameHasChanged()
void setSkillId(const std::string &id)
void setInfoText(const std::string &info)
void setIconName(const std::string &iconName)
void setShortcutName(const std::string &name)
SkillDashboardConfigWindow(QWidget *parent=nullptr)
QString getShortcutName()
void setSkillConfig(const std::string &config)
This file offers overloads of toIce() and fromIce() functions for STL container types.