Updated width settings for the Channels, Logical Switches and Special Functions tabs. Used to look good for Taranis and not at all good for 9x. Both OK now.

This commit is contained in:
Kjell Kernen
2014-03-26 12:48:25 +01:00
parent ef95b8e01d
commit ffa06b0143
5 changed files with 59 additions and 24 deletions
+14 -10
View File
@@ -10,20 +10,24 @@ Channels::Channels(QWidget * parent, ModelData & model):
ModelPanel(parent, model) ModelPanel(parent, model)
{ {
QGridLayout * gridLayout = new QGridLayout(this); QGridLayout * gridLayout = new QGridLayout(this);
bool minimize = false;
int col = 1; int col = 1;
if (GetEepromInterface()->getCapability(ChannelsName)) if (GetEepromInterface()->getCapability(ChannelsName))
{
minimize=true;
addLabel(gridLayout, tr("Name"), col++); addLabel(gridLayout, tr("Name"), col++);
addLabel(gridLayout, tr("Offset"), col++); }
addLabel(gridLayout, tr("Min"), col++); addLabel(gridLayout, tr("Offset"), col++, minimize);
addLabel(gridLayout, tr("Max"), col++); addLabel(gridLayout, tr("Min"), col++, minimize);
addLabel(gridLayout, tr("Invert"), col++); addLabel(gridLayout, tr("Max"), col++, minimize);
addLabel(gridLayout, tr("Invert"), col++, minimize);
if (IS_TARANIS(GetEepromInterface()->getBoard())) if (IS_TARANIS(GetEepromInterface()->getBoard()))
addLabel(gridLayout, tr("Curve"), col++); addLabel(gridLayout, tr("Curve"), col++, minimize);
if (GetEepromInterface()->getCapability(PPMCenter)) if (GetEepromInterface()->getCapability(PPMCenter))
addLabel(gridLayout, tr("Center"), col++); addLabel(gridLayout, tr("Center"), col++, minimize);
if (GetEepromInterface()->getCapability(SYMLimits)) if (GetEepromInterface()->getCapability(SYMLimits))
addLabel(gridLayout, tr("Sym"), col++); addLabel(gridLayout, tr("Sym"), col++, true);
for (int i=0; i<GetEepromInterface()->getCapability(Outputs); i++) { for (int i=0; i<GetEepromInterface()->getCapability(Outputs); i++) {
col = 0; col = 0;
@@ -31,6 +35,7 @@ Channels::Channels(QWidget * parent, ModelData & model):
// Channel label // Channel label
QLabel *label = new QLabel(this); QLabel *label = new QLabel(this);
label->setText(tr("Channel %1").arg(i+1)); label->setText(tr("Channel %1").arg(i+1));
label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
gridLayout->addWidget(label, i+1, col++, 1, 1); gridLayout->addWidget(label, i+1, col++, 1, 1);
// Channel name // Channel name
@@ -125,9 +130,8 @@ Channels::Channels(QWidget * parent, ModelData & model):
gridLayout->addWidget(symlimits, i+1, col++, 1, 1); gridLayout->addWidget(symlimits, i+1, col++, 1, 1);
} }
} }
// Push the rows up
QSpacerItem * verticalSpacer = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); addVSpring(gridLayout, 0,GetEepromInterface()->getCapability(Outputs)+1);
gridLayout->addItem(verticalSpacer, GetEepromInterface()->getCapability(Outputs)+1, 0, 1, 1);
} }
Channels::~Channels() Channels::~Channels()
+8 -6
View File
@@ -57,7 +57,8 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
addLabel(gridLayout, tr("Switch"), 1); addLabel(gridLayout, tr("Switch"), 1);
addLabel(gridLayout, tr("Action"), 2); addLabel(gridLayout, tr("Action"), 2);
addLabel(gridLayout, tr("Parameters"), 3); addLabel(gridLayout, tr("Parameters"), 3);
addLabel(gridLayout, tr("Enable"), 4); addLabel(gridLayout, tr("Enable"), 4, true );
addEmptyLabel(gridLayout, 5 );
lock = true; lock = true;
int num_fsw = GetEepromInterface()->getCapability(CustomFunctions); int num_fsw = GetEepromInterface()->getCapability(CustomFunctions);
@@ -104,12 +105,14 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
label->setMouseTracking(true); label->setMouseTracking(true);
label->setProperty("index", i); label->setProperty("index", i);
label->setText(tr("SF%1").arg(i+1)); label->setText(tr("SF%1").arg(i+1));
gridLayout->addWidget(label, i+1, 0); label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
connect(label, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(fsw_customContextMenuRequested(QPoint))); connect(label, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(fsw_customContextMenuRequested(QPoint)));
gridLayout->addWidget(label, i+1, 0);
// The switch // The switch
fswtchSwtch[i] = new QComboBox(this); fswtchSwtch[i] = new QComboBox(this);
fswtchSwtch[i]->setProperty("index", i); fswtchSwtch[i]->setProperty("index", i);
fswtchSwtch[i]->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
connect(fswtchSwtch[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited())); connect(fswtchSwtch[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));
gridLayout->addWidget(fswtchSwtch[i], i+1, 1); gridLayout->addWidget(fswtchSwtch[i], i+1, 1);
populateSwitchCB(fswtchSwtch[i], model.funcSw[i].swtch, POPULATE_ONOFF); populateSwitchCB(fswtchSwtch[i], model.funcSw[i].swtch, POPULATE_ONOFF);
@@ -183,14 +186,13 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
fswtchEnable[i] = new QCheckBox(this); fswtchEnable[i] = new QCheckBox(this);
fswtchEnable[i]->setProperty("index", i); fswtchEnable[i]->setProperty("index", i);
fswtchEnable[i]->setText(tr("ON")); fswtchEnable[i]->setText(tr("ON"));
fswtchEnable[i]->setFixedWidth( 50 );
repeatLayout->addWidget(fswtchEnable[i], i+1); repeatLayout->addWidget(fswtchEnable[i], i+1);
fswtchEnable[i]->setChecked(model.funcSw[i].enabled); fswtchEnable[i]->setChecked(model.funcSw[i].enabled);
connect(fswtchEnable[i], SIGNAL(stateChanged(int)), this, SLOT(customFunctionEdited())); connect(fswtchEnable[i], SIGNAL(stateChanged(int)), this, SLOT(customFunctionEdited()));
} }
// Push rows upward
QSpacerItem * verticalSpacer = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); addDoubleSpring(gridLayout, 5, num_fsw+1);
gridLayout->addItem(verticalSpacer, num_fsw+1, 0);
lock = false; lock = false;
} }
+3 -4
View File
@@ -31,6 +31,7 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model):
label->setText(tr("L%1").arg(i+1)); label->setText(tr("L%1").arg(i+1));
label->setContextMenuPolicy(Qt::CustomContextMenu); label->setContextMenuPolicy(Qt::CustomContextMenu);
label->setMouseTracking(true); label->setMouseTracking(true);
label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
connect(label, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(csw_customContextMenuRequested(QPoint))); connect(label, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(csw_customContextMenuRequested(QPoint)));
gridLayout->addWidget(label, i+1, 0); gridLayout->addWidget(label, i+1, 0);
@@ -113,10 +114,8 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model):
gridLayout->addWidget(cswitchDelay[i], i+1, 6); gridLayout->addWidget(cswitchDelay[i], i+1, 6);
} }
} }
// Push rows upward
QSpacerItem * verticalSpacer = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); addVSpring(gridLayout,0,GetEepromInterface()->getCapability(LogicalSwitches)+1);
gridLayout->addItem(verticalSpacer, GetEepromInterface()->getCapability(LogicalSwitches)+1, 0, 1, 1);
lock = false; lock = false;
} }
+29 -2
View File
@@ -16,15 +16,42 @@ void ModelPanel::update()
{ {
} }
void ModelPanel::addLabel(QGridLayout * gridLayout, QString text, int col) void ModelPanel::addLabel(QGridLayout * gridLayout, QString text, int col, bool minimize)
{ {
QLabel *label = new QLabel(this); QLabel *label = new QLabel(this);
label->setFrameShape(QFrame::Panel); label->setFrameShape(QFrame::Panel);
label->setFrameShadow(QFrame::Raised); label->setFrameShadow(QFrame::Raised);
label->setMidLineWidth(0); label->setMidLineWidth(0);
label->setAlignment(Qt::AlignCenter); label->setAlignment(Qt::AlignCenter);
label->setMargin(3); label->setMargin(5);
label->setText(text); label->setText(text);
if (!minimize)
label->setMinimumWidth(100);
gridLayout->addWidget(label, 0, col, 1, 1); gridLayout->addWidget(label, 0, col, 1, 1);
} }
void ModelPanel::addEmptyLabel(QGridLayout * gridLayout, int col)
{
QLabel *label = new QLabel(this);
label->setText("");
gridLayout->addWidget(label, 0, col, 1, 1);
}
void ModelPanel::addHSpring(QGridLayout * gridLayout, int col, int row)
{
QSpacerItem * spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
gridLayout->addItem(spacer, row, col);
}
void ModelPanel::addVSpring(QGridLayout * gridLayout, int col, int row)
{
QSpacerItem * spacer = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding );
gridLayout->addItem(spacer, row, col);
}
void ModelPanel::addDoubleSpring(QGridLayout * gridLayout, int col, int row)
{
QSpacerItem * spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding );
gridLayout->addItem(spacer, row, col);
}
+5 -2
View File
@@ -22,8 +22,11 @@ class ModelPanel : public QWidget
protected: protected:
ModelData & model; ModelData & model;
bool lock; bool lock;
void addLabel(QGridLayout * gridLayout, QString text, int col); void addLabel(QGridLayout * gridLayout, QString text, int col, bool mimimize=false);
void addEmptyLabel(QGridLayout * gridLayout, int col);
void addHSpring(QGridLayout *, int col, int row);
void addVSpring(QGridLayout *, int col, int row);
void addDoubleSpring(QGridLayout *, int col, int row);
}; };
#endif // CHANNELS_H #endif // CHANNELS_H