コード例 #1
0
void CHexViewView::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar) {
  m_shift = shiftKeyPressed();
  switch(nSBCode) {
  case SB_TOP           :
    setTopLine(0, false).setCaretY(0);
    break;
  case SB_BOTTOM        :
    setTopLine(m_maxTopLine, false).setCaretY(m_maxCaret.y);
    break;
  case SB_ENDSCROLL     :                    break;
  case SB_LINEUP        : scrollVert(-1);    break;
  case SB_LINEDOWN      : scrollVert( 1);    break;
  case SB_PAGEUP        : pageUp(m_shift);   break;
  case SB_PAGEDOWN      : pageDown(m_shift); break;
  case SB_THUMBPOSITION :                    break;
  case SB_THUMBTRACK    :
    { // Dont use parameter nPos as it is only 16-bits int
      SCROLLINFO scrollInfo;
      GetScrollInfo(SB_VERT,&scrollInfo);
      if(scrollInfo.nTrackPos >= 0 && scrollInfo.nTrackPos <= m_maxTopLine) {
        setTopLine(scrollInfo.nTrackPos);
      }
    }
    break;
  }
}
コード例 #2
0
/****************************************************************************
Name:	defaultKeyAction
Desc:
*****************************************************************************/
void F_DynamicList::defaultKeyAction(
	FLMUINT uiKey)
{
	switch( uiKey)
	{
		case FKB_UP:
			cursorUp();
			break;
		case FKB_DOWN:
			cursorDown();
			break;
		case FKB_PGUP:
			pageUp();
			break;
		case FKB_PGDN:
			pageDown();
			break;
		case FKB_HOME:
			home();
			break;
		case FKB_END:
			end();
			break;
		case 'd':
		case 'D':
		{
			RCODE rc = NE_FLM_OK;
			rc = this->dumpToFile();
			break;
		}
	}
	refresh();
}
コード例 #3
0
void VScrollBar::logic()
{
    upButton->logic();
    downButton->logic();
    
    int event;
    while ( (event = myEvents.nextEvent()) ) switch ( event )
    {
        case Events::GoUp:   stepUp(); break;
        case Events::GoDown: stepDown(); break;
    }
    
    myEvents.reset();
    
    if ( repeat_scroll && repeat_timer.isTimeOut() )
    {
        if ( repeat_scroll > 0 )
        {
            pageDown();
        }
        else
        {
            pageUp();
        }

        repeat_timer.setTimeOut(repeat_other);
        repeat_timer.reset();

        if ( (value == 0) || (value == virtualTotalHeight) )
        {
            repeat_scroll = 0;
        }
    }

}
コード例 #4
0
void VScrollBar::onSelectStart()
{
    if ( hoveringComponent )
    {
        hoveringComponent->onSelectStart();
        selectingComponent = hoveringComponent;
    }
    else
    {
        const int my = GameInput::InputManager::getMouseY();
        if ( ! overScrollable )
        {
            if ( my < movableBar.getLocationY() )
            {
                pageUp();
                repeat_scroll = -1;
                repeat_timer.setTimeOut(repeat_initial);
                repeat_timer.reset();
            }
            else if ( my >= movableBar.getEndY() )
            {
                pageDown();
                repeat_scroll = 1;
                repeat_timer.setTimeOut(repeat_initial);
                repeat_timer.reset();
            }
        }
        else
        {
            mouseScrolling = true;
            movableClickPos = movableBar.getLocationY() - my;
        }
    }
}
コード例 #5
0
ファイル: codeFrame.cpp プロジェクト: robpot/SnowPlusPlus
// used for pressing the arrow to change pages 
void codeFrame::mousePressEvent(QMouseEvent *e){
   int ypos = e->pos().y();
   if(e->button() == Qt::LeftButton){
      if(ypos < topA->height()+8){
	 pageUp();	 
      }
      if(ypos > (height() - botA->height() -8)){
	 pageDown();
      }
   }
}
コード例 #6
0
ファイル: choiceview.cpp プロジェクト: clee/runcible
void ChoiceView::keyPressEvent(QKeyEvent *event) {
    if (event->key() >= Qt::Key_0 && event->key() <= Qt::Key_9) {
        int chosen = event->key() - Qt::Key_0 + _offset - 1;
        if (chosen < _offset) chosen += 10;
        if (chosen < _choices.size()) {
            choose(chosen);
            return;
        }
    } else if (event->key() == Qt::Key_Down) {
        pageDown();
        return;
    } else if (event->key() == Qt::Key_Up) {
        pageUp();
        return;
    }
    QWidget::keyPressEvent(event);
}
コード例 #7
0
ファイル: list_widget.cpp プロジェクト: HeryLong/booxsdk
void OnyxListWidget::keyReleaseEvent(QKeyEvent * event)
{
    int key = event->key();
    if (key == Qt::Key_PageDown)
    {
        if (pageDown())
            update();
    }
    else if (key == Qt::Key_PageUp)
    {
        if (pageUp())
            update();
    }
    else if (key == Qt::Key_Enter)
    {
        activate(); // Activate current selected.
    }
}
コード例 #8
0
ファイル: tree_view.cpp プロジェクト: yoshi314/boox-explorer
void ObxTreeView::onItemReleased(ObxTreeViewItem *item, const QPoint &point)
{
    int direction = sys::SystemConfig::direction(pressed_point_, point);

    if (direction == 0)
    {
        onItemClicked(item);
        return;
    }

    if (direction > 0)
    {
        pageDown();
    }
    else if (direction < 0)
    {
        pageUp();
    }
}
コード例 #9
0
GtkProxyStyle::GtkProxyStyle(ScrollbarType sb)
    : QProxyStyle()
    #ifdef ENABLE_OVERLAYSCROLLBARS
    , sbarThumb(0)
    , sbarWidth(-1)
    , sbarAreaWidth(-1)
    , sbarOffset(0xffffffff)
    , sbarLastPos(-1)
    , sbarThumbTarget(0)
    #endif
{
    shortcutHander=new ShortcutHandler(this);

    sbarType=sb;

    if (SB_Standard!=sbarType) {
        QByteArray env=qgetenv("LIBOVERLAY_SCROLLBAR");
        if (!env.isEmpty() && env!="1") {
            sbarType=SB_Standard;
        }
    }

    setBaseStyle(qApp->style());
    toolbarCombo=new QComboBox(new QToolBar());
    if (SB_Standard!=sbarType) {
        int fh=QApplication::fontMetrics().height();
        sbarPlainViewWidth=fh/1.75;

        #ifdef ENABLE_OVERLAYSCROLLBARS
        if (SB_Overlay==sbarType && Qt::LeftToRight==QApplication::layoutDirection()) { //  && revertQGtkStyleOverlayMod()) {
            sbarWidth=qMax(fh/5, 3);
            sbarAreaWidth=sbarWidth*6;
            sbarThumb=new OsThumb();
            sbarThumb->setVisible(false);
            connect(sbarThumb, SIGNAL(thumbDragged(QPoint)), SLOT(sbarThumbMoved(QPoint)));
            connect(sbarThumb, SIGNAL(pageUp()), SLOT(sbarPageUp()));
            connect(sbarThumb, SIGNAL(pageDown()), SLOT(sbarPageDown()));
            connect(sbarThumb, SIGNAL(hiding()), SLOT(sbarThumbHiding()));
            connect(sbarThumb, SIGNAL(showing()),SLOT(sbarThumbShowing()));
        }
        #endif
    }
}
コード例 #10
0
BOOL LLScrollbar::handleMouseDown(S32 x, S32 y, MASK mask)
{
	// Check children first
	BOOL handled_by_child = LLView::childrenHandleMouseDown(x, y, mask) != NULL;
	if( !handled_by_child )
	{
		if( mThumbRect.pointInRect(x,y) )
		{
			// Start dragging the thumb
			// No handler needed for focus lost since this clas has no state that depends on it.
			gFocusMgr.setMouseCapture( this );  
			mDragStartX = x;
			mDragStartY = y;
			mOrigRect.mTop = mThumbRect.mTop;
			mOrigRect.mBottom = mThumbRect.mBottom;
			mOrigRect.mLeft = mThumbRect.mLeft;
			mOrigRect.mRight = mThumbRect.mRight;
			mLastDelta = 0;
		}
		else
		{
			if( 
				( (LLScrollbar::VERTICAL == mOrientation) && (mThumbRect.mTop < y) ) ||
				( (LLScrollbar::HORIZONTAL == mOrientation) && (x < mThumbRect.mLeft) )
			)
			{
				// Page up
				pageUp(0);
			}
			else
			if(
				( (LLScrollbar::VERTICAL == mOrientation) && (y < mThumbRect.mBottom) ) ||
				( (LLScrollbar::HORIZONTAL == mOrientation) && (mThumbRect.mRight < x) )
			)
			{
				// Page down
				pageDown(0);
			}
		}
	}

	return TRUE;
}
コード例 #11
0
ファイル: scrollscale.cpp プロジェクト: faesong/oom
void ScrollScale::setPageButtons(bool flag)
{
	if (flag == pageButtons)
		return;

	if (flag)
	{
		if (up == 0)
		{
			up = new QToolButton;
			up->setIcon(QIcon(*upIcon));
			down = new QToolButton;
			down->setIcon(QIcon(*downIcon));
			pageNo = new QLabel;
			QString s;
			s.setNum(_page + 1);
			pageNo->setText(s);
			down->setToolTip(tr("next page"));
			up->setToolTip(tr("previous page"));
			pageNo->setToolTip(tr("current page number"));
			box->insertWidget(1, up);
			box->insertWidget(2, down);
			box->insertSpacing(3, 5);
			box->insertWidget(4, pageNo);
			box->insertSpacing(5, 5);
			connect(up, SIGNAL(clicked()), SLOT(pageUp()));
			connect(down, SIGNAL(clicked()), SLOT(pageDown()));
		}
		up->show();
		down->show();
		pageNo->show();
		if (_page == (_pages - 1))
			down->setEnabled(false);
		if (_page == 0)
			up->setEnabled(false);
	}
	else
	{
		up->hide();
		down->hide();
	}
	pageButtons = flag;
}
コード例 #12
0
void DuokanTreeView::onItemReleased(DuokanTreeViewItem *item, const QPoint &point)
{
    int direction = PageTurningConfig::direction(pressed_point_, point);

    if (direction == 0)
    {
        onItemClicked(item);
        return;
    }

    if (direction > 0)
    {
        pageDown();
    }
    else if (direction < 0)
    {
        pageUp();
    }
}
コード例 #13
0
ファイル: tree_view.cpp プロジェクト: yoshi314/boox-explorer
void ObxTreeView::keyReleaseEvent(QKeyEvent * event)
{
    int key = event->key();
    switch (key)
    {
    case Qt::Key_PageDown:
        {
            event->accept();
            pageDown();
            return;
        }
    case Qt::Key_PageUp:
        {
            event->accept();
            pageUp();
            return;
        }
    case Qt::Key_Up:
        {
            event->accept();
            navigate(-1);
            return;
        }
    case Qt::Key_Down:
        {
            event->accept();
            navigate(1);
            return;
        }
    case Qt::Key_Enter:
    case Qt::Key_Return:
        {
            event->accept();
            activate();
            return;
        }
    default:
        break;
    }
    event->ignore();
}
コード例 #14
0
ファイル: llscrollbar.cpp プロジェクト: kentron/imprudence
BOOL LLScrollbar::handleKeyHere(KEY key, MASK mask)
{
    BOOL handled = FALSE;

    switch( key )
    {
    case KEY_HOME:
        setDocPos( 0 );
        handled = TRUE;
        break;

    case KEY_END:
        setDocPos( getDocPosMax() );
        handled = TRUE;
        break;

    case KEY_DOWN:
        setDocPos( getDocPos() + mStepSize );
        handled = TRUE;
        break;

    case KEY_UP:
        setDocPos( getDocPos() - mStepSize );
        handled = TRUE;
        break;

    case KEY_PAGE_DOWN:
        pageDown(1);
        break;

    case KEY_PAGE_UP:
        pageUp(1);
        break;
    }

    return handled;
}
コード例 #15
0
//==============================================================================
bool CodeEditorComponent::keyPressed (const KeyPress& key)
{
    const bool moveInWholeWordSteps = key.getModifiers().isCtrlDown() || key.getModifiers().isAltDown();
    const bool shiftDown = key.getModifiers().isShiftDown();

    if (key.isKeyCode (KeyPress::leftKey))
    {
        cursorLeft (moveInWholeWordSteps, shiftDown);
    }
    else if (key.isKeyCode (KeyPress::rightKey))
    {
        cursorRight (moveInWholeWordSteps, shiftDown);
    }
    else if (key.isKeyCode (KeyPress::upKey))
    {
        if (key.getModifiers().isCtrlDown() && ! shiftDown)
            scrollDown();
#if JUCE_MAC
        else if (key.getModifiers().isCommandDown())
            goToStartOfDocument (shiftDown);
#endif
        else
            cursorUp (shiftDown);
    }
    else if (key.isKeyCode (KeyPress::downKey))
    {
        if (key.getModifiers().isCtrlDown() && ! shiftDown)
            scrollUp();
#if JUCE_MAC
        else if (key.getModifiers().isCommandDown())
            goToEndOfDocument (shiftDown);
#endif
        else
            cursorDown (shiftDown);
    }
    else if (key.isKeyCode (KeyPress::pageDownKey))
    {
        pageDown (shiftDown);
    }
    else if (key.isKeyCode (KeyPress::pageUpKey))
    {
        pageUp (shiftDown);
    }
    else if (key.isKeyCode (KeyPress::homeKey))
    {
        if (moveInWholeWordSteps)
            goToStartOfDocument (shiftDown);
        else
            goToStartOfLine (shiftDown);
    }
    else if (key.isKeyCode (KeyPress::endKey))
    {
        if (moveInWholeWordSteps)
            goToEndOfDocument (shiftDown);
        else
            goToEndOfLine (shiftDown);
    }
    else if (key.isKeyCode (KeyPress::backspaceKey))
    {
        backspace (moveInWholeWordSteps);
    }
    else if (key.isKeyCode (KeyPress::deleteKey))
    {
        deleteForward (moveInWholeWordSteps);
    }
    else if (key == KeyPress (T('c'), ModifierKeys::commandModifier, 0))
    {
        copy();
    }
    else if (key == KeyPress (T('x'), ModifierKeys::commandModifier, 0))
    {
        copyThenCut();
    }
    else if (key == KeyPress (T('v'), ModifierKeys::commandModifier, 0))
    {
        paste();
    }
    else if (key == KeyPress (T('z'), ModifierKeys::commandModifier, 0))
    {
        undo();
    }
    else if (key == KeyPress (T('y'), ModifierKeys::commandModifier, 0)
              || key == KeyPress (T('z'), ModifierKeys::commandModifier | ModifierKeys::shiftModifier, 0))
    {
        redo();
    }
    else if (key == KeyPress (T('a'), ModifierKeys::commandModifier, 0))
    {
        selectAll();
    }
    else if (key == KeyPress::tabKey || key.getTextCharacter() == '\t')
    {
        insertTabAtCaret();
    }
    else if (key == KeyPress::returnKey)
    {
        newTransaction();
        insertTextAtCaret (document.getNewLineCharacters());
    }
    else if (key.isKeyCode (KeyPress::escapeKey))
    {
        newTransaction();
    }
    else if (key.getTextCharacter() >= ' ')
    {
        insertTextAtCaret (String::charToString (key.getTextCharacter()));
    }
    else
    {
        return false;
    }

    return true;
}
コード例 #16
0
ファイル: qibusengine.cpp プロジェクト: ascetic85/ibus-qt
void
Engine::PageDown()
{
    pageDown();
}
コード例 #17
0
void CMainFrame::OnActivatePartner() {
  TextView *view = getActiveTextView();
  if(view) {
    view->activatePartner();
  }
}

#define APPLY_TO_ACTIVE_TEXTVIEW(f)  { TextView *view = getActiveTextView(); if(view) { view->f; } }

void CMainFrame::OnCharLeft()      { APPLY_TO_ACTIVE_TEXTVIEW(charLeft()     ) }
void CMainFrame::OnCharRight()     { APPLY_TO_ACTIVE_TEXTVIEW(charRight()    ) }
void CMainFrame::OnCtrlCharLeft()  { APPLY_TO_ACTIVE_TEXTVIEW(ctrlCharLeft() ) }
void CMainFrame::OnCtrlCharRight() { APPLY_TO_ACTIVE_TEXTVIEW(ctrlCharRight()) }
void CMainFrame::OnLineDown()      { APPLY_TO_ACTIVE_TEXTVIEW(lineDown()     ) }
void CMainFrame::OnLineUp()        { APPLY_TO_ACTIVE_TEXTVIEW(lineUp()       ) }
void CMainFrame::OnPageDown()      { APPLY_TO_ACTIVE_TEXTVIEW(pageDown()     ) }
void CMainFrame::OnPageUp()        { APPLY_TO_ACTIVE_TEXTVIEW(pageUp()       ) }
void CMainFrame::OnHome()          { APPLY_TO_ACTIVE_TEXTVIEW(home()         ) }
void CMainFrame::OnEnd()           { APPLY_TO_ACTIVE_TEXTVIEW(end()          ) }
void CMainFrame::OnCtrlHome()      { APPLY_TO_ACTIVE_TEXTVIEW(ctrlHome()     ) }
void CMainFrame::OnCtrlEnd()       { APPLY_TO_ACTIVE_TEXTVIEW(ctrlEnd()      ) }

void CMainFrame::refreshDoc(bool recomp) {
  TextView *view = getActiveTextView();
  if(view == NULL) {
    return;
  }

  CWinDiffDoc *doc = view->getDocument();
  if(recomp) {
    doc->recompare();
コード例 #18
0
ファイル: ocompletionbox.cpp プロジェクト: opieproject/opie
bool OCompletionBox::eventFilter( QObject *o, QEvent *e )
{
    int type = e->type();

    if ( o == d->m_parent ) {
        if ( isVisible() ) {
            if ( type == QEvent::KeyPress ) {
                QKeyEvent *ev = static_cast<QKeyEvent *>( e );
                switch ( ev->key() ) {
                    case Key_BackTab:
                        if ( d->tabHandling ) {
                            up();
                            ev->accept();
                            return true;
                        }
                        break;
                    case Key_Tab:
                        if ( d->tabHandling ) {
                            down(); // Only on TAB!!
                            ev->accept();
                            return true;
                        }
                        break;
                    case Key_Down:
                        down();
                        ev->accept();
                        return true;
                    case Key_Up:
                        up();
                        ev->accept();
                        return true;
                    case Key_Prior:
                        pageUp();
                        ev->accept();
                        return true;
                    case Key_Next:
                        pageDown();
                        ev->accept();
                        return true;
                    case Key_Escape:
                        cancelled();
                        ev->accept();
                        return true;
                    case Key_Enter:
                    case Key_Return:
                        if ( ev->state() & ShiftButton ) {
                            hide();
                            ev->accept();  // Consume the Enter event
                            return true;
                        }
                        break;
                    default:
                        break;
                }
            }
            else if ( type == QEvent::AccelOverride ) {
                // Override any acceleartors that match
                // the key sequences we use here...
                QKeyEvent *ev = static_cast<QKeyEvent *>( e );
                switch ( ev->key() ) {
                    case Key_Tab:
                    case Key_BackTab:
                    case Key_Down:
                    case Key_Up:
                    case Key_Prior:
                    case Key_Next:
                    case Key_Escape:
                    case Key_Enter:
                    case Key_Return:
                      ev->accept();
                      return true;
                      break;
                    default:
                        break;
                }
            }

            // parent loses focus or gets a click -> we hide
            else if ( type == QEvent::FocusOut || type == QEvent::Resize ||
                      type == QEvent::Close || type == QEvent::Hide ||
                      type == QEvent::Move ) {
                hide();
            }
            else if ( type == QEvent::Move )
                move( d->m_parent->mapToGlobal(QPoint(0, d->m_parent->height())));
            else if ( type == QEvent::Resize )
                resize( sizeHint() );
        }
    }

    // any mouse-click on something else than "this" makes us hide
    else if ( type == QEvent::MouseButtonPress ) {
        QMouseEvent *ev = static_cast<QMouseEvent *>( e );
        if ( !rect().contains( ev->pos() )) // this widget
            hide();
    }

    return OListBox::eventFilter( o, e );
}
コード例 #19
0
ファイル: Rword.CPP プロジェクト: galexcode/RwordXp
void iSpecialKeyboard(unsigned char key)
{
	selflag = 0;
	//retrieve charactre index in terms of cursor position
	j = x/ charSpace;
	i = ((height-15-lineSpace - y)/lineSpace) + s;

	if (glutGetModifiers() == GLUT_ACTIVE_ALT && key == GLUT_KEY_F4 )
	{
		FILE *fp;
		char tempfile[80];
		strcpy(tempfile, syspath);
		strcat(tempfile, ":\\Program Files\\Rword\\settings.dat");
		fp = fopen(tempfile, "wb");
		fwrite(&flebel, sizeof(int), 1, fp);
		fclose(fp);

		free(str);
		exit(0);			//exit action
	}
	else if(key == GLUT_KEY_LEFT)			//aroow keys
	{
		upArrow=0;
		downArrow=0;
		leftarrow();
	}
	else if(key == GLUT_KEY_RIGHT)
	{
		upArrow=0;
		downArrow=0;
		rightarrow();
	}

	else if(key == GLUT_KEY_UP)
	{
		uparrow();
	}

	else if (key == GLUT_KEY_DOWN)
	{
		downarrow();
	}
	else if (key == GLUT_KEY_F1)			//help option
	{
		char tempfile[80];
		strcpy(tempfile, syspath);
		strcat(tempfile, ":\\Program Files\\Rword\\Rhelp.chm");
		ShellExecute(NULL,"open", tempfile, NULL,NULL, SW_SHOW);
		menuflag =0;
	}
	else if (key == GLUT_KEY_F3)			//selection shortcut
	{
		selectText();
	}
	
	else if (key == GLUT_KEY_PAGE_UP)		//page keys
	{
		pageUp();
	}

	else if (key == GLUT_KEY_PAGE_DOWN)
	{
		pageDown();
	}

	else if (key == GLUT_KEY_HOME)
	{
			j = 0;
			x = 0;
	}

	else if (key == GLUT_KEY_END)
	{
		j = strlen(str+i*charMax*sizeof(char));
		x = j*charSpace;
	}

	else if (key == GLUT_KEY_INSERT)
	{
		insert = (insert)?0:1;
	}
}
コード例 #20
0
ファイル: shortcuts.cpp プロジェクト: AlFoX/qt-client
void shortcuts::setStandardKeys(QWidget* widget)
{
  if (!widget)
    return;

  // Add standard shortcuts to applicable buttons
  bool hasShortcut = false;
  QPushButton* button;

  // For Save
  button = widget->findChild<QPushButton*>("_save");
  if (button)
  {
    button->setShortcut(QKeySequence::Save);
    button->setToolTip(button->text().remove("&")  + " " +
                       button->shortcut().toString(QKeySequence::NativeText));
    hasShortcut = true;
  }
  if (!hasShortcut) // Because some screens have both
  {
    // For Post
    button = widget->findChild<QPushButton*>("_post");
    if (button)
    {
      button->setShortcut(QKeySequence::Save);
      button->setToolTip(button->text().remove("&")  + " " +
                         button->shortcut().toString(QKeySequence::NativeText));
    }
  }
  if (!hasShortcut)
  {
    QDialogButtonBox* bb = widget->findChild<QDialogButtonBox*>();
    if (bb)
    {
      QList<QAbstractButton*> buttons =  bb->buttons();
      for (int i = 0; i < buttons.size(); ++i)
      {
        QAbstractButton *bbutton = buttons.at(i);
        QDialogButtonBox::ButtonRole btnrole = bb->buttonRole(buttons.at(i));
        if (btnrole == QDialogButtonBox::AcceptRole)
        {
          bbutton->setShortcut(QKeySequence::Save);
          bbutton->setToolTip(bbutton->text().remove("&")  + " " +
                              bbutton->shortcut().toString(QKeySequence::NativeText));

        }
        else if (btnrole == QDialogButtonBox::RejectRole)
        {
          bbutton->setShortcut(QKeySequence::Close);
          bbutton->setToolTip(bbutton->text().remove("&")  + " " +
                              bbutton->shortcut().toString(QKeySequence::NativeText));

        }
      }
    }
  }

  // For Close
  hasShortcut = false;
  button = widget->findChild<QPushButton*>("_close");
  if (button)
  {
    button->setShortcut(QKeySequence::Close);
    button->setToolTip(button->text().remove("&")  + " " +
                       button->shortcut().toString(QKeySequence::NativeText));
    hasShortcut = true;
  }
  if (!hasShortcut) // Because some screens have both
  {
    // For Post
    button = widget->findChild<QPushButton*>("_cancel");
    if (button)
    {
      button->setShortcut(QKeySequence::Close);
      button->setToolTip(button->text().remove("&")  + " " +
                         button->shortcut().toString(QKeySequence::NativeText));
    }
  }

  // For New
  button = widget->findChild<QPushButton*>("_new");
  if (button)
  {
    button->setShortcut(QKeySequence::New);
    button->setToolTip(button->text().remove("&")  + " " +
                       button->shortcut().toString(QKeySequence::NativeText));
    hasShortcut = true;
  }

  // For Print
  button = widget->findChild<QPushButton*>("_print");
  if (button)
  {
    button->setShortcut(QKeySequence::Print);
    button->setToolTip(button->text().remove("&")  + " " +
                       button->shortcut().toString(QKeySequence::NativeText));
    hasShortcut = true;
  }

  // For Query
  button = widget->findChild<QPushButton*>("_query");
  if (button)
  {
    button->setShortcut(QKeySequence::Refresh);
    button->setToolTip(button->text().remove("&")  + " " +
                       button->shortcut().toString(QKeySequence::NativeText));
    hasShortcut = true;
  }

  // Page up/down for tab widgets
  QTabWidget* tab = widget->findChild<QTabWidget*>();
  if (tab)
  {
    TabWidgetNavigtor* tabNav = new TabWidgetNavigtor(tab, widget);
    QAction* pagedownAct = new QAction(tab);
    pagedownAct->setShortcut(QKeySequence::MoveToNextPage);
    pagedownAct->connect(pagedownAct, SIGNAL(triggered()), tabNav, SLOT(pageDown()));
    tab->addAction(pagedownAct);

    QAction* pageupAct = new QAction(tab);
    pageupAct->setShortcut(QKeySequence::MoveToPreviousPage);
    pageupAct->connect(pageupAct, SIGNAL(triggered()), tabNav, SLOT(pageUp()));
    tab->addAction(pageupAct);
  }
}
コード例 #21
0
ファイル: kcompletionbox.cpp プロジェクト: vasi/kdelibs
bool KCompletionBox::eventFilter( QObject *o, QEvent *e )
{
    int type = e->type();
    QWidget *wid = qobject_cast<QWidget*>(o);

    if (o == this) {
        return false;
    }

    if (wid && wid == d->m_parent &&
        (type == QEvent::Move || type == QEvent::Resize)) {
        hide();
        return false;
    }

    if (wid && (wid->windowFlags() & Qt::Window) &&
        type == QEvent::Move && wid == d->m_parent->window()) {
        hide();
        return false;
    }

    if (type == QEvent::MouseButtonPress && (wid && !isAncestorOf(wid))) {
        if (!d->emitSelected && currentItem() && !qobject_cast<QScrollBar*>(o)) {
            Q_ASSERT(currentItem());
            emit currentTextChanged(currentItem()->text() );
        }
        hide();
        e->accept();
        return true;
    }

    if (wid && wid->isAncestorOf(d->m_parent) && isVisible()) {
        if ( type == QEvent::KeyPress ) {
            QKeyEvent *ev = static_cast<QKeyEvent *>( e );
            switch ( ev->key() ) {
            case Qt::Key_Backtab:
                if ( d->tabHandling && (ev->modifiers() == Qt::NoButton ||
                                        (ev->modifiers() & Qt::ShiftModifier)) ) {
                    up();
                    ev->accept();
                    return true;
                }
                break;
            case Qt::Key_Tab:
                if ( d->tabHandling && (ev->modifiers() == Qt::NoButton) ) {
                    down();
                    // #65877: Key_Tab should complete using the first
                    // (or selected) item, and then offer completions again
                    if (count() == 1) {
                        KLineEdit* parent = qobject_cast<KLineEdit*>(d->m_parent);
                        if (parent) {
                            parent->doCompletion(currentItem()->text());
                        } else {
                            hide();
                        }
                    }
                    ev->accept();
                    return true;
                }
                break;
            case Qt::Key_Down:
                down();
                ev->accept();
                return true;
            case Qt::Key_Up:
                // If there is no selected item and we've popped up above
                // our parent, select the first item when they press up.
                if ( !selectedItems().isEmpty() ||
                     mapToGlobal( QPoint( 0, 0 ) ).y() >
                     d->m_parent->mapToGlobal( QPoint( 0, 0 ) ).y() )
                    up();
                else
                    down();
                ev->accept();
                return true;
            case Qt::Key_PageUp:
                pageUp();
                ev->accept();
                return true;
            case Qt::Key_PageDown:
                pageDown();
                ev->accept();
                return true;
            case Qt::Key_Escape:
                canceled();
                ev->accept();
                return true;
            case Qt::Key_Enter:
            case Qt::Key_Return:
                if ( ev->modifiers() & Qt::ShiftModifier ) {
                    hide();
                    ev->accept();  // Consume the Enter event
                    return true;
                }
                break;
            case Qt::Key_End:
                if ( ev->modifiers() & Qt::ControlModifier )
                {
                    end();
                    ev->accept();
                    return true;
                }
                break;
            case Qt::Key_Home:
                if ( ev->modifiers() & Qt::ControlModifier )
                {
                    home();
                    ev->accept();
                    return true;
                }
            default:
                break;
            }
        } else if ( type == QEvent::ShortcutOverride ) {
            // Override any accelerators that match
            // the key sequences we use here...
            QKeyEvent *ev = static_cast<QKeyEvent *>( e );
            switch ( ev->key() ) {
            case Qt::Key_Down:
            case Qt::Key_Up:
            case Qt::Key_PageUp:
            case Qt::Key_PageDown:
            case Qt::Key_Escape:
            case Qt::Key_Enter:
            case Qt::Key_Return:
                ev->accept();
                return true;
                break;
            case Qt::Key_Tab:
            case Qt::Key_Backtab:
                if ( ev->modifiers() == Qt::NoButton ||
                     (ev->modifiers() & Qt::ShiftModifier))
                {
                    ev->accept();
                    return true;
                }
                break;
            case Qt::Key_Home:
            case Qt::Key_End:
                if ( ev->modifiers() & Qt::ControlModifier )
                {
                    ev->accept();
                    return true;
                }
                break;
            default:
                break;
            }
        } else if ( type == QEvent::FocusOut ) {
            QFocusEvent* event = static_cast<QFocusEvent*>( e );
            if (event->reason() != Qt::PopupFocusReason
#ifdef Q_WS_WIN
                && (event->reason() != Qt::ActiveWindowFocusReason || QApplication::activeWindow() != this)
#endif
                )
                hide();
        }
    }

    return KListWidget::eventFilter( o, e );
}
コード例 #22
0
ファイル: cuculusview.cpp プロジェクト: cornelius/cuculus
CuculusView::CuculusView(QWidget *)
  : m_currentTweetIndex( 0 )
{
  setObjectName( "view" );

  m_model = new CuculusModel;

  QBoxLayout *mainLayout = new QHBoxLayout( this );
  
  QBoxLayout *topLayout = new QVBoxLayout;
  mainLayout->addLayout( topLayout );

  m_timeLabel = new QLabel;
  topLayout->addWidget( m_timeLabel );
  m_timeLabel->setAlignment( Qt::AlignCenter );

  connect( &m_timeLabelTimer, SIGNAL( timeout() ), SLOT( updateTimeLabel() ) );
  m_timeLabelTimer.start( 60 * 1000 );

  QBoxLayout *countLayout = new QHBoxLayout;
  topLayout->addLayout( countLayout );

  QLabel *label = new QLabel( i18n("What are you doing?") );
  countLayout->addWidget( label );

  countLayout->addStretch( 1 );

  m_countLabel = new QLabel;
  countLayout->addWidget( m_countLabel );


  m_tweetEdit = new QTextEdit;
  m_tweetEdit->setFixedHeight( 60 );
  topLayout->addWidget( m_tweetEdit );
  connect( m_tweetEdit, SIGNAL( textChanged() ), SLOT( updateEditCount() ) );
  connect( m_tweetEdit, SIGNAL( textChanged() ), SLOT( checkUpdateButton() ) );

  m_updateButton = new QPushButton( "Update" );
  topLayout->addWidget( m_updateButton );
  connect( m_updateButton, SIGNAL( clicked() ), SLOT( sendTweet() ) );


  QBoxLayout *updateLayout = new QHBoxLayout;
  topLayout->addLayout( updateLayout );
  
  updateLayout->addStretch( 1 );

  QPushButton *button = new QPushButton( "Get latest tweets" );
  updateLayout->addWidget( button );
  connect( button, SIGNAL( clicked() ), SLOT( updateTimeline() ) );


  m_upButton = new QPushButton;
  connect( m_upButton, SIGNAL( clicked() ), SLOT( pageUp() ) );
  QString picPath = KStandardDirs::locate( "appdata", "1uparrow.png" );
  m_upButton->setIcon( QPixmap( picPath ) );
  topLayout->addWidget( m_upButton );

  m_tweetsView = new TweetListView;
  topLayout->addWidget( m_tweetsView, 1 );
  m_tweetsView->setStyleSheet("background-color: white");

  m_downButton = new QPushButton;
  connect( m_downButton, SIGNAL( clicked() ), SLOT( pageDown() ) );
  picPath = KStandardDirs::locate( "appdata", "1downarrow.png" );
  m_downButton->setIcon( QPixmap( picPath ) );
  topLayout->addWidget( m_downButton );


  FriendsView *friendsView = new FriendsView;
  mainLayout->addWidget( friendsView );

  
  updateEditCount();
  checkUpdateButton();
  updateTimeLabel();
  updatePageButtons();
  
  settingsChanged();
  setAutoFillBackground(true);

  updateTimeline();
}