Beispiel #1
0
    QmTap::QmTap(QObject *parent) : QmSensor(parent)
    {
        QmTapPrivate *priv = new QmTapPrivate(this);
        connect(priv, SIGNAL(tapped(MeeGo::QmTapReading)), this, SIGNAL(tapped(MeeGo::QmTapReading)));
        priv_ptr = priv;

    }
SpeedDialWidget::SpeedDialWidget(QWidget* parent, Qt::WindowFlags flags)
    : QWidget(parent, flags)
    , m_fadeIn(NULL)
    , m_fadeOut(NULL)
    , m_hold(NULL)
    , m_optionalTextGroup(NULL)
    , m_optionalTextEdit(NULL)
{
    QSettings settings;
    QVariant var;
    QBoxLayout* lay = NULL;

    /* Layout with customizable direction */
    var = settings.value(SETTINGS_DIRECTION);
    if (var.isValid() == true)
        lay = new QBoxLayout(QBoxLayout::Direction(var.toInt()), this);
    else
        lay = new QBoxLayout(QBoxLayout::TopToBottom, this);

    /* Create dials */
    m_fadeIn = new SpeedDial(this);
    m_fadeIn->setTitle(tr("Fade In"));
    layout()->addWidget(m_fadeIn);
    connect(m_fadeIn, SIGNAL(valueChanged(int)), this, SIGNAL(fadeInChanged(int)));
    connect(m_fadeIn, SIGNAL(tapped()), this, SIGNAL(fadeInTapped()));

    m_fadeOut = new SpeedDial(this);
    m_fadeOut->setTitle(tr("Fade Out"));
    layout()->addWidget(m_fadeOut);
    connect(m_fadeOut, SIGNAL(valueChanged(int)), this, SIGNAL(fadeOutChanged(int)));
    connect(m_fadeOut, SIGNAL(tapped()), this, SIGNAL(fadeOutTapped()));

    m_hold = new SpeedDial(this);
    m_hold->setTitle(tr("Hold"));
    layout()->addWidget(m_hold);
    connect(m_hold, SIGNAL(valueChanged(int)), this, SIGNAL(holdChanged(int)));
    connect(m_hold, SIGNAL(tapped()), this, SIGNAL(holdTapped()));

    /* Optional text */
    m_optionalTextGroup = new QGroupBox(this);
    layout()->addWidget(m_optionalTextGroup);
    new QVBoxLayout(m_optionalTextGroup);
    m_optionalTextEdit = new QLineEdit(m_optionalTextGroup);
    m_optionalTextGroup->layout()->addWidget(m_optionalTextEdit);
    m_optionalTextGroup->setVisible(false);
    connect(m_optionalTextEdit, SIGNAL(textEdited(const QString&)),
            this, SIGNAL(optionalTextEdited(const QString&)));

    lay->addStretch();

    /* Position */
    var = settings.value(SETTINGS_GEOMETRY);
    if (var.isValid() == true)
        this->restoreGeometry(var.toByteArray());
    AppUtil::ensureWidgetIsVisible(this);
}
Beispiel #3
0
VCSpeedDial::VCSpeedDial(QWidget* parent, Doc* doc)
    : VCWidget(parent, doc)
    , m_speedTypes(VCSpeedDial::Duration)
    , m_dial(NULL)
    , m_absoluteValueMin(0)
    , m_absoluteValueMax(1000 * 10)
{
    new QVBoxLayout(this);

    m_dial = new SpeedDial(this);
    layout()->addWidget(m_dial);
    connect(m_dial, SIGNAL(valueChanged(int)), this, SLOT(slotDialValueChanged(int)));
    connect(m_dial, SIGNAL(tapped()), this, SLOT(slotDialTapped()));

    setType(VCWidget::SpeedDialWidget);
    setCaption(tr("Duration"));

    QSettings settings;
    QVariant var = settings.value(SETTINGS_SPEEDDIAL_SIZE);
    if (var.isValid() == true)
        resize(var.toSize());
    else
        resize(VCSpeedDial::defaultSize);

    var = settings.value(SETTINGS_SPEEDDIAL_VALUE);
    if (var.isValid() == true)
        m_dial->setValue(var.toUInt());

    slotModeChanged(doc->mode());
}
Beispiel #4
0
void SpeedDial::slotTapClicked()
{
    if (m_tapTime == NULL)
    {
        m_tapTime = new QTime(QTime::currentTime());
        if (m_tapTickTimer == NULL)
        {
            m_tapTickTimer = new QTimer();
            connect(m_tapTickTimer, SIGNAL(timeout()),
                    this, SLOT(slotTapTimeout()));
        }
        m_tapTime->start();
        return;
    }
    // Round the elapsed time to the nearest full 10th ms.
    int remainder = m_tapTime->elapsed() % MS_DIV;
    m_value = m_tapTime->elapsed() - remainder;
    if (remainder >= (MS_DIV / 2))
        m_value += MS_DIV;
    setSpinValues(m_value);
    m_tapTime->restart();
    if (m_tapTickTimer)
    {
        m_tapTickTimer->setInterval(m_value);
        m_tapTickTimer->start();
    }
    emit tapped();
}
Beispiel #5
0
void Bus_Test::tap()
{
    QSignalSpy spy(Bus::instance(), SIGNAL(tapped(quint32)));

    /* Tapping an existing bus should produce a signal */
    Bus::instance()->tap(17);
    QVERIFY(spy.count() == 1);
    QVERIFY(spy.at(0).at(0).toUInt() == 17);

    /* Tapping a non-existing bus should produce a signal */
    Bus::instance()->tap(6342);
    QVERIFY(spy.count() == 1);
    QVERIFY(spy.at(0).at(0).toUInt() == 17);
}
Beispiel #6
0
Chaser::Chaser(Doc* doc) : Function(doc)
{
    m_runTimeDirection = Forward;
    m_runTimePosition = 0;
    m_runner = NULL;

    setName(tr("New Chaser"));
    setBus(Bus::defaultHold());

    connect(Bus::instance(), SIGNAL(tapped(quint32)),
            this, SLOT(slotBusTapped(quint32)));

    // Listen to member Function removals
    connect(doc, SIGNAL(functionRemoved(t_function_id)),
            this, SLOT(slotFunctionRemoved(t_function_id)));
}
Beispiel #7
0
void SpeedDial::slotTapClicked()
{
    if (m_tapTime == NULL)
    {
        m_tapTime = new QTime(QTime::currentTime());
        m_tapTime->start();
        return;
    }
    // Round the elapsed time to the nearest full 10th ms.
    m_value = m_tapTime->elapsed();
    setSpinValues(m_value);

    m_tapTime->restart();

    // time has changed - update tap button blinking
    updateTapTimer();

    emit tapped();
}
Beispiel #8
0
Chaser::Chaser(QObject* parent) : Function(parent)
{
	m_runTimeDirection = Forward;
	m_runTimePosition = 0;
	m_masterTimer = NULL;

	setName(tr("New Chaser"));
	setBus(Bus::defaultHold());

	connect(Bus::instance(), SIGNAL(tapped(quint32)),
		this, SLOT(slotBusTapped(quint32)));

	Doc* doc = qobject_cast <Doc*> (parent);
	if (doc != NULL)
	{
		/* Listen to function removals so that they can be removed from
		   this chaser as well. Parent might not always be Doc, but an
		   editor dialog, for example. Such chasers cannot be run,
		   though. */
		connect(doc, SIGNAL(functionRemoved(t_function_id)),
			this, SLOT(slotFunctionRemoved(t_function_id)));
	}
}
Beispiel #9
0
void Bus::tap(quint32 bus)
{
	if (bus < KBusCount)
		emit tapped(bus);
}
Beispiel #10
0
VCSpeedDial::VCSpeedDial(QWidget* parent, Doc* doc)
    : VCWidget(parent, doc)
    , m_currentFactor(1)
    , m_resetFactorOnDialChange(false)
    , m_absoluteValueMin(0)
    , m_absoluteValueMax(1000 * 10)
{
    setFrameStyle(KVCFrameStyleSunken);

    QVBoxLayout* vBox = new QVBoxLayout(this);
    vBox->setMargin(0);

    QHBoxLayout* speedDialHBox = new QHBoxLayout();
    vBox->addLayout(speedDialHBox);

    m_dial = new SpeedDial(this);
    speedDialHBox->addWidget(m_dial);
    connect(m_dial, SIGNAL(valueChanged(int)), this, SLOT(slotDialValueChanged()));
    connect(m_dial, SIGNAL(tapped()), this, SLOT(slotDialTapped()));

    m_factoredValue = m_dial->value();

    setType(VCWidget::SpeedDialWidget);
    setCaption(tr("Duration"));

    QSettings settings;
    QVariant var = settings.value(SETTINGS_SPEEDDIAL_SIZE);
    if (var.isValid() == true)
        resize(var.toSize());
    else
        resize(VCSpeedDial::defaultSize);

    var = settings.value(SETTINGS_SPEEDDIAL_VALUE);
    if (var.isValid() == true)
        m_dial->setValue(var.toUInt());

    // Multiplier, factor, divider and reset box
    QHBoxLayout* multFactorDivHBox = new QHBoxLayout();

    m_divButton = new QToolButton();
    m_divButton->setIconSize(QSize(32, 32));
    m_divButton->setIcon(QIcon(":/back.png"));
    m_divButton->setToolTip(tr("Divide the current time by 2"));
    connect(m_divButton, SIGNAL(clicked()),
            this, SLOT(slotDiv()));
    multFactorDivHBox->addWidget(m_divButton, Qt::AlignVCenter | Qt::AlignLeft);

    QVBoxLayout* labelsVboxBox = new QVBoxLayout();

    m_multDivLabel = new QLabel();
    m_multDivLabel->setAlignment(Qt::AlignCenter);
    m_multDivLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    labelsVboxBox->addWidget(m_multDivLabel, Qt::AlignVCenter | Qt::AlignLeft);

    m_multDivResultLabel = new QLabel();
    m_multDivResultLabel->setAlignment(Qt::AlignCenter);
    m_multDivResultLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    m_multDivResultLabel->setBackgroundRole(QPalette::BrightText);
    labelsVboxBox->addWidget(m_multDivResultLabel);

    multFactorDivHBox->addLayout(labelsVboxBox);

    m_multButton = new QToolButton();
    m_multButton->setIconSize(QSize(32, 32));
    m_multButton->setIcon(QIcon(":/forward.png"));
    m_multButton->setToolTip(tr("Multiply the current time by 2"));
    connect(m_multButton, SIGNAL(clicked()),
            this, SLOT(slotMult()));
    multFactorDivHBox->addWidget(m_multButton, Qt::AlignVCenter | Qt::AlignLeft);

    m_multDivResetButton = new QToolButton();
    m_multDivResetButton->setIconSize(QSize(32, 32));
    m_multDivResetButton->setIcon(QIcon(":/fileclose.png"));
    m_multDivResetButton->setToolTip(tr("Reset the current factor to 1x"));
    connect(m_multDivResetButton, SIGNAL(clicked()),
            this, SLOT(slotMultDivReset()));
    multFactorDivHBox->addWidget(m_multDivResetButton);

    vBox->addLayout(multFactorDivHBox);

    // Update labels
    slotMultDivChanged();

    // Apply button
    m_applyButton = new QPushButton();
    m_applyButton->setStyleSheet(presetBtnSS.arg("#DDDDDD"));
    m_applyButton->setText(tr("Apply"));
    m_applyButton->setToolTip(tr("Send the current value to the function now"));
    connect(m_applyButton, SIGNAL(clicked()),
            this, SLOT(slotFactoredValueChanged()));
    vBox->addWidget(m_applyButton);

    // Presets
    m_presetsLayout = new FlowLayout(3);
    vBox->addLayout(m_presetsLayout);

    // Don't show Infinite button: it's handled by presets
    setVisibilityMask(SpeedDial::defaultVisibilityMask() & ~SpeedDial::Infinite);

    /* Update timer */
    m_updateTimer = new QTimer(this);
    connect(m_updateTimer, SIGNAL(timeout()),
            this, SLOT(slotUpdate()));
    m_updateTimer->setSingleShot(true);

    slotModeChanged(m_doc->mode());
    setLiveEdit(m_liveEdit);
}