From ffa06b0143587b0c6169567cd389d49fe2aa6c50 Mon Sep 17 00:00:00 2001 From: Kjell Kernen Date: Wed, 26 Mar 2014 12:48:25 +0100 Subject: [PATCH] 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. --- companion/src/modeledit/channels.cpp | 24 +++++++++------- companion/src/modeledit/customfunctions.cpp | 14 ++++++---- companion/src/modeledit/logicalswitches.cpp | 7 ++--- companion/src/modeledit/modelpanel.cpp | 31 +++++++++++++++++++-- companion/src/modeledit/modelpanel.h | 7 +++-- 5 files changed, 59 insertions(+), 24 deletions(-) diff --git a/companion/src/modeledit/channels.cpp b/companion/src/modeledit/channels.cpp index 94c21e79d..119c320ae 100644 --- a/companion/src/modeledit/channels.cpp +++ b/companion/src/modeledit/channels.cpp @@ -10,20 +10,24 @@ Channels::Channels(QWidget * parent, ModelData & model): ModelPanel(parent, model) { QGridLayout * gridLayout = new QGridLayout(this); + bool minimize = false; int col = 1; if (GetEepromInterface()->getCapability(ChannelsName)) + { + minimize=true; addLabel(gridLayout, tr("Name"), col++); - addLabel(gridLayout, tr("Offset"), col++); - addLabel(gridLayout, tr("Min"), col++); - addLabel(gridLayout, tr("Max"), col++); - addLabel(gridLayout, tr("Invert"), col++); + } + addLabel(gridLayout, tr("Offset"), col++, minimize); + addLabel(gridLayout, tr("Min"), col++, minimize); + addLabel(gridLayout, tr("Max"), col++, minimize); + addLabel(gridLayout, tr("Invert"), col++, minimize); if (IS_TARANIS(GetEepromInterface()->getBoard())) - addLabel(gridLayout, tr("Curve"), col++); + addLabel(gridLayout, tr("Curve"), col++, minimize); if (GetEepromInterface()->getCapability(PPMCenter)) - addLabel(gridLayout, tr("Center"), col++); + addLabel(gridLayout, tr("Center"), col++, minimize); if (GetEepromInterface()->getCapability(SYMLimits)) - addLabel(gridLayout, tr("Sym"), col++); + addLabel(gridLayout, tr("Sym"), col++, true); for (int i=0; igetCapability(Outputs); i++) { col = 0; @@ -31,6 +35,7 @@ Channels::Channels(QWidget * parent, ModelData & model): // Channel label QLabel *label = new QLabel(this); label->setText(tr("Channel %1").arg(i+1)); + label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); gridLayout->addWidget(label, i+1, col++, 1, 1); // Channel name @@ -125,9 +130,8 @@ Channels::Channels(QWidget * parent, ModelData & model): gridLayout->addWidget(symlimits, i+1, col++, 1, 1); } } - - QSpacerItem * verticalSpacer = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); - gridLayout->addItem(verticalSpacer, GetEepromInterface()->getCapability(Outputs)+1, 0, 1, 1); + // Push the rows up + addVSpring(gridLayout, 0,GetEepromInterface()->getCapability(Outputs)+1); } Channels::~Channels() diff --git a/companion/src/modeledit/customfunctions.cpp b/companion/src/modeledit/customfunctions.cpp index 2bd25ddc3..035a6ba6e 100644 --- a/companion/src/modeledit/customfunctions.cpp +++ b/companion/src/modeledit/customfunctions.cpp @@ -57,7 +57,8 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model, addLabel(gridLayout, tr("Switch"), 1); addLabel(gridLayout, tr("Action"), 2); addLabel(gridLayout, tr("Parameters"), 3); - addLabel(gridLayout, tr("Enable"), 4); + addLabel(gridLayout, tr("Enable"), 4, true ); + addEmptyLabel(gridLayout, 5 ); lock = true; int num_fsw = GetEepromInterface()->getCapability(CustomFunctions); @@ -104,12 +105,14 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model, label->setMouseTracking(true); label->setProperty("index", i); 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))); + gridLayout->addWidget(label, i+1, 0); // The switch fswtchSwtch[i] = new QComboBox(this); fswtchSwtch[i]->setProperty("index", i); + fswtchSwtch[i]->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum); connect(fswtchSwtch[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited())); gridLayout->addWidget(fswtchSwtch[i], i+1, 1); 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]->setProperty("index", i); fswtchEnable[i]->setText(tr("ON")); + fswtchEnable[i]->setFixedWidth( 50 ); repeatLayout->addWidget(fswtchEnable[i], i+1); fswtchEnable[i]->setChecked(model.funcSw[i].enabled); connect(fswtchEnable[i], SIGNAL(stateChanged(int)), this, SLOT(customFunctionEdited())); } - - QSpacerItem * verticalSpacer = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); - gridLayout->addItem(verticalSpacer, num_fsw+1, 0); - + // Push rows upward + addDoubleSpring(gridLayout, 5, num_fsw+1); lock = false; } diff --git a/companion/src/modeledit/logicalswitches.cpp b/companion/src/modeledit/logicalswitches.cpp index f6f7ab460..5ccb5ba21 100644 --- a/companion/src/modeledit/logicalswitches.cpp +++ b/companion/src/modeledit/logicalswitches.cpp @@ -31,6 +31,7 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model): label->setText(tr("L%1").arg(i+1)); label->setContextMenuPolicy(Qt::CustomContextMenu); label->setMouseTracking(true); + label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); connect(label, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(csw_customContextMenuRequested(QPoint))); gridLayout->addWidget(label, i+1, 0); @@ -113,10 +114,8 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model): gridLayout->addWidget(cswitchDelay[i], i+1, 6); } } - - QSpacerItem * verticalSpacer = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); - gridLayout->addItem(verticalSpacer, GetEepromInterface()->getCapability(LogicalSwitches)+1, 0, 1, 1); - + // Push rows upward + addVSpring(gridLayout,0,GetEepromInterface()->getCapability(LogicalSwitches)+1); lock = false; } diff --git a/companion/src/modeledit/modelpanel.cpp b/companion/src/modeledit/modelpanel.cpp index b4c257aba..ed4424773 100644 --- a/companion/src/modeledit/modelpanel.cpp +++ b/companion/src/modeledit/modelpanel.cpp @@ -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); label->setFrameShape(QFrame::Panel); label->setFrameShadow(QFrame::Raised); label->setMidLineWidth(0); label->setAlignment(Qt::AlignCenter); - label->setMargin(3); + label->setMargin(5); label->setText(text); + if (!minimize) + label->setMinimumWidth(100); 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); +} + diff --git a/companion/src/modeledit/modelpanel.h b/companion/src/modeledit/modelpanel.h index 8e37010dd..ebe4f73a0 100644 --- a/companion/src/modeledit/modelpanel.h +++ b/companion/src/modeledit/modelpanel.h @@ -22,8 +22,11 @@ class ModelPanel : public QWidget protected: ModelData & model; 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