void UserProgram::stop() { CbobData::instance()->resetPullups(); if(m_userProgram.state() != QProcess::NotRunning) { toggleState(); } }
LEDControl::~LEDControl() { // turn the torch off when closing the app if( isOn() ) toggleState(); releaseGstreamerTorch(); }
//-------------------------------------------------------------- void Game::keyReleased(int key) { if (key == 'p') startGame(); if (key == 'r') toggleState(); if (!locked) { //players keyboards extra controls switch(key) { case OF_KEY_UP: playerList[0].applyImpulse(); break; case OF_KEY_DOWN: playerList[0].setDirection(0); break; case OF_KEY_LEFT: playerList[0].setDirectionIncrement(-1); break; case OF_KEY_RIGHT: playerList[0].setDirectionIncrement(1); break; case 'w': playerList[1].applyImpulse(); break; case 's': playerList[1].setDirection(0); break; case 'a': playerList[1].setDirectionIncrement(-1); break; case 'd': playerList[1].setDirectionIncrement(1); break; case 'y': playerList[2].applyImpulse(); break; case 'h': playerList[2].setDirection(0); break; case 'g': playerList[2].setDirectionIncrement(-1); break; case 'j': playerList[2].setDirectionIncrement(1); break; case 'Y': playerList[3].applyImpulse(); break; case 'H': playerList[3].setDirection(0); break; case 'G': playerList[3].setDirectionIncrement(-1); break; case 'J': playerList[3].setDirectionIncrement(1); break; } } }
bool SliderKnob::leftDragStart(float xPos, float yPos) { mStartPos = mDim == DIM_X ? xPos : yPos; mStartOffset = mFrame->dexpand(mDim) ? (mStartPos - mFrame->parent()->dabsolute(mDim)) : mFrame->dposition(mDim); toggleState(ACTIVATED); return true; }
// HACK: Committing a button is the same as instantly clicking it. // virtual void LLButton::onCommit() { // WARNING: Sometimes clicking a button destroys the floater or // panel containing it. Therefore we need to call LLUICtrl::onCommit() // LAST, otherwise this becomes deleted memory. if (mMouseDownSignal) (*mMouseDownSignal)(this, LLSD()); if (mMouseUpSignal) (*mMouseUpSignal)(this, LLSD()); if (getSoundFlags() & MOUSE_DOWN) { make_ui_sound("UISndClick"); } if (getSoundFlags() & MOUSE_UP) { make_ui_sound("UISndClickRelease"); } if (mIsToggle) { toggleState(); } // do this last, as it can result in destroying this button LLUICtrl::onCommit(); }
bool DoorRenderer::action(const BLOCK_WDATA block, const int local_x, const int local_y, const int local_z, Chunk &c) { bool door_open = getBLOCKDATA(block) & DOOR_OPEN; toggleState(block, local_x, local_y, local_z, c, door_open ? 0 : (DOOR_OPEN | DOOR_FORCE_OPEN)); return true; }
void activateTrigger(const actuator_t* const actuator_p) { ioSetOutput(actuator_p->output_on); ioResetOutput(actuator_p->output_off); ioToggleOutput(actuator_p->output_toggle); setState(actuator_p->state_on); resetState(actuator_p->state_off); toggleState(actuator_p->state_toggle); }
void NerdMain::setSignalSlot(){ connect(ui->menuNextRecord,SIGNAL(triggered()),data,SLOT(setNextRecord())); connect(ui->menuPrevRecord,SIGNAL(triggered()),data,SLOT(setPrevRecord())); connect(ui->menuNextCell,SIGNAL(triggered()),data,SLOT(setNextCell())); connect(ui->menuPrevCell,SIGNAL(triggered()),data,SLOT(setPrevCell())); connect(ui->menuAbout,SIGNAL(triggered()),aboutWin,SLOT(show())); connect(ui->menuHomepage,SIGNAL(triggered()),this,SLOT(openHomepage())); connect(open,SIGNAL(fileOpen()),this,SLOT(openFile())); connect(ui->menuOpen,SIGNAL(triggered()),open,SLOT(btnClicked())); connect(ui->menuExit,SIGNAL(triggered()),this,SLOT(close())); connect(ui->menuStart,SIGNAL(triggered()),data,SLOT(toggleState())); connect(ui->menuStop,SIGNAL(triggered()),data,SLOT(toggleState())); connect(data,SIGNAL(stateChange()),this,SLOT(toggleState())); connect(data,SIGNAL(nextState(bool)),this,SLOT(toggleNext(bool))); connect(data,SIGNAL(nextCellState(bool)),this,SLOT(toggleNextCell(bool))); connect(data,SIGNAL(prevState(bool)),this,SLOT(togglePrev(bool))); connect(data,SIGNAL(prevCellState(bool)),this,SLOT(togglePrevCell(bool))); }
void LEDControl::setUseGStreamer(bool gstreamer) { qDebug() << "setUseGStreamer called, setting value to: " << gstreamer; if (m_useGStreamer != gstreamer) { // if torch is on, turn it off before changing the method if (isOn() ) toggleState(); applicationSettings->setValue("useGStreamer",gstreamer);// store in settings m_useGStreamer = gstreamer; } }
TimeWidget::TimeWidget() { m_main_layout = new QVBoxLayout(this); // Time inputs auto widget_hours_label = new JLabel(tr("Hours")); m_widget_hours_input = new QSpinBox; m_widget_hours_input->setMinimum(0); auto widget_mins_label = new JLabel(tr("Minutes")); m_widget_mins_input = new QSpinBox; m_widget_mins_input->setMinimum(0); auto widget_secs_label = new JLabel(tr("Seconds")); m_widget_secs_input = new QSpinBox; m_widget_secs_input->setMinimum(0); m_widget_progress = new QProgressBar; m_widget_progress->setMinimum(0); m_widget_button = new QPushButton; // Widgets placement auto time_label_layout = new QHBoxLayout; time_label_layout->setAlignment(Qt::AlignTop); time_label_layout->addWidget(widget_hours_label, 0, Qt::AlignCenter); time_label_layout->addWidget(widget_mins_label, 0, Qt::AlignCenter); time_label_layout->addWidget(widget_secs_label, 0, Qt::AlignCenter); auto time_input_layout = new QHBoxLayout; time_input_layout->setAlignment(Qt::AlignTop); time_input_layout->addWidget(m_widget_hours_input, 0, Qt::AlignTop); time_input_layout->addWidget(m_widget_mins_input, 0, Qt::AlignTop); time_input_layout->addWidget(m_widget_secs_input, 0, Qt::AlignTop); m_main_layout->addLayout(time_label_layout); m_main_layout->addLayout(time_input_layout); m_main_layout->addWidget(m_widget_progress); m_buttons_layout = new QHBoxLayout; m_buttons_layout->addWidget(m_widget_button); m_main_layout->addLayout(m_buttons_layout); m_timer = new QTimer(this); // Events connect(widget_hours_label, SIGNAL(clicked()), m_widget_hours_input, SLOT(setFocus())); connect(widget_mins_label, SIGNAL(clicked()), m_widget_mins_input, SLOT(setFocus())); connect(widget_secs_label, SIGNAL(clicked()), m_widget_secs_input, SLOT(setFocus())); connect(m_widget_button, SIGNAL(pressed()), this, SLOT(toggleState())); connect(m_timer, SIGNAL(timeout()), this, SLOT(updateTime())); cancelState(); }
LED::LED(QWidget* parent) : QWidget(parent), diameter_(5), color_(QColor("red")), alignment_(Qt::AlignCenter), initialState_(true), state_(true), flashRate_(200), flashing_(false) { timer_ = new QTimer(this); connect(timer_, SIGNAL(timeout()), this, SLOT(toggleState())); setDiameter(diameter_); }
BOOL LLButton::handleKeyHere(KEY key, MASK mask ) { BOOL handled = FALSE; if( mCommitOnReturn && KEY_RETURN == key && mask == MASK_NONE && !gKeyboard->getKeyRepeated(key)) { if (mIsToggle) { toggleState(); } handled = TRUE; LLUICtrl::onCommit(); } return handled; }
BOOL LLButton::handleUnicodeCharHere(llwchar uni_char) { BOOL handled = FALSE; if(' ' == uni_char && !gKeyboard->getKeyRepeated(' ')) { if (mIsToggle) { toggleState(); } LLUICtrl::onCommit(); handled = TRUE; } return handled; }
BOOL LLButton::handleMouseUp(S32 x, S32 y, MASK mask) { // We only handle the click if the click both started and ended within us if( hasMouseCapture() ) { // Always release the mouse gFocusMgr.setMouseCapture( NULL ); /* * ATTENTION! This call fires another mouse up callback. * If you wish to remove this call emit that signal directly * by calling LLUICtrl::mMouseUpSignal(x, y, mask); */ LLUICtrl::handleMouseUp(x, y, mask); LLViewerEventRecorder::instance().updateMouseEventInfo(x,y,-55,-55,getPathname()); // Regardless of where mouseup occurs, handle callback if(mMouseUpSignal) (*mMouseUpSignal)(this, LLSD()); resetMouseDownTimer(); // DO THIS AT THE VERY END to allow the button to be destroyed as a result of being clicked. // If mouseup in the widget, it's been clicked if (pointInView(x, y)) { if (getSoundFlags() & MOUSE_UP) { make_ui_sound("UISndClickRelease"); } if (mIsToggle) { toggleState(); } LLUICtrl::onCommit(); } } else { childrenHandleMouseUp(x, y, mask); } return TRUE; }
BOOL LLButton::handleUnicodeCharHere(llwchar uni_char, BOOL called_from_parent) { BOOL handled = FALSE; if( getVisible() && mEnabled && !called_from_parent && ' ' == uni_char && !gKeyboard->getKeyRepeated(' ')) { if (mIsToggle) { toggleState(); } if (mClickedCallback) { (*mClickedCallback)( mCallbackUserData ); } handled = TRUE; } return handled; }
void MApplicationMenuButtonViewPrivate::refreshIconImage() { Q_Q(MApplicationMenuButtonView); QSize size = q->style()->iconSize(); QString iconID = q->model()->iconID(); if (toggleState() && !q->model()->toggledIconID().isEmpty()) iconID = q->model()->toggledIconID(); if (iconID != iconImage->image() || (!iconID.isEmpty() && iconID == iconImage->image() && size != iconImage->imageSize())) { //Apply image and refresh layout only if image itself or size of the existing image //should be changed (avoid some flickering). iconImage->setImage(iconID, size); refreshLayout(); } }
BOOL LLButton::handleUnicodeCharHere(llwchar uni_char) { BOOL handled = FALSE; if(' ' == uni_char && !gKeyboard->getKeyRepeated(' ')) { if (mIsToggle) { toggleState(); } if (mClickedCallback) { (*mClickedCallback)( mCallbackUserData ); } handled = TRUE; } return handled; }
BOOL LLButton::handleKeyHere(KEY key, MASK mask ) { BOOL handled = FALSE; if( mCommitOnReturn && KEY_RETURN == key && mask == MASK_NONE && !gKeyboard->getKeyRepeated(key)) { if (mIsToggle) { toggleState(); } handled = TRUE; if (mClickedCallback) { (*mClickedCallback)( mCallbackUserData ); } } return handled; }
void UartParseIncommingPacket(void) { BYTE command = uart0Packet.uartPacketBuffer.packetdata[0]; switch(command) { case UART_CMD_GET_VERSION: // 01 01 01 { BYTE response_buffer[] = {UART_CMD_GET_VERSION, TEST_BOARD_VERSION}; Uart0SendPacket(response_buffer, sizeof(response_buffer)); } break; case UART_CMD_TEST_CONFIGURATION: if (uart0Packet.length == (MAX_PIN_NUMBER + 1)) { // sizeof setup frame SetUpPins(); } break; case UART_CMD_TOGGLE_STATE: // 01 02 03 00 toggleState(uart0Packet.uartPacketBuffer.uartPacketToggleState.pin); break; case UART_CMD_PULSE: testPulse( uart0Packet.uartPacketBuffer.uartPacketTestPulse.pin, uart0Packet.uartPacketBuffer.uartPacketTestPulse.duration.Word); break; case UART_CMD_WAIT_FOR_PIN: // 01 07 05 00 00 00 00 07 D0 waitPinState( uart0Packet.uartPacketBuffer.uartPacketWaitPinState.pin, uart0Packet.uartPacketBuffer.uartPacketWaitPinState.state, uart0Packet.uartPacketBuffer.uartPacketWaitPinState.duration.Word); break; case UART_CMD_PWM: break; default: break; } }
BOOL LLButton::handleMouseUp(S32 x, S32 y, MASK mask) { // We only handle the click if the click both started and ended within us if( hasMouseCapture() ) { // Always release the mouse gFocusMgr.setMouseCapture( NULL ); // Regardless of where mouseup occurs, handle callback if (mMouseUpCallback) { (*mMouseUpCallback)(mCallbackUserData); } mMouseDownTimer.stop(); mMouseDownTimer.reset(); // DO THIS AT THE VERY END to allow the button to be destroyed as a result of being clicked. // If mouseup in the widget, it's been clicked if (pointInView(x, y)) { if (getSoundFlags() & MOUSE_UP) { make_ui_sound("UISndClickRelease"); } if (mIsToggle) { toggleState(); } if (mClickedCallback) { (*mClickedCallback)( mCallbackUserData ); } } } return TRUE; }
// HACK: Committing a button is the same as instantly clicking it. // virtual void LLButton::onCommit() { // WARNING: Sometimes clicking a button destroys the floater or // panel containing it. Therefore we need to call mClickedCallback // LAST, otherwise this becomes deleted memory. LLUICtrl::onCommit(); if (mMouseDownCallback) { (*mMouseDownCallback)(mCallbackUserData); } if (mMouseUpCallback) { (*mMouseUpCallback)(mCallbackUserData); } if (mSoundFlags & MOUSE_DOWN) { make_ui_sound("UISndClick"); } if (mSoundFlags & MOUSE_UP) { make_ui_sound("UISndClickRelease"); } if (mIsToggle) { toggleState(); } // do this last, as it can result in destroying this button if (mClickedCallback) { (*mClickedCallback)( mCallbackUserData ); } }
void DoorRenderer::tick(const BLOCK_WDATA block, int local_x, int local_y, int local_z, Chunk &c) { //Only the bottom reacts if(getBLOCKDATA(block) & DOOR_TOP) return; //A manually opened door doesn't change state by itself if(getBLOCKDATA(block) & DOOR_FORCE_OPEN) return; bool redstone_state = c.isBlockPoweredOrPowering(local_x, local_y - 1, local_z) || c.isBlockPoweredOrPowering(local_x, local_y + 2, local_z) || c.isBlockPoweredOrPowering(local_x - 1, local_y, local_z) || c.isBlockPoweredOrPowering(local_x - 1, local_y + 1, local_z) || c.isBlockPoweredOrPowering(local_x + 1, local_y, local_z) || c.isBlockPoweredOrPowering(local_x + 1, local_y + 1, local_z) || c.isBlockPoweredOrPowering(local_x, local_y, local_z - 1) || c.isBlockPoweredOrPowering(local_x, local_y + 1, local_z - 1) || c.isBlockPoweredOrPowering(local_x, local_y, local_z + 1) || c.isBlockPoweredOrPowering(local_x, local_y + 1, local_z + 1); bool door_open = getBLOCKDATA(block) & DOOR_OPEN; if(redstone_state == door_open) return; toggleState(block, local_x, local_y, local_z, c, redstone_state ? DOOR_OPEN : 0); }
LEDControl::LEDControl(QObject *parent) : QObject(parent), m_isValid(false), pipeline(0), src(0), sink(0), m_gStreamerInitialised(false), m_useGStreamer(false) { // initialise settings object applicationSettings = new QSettings(); // application name defaults to binary name // check settings to determine whether to use gstreamer, default to true and ask the user to set it on first run m_useGStreamer = applicationSettings->value("useGStreamer",true).toBool(); // initialise gstreamer pipeline initGstreamerTorch(); // on hammerhead the control file is /sys/class/leds/led\:flash_torch/brightness // on Jolla phone it is /sys/kernel/debug/flash_adp1650/mode // check for path stored in app settings if( applicationSettings->contains("controlFilePath") && applicationSettings->contains("device") && applicationSettings->contains("brightness") ) { setPath( applicationSettings->value( "controlFilePath", QString("") ).toString() ); setDevice( applicationSettings->value( "device", QString("") ).toString() ); setBrightness( applicationSettings->value( "brightness", QString::number(1) ).toString() ); } else { // try autodetecting detectPath(); } // get initial file state m_isOn = checkFile(); // if light is not on, turn it on if (!m_isOn) { toggleState(); } qDebug() << "end of constructor"; }
bool SliderKnob::leftDragEnd(float xPos, float yPos) { mParent->as<Slider>().offsetChange(offset(mDim == DIM_X ? xPos : yPos), true); toggleState(ACTIVATED); return true; }
void LEDButton::toggle() { toggleState(); }
void RadiobuttonWidget::handleMouseUp(int x, int y, int button, int clickCount) { if (isEnabled() && x >= 0 && x < _w && y >= 0 && y < _h) { toggleState(); } }
bool WrapButton::leftPressed(float x, float y) { UNUSED(x); UNUSED(y); toggleState(TRIGGERED); return true; }
void testPulse(U8 pin, U32 duration) { toggleState(pin); delayedAction(toggleState, duration, pin); }
void CheckboxWidget::handleMouseUp(int x, int y, int button, int clickCount) { if (isEnabled() && _duringPress && x >= 0 && x < _w && y >= 0 && y < _h) { toggleState(); } _duringPress = false; }
void UserProgram::start() { if(m_userProgram.state() == QProcess::NotRunning) { toggleState(); } }