void Widget::initMenu() { QMenu* command = menuBar()->addMenu("Control"); command->addAction("Start / Stop", this, SLOT(toggleReading()), QKeySequence(Qt::Key_F4)); command->addAction("Slower", this, SLOT(slower()), QKeySequence(Qt::Key_F5)); command->addAction("Faster", this, SLOT(faster()), QKeySequence(Qt::Key_F6)); }
/* * getchar with timeout. */ int tgetchar(void) { static struct timeval timeleft; char c; /* * Reset timeleft to fallrate whenever it is not positive. * In any case, wait to see if there is any input. If so, * take it, and update timeleft so that the next call to * tgetchar() will not wait as long. If there is no input, * make timeleft zero or negative, and return -1. * * Most of the hard work is done by rwait(). */ if (!TV_POS(&timeleft)) { faster(); /* go faster */ timeleft.tv_sec = 0; timeleft.tv_usec = fallrate; } if (!rwait(&timeleft)) return (-1); if (read(0, &c, 1) != 1) stop("end of file, help"); return ((int)(unsigned char)c); }
/** Get char with timeout * */ int tgetchar(void) { /* * Reset timeleft to fallrate whenever it is not positive * and increase speed. */ if (timeleft <= 0) { faster(); timeleft = fallrate; } /* * Wait to see if there is any input. If so, take it and * update timeleft so that the next call to tgetchar() * will not wait as long. If there is no input, * make timeleft zero and return -1. */ wchar_t c = 0; while (c == 0) { kbd_event_t event; if (!console_get_kbd_event_timeout(console, &event, &timeleft)) { timeleft = 0; return -1; } if (event.type == KEY_PRESS) c = event.c; } return (int) c; }
std::string execute(int variation) { switch (variation) { case 0: return to_string(bruteForce()); case -1: case 1: return to_string(faster()); default: return std::string("unavailable"); } return NULL; }
void QVLCMenu::PopupMenuControlEntries( QMenu *menu, intf_thread_t *p_intf ) { QAction *action; /* Faster/Slower */ action = menu->addAction( qtr( "&Faster" ), THEMIM->getIM(), SLOT( faster() ) ); action->setIcon( QIcon( ":/toolbar/faster") ); action->setData( STATIC_ENTRY ); action = menu->addAction( qtr( "Faster (fine)" ), THEMIM->getIM(), SLOT( littlefaster() ) ); action->setData( STATIC_ENTRY ); action = menu->addAction( qtr( "N&ormal Speed" ), THEMIM->getIM(), SLOT( normalRate() ) ); action->setData( STATIC_ENTRY ); action = menu->addAction( qtr( "Slower (fine)" ), THEMIM->getIM(), SLOT( littleslower() ) ); action->setData( STATIC_ENTRY ); action = menu->addAction( qtr( "Slo&wer" ), THEMIM->getIM(), SLOT( slower() ) ); action->setIcon( QIcon( ":/toolbar/slower") ); action->setData( STATIC_ENTRY ); menu->addSeparator(); action = menu->addAction( qtr( "&Jump Forward" ), THEMIM->getIM(), SLOT( jumpFwd() ) ); action->setIcon( QIcon( ":/toolbar/skip_fw") ); action->setData( STATIC_ENTRY ); action = menu->addAction( qtr( "Jump Bac&kward" ), THEMIM->getIM(), SLOT( jumpBwd() ) ); action->setIcon( QIcon( ":/toolbar/skip_back") ); action->setData( STATIC_ENTRY ); addDPStaticEntry( menu, qtr( I_MENU_GOTOTIME ),"", SLOT( gotoTimeDialog() ), "Ctrl+T" ); menu->addSeparator(); }
/********************************************************************** * Speed control widget **********************************************************************/ SpeedControlWidget::SpeedControlWidget( intf_thread_t *_p_i, QWidget *_parent ) : QFrame( _parent ), p_intf( _p_i ) { QSizePolicy sizePolicy( QSizePolicy::Fixed, QSizePolicy::Maximum ); sizePolicy.setHorizontalStretch( 0 ); sizePolicy.setVerticalStretch( 0 ); speedSlider = new QSlider( this ); speedSlider->setSizePolicy( sizePolicy ); speedSlider->setMinimumSize( QSize( 140, 20 ) ); speedSlider->setOrientation( Qt::Horizontal ); speedSlider->setTickPosition( QSlider::TicksBelow ); speedSlider->setRange( -34, 34 ); speedSlider->setSingleStep( 1 ); speedSlider->setPageStep( 1 ); speedSlider->setTickInterval( 17 ); CONNECT( speedSlider, valueChanged( int ), this, updateRate( int ) ); QToolButton *normalSpeedButton = new QToolButton( this ); normalSpeedButton->setMaximumSize( QSize( 26, 16 ) ); normalSpeedButton->setAutoRaise( true ); normalSpeedButton->setText( "1x" ); normalSpeedButton->setToolTip( qtr( "Revert to normal play speed" ) ); CONNECT( normalSpeedButton, clicked(), this, resetRate() ); QToolButton *slowerButton = new QToolButton( this ); slowerButton->setMaximumSize( QSize( 26, 16 ) ); slowerButton->setAutoRaise( true ); slowerButton->setToolTip( tooltipL[SLOWER_BUTTON] ); slowerButton->setIcon( QIcon( iconL[SLOWER_BUTTON] ) ); CONNECT( slowerButton, clicked(), THEMIM->getIM(), slower() ); QToolButton *fasterButton = new QToolButton( this ); fasterButton->setMaximumSize( QSize( 26, 16 ) ); fasterButton->setAutoRaise( true ); fasterButton->setToolTip( tooltipL[FASTER_BUTTON] ); fasterButton->setIcon( QIcon( iconL[FASTER_BUTTON] ) ); CONNECT( fasterButton, clicked(), THEMIM->getIM(), faster() ); /* spinBox = new QDoubleSpinBox(); spinBox->setDecimals( 2 ); spinBox->setMaximum( 32 ); spinBox->setMinimum( 0.03F ); spinBox->setSingleStep( 0.10F ); spinBox->setAlignment( Qt::AlignRight ); CONNECT( spinBox, valueChanged( double ), this, updateSpinBoxRate( double ) ); */ QGridLayout* speedControlLayout = new QGridLayout( this ); speedControlLayout->addWidget( speedSlider, 0, 0, 1, 3 ); speedControlLayout->addWidget( slowerButton, 1, 0 ); speedControlLayout->addWidget( normalSpeedButton, 1, 1, 1, 1, Qt::AlignRight ); speedControlLayout->addWidget( fasterButton, 1, 2, 1, 1, Qt::AlignRight ); //speedControlLayout->addWidget( spinBox ); speedControlLayout->setContentsMargins( 0, 0, 0, 0 ); speedControlLayout->setSpacing( 0 ); lastValue = 0; activateOnState(); }
int singleplayer_process_input (struct state *st, struct ui *ui, char c) { int cursi = ui->cursor.i; int cursj = ui->cursor.j; switch (c) { case 'q': case 'Q': return 1; case 'f': st->prev_speed = st->speed; st->speed = faster(st->speed); break; case 's': st->prev_speed = st->speed; st->speed = slower(st->speed); break; case 'p': if (st->speed == sp_pause) st->speed = st->prev_speed; else { st->prev_speed = st->speed; st->speed = sp_pause; } break; case 'h': case K_LEFT: cursi--; break; case 'l': case K_RIGHT: cursi++; break; case 'k': case K_UP: cursj--; if (cursj % 2 == 1) cursi++; break; case 'j': case K_DOWN: cursj++; if (cursj % 2 == 0) cursi--; break; case ' ': if (st->fg[st->controlled].flag[ui->cursor.i][ui->cursor.j] == 0) add_flag (&st->grid, &st->fg[st->controlled], ui->cursor.i, ui->cursor.j, FLAG_POWER); else remove_flag (&st->grid, &st->fg[st->controlled], ui->cursor.i, ui->cursor.j, FLAG_POWER); break; case 'x': remove_flags_with_prob (&st->grid, &st->fg[st->controlled], 1.0); break; case 'c': remove_flags_with_prob (&st->grid, &st->fg[st->controlled], 0.5); break; case 'r': case 'v': build (&st->grid, &st->country[st->controlled], st->controlled, ui->cursor.i, ui->cursor.j); break; case ESCAPE: case 91: break; } adjust_cursor(st, ui, cursi, cursj); return 0; }