add interface wizard: clearified dr5000 usb protocol page
Dieser Commit ist enthalten in:
Ursprung
7cc5a2ff0a
Commit
f5a477ee7e
@ -333,11 +333,13 @@
|
|||||||
"protocol_dr5000_usb": {
|
"protocol_dr5000_usb": {
|
||||||
"title": "$wizard.add_interface.protocol:title$",
|
"title": "$wizard.add_interface.protocol:title$",
|
||||||
"text": "$wizard.add_interface.protocol:text$",
|
"text": "$wizard.add_interface.protocol:text$",
|
||||||
|
"bottom_text": "$wizard.add_interface.protocol_dr5000_usb:bottom_text$",
|
||||||
"type": "radio",
|
"type": "radio",
|
||||||
"options": [
|
"options": [
|
||||||
{
|
{
|
||||||
"name": "LocoNet",
|
"name": "LocoNet ($wizard.add_interface:recommended$)",
|
||||||
"next": "serial_port",
|
"next": "serial_port",
|
||||||
|
"checked": true,
|
||||||
"actions": {
|
"actions": {
|
||||||
"create_interface": {
|
"create_interface": {
|
||||||
"class_id": "interface.loconet",
|
"class_id": "interface.loconet",
|
||||||
|
|||||||
@ -225,13 +225,17 @@ class RadioPageJSON : public RadioPage, public PageJSON
|
|||||||
|
|
||||||
void initializePage() override
|
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())
|
for(const auto& option : m_pageData["options"].toArray())
|
||||||
{
|
{
|
||||||
auto item = option.toObject();
|
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
|
void cleanupPage() override
|
||||||
@ -469,4 +473,4 @@ Properties JSONWizard::toProperties(const QJsonObject& object)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,11 +24,19 @@
|
|||||||
#include <QLayout>
|
#include <QLayout>
|
||||||
#include <QButtonGroup>
|
#include <QButtonGroup>
|
||||||
#include <QRadioButton>
|
#include <QRadioButton>
|
||||||
|
#include <QLabel>
|
||||||
|
|
||||||
RadioPage::RadioPage(QWidget* parent)
|
RadioPage::RadioPage(QWidget* parent)
|
||||||
: TextPage(parent)
|
: TextPage(parent)
|
||||||
, m_group{new QButtonGroup(this)}
|
, 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
|
int RadioPage::currentIndex() const
|
||||||
@ -36,23 +44,25 @@ int RadioPage::currentIndex() const
|
|||||||
return m_group->id(m_group->checkedButton());
|
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);
|
auto* button = new QRadioButton(label);
|
||||||
|
button->setChecked(checked && !disabled);
|
||||||
button->setDisabled(disabled);
|
button->setDisabled(disabled);
|
||||||
m_group->addButton(button, m_group->buttons().size());
|
m_group->addButton(button, m_group->buttons().size());
|
||||||
layout()->addWidget(button);
|
static_cast<QVBoxLayout*>(layout())->insertWidget(layout()->count() - 2, button);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RadioPage::clear()
|
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);
|
delete button;
|
||||||
if(item->widget())
|
|
||||||
{
|
|
||||||
delete item->widget();
|
|
||||||
}
|
|
||||||
layout()->removeItem(item);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RadioPage::setBottomText(const QString& text)
|
||||||
|
{
|
||||||
|
m_bottomText->setText(text);
|
||||||
|
m_bottomText->setVisible(!text.isEmpty());
|
||||||
|
}
|
||||||
|
|||||||
@ -31,14 +31,17 @@ class RadioPage : public TextPage
|
|||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
QButtonGroup* m_group;
|
QButtonGroup* m_group;
|
||||||
|
QLabel* m_bottomText;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit RadioPage(QWidget* parent = nullptr);
|
explicit RadioPage(QWidget* parent = nullptr);
|
||||||
|
|
||||||
int currentIndex() const;
|
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 clear();
|
||||||
|
|
||||||
|
void setBottomText(const QString& text);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -6701,5 +6701,13 @@
|
|||||||
"reference": "",
|
"reference": "",
|
||||||
"comment": "",
|
"comment": "",
|
||||||
"fuzzy": 0
|
"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."
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -6377,5 +6377,13 @@
|
|||||||
"reference": "",
|
"reference": "",
|
||||||
"comment": "",
|
"comment": "",
|
||||||
"fuzzy": 0
|
"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."
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
Laden…
x
In neuem Issue referenzieren
Einen Benutzer sperren