Files
lsim/src/stopperwidget.cpp
2008-11-21 23:56:10 +00:00

106 lines
4.1 KiB
C++

/***************************************************************************
* Copyright (C) 2008 by Peter Dahlberg *
* pdahlberg@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "stopperwidget.h"
#include "stopperitem.h"
#include "expdoublespinbox.h"
#include <QVBoxLayout>
#include <QtDebug>
#include <QDial>
#include <QGroupBox>
#include <QLabel>
#include <QDoubleSpinBox>
StopperWidget::StopperWidget(QWidget* parent, Qt::WindowFlags f, StopperItem* stopperI): QWidget() {
stopperItem = stopperI;
createWidget();
}
StopperWidget::~StopperWidget() {
}
void StopperWidget::createWidget()
{
QDoubleSpinBox *widthBox = new QDoubleSpinBox;
widthBox->setRange(StopperItem::MinimumWidth, 5000);
widthBox->setKeyboardTracking(false);
connect(stopperItem ,SIGNAL(widthChanged(double)),widthBox, SLOT(setValue(double)) );
connect(widthBox, SIGNAL(valueChanged(double)),stopperItem ,SLOT(setRectFWidth(double)) );
QLabel* xLabel = new QLabel(tr("x:"));
QLabel* yLabel = new QLabel(tr("y:"));
QLabel* widthLabel = new QLabel(tr("Breite:"));
QLabel* rotationLabel = new QLabel(tr("Rotation:"));
QDoubleSpinBox *posXBox = new QDoubleSpinBox;
posXBox->setRange(-5000, 5000);
posXBox->setKeyboardTracking(false);
connect(stopperItem ,SIGNAL(ScenePosXChanged(double)),posXBox, SLOT(setValue(double)) );
connect(posXBox, SIGNAL(valueChanged(double)),stopperItem ,SLOT(setScenePosX(double)) );
QDoubleSpinBox *posYBox = new QDoubleSpinBox;
posYBox->setRange(-5000, 5000);
posYBox->setKeyboardTracking(false);
connect(stopperItem ,SIGNAL(ScenePosYChanged(double)),posYBox, SLOT(setValue(double)) );
connect(posYBox, SIGNAL(valueChanged(double)),stopperItem ,SLOT(setScenePosY(double)) );
QSpinBox* rotationBox = new QSpinBox;
rotationBox->setRange(0,359);
rotationBox->setSuffix("\260");
rotationBox->setWrapping(true);
rotationBox->setKeyboardTracking(false);
connect(rotationBox, SIGNAL(valueChanged(int)),stopperItem ,SLOT(setRotation(int)) );
connect(stopperItem, SIGNAL(rotationChanged(int)),rotationBox ,SLOT(setValue(int)) );
QGridLayout* geomGridLayout = new QGridLayout;
//geomGridLayout->setSizeConstraint(QLayout::SetFixedSize);
geomGridLayout->addWidget(rotationBox,0,1);
geomGridLayout->addWidget(posYBox,2,1);
geomGridLayout->addWidget(posXBox,1,1);
geomGridLayout->addWidget(xLabel,1,0,Qt::AlignRight);
geomGridLayout->addWidget(yLabel,2,0,Qt::AlignRight);
geomGridLayout->addWidget(widthLabel,3,0,Qt::AlignRight);
geomGridLayout->addWidget(rotationLabel,0,0,Qt::AlignRight);
geomGridLayout->addWidget(widthBox,3,1);
//geomGridLayout->addWidget(rotationDial, 1,0,2,2);
QGroupBox* geometryBox = new QGroupBox(tr("Geometrie"));
geometryBox->setLayout(geomGridLayout);
QVBoxLayout * mainLayout = new QVBoxLayout(this);
mainLayout -> addWidget(geometryBox);
mainLayout -> addStretch();
QWidget::setTabOrder (rotationBox, posXBox);
QWidget::setTabOrder (posXBox, posYBox);
QWidget::setTabOrder (posYBox, widthBox);
this -> setLayout(mainLayout);
}