Beispiel #1
0
void KSystemTray::mousePressEvent(QMouseEvent *e)
{
    if(!rect().contains(e->pos()))
        return;

    switch(e->button())
    {
    case LeftButton:
        toggleActive();
        break;
    case MidButton:
    // fall through
    case RightButton:
        if(parentWidget())
        {
            KAction *action = d->actionCollection->action("minimizeRestore");
            if(parentWidget()->isVisible())
                action->setText(i18n("&Minimize"));
            else
                action->setText(i18n("&Restore"));
        }
        contextMenuAboutToShow(menu);
        menu->popup(e->globalPos());
        break;
    default:
        // nothing
        break;
    }
}
Beispiel #2
0
void SystemTray::mouseReleaseEvent(QMouseEvent *event)
{
	m_canDrag = false;
	if (event->button() == Qt::LeftButton)         // Show / hide main window
		if ( rect().contains(event->pos()) ) {     // Accept only if released in systemTray
			toggleActive();
			emit showPart();
			event->accept();
		} else
			event->ignore();
}
void
KMixDockWidget::mousePressEvent(QMouseEvent *me)
{
	if ( _dockAreaPopup == 0 ) {
		return KSystemTray::mousePressEvent(me);
	}

        // esken: Due to overwhelming request, LeftButton shows the ViewDockAreaPopup, if configured
        //        to do so. Otherwise the main window will be shown.
	if ( me->button() == LeftButton )
	{
		if ( ! _volumePopup ) {
                    // Case 1: User wants to show main window => This is the KSystemTray default action
		    return KSystemTray::mousePressEvent(me);
		}

                // Case 2: User wants to show volume popup
		if ( _dockAreaPopup->justHidden() )
			return;
                  
		if ( _dockAreaPopup->isVisible() )
		{
			_dockAreaPopup->hide();
			return;
		}

		int h = _dockAreaPopup->height();
		int x = this->mapToGlobal( QPoint( 0, 0 ) ).x() + this->width()/2 - _dockAreaPopup->width()/2;
		int y = this->mapToGlobal( QPoint( 0, 0 ) ).y() - h;
		if ( y < 0 )
			y = y + h + this->height();

		_dockAreaPopup->move(x, y);  // so that the mouse is outside of the widget

		// Now handle Multihead displays. And also make sure that the dialog is not
		// moved out-of-the screen on the right (see Bug 101742).
		QDesktopWidget* vdesktop = QApplication::desktop();
		const QRect& vScreenSize = vdesktop->screenGeometry(_dockAreaPopup);
		if ( (x+_dockAreaPopup->width()) > (vScreenSize.width() + vScreenSize.x()) ) {
			// move horizontally, so that it is completely visible
			_dockAreaPopup->move(vScreenSize.width() + vScreenSize.x() - _dockAreaPopup->width() -1 , y);
		} // horizontally out-of bound
		else if ( x < vScreenSize.x() ) {
			_dockAreaPopup->move(vScreenSize.x(), y);
		}
		// the above stuff could also be implemented vertically

		_dockAreaPopup->show();
		KWin::setState(_dockAreaPopup->winId(), NET::StaysOnTop | NET::SkipTaskbar | NET::SkipPager );

		QWidget::mousePressEvent(me); // KSystemTray's shouldn't do the default action for this
		return;
	} // LeftMouseButton pressed
	else if ( me->button() ==  MidButton ) {
		toggleActive();
		return;
	}
	else {
		KSystemTray::mousePressEvent(me);
	} // Other MouseButton pressed

}
Beispiel #4
0
void Lights::lightInput(SDL_Event incomingEvent, float delta_Time)
{	
	//Manages light input and differnet movement depending on keybinds. As well as toggling through the lights and toggle if active or not. 
	switch(incomingEvent.type)
	{
	case SDL_KEYDOWN:
		switch( incomingEvent.key.keysym.sym )
		{

		case SDLK_q:
			if(pointLights[activeLight].PLactive)
			{
				if(leftShiftPressed)
				{
					activeLightModelPos.z += 10.0f* delta_Time;
				}
			}
			break;
		case SDLK_e:
			if(pointLights[activeLight].PLactive)
			{
				if(leftShiftPressed)
				{
					activeLightModelPos.z -=10.0f* delta_Time;
				}
			}
			break;
		case SDLK_w:
			if(pointLights[activeLight].PLactive)
			{
				if(leftShiftPressed)
				{
					activeLightModelPos.y += 10.0f* delta_Time;
				}
			}
			break;
		case SDLK_a:
			if(pointLights[activeLight].PLactive)
			{
				if(leftShiftPressed)
				{
					activeLightModelPos.x -= 10.0f* delta_Time;
				}
			}
			break;
		case SDLK_s:
			if(pointLights[activeLight].PLactive)
			{
				if(leftShiftPressed)
				{
					activeLightModelPos.y -= 10.0f* delta_Time;
				}
			}
			break;
		case SDLK_d:
			if(pointLights[activeLight].PLactive)
			{
				if(leftShiftPressed)
				{
					activeLightModelPos.x += 10.0f* delta_Time;
				}
			}
			break;

		case SDLK_LSHIFT:
			leftShiftPressed = true;
			break;
		case SDLK_TAB:
			activeLight ++;
			if( activeLight >= pointLights.size() )
			{
				activeLight = 0;
			}
			activeLightModelPos = glm::vec3(pointLights[activeLight].PLposition.x, pointLights[activeLight].PLposition.y, pointLights[activeLight].PLposition.z);
			printf("\n The Current Active light is: %i ", activeLight);
			break;
		case SDLK_c:
			toggleActive();
			break;
		}
		break;
	case SDL_KEYUP:
		switch(incomingEvent.key.keysym.sym)
		{
		case SDLK_LSHIFT:
			leftShiftPressed = false;
			break;
		}
		break;
	}

}
void ReplacementSelection<obj>::sortPreMerge(std::istream& infile,std::ostream& outfile){
	vector<vector<obj> >sortedLists;
	vector<obj> currentList;
	obj newelement;
	obj lastElement;
	bool pendingFull=false;
	bool currentHeapEligible;
	bool endOfFile=false;
	///while replacement selection vector is not full, heapify a new element
	newelement = fill(infile);
	///while there is a new element
	while(!endOfFile){
		///Pop the root of the current heap, adding it to the current list.
		if(infile.eof()){
			endOfFile=true;
		}
		lastElement=pop();
		currentList.push_back(lastElement);
		if(ascending){
			if(newelement>=lastElement){
				currentHeapEligible=true;
			}
			else{
				currentHeapEligible=false;
			}
		}
		else {
			if(newelement<=lastElement){
				currentHeapEligible=true;
			}
			else{
				currentHeapEligible=false;
			}
		}
		///If the new element is greater than or equal to the last element popped, push it onto the current heap
		if(currentHeapEligible){
					current_heap_push(newelement);
				}
		///If the new element is less than (for a min-heap) to the last element popped,
		else {
			///push it onto the pending heap

			pending_heap_push(newelement);
			if(activeLeft){
				if(leftStart>leftEnd){
					pendingFull=true;
				}
				else{
				}
			}
			else {
				if(rightStart<rightEnd){
					pendingFull=true;
				}
				else {
				}
			}

			if(pendingFull){
				sortedLists.push_back(currentList);
				currentList.resize(0);
				toggleActive();
				pendingFull=false;
			}
		}

		infile>>newelement;
	}
	if(activeLeft){
		while(leftStart<=leftEnd){
			currentList.push_back(pop());
			leftEnd--;

		}
	}
	else {
		while(rightStart>=rightEnd){
			currentList.push_back(pop());
			rightEnd++;

		}
	}
	sortedLists.push_back(currentList);
	currentList.resize(0);
	toggleActive();
	if(activeLeft){
		while(leftStart<=leftEnd){
			currentList.push_back(pop());
			leftEnd--;

		}
	}
	else {
		while(rightStart>=rightEnd){
			currentList.push_back(pop());
			rightEnd++;

		}
	}
	sortedLists.push_back(currentList);
	for(int i=0; i<sortedLists.size(); i++){
		for(int j=0; j<sortedLists[i].size(); j++)
			outfile<<sortedLists[i][j]<<" ";
		outfile<<endl;
	}
	
}
Beispiel #6
0
//process key events
void ofxConsole::keyPressed(ofKeyEventArgs &e){

	int key = e.key;

	if(key==toggleKey) {
		toggleActive();
		return;
	}

	if(!bActive) return;
	switch(key){
		case OF_KEY_RIGHT : case OF_KEY_LEFT:
			break;

		case OF_KEY_BACKSPACE:
			passBackspace();
			break;

		case OF_KEY_RETURN:

			if( bSugestMode )
			{
				doSugest();
				clearSuggest();
			}else{
				passIntro();
			}
			break;

		case OF_KEY_UP:
			if( bSugestMode ){
				sugestGo(-1);
			}else{
				historyGo(-1);
			}
			break;

		case OF_KEY_DOWN:	
			if(bSugestMode){
				sugestGo(1);
			}else{
				historyGo(1);
			}
			break;

			// TAB
		case 9:
			if(bSugestMode){
				sugestGo(1);
			}else{
				bSugestMode = true;
				searchSugest(commandLine);
				sugestGo(0);
			}
			break;

		case OF_KEY_ESC:
			clearSuggest();
			commandLine.clear();
			break;

		case ' ':
			// using in ShortCytKey.cpp so do nothing
			if( ofKeyControl() ) 
				break;

			// else FOLLW THROUGH 

		default:
			passKey(key);
			if(bSugestMode) 
				clearSuggest();

			//passIntroPre();
			break;
	}
		
}