mirror of
https://github.com/Lurkki14/tuxclocker.git
synced 2025-02-25 18:55:24 -06:00
interface/qt: add EnumRange constructor and value getter
This commit is contained in:
parent
77ea61900c
commit
943ffc9a64
@ -1,7 +1,7 @@
|
||||
#include "EnumEditor.h"
|
||||
|
||||
EnumEditor::EnumEditor(QWidget *parent) : QWidget(parent) {
|
||||
m_mainLayout = new QHBoxLayout;
|
||||
m_mainLayout->setMargin(0);
|
||||
|
||||
m_comboBox = new QComboBox;
|
||||
m_mainLayout->addWidget(m_comboBox);
|
||||
@ -12,6 +12,28 @@ EnumEditor::EnumEditor(QWidget *parent) : QWidget(parent) {
|
||||
setLayout(m_mainLayout);
|
||||
}
|
||||
|
||||
EnumEditor::EnumEditor(QWidget* parent, const AssignableData &data) : QWidget(parent) {
|
||||
m_mainLayout = new QHBoxLayout;
|
||||
m_mainLayout->setMargin(0);
|
||||
|
||||
m_comboBox = new QComboBox;
|
||||
m_mainLayout->addWidget(m_comboBox);
|
||||
|
||||
QStringList opts;
|
||||
// Construct the combo box entries
|
||||
for (uint16_t i = 0; i < data.m_enumInfo.property_count; i++) {
|
||||
opts.append(QString(data.m_enumInfo.properties[i]));
|
||||
}
|
||||
m_options = opts;
|
||||
m_comboBox->addItems(m_options);
|
||||
|
||||
setLayout(m_mainLayout);
|
||||
}
|
||||
|
||||
QString EnumEditor::value() {
|
||||
return m_comboBox->currentText();
|
||||
}
|
||||
|
||||
void EnumEditor::setData(QStringList &strings) {
|
||||
// Remove old entries
|
||||
m_comboBox->clear();
|
||||
|
@ -3,14 +3,20 @@
|
||||
// Editor for selecting enumerated values
|
||||
|
||||
#include <QWidget>
|
||||
#include <QVariant>
|
||||
#include <QHBoxLayout>
|
||||
#include <QComboBox>
|
||||
#include <AssignableData.h>
|
||||
|
||||
|
||||
class EnumEditor : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
EnumEditor(QWidget *parent = nullptr);
|
||||
EnumEditor(QWidget *parent = nullptr, const AssignableData &data = nullptr);
|
||||
|
||||
// Return selected string
|
||||
QString value();
|
||||
void setData(QStringList &strings);
|
||||
private:
|
||||
QHBoxLayout *m_mainLayout;
|
||||
|
Loading…
Reference in New Issue
Block a user