From 91e3ee13fd37f275395c2236d04f2d644881609a Mon Sep 17 00:00:00 2001 From: zedamota Date: Sat, 18 Feb 2012 20:37:30 +0000 Subject: [PATCH] Fix input and output configuration layout issues. --- .../src/plugins/config/configinputwidget.cpp | 2 +- .../src/plugins/config/inputchannelform.cpp | 17 ++++++++++++++++- .../src/plugins/config/inputchannelform.h | 2 +- .../src/plugins/config/inputchannelform.ui | 2 +- .../src/plugins/config/outputchannelform.cpp | 12 ++++++++++++ 5 files changed, 31 insertions(+), 4 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp index 67a54aa6d..2789e8967 100644 --- a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp @@ -62,7 +62,7 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) : ConfigTaskWidget(parent) Q_ASSERT(index < ManualControlSettings::CHANNELGROUPS_NUMELEM); inputChannelForm * inp=new inputChannelForm(this,index==0); m_config->channelSettings->layout()->addWidget(inp); - inp->ui->channelName->setText(name); + inp->setName(name); addUAVObjectToWidgetRelation("ManualControlSettings","ChannelGroups",inp->ui->channelGroup,index); addUAVObjectToWidgetRelation("ManualControlSettings","ChannelNumber",inp->ui->channelNumber,index); addUAVObjectToWidgetRelation("ManualControlSettings","ChannelMin",inp->ui->channelMin,index); diff --git a/ground/openpilotgcs/src/plugins/config/inputchannelform.cpp b/ground/openpilotgcs/src/plugins/config/inputchannelform.cpp index 98f71ea31..b8faa0fcb 100644 --- a/ground/openpilotgcs/src/plugins/config/inputchannelform.cpp +++ b/ground/openpilotgcs/src/plugins/config/inputchannelform.cpp @@ -23,7 +23,6 @@ inputChannelForm::inputChannelForm(QWidget *parent,bool showlegend) : delete ui->legend4; delete ui->legend5; } - connect(ui->channelMin,SIGNAL(valueChanged(int)),this,SLOT(minMaxUpdated())); connect(ui->channelMax,SIGNAL(valueChanged(int)),this,SLOT(minMaxUpdated())); connect(ui->channelGroup,SIGNAL(currentIndexChanged(int)),this,SLOT(groupUpdated())); @@ -40,6 +39,22 @@ inputChannelForm::~inputChannelForm() { delete ui; } +void inputChannelForm::setName(QString &name) +{ + ui->channelName->setText(name); + QFontMetrics metrics(ui->channelName->font()); + int width=metrics.width(name)+5; + foreach(inputChannelForm * form,parent()->findChildren()) + { + if(form==this) + continue; + if(form->ui->channelName->minimumSize().width()ui->channelName->setMinimumSize(width,0); + else + width=form->ui->channelName->minimumSize().width(); + } + ui->channelName->setMinimumSize(width,0); +} /** * Update the direction of the slider and boundaries diff --git a/ground/openpilotgcs/src/plugins/config/inputchannelform.h b/ground/openpilotgcs/src/plugins/config/inputchannelform.h index eb8ad7d18..c6534dc48 100644 --- a/ground/openpilotgcs/src/plugins/config/inputchannelform.h +++ b/ground/openpilotgcs/src/plugins/config/inputchannelform.h @@ -15,7 +15,7 @@ public: explicit inputChannelForm(QWidget *parent = 0,bool showlegend=false); ~inputChannelForm(); friend class ConfigInputWidget; - + void setName(QString &name); private slots: void minMaxUpdated(); void neutralUpdated(int); diff --git a/ground/openpilotgcs/src/plugins/config/inputchannelform.ui b/ground/openpilotgcs/src/plugins/config/inputchannelform.ui index 044e2437f..6e3395aab 100644 --- a/ground/openpilotgcs/src/plugins/config/inputchannelform.ui +++ b/ground/openpilotgcs/src/plugins/config/inputchannelform.ui @@ -36,7 +36,7 @@ - 70 + 10 0 diff --git a/ground/openpilotgcs/src/plugins/config/outputchannelform.cpp b/ground/openpilotgcs/src/plugins/config/outputchannelform.cpp index 131af2623..64e7df893 100644 --- a/ground/openpilotgcs/src/plugins/config/outputchannelform.cpp +++ b/ground/openpilotgcs/src/plugins/config/outputchannelform.cpp @@ -185,6 +185,18 @@ void OutputChannelForm::neutral(int value) void OutputChannelForm::setAssignment(const QString &assignment) { ui.actuatorName->setText(assignment); + QFontMetrics metrics(ui.actuatorName->font()); + int width=metrics.width(assignment)+1; + foreach(OutputChannelForm * form,parent()->findChildren()) + { + if(form==this) + continue; + if(form->ui.actuatorName->minimumSize().width()ui.actuatorName->setMinimumSize(width,0); + else + width=form->ui.actuatorName->minimumSize().width(); + } + ui.actuatorName->setMinimumSize(width,0); } /**