Ejemplo n.º 1
0
void MyDoubleSpinBox::focusInEvent(QFocusEvent *event)
{
	QDoubleSpinBox::focusInEvent(event);

	QString type = GetType(objectName());
	if (type != "text")
	{
		if (!slider)
		{
			QWidget *topWidget = window();
			slider = new cFrameSliderPopup(topWidget);
			slider->setFocusPolicy(Qt::NoFocus);

			if (type == QString("spinboxd") || type == QString("spinboxd3")
					|| type == QString("spinboxd4"))
			{
				int dialScale = pow(10.0, double(decimals()));
				slider->SetDialMode(dialScale, value());
				hasDial = true;
			}

			slider->hide();
		}

		QWidget *topWidget = window();
		QPoint windowPoint = mapTo(topWidget, QPoint());
		int width = this->width();
		int hOffset = height();
		slider->adjustSize();
		QSize minimumSize = slider->minimumSizeHint();
		width = max(width, int(minimumSize.width() * 0.6));
		slider->setFixedWidth(width);

		if (windowPoint.y() + slider->height() + hOffset > topWidget->height())
			hOffset = -slider->height();

		slider->move(windowPoint.x(), windowPoint.y() + hOffset);
		slider->show();

		connect(slider, SIGNAL(resetPressed()), this, SLOT(slotResetToDefault()));
		connect(slider, SIGNAL(intPressed()), this, SLOT(slotRoundValue()));

		if (hasDial)
		{
			connect(this, SIGNAL(valueChanged(double)), slider, SLOT(slotUpdateValue(double)));
			connect(slider, SIGNAL(valueChanged(double)), this, SLOT(setValue(double)));
			connect(slider, SIGNAL(upPressed()), this, SLOT(slotZeroValue()));
			connect(slider, SIGNAL(downPressed()), this, SLOT(slot180Value()));
			connect(slider, SIGNAL(rightPressed()), this, SLOT(slot90Value()));
			connect(slider, SIGNAL(leftPressed()), this, SLOT(slotMinus90Value()));
		}
		else
		{
			connect(slider, SIGNAL(timerTrigger()), this, SLOT(slotSliderTimerUpdateValue()));
			connect(slider, SIGNAL(zeroPressed()), this, SLOT(slotZeroValue()));
			connect(slider, SIGNAL(halfPressed()), this, SLOT(slotHalfValue()));
			connect(slider, SIGNAL(doublePressed()), this, SLOT(slotDoubleValue()));
			connect(slider, SIGNAL(minusPressed()), this, SLOT(slotInvertSign()));
		}
	}
Ejemplo n.º 2
0
void MyLineEdit::focusInEvent(QFocusEvent *event)
{
	QLineEdit::focusInEvent(event);

	QString type = GetType(objectName());
	if (type != "text")
	{
		if (!slider)
		{
			QWidget *topWidget = window();
			slider = new cFrameSliderPopup(topWidget);
			slider->setFocusPolicy(Qt::NoFocus);
			slider->hide();
		}

		QWidget *topWidget = window();
		QPoint windowPoint = mapTo(topWidget, QPoint());
		int width = this->width();
		int hOffset = height();

		QSize minimumSize = slider->minimumSizeHint();
		width = max(width, int(minimumSize.width() * 0.6));

		slider->adjustSize();
		slider->setFixedWidth(width);

		if (windowPoint.y() + slider->height() + hOffset > topWidget->height())
			hOffset = -slider->height();

		slider->move(windowPoint.x(), windowPoint.y() + hOffset);
		slider->show();

		connect(slider, SIGNAL(timerTrigger()), this, SLOT(slotSliderTimerUpdateValue()));
		connect(slider, SIGNAL(resetPressed()), this, SLOT(slotResetToDefault()));
		connect(slider, SIGNAL(zeroPressed()), this, SLOT(slotZeroValue()));
		connect(slider, SIGNAL(minusPressed()), this, SLOT(slotInvertSign()));
		connect(slider, SIGNAL(halfPressed()), this, SLOT(slotHalfValue()));
		connect(slider, SIGNAL(doublePressed()), this, SLOT(slotDoubleValue()));
		connect(slider, SIGNAL(intPressed()), this, SLOT(slotRoundValue()));
	}
}
Ejemplo n.º 3
0
void MySpinBox::focusInEvent(QFocusEvent *event)
{
	QSpinBox::focusInEvent(event);

	QString type = GetType(objectName());
	if (type != "text")
	{
		if (!slider)
		{
			QWidget *topWidget = window();
			slider = new cFrameSliderPopup(topWidget);
			slider->setFocusPolicy(Qt::NoFocus);
			slider->hide();
		}
		// update min and max
		slider->SetIntegerMode(minimum(), maximum(), value());

		QWidget *topWidget = window();
		QPoint windowPoint = mapTo(topWidget, QPoint());
		int width = this->width();
		int hOffset = height();
		slider->adjustSize();
		slider->setFixedWidth(width);

		if (windowPoint.y() + slider->height() + hOffset > topWidget->height())
			hOffset = -slider->height();

		slider->move(windowPoint.x(), windowPoint.y() + hOffset);
		slider->show();

		connect(slider, SIGNAL(resetPressed()), this, SLOT(slotResetToDefault()));
		connect(slider, SIGNAL(halfPressed()), this, SLOT(slotHalfValue()));
		connect(slider, SIGNAL(doublePressed()), this, SLOT(slotDoubleValue()));
		connect(this, SIGNAL(valueChanged(int)), slider, SLOT(slotUpdateValue(int)));
		connect(slider, SIGNAL(valueChanged(int)), this, SLOT(setValue(int)));
	}
}