1
0
Fork 0
forked from len0rd/rockbox

Theme Editor: Switched device configuration panel to a QFormLayout

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27267 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Robert Bieber 2010-07-03 23:48:10 +00:00
parent e472c3975e
commit d4e7ab7a93

View file

@ -29,6 +29,7 @@
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QLabel> #include <QLabel>
#include <QLineEdit> #include <QLineEdit>
#include <QFormLayout>
DeviceState::DeviceState(QWidget *parent) : DeviceState::DeviceState(QWidget *parent) :
@ -39,7 +40,7 @@ DeviceState::DeviceState(QWidget *parent) :
setWindowIcon(QIcon(":/resources/windowicon.png")); setWindowIcon(QIcon(":/resources/windowicon.png"));
setWindowTitle(tr("Device Settings")); setWindowTitle(tr("Device Settings"));
QVBoxLayout* layout = new QVBoxLayout(this); QFormLayout* layout = new QFormLayout(this);
layout->addWidget(&tabs); layout->addWidget(&tabs);
this->setLayout(layout); this->setLayout(layout);
@ -68,7 +69,7 @@ DeviceState::DeviceState(QWidget *parent) :
panel = new QWidget(); panel = new QWidget();
currentArea = new QScrollArea(); currentArea = new QScrollArea();
layout = new QVBoxLayout(panel); layout = new QFormLayout(panel);
currentArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); currentArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
currentArea->setWidget(panel); currentArea->setWidget(panel);
currentArea->setWidgetResizable(true); currentArea->setWidgetResizable(true);
@ -84,18 +85,11 @@ DeviceState::DeviceState(QWidget *parent) :
QString type = elements[2].trimmed(); QString type = elements[2].trimmed();
QString defVal = elements[3].trimmed(); QString defVal = elements[3].trimmed();
subLayout = new QHBoxLayout();
if(type != "check")
subLayout->addWidget(new QLabel(elements[1].trimmed(),
currentArea));
layout->addLayout(subLayout);
elements = type.split("("); elements = type.split("(");
if(elements[0].trimmed() == "text") if(elements[0].trimmed() == "text")
{ {
QLineEdit* temp = new QLineEdit(defVal, currentArea); QLineEdit* temp = new QLineEdit(defVal, currentArea);
subLayout->addWidget(temp); layout->addRow(title, temp);
inputs.insert(tag, QPair<InputType, QWidget*>(Text, temp)); inputs.insert(tag, QPair<InputType, QWidget*>(Text, temp));
temp->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, temp->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
@ -107,7 +101,7 @@ DeviceState::DeviceState(QWidget *parent) :
else if(elements[0].trimmed() == "check") else if(elements[0].trimmed() == "check")
{ {
QCheckBox* temp = new QCheckBox(title, currentArea); QCheckBox* temp = new QCheckBox(title, currentArea);
subLayout->addWidget(temp); layout->addRow(temp);
if(defVal.toLower() == "true") if(defVal.toLower() == "true")
temp->setChecked(true); temp->setChecked(true);
else else
@ -129,7 +123,7 @@ DeviceState::DeviceState(QWidget *parent) :
temp->setMinimum(min); temp->setMinimum(min);
temp->setMaximum(max); temp->setMaximum(max);
temp->setValue(defVal.toInt()); temp->setValue(defVal.toInt());
subLayout->addWidget(temp); layout->addRow(title, temp);
inputs.insert(tag, QPair<InputType, QWidget*>(Slide, temp)); inputs.insert(tag, QPair<InputType, QWidget*>(Slide, temp));
QObject::connect(temp, SIGNAL(valueChanged(int)), QObject::connect(temp, SIGNAL(valueChanged(int)),
@ -147,7 +141,7 @@ DeviceState::DeviceState(QWidget *parent) :
temp->setMinimum(min); temp->setMinimum(min);
temp->setMaximum(max); temp->setMaximum(max);
temp->setValue(defVal.toInt()); temp->setValue(defVal.toInt());
subLayout->addWidget(temp); layout->addRow(title, temp);
inputs.insert(tag, QPair<InputType, QWidget*>(Spin, temp)); inputs.insert(tag, QPair<InputType, QWidget*>(Spin, temp));
QObject::connect(temp, SIGNAL(valueChanged(int)), QObject::connect(temp, SIGNAL(valueChanged(int)),
@ -166,7 +160,7 @@ DeviceState::DeviceState(QWidget *parent) :
temp->setMaximum(max); temp->setMaximum(max);
temp->setValue(defVal.toDouble()); temp->setValue(defVal.toDouble());
temp->setSingleStep(0.1); temp->setSingleStep(0.1);
subLayout->addWidget(temp); layout->addRow(title, temp);
inputs.insert(tag, QPair<InputType, QWidget*>(DSpin, temp)); inputs.insert(tag, QPair<InputType, QWidget*>(DSpin, temp));
QObject::connect(temp, SIGNAL(valueChanged(double)), QObject::connect(temp, SIGNAL(valueChanged(double)),
@ -188,7 +182,7 @@ DeviceState::DeviceState(QWidget *parent) :
defIndex = i; defIndex = i;
} }
temp->setCurrentIndex(defIndex); temp->setCurrentIndex(defIndex);
subLayout->addWidget(temp); layout->addRow(title, temp);
inputs.insert(tag, QPair<InputType, QWidget*>(Combo, temp)); inputs.insert(tag, QPair<InputType, QWidget*>(Combo, temp));
QObject::connect(temp, SIGNAL(currentIndexChanged(int)), QObject::connect(temp, SIGNAL(currentIndexChanged(int)),