add interface wizard: clearified dr5000 usb protocol page

Dieser Commit ist enthalten in:
Reinder Feenstra 2024-12-08 18:29:52 +01:00
Ursprung 7cc5a2ff0a
Commit f5a477ee7e
6 geänderte Dateien mit 49 neuen und 14 gelöschten Zeilen

Datei anzeigen

@ -333,11 +333,13 @@
"protocol_dr5000_usb": {
"title": "$wizard.add_interface.protocol:title$",
"text": "$wizard.add_interface.protocol:text$",
"bottom_text": "$wizard.add_interface.protocol_dr5000_usb:bottom_text$",
"type": "radio",
"options": [
{
"name": "LocoNet",
"name": "LocoNet ($wizard.add_interface:recommended$)",
"next": "serial_port",
"checked": true,
"actions": {
"create_interface": {
"class_id": "interface.loconet",

Datei anzeigen

@ -225,13 +225,17 @@ class RadioPageJSON : public RadioPage, public PageJSON
void initializePage() override
{
setTitleAndText(*static_cast<JSONWizard*>(wizard()), this, m_pageData);
auto* jsonWizard = static_cast<JSONWizard*>(wizard());
setTitleAndText(*jsonWizard, this, m_pageData);
for(const auto& option : m_pageData["options"].toArray())
{
auto item = option.toObject();
addItem(static_cast<JSONWizard*>(wizard())->translateAndReplaceVariables(item["name"].toString()), item["disabled"].toBool());
addItem(jsonWizard->translateAndReplaceVariables(item["name"].toString()), item["checked"].toBool(), item["disabled"].toBool());
}
setBottomText(jsonWizard->translateAndReplaceVariables(m_pageData["bottom_text"].toString()));
}
void cleanupPage() override
@ -469,4 +473,4 @@ Properties JSONWizard::toProperties(const QJsonObject& object)
}
}
return properties;
}
}

Datei anzeigen

@ -24,11 +24,19 @@
#include <QLayout>
#include <QButtonGroup>
#include <QRadioButton>
#include <QLabel>
RadioPage::RadioPage(QWidget* parent)
: TextPage(parent)
, m_group{new QButtonGroup(this)}
, m_bottomText{new QLabel(this)}
{
m_bottomText->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
m_bottomText->setWordWrap(true);
setBottomText({});
static_cast<QVBoxLayout*>(layout())->addStretch();
layout()->addWidget(m_bottomText);
}
int RadioPage::currentIndex() const
@ -36,23 +44,25 @@ int RadioPage::currentIndex() const
return m_group->id(m_group->checkedButton());
}
void RadioPage::addItem(const QString& label, bool disabled)
void RadioPage::addItem(const QString& label, bool checked, bool disabled)
{
auto* button = new QRadioButton(label);
button->setChecked(checked && !disabled);
button->setDisabled(disabled);
m_group->addButton(button, m_group->buttons().size());
layout()->addWidget(button);
static_cast<QVBoxLayout*>(layout())->insertWidget(layout()->count() - 2, button);
}
void RadioPage::clear()
{
while(layout()->count() > 1) // remove all but first (=text label)
for(auto* button : m_group->buttons())
{
auto* item = layout()->itemAt(layout()->count() - 1);
if(item->widget())
{
delete item->widget();
}
layout()->removeItem(item);
delete button;
}
}
void RadioPage::setBottomText(const QString& text)
{
m_bottomText->setText(text);
m_bottomText->setVisible(!text.isEmpty());
}

Datei anzeigen

@ -31,14 +31,17 @@ class RadioPage : public TextPage
{
protected:
QButtonGroup* m_group;
QLabel* m_bottomText;
public:
explicit RadioPage(QWidget* parent = nullptr);
int currentIndex() const;
void addItem(const QString& label, bool disabled = false);
void addItem(const QString& label, bool checked = false, bool disabled = false);
void clear();
void setBottomText(const QString& text);
};
#endif

Datei anzeigen

@ -6701,5 +6701,13 @@
"reference": "",
"comment": "",
"fuzzy": 0
},
{
"term": "wizard.add_interface:recommended",
"definition": "Recommended"
},
{
"term":"wizard.add_interface.protocol_dr5000_usb:bottom_text",
"definition": "The %command_station% supports two different protocols for communication. Although both are supported by Traintastic, using LocoNet is recommended as it is more versatile."
}
]

Datei anzeigen

@ -6377,5 +6377,13 @@
"reference": "",
"comment": "",
"fuzzy": 0
},
{
"term": "wizard.add_interface:recommended",
"definition": "Aanbevolen"
},
{
"term": "wizard.add_interface.protocol_dr5000_usb:bottom_text",
"definition": "Hoewel beide worden ondersteund door Traintastic, wordt het aanbevolen om LocoNet te gebruiken, omdat het veelzijdiger is."
}
]