예제 #1
0
SmoothToolTip::SmoothToolTip(Applet *applet)
	: DelayedToolTip(applet),
	  m_widget(new ToolTipWidget(this)),
	  m_previews(),
	  m_previewsAvailable(false),
	  m_background(new Plasma::FrameSvg(this)),
	  m_hover(false),
	  m_menuShown(false),
	  m_previewsUpdated(false),
	  m_hoverPreview(NULL),
	  m_highlightDelay(new QTimer(this)),
	  m_highlighting(false),
	  m_scrollAnimation(0),
	  m_dx(0),
	  m_xStart(0),
	  m_dy(0),
	  m_yStart(0),
	  m_moveAnimation(false),
	  m_moveAnimationUpdated(false),
	  m_position(0),
	  m_size(0, 0),
	  m_closeIcon(),
	  m_hoverCloseIcon() {
	
	connect(
		Plasma::Animator::self(), SIGNAL(customAnimationFinished(int)),
		this, SLOT(animationFinished(int)));

	connect(
		applet, SIGNAL(mouseEnter()),
		this, SLOT(stopEffect()));

	previewLayoutChanged(m_applet->previewLayout());

	m_background->setImagePath("widgets/tooltip");
	m_background->setEnabledBorders(Plasma::FrameSvg::AllBorders);

	updateTheme();

	m_highlightDelay->setInterval(m_applet->highlightDelay());
	m_highlightDelay->setSingleShot(true);
	
	connect(m_highlightDelay, SIGNAL(timeout()), this, SLOT(highlightDelayTimeout()));
	connect(m_background, SIGNAL(repaintNeeded()), this, SLOT(updateTheme()));
	connect(
		m_applet, SIGNAL(previewLayoutChanged(Applet::PreviewLayoutType)),
		this, SLOT(previewLayoutChanged(Applet::PreviewLayoutType)));
}
예제 #2
0
//--------------------------------------------------------------
// handle mouse movement in screen coordinates
void mgScriptPlatform::mouseMoveRel(
  int dx, 
  int dy,
  int flags)
{
  // relative moves should only happen with mouse captured,
  // and there should be no mouseExit.  But just in case...
  if (!m_mouseInside)
    mouseEnter(m_lastCursorX, m_lastCursorY);

  if (m_theApp != NULL)
  {
    if ((flags & MG_EVENT_MOUSE_BUTTONS) != 0)
      m_theApp->appMouseDrag(dx, dy, flags);
    else m_theApp->appMouseMove(dx, dy, flags);
  }
}
예제 #3
0
void systemTrayIcon::checkMousePos()
{
    if (geometry().contains(QCursor::pos()))
    {
        if (!m_bMouseHorer)
        {
            m_bMouseHorer = true;
            emit mouseEnter();
        }
    }
    else
    {
        if (m_bMouseHorer)
        {
            m_bMouseHorer = false;
            emit mouseLeave();
        }
    }
}
예제 #4
0
//--------------------------------------------------------------
// handle mouse movement in screen coordinates
void mgScriptPlatform::mouseMoveAbs(
  int x, 
  int y,
  int flags)
{
  // if this is first point after mouse left, do setup
  if (!m_mouseInside)
    mouseEnter(x, y);

  // figure delta as different from last coord
  int dx = x - m_lastCursorX;
  int dy = y - m_lastCursorY;
  m_lastCursorX = x;
  m_lastCursorY = y;

  if (m_theApp != NULL)
  {
    if ((flags & MG_EVENT_MOUSE_BUTTONS) != 0)
      m_theApp->appMouseDrag(dx, dy, flags);
    else m_theApp->appMouseMove(dx, dy, flags);
  }
}
예제 #5
0
void VOIPChatWidgetHolder::addVideoData(const RsPeerId &peer_id, QByteArray* array)
{
	if (!videoCaptureToggleButton->isChecked()) {
		if (mChatWidget) {
			QString buttonName = QString::fromUtf8(rsPeers->getPeerName(peer_id).c_str());
			if (buttonName.isEmpty()) buttonName = "VoIP";//TODO maybe change all with GxsId
			button_map::iterator it = buttonMapTakeVideo.find(buttonName);
			if (it == buttonMapTakeVideo.end()){
				mChatWidget->addChatMsg(true, tr("VoIP Status"), QDateTime::currentDateTime(), QDateTime::currentDateTime()
				                        , tr("%1 inviting you to start a video conversation. do you want Accept or Decline the invitation?").arg(buttonName), ChatWidget::MSGTYPE_SYSTEM);
				RSButtonOnText *button = mChatWidget->getNewButtonOnTextBrowser(tr("Accept Video Call"));
				button->setToolTip(tr("Activate camera"));
				button->setStyleSheet(QString("border: 1px solid #199909;")
                              .append("font-size: 12pt;  color: white;")
                              .append("min-width: 128px; min-height: 24px;")
				                      .append("border-radius: 6px;")
				                      .append("background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.67, "
                                        "stop: 0 #22c70d, stop: 1 #116a06);")

				                      );

				button->updateImage();

				connect(button,SIGNAL(clicked()),this,SLOT(startVideoCapture()));
				connect(button,SIGNAL(mouseEnter()),this,SLOT(botMouseEnter()));
				connect(button,SIGNAL(mouseLeave()),this,SLOT(botMouseLeave()));

				buttonMapTakeVideo.insert(buttonName, button);
			}
		}

		//TODO make a sound for the incoming call
//        soundManager->play(VOIP_SOUND_INCOMING_CALL);
		if (mVOIPNotify) mVOIPNotify->notifyReceivedVoipVideoCall(peer_id);

	} else {
		outputVideoProcessor->receiveEncodedData((unsigned char *)array->data(),array->size()) ;
	}
}
예제 #6
0
void VOIPChatWidgetHolder::addAudioData(const RsPeerId &peer_id, QByteArray* array)
{
    if (!audioCaptureToggleButton->isChecked()) {
        //launch an animation. Don't launch it if already animating
        if (!audioCaptureToggleButton->graphicsEffect() ||
            (audioCaptureToggleButton->graphicsEffect()->inherits("QGraphicsOpacityEffect") &&
                ((QGraphicsOpacityEffect*)audioCaptureToggleButton->graphicsEffect())->opacity() == 1)
            ) {
            QGraphicsOpacityEffect *effect = new QGraphicsOpacityEffect(audioListenToggleButton);
            audioCaptureToggleButton->setGraphicsEffect(effect);
            QPropertyAnimation *anim = new QPropertyAnimation(effect, "opacity", effect);
            anim->setStartValue(1);
            anim->setKeyValueAt(0.5,0);
            anim->setEndValue(1);
            anim->setDuration(400);
            anim->start();
        }
        
        if (mChatWidget) {
        QString buttonName = QString::fromUtf8(rsPeers->getPeerName(peer_id).c_str());
        if (buttonName.isEmpty()) buttonName = "VoIP";//TODO maybe change all with GxsId
        button_map::iterator it = buttonMapTakeVideo.find(buttonName);
        if (it == buttonMapTakeVideo.end()){
				mChatWidget->addChatMsg(true, tr("VoIP Status"), QDateTime::currentDateTime(), QDateTime::currentDateTime()
				                        , tr("%1 inviting you to start a audio conversation. do you want Accept or Decline the invitation?").arg(buttonName), ChatWidget::MSGTYPE_SYSTEM);
				RSButtonOnText *button = mChatWidget->getNewButtonOnTextBrowser(tr("Accept Call"));
				button->setToolTip(tr("Activate audio"));
				button->setStyleSheet(QString("border: 1px solid #199909;")
				                      .append("font-size: 12pt;  color: white;")
				                      .append("min-width: 128px; min-height: 24px;")
				                      .append("border-radius: 6px;")
				                      .append("background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.67, "
                                        "stop: 0 #22c70d, stop: 1 #116a06);")

				                      );
                                       

				button->updateImage();

				connect(button,SIGNAL(clicked()),this,SLOT(startAudioCapture()));
				connect(button,SIGNAL(mouseEnter()),this,SLOT(botMouseEnter()));
				connect(button,SIGNAL(mouseLeave()),this,SLOT(botMouseLeave()));

				buttonMapTakeVideo.insert(buttonName, button);
        }
        }

        audioCaptureToggleButton->setToolTip(tr("Answer"));

        //TODO make a sound for the incoming call
//        soundManager->play(VOIP_SOUND_INCOMING_CALL);
        if (mVOIPNotify) mVOIPNotify->notifyReceivedVoipAudioCall(peer_id);

        return;
    }

    if (!outputAudioDevice) {
        outputAudioDevice = AudioDeviceHelper::getDefaultOutputDevice();
    }

    if (!outputAudioProcessor) {
        //start output audio device
        outputAudioProcessor = new QtSpeex::SpeexOutputProcessor();
        if (inputAudioProcessor) {
            connect(outputAudioProcessor, SIGNAL(playingFrame(QByteArray*)), inputAudioProcessor, SLOT(addEchoFrame(QByteArray*)));
        }
        outputAudioProcessor->open(QIODevice::ReadOnly | QIODevice::Unbuffered);
        outputAudioDevice->start(outputAudioProcessor);
    }

    if (outputAudioDevice && outputAudioDevice->error() != QAudio::NoError) {
        std::cerr << "Restarting output device. Error before reset " << outputAudioDevice->error() << " buffer size : " << outputAudioDevice->bufferSize() << std::endl;
        outputAudioDevice->stop();
        outputAudioDevice->reset();
        if (outputAudioDevice->error() == QAudio::UnderrunError)
            outputAudioDevice->setBufferSize(20);
        outputAudioDevice->start(outputAudioProcessor);
    }
    outputAudioProcessor->putNetworkPacket(QString::fromStdString(peer_id.toStdString()), *array);

    //check the input device for errors
    if (inputAudioDevice && inputAudioDevice->error() != QAudio::NoError) {
        std::cerr << "Restarting input device. Error before reset " << inputAudioDevice->error() << std::endl;
        inputAudioDevice->stop();
        inputAudioDevice->reset();
        inputAudioDevice->start(inputAudioProcessor);
    }
}
예제 #7
0
void MusicPage::enterEvent(QEvent *e)//鼠标进入事件
{
    emit mouseEnter();
}
예제 #8
0
void DockAppIcon::enterEvent(QEvent *)
{
    if (m_modeData->getDockMode() == Dock::FashionMode)
        emit mouseEnter();
}
예제 #9
0
파일: form.cpp 프로젝트: yujinwunz/SDLGUI
void form::handleMouseMove(SDL_Event &e){
		if(within(left,top,width,height,e.motion.x,e.motion.y)){
			this->mouseEnter(&e);
		}else{
			this->mouseLeave(&e);
			//return;
		}
		if(_DEGUGG) cout<<name<<"\t"<<"Before: "<<e.motion.x<<","<<e.motion.y<<" After: ";
		//MOTION. trickkky.--------------------------------------------
		int state = SDL_GetMouseState(NULL,NULL);
		//this part handles the case of pointers dragging into the window. In which, ignore.
		if((state&SDL_BUTTON_LMASK)&&leftBindedControl==-2) return;
		if((state&SDL_BUTTON_MMASK)&&middleBindedControl==-2) return;
		if((state&SDL_BUTTON_RMASK)&&rightBindedControl==-2) return;

		//this part handles the case of pointers leaving, releasing and then entering.
		SDL_Event sim;
		sim.type = SDL_MOUSEBUTTONUP;
		sim.button.state = SDL_RELEASED;
		sim.button.type = SDL_MOUSEBUTTONUP;
		sim.button.x = e.motion.x;
		sim.button.y = e.motion.y;
		sim.button.which = 1;

		if(!(state&SDL_BUTTON_LMASK)&&leftBindedControl!=-2){
			sim.button.button = SDL_BUTTON_LEFT;
			SDL_PushEvent(&sim); SDL_PushEvent(&e);
			return;
		}
		if(!(state&SDL_BUTTON_MMASK)&&middleBindedControl!=-2){
			sim.button.button = SDL_BUTTON_MIDDLE;
			SDL_PushEvent(&sim); SDL_PushEvent(&e);
			return;
		}
		if(!(state&SDL_BUTTON_RMASK)&&rightBindedControl!=-2){
			sim.button.button = SDL_BUTTON_RIGHT;
			SDL_PushEvent(&sim); SDL_PushEvent(&e);
			return;
		}
		//by this point, if there is a button down, there is one corresponding binded control. If there is a button down, send to the corresponding control only
		e.motion.x -= left;
		e.motion.y -= top;
		if(_DEGUGG) cout<<e.motion.x<<","<<e.motion.y<<"\n";
		if(state){
			int control = max(leftBindedControl,max(rightBindedControl,middleBindedControl));
			if(control==-1){
				this->callEvent(&e,e.type);
			}else{
				if(within(children[control]->left,children[control]->top,
					children[control]->width,children[control]->height,
					e.motion.x,e.motion.y)){
						children[control]->mouseEnter(&e);
						children[control]->handleEvent(e);
						hoveredControl = control;
				}else{
					children[control]->mouseLeave(&e);
					children[control]->handleEvent(e);
					hoveredControl = -2;
				}
			}
				
		}else{
			//find which control this belongs to.
			int control = -2;
			if(within(left,top,width,height,e.motion.x,e.motion.y)) control = -1;
			for(int i = 0; i < children.size(); i++){
				if(within(children[i]->left,children[i]->top,children[i]->width,
					children[i]->height,e.motion.x,e.motion.y)){
					control = i;
				}
			}
			if(control!=hoveredControl){
				if(hoveredControl==-1) mouseLeave(&e);
				if(hoveredControl>=0) children[hoveredControl] -> mouseLeave(&e);	
			}
			if(control==-1){
				mouseEnter(&e);
				callEvent(&e,e.type);
			}
			if(control>=0){
				children[control]->mouseEnter(&e);
				children[control]->handleEvent(e);
			}
			hoveredControl = control;
		}

}
예제 #10
0
FramelessMainWindow::FramelessMainWindow( QWidget *parent ) :
   QMainWindow( parent ),
   m_scene( new QGraphicsScene( this ) ),
   m_browser( new GraphicsBrowser( m_scene, *this ) ),
   m_mouseFilter( *this, *qApp ),
   m_video( new EventfulVidgetVideo( this ) ),
   m_intro( new QGraphicsScene ),
   m_control( new VideoControl( this ) ),
   m_closeControl( new QFrame( this ) ),
   m_hostApp( new HostApp( m_browser->webView(), this ) )
{
    m_video->hide();
    m_control->hide();
    m_browser->webView()->page()->settings()->setAttribute( QWebSettings::JavascriptCanOpenWindows, true );

    m_control->setVolume( m_hostApp->getVolume() );

    m_closeControl->hide();
    m_closeControl->setStyleSheet( "QFrame{background-color:black; } "
                                   "QPushButton { background-image: url(':/close-styled'); width:31;} "
                                   "QWidget{border:none; padding:0; spacing:0; height:30;}" );
    QHBoxLayout *hl = new QHBoxLayout( m_closeControl );
    hl->setContentsMargins( QMargins() );
    hl->addSpacerItem( new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ) );

    m_closeButton = new QPushButton();
    m_closeButton->setCursor( Qt::PointingHandCursor );
//  btn->setFlat( true );
    hl->addWidget( m_closeButton );
    connect( m_control, SIGNAL( uiShow() ), m_closeButton, SLOT( show() ) );
    connect( m_control, SIGNAL( uiHide() ), m_closeButton, SLOT( hide() ) );


    setWindowTitle( "Popcorn Time" );
    m_intro->addPixmap( QPixmap( ":/intro" ).scaled( DEFAULT_WIDTH, DEFAULT_HEIGHT, Qt::IgnoreAspectRatio ) );
    m_browser->setScene( m_intro );
    new QShortcut( QKeySequence( "Ctrl+M" ), this, SLOT( minimize() ) );

    QObject::connect( m_hostApp->thread(), SIGNAL( torrentUrlAvailable( QString ) ),
                      this, SLOT( playMedia( QString ) ) );
    QObject::connect( m_browser->webView(), SIGNAL( loadFinished( bool ) ),
                      this, SLOT( removeIntro() ) );
    QObject::connect( m_hostApp, SIGNAL( commandedClose() ),
                      this, SLOT( close() ) );
    QObject::connect( m_hostApp, SIGNAL( commandedMinimize() ),
                      this, SLOT( minimize() ) );
    QObject::connect( m_hostApp, SIGNAL( toggledMaximize() ),
                      this, SLOT( toggleMaximize() ) );
    QObject::connect( m_hostApp, SIGNAL( haveSubtitles( SubtitleItem ) ),
                      m_control, SLOT( addSubtitle( SubtitleItem ) ) );
    QObject::connect( m_hostApp, SIGNAL( downloadInfoChanged( DownloadInfo ) ),
                      m_control, SLOT( updateDownloadStatus( DownloadInfo ) ) );
    QObject::connect( m_control, SIGNAL( volumeChanged( int ) ),
                      m_hostApp, SLOT( setVolume( int ) ) );

    QObject::connect( m_control, SIGNAL( newImage( QString ) ),
                      m_video, SLOT( setImage( QString ) ) );

    QObject::connect( m_control->fullscreenButton(), SIGNAL( clicked() ),
                      this, SLOT( toggleMaximize() ) );
    QObject::connect( &m_mouseFilter, SIGNAL( enterPressed() ),
                      this, SLOT( toggleMaximize() ) );
    QObject::connect( &m_mouseFilter, SIGNAL( upPressed() ),
                      m_control, SLOT( volumeUp() ) );
    QObject::connect( &m_mouseFilter, SIGNAL( downPressed() ),
                      m_control, SLOT( volumeDown() ) );
    QObject::connect( &m_mouseFilter, SIGNAL( pausePressed() ),
                      m_control, SLOT( pauseToggleReq() ) );

    connect( m_video, SIGNAL( mouseEnter() ), m_control, SLOT( showForDefaultPeriod() ) );

    this->setWindowFlags( Qt::FramelessWindowHint | Qt::WindowMinimizeButtonHint );
#ifdef Q_OS_MAC
    fixNativeWindow( this );
#endif
    this->setMinimumSize( 800, 330 );
    this->setMouseTracking( true );
    this->setCentralWidget( m_browser );
    qApp->installEventFilter( this );

    reconnectMediaPlayer();

    QObject::connect( VLC::VLCObject(), SIGNAL( mediaPlayerReplaced() ),
                      this, SLOT( reconnectMediaPlayer() ) );
}
예제 #11
0
void FLineEdit::enterEvent(QEvent * event) {
	QLineEdit::enterEvent(event);
	if (m_readOnly) {
		emit mouseEnter();
	}
}
예제 #12
0
파일: Events.cpp 프로젝트: JERlabs/JERonimo
  const SUCCESS Events::handleEvent(const SDL_Event * const Event)
  {
    switch(Event->type)
    {  //newline brackets implemented since this is a lot of nesting
    case SDL_WINDOWEVENT: ///Some sort of input or output gained or lost
      {
        const Uint8 &winID = Event->window.windowID;
        switch(Event->window.event) 
        {
        case SDL_WINDOWEVENT_ENTER:   ///Mouse message handling gained or lost
          return mouseEnter(winID);
          
        case SDL_WINDOWEVENT_LEAVE:   ///General input message handling gained or lost
          return mouseLeave(winID);

        case SDL_WINDOWEVENT_MINIMIZED:   ///Output to the screen at all gained or lost
          return minimized(winID);
          
        case SDL_WINDOWEVENT_RESTORED:
          return restored(winID);
          
        case SDL_WINDOWEVENT_MAXIMIZED:
          return maximized(winID);
          
        case SDL_WINDOWEVENT_SHOWN:
          return shown(winID);
          
        case SDL_WINDOWEVENT_HIDDEN:
          return hidden(winID);
          
        case SDL_WINDOWEVENT_EXPOSED:
          return exposed(winID);
          
        case SDL_WINDOWEVENT_FOCUS_GAINED:
          return keyboardFocusGain(winID);
          
        case SDL_WINDOWEVENT_FOCUS_LOST:
          return keyboardFocusLost(winID);
          
        case SDL_WINDOWEVENT_SIZE_CHANGED:
            return changeSize(winID);
            
        case SDL_WINDOWEVENT_RESIZED:
          return resized(winID, Dimensions<int>(Event->window.data1, Event->window.data2));
          
        case SDL_WINDOWEVENT_MOVED:
          return moved(winID, Point<int>(Event->window.data1, Event->window.data2));
          
        case SDL_WINDOWEVENT_CLOSE:
          return windowExited(winID);
          
        default:   ///For some reason there is an unknown window event
          return FAILED;
        }
        break;
      }
    case SDL_KEYDOWN:
      {
        if(Event->key.repeat)
        {
          return keyHeld(Event->key.windowID, Event->key.keysym);
        }
        else
        {
          return keyPressed(Event->key.windowID, Event->key.keysym);
        }
        break;
      }
    case SDL_KEYUP:
        return keyReleased(Event->key.windowID, Event->key.keysym);
        
    case SDL_TEXTINPUT:
        return textInput(Event->text.windowID, Event->text.text);
        
    case SDL_TEXTEDITING:
        return textEdit(Event->edit.windowID, Event->edit.text, Event->edit.start, Event->edit.length);
        
    case SDL_MOUSEMOTION:
      return mouseMove(Event->motion.windowID, Event->motion.which,
                       Delta<Point<int> >(Point<int>(Event->motion.xrel, Event->motion.yrel), 
                                          Point<int>(Event->motion.x, Event->motion.y)),
                       bitset<N_MOUSE_BUTTONS>(Event->motion.state));
                       
    case SDL_MOUSEBUTTONDOWN:
      return mouseButtonPressed(Event->button.windowID, Event->button.which, Event->button.button, Event->button.clicks,
                                Point<int>(Event->button.x, Event->button.y));
      
    case SDL_MOUSEBUTTONUP:
        return mouseButtonReleased(Event->button.windowID, Event->button.which, Event->button.button, Event->button.clicks,
                                  Point<int>(Event->button.x, Event->button.y));
     
    case SDL_MOUSEWHEEL:
        return mouseWheel(Event->wheel.windowID, Event->wheel.which, Point<int>(Event->wheel.x, Event->wheel.y));
        
    case SDL_JOYAXISMOTION:
      return joyAxis(Event->jaxis.which, Event->jaxis.axis, Event->jaxis.value);
    
    case SDL_JOYBUTTONDOWN:
      return joyButtonPressed(Event->jbutton.which, Event->jbutton.button);
      
    case SDL_JOYBUTTONUP:
      return joyButtonReleased(Event->jbutton.which, Event->jbutton.button);
      
    case SDL_JOYHATMOTION:
      return joyHatChange(Event->jhat.which, Event->jhat.hat, Event->jhat.value);
        
    case SDL_JOYBALLMOTION:
      return joyBallMove(Event->jball.which, Event->jball.ball, Point<int>(Event->jball.xrel, Event->jball.yrel));
      
    case SDL_DROPFILE:
    {
      const SUCCESS ret = droppedFile(Event->drop.file);
      SDL_free(Event->drop.file);
      return ret;
    }
      
    case SDL_SYSWMEVENT:
      return unhandledSystemEvent(Event->syswm.msg);
     
    case SDL_QUIT:
      return appExited();
        
    case SDL_USEREVENT:
    default:
      {
        return userEvent(Event->user.windowID, Event->user.code, Event->user.data1, Event->user.data2);
      }
    }

    return FAILED;
  }
예제 #13
0
void ViewSelectorButton::hoverEnterEvent(QGraphicsSceneHoverEvent* e)
{
    Q_UNUSED(e);
    emit(mouseEnter(label));
}
예제 #14
0
void EventfulVidgetVideo::enterEvent( QEvent * ) { emit mouseEnter(); }
예제 #15
0
void DArrowButton::enterEvent(QEvent *)
{
    emit mouseEnter();
}
예제 #16
0
void ImageView::hoverEnterEvent(QGraphicsSceneHoverEvent *a_event_ptr) {
  Q_EMIT mouseEnter();
  QGraphicsObject::hoverEnterEvent(a_event_ptr);
}
예제 #17
0
bool RSButtonOnText::eventFilter(QObject *obj, QEvent *event)
{
    // comment electron:
    // the guard is here, because someone deletes this object in callbacks(slots) called from here
    // the QPointer can detect this
    // but this is bad practice, because it hides the root cause for the problem,
    // which is the deletion of objects in their own signals
    // TODO: better use the Qt function deleteLater
	QPointer<QAbstractButton> guard(this);
	QPoint point;
	if (isEventForThis(obj, event, point)) {
		if (event->type() == QEvent::ToolTip)	{
			QToolTip::showText(point, this->toolTip());
			event->ignore();//For other don't clear this one
			return true;
		}
		if (event->type() == QEvent::MouseButtonPress)	{
			QMouseEvent* mouseEvent = new QMouseEvent(QEvent::MouseButtonPress
			                                          ,QPoint(1,1),Qt::LeftButton,Qt::LeftButton,0);
			QPushButton::mousePressEvent(mouseEvent);
			delete mouseEvent;
            if (guard) _pressed = true;
			//if (guard) emit pressed();
			if (guard) updateImage();
		}
		if (event->type() == QEvent::MouseButtonRelease)	{
			QMouseEvent* mouseEvent = new QMouseEvent(QEvent::MouseButtonPress
			                                          ,QPoint(1,1),Qt::LeftButton,Qt::LeftButton,0);
			QPushButton::mouseReleaseEvent(mouseEvent);
			delete mouseEvent;
            if (guard) _pressed = false;
			//if (guard) emit released();
			//if (guard) emit clicked();
			//if (guard) if (isCheckable()) emit clicked(QPushButton::isChecked());
			//if (guard) if (isCheckable()) emit toggled(QPushButton::isChecked());
			if (guard) updateImage();
		}
		if (event->type() == QEvent::MouseMove)	{
			if (!_mouseOver){
				//QMouseEvent* mouseEvent = new QMouseEvent(QEvent::MouseButtonPress
				//                                          ,QPoint(1,1),Qt::LeftButton,Qt::LeftButton,0);
				//QPushButton::enterEvent(mouseEvent);//Do nothing
				//delete mouseEvent;
				//QPushButton::setDown(true);
				if (guard) emit mouseEnter();
			}
            if (guard) _mouseOver = true;
			if (guard) updateImage();
		}
	} else {
		if (event->type() == QEvent::MouseMove)	{
			if (_mouseOver) {
				//QMouseEvent* mouseEvent = new QMouseEvent(QEvent::MouseButtonPress
				//                                          ,QPoint(1,1),Qt::LeftButton,Qt::LeftButton,0);
				//QPushButton::leaveEvent(mouseEvent);//Do nothing
				//delete mouseEvent;
				//QPushButton::setDown(false);
				_mouseOver = false;
				if (guard) emit mouseLeave();
				if (guard) updateImage();
			}
			if (_pressed){
				QMouseEvent* mouseEvent = new QMouseEvent(QEvent::MouseButtonPress
				                                          ,QPoint(1,1),Qt::LeftButton,Qt::LeftButton,0);
				QPushButton::mouseReleaseEvent(mouseEvent);
				delete mouseEvent;
				//if (guard) emit released();
				if (guard) updateImage();
			}
		}
	}

	if (!guard)
		std::cerr << "BIG FAT WARNING from RSButtonOnText::eventFilter(): i was deleted in my own event handler. This is bad practice. Please make a patch and use deleteLater to delay deletion." << std::endl ;

	// pass the event on to the parent class
	return QWidget::eventFilter(obj, event);
}
void LayoutButton::enterEvent(QEvent *event) {
    emit mouseEnter(m_text);
    Q_UNUSED(event);
//    qDebug() << "enterEvent;";
    updateStyleSelf();
}
예제 #19
0
HtmlInfoView::HtmlInfoView(QWidget * parent) : QScrollArea(parent) 
{
    this->setWidgetResizable(true);
	this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    QFrame * mainFrame = new QFrame(this);
	mainFrame->setObjectName("infoViewMainFrame");

	m_lastTitleItemBase = NULL;
	m_lastTagsModelPart = NULL;
	m_lastConnectorItem = NULL;
	m_lastIconItemBase = NULL;
	m_lastPropsModelPart = NULL;
	m_lastPropsItemBase = NULL;

	m_partTitle = NULL;
	m_partUrl = NULL;
	m_partVersion = NULL;
	m_lockCheckbox = NULL;
	m_stickyCheckbox = NULL;
	m_connDescr = NULL;
	m_tagsTextLabel = NULL;
	m_lastSwappingEnabled = false;
	m_lastItemBase = NULL;
	m_infoGraphicsView = NULL;
	m_setContentTimer.setSingleShot(true);
	m_setContentTimer.setInterval(10);
	connect(&m_setContentTimer, SIGNAL(timeout()), this, SLOT(setContent()));
	QVBoxLayout *vlo = new QVBoxLayout(mainFrame);
	vlo->setSpacing(0);
	vlo->setContentsMargins(0, 0, 0, 0);
	vlo->setSizeConstraint( QLayout::SetMinAndMaxSize );

        /* Part Title */

	m_titleEdit = new FLineEdit(mainFrame);
	m_titleEdit->setObjectName("instanceTitleEditor");
	m_titleEdit->setToolTip(tr("Change the part label here"));
	m_titleEdit->setAlignment(Qt::AlignLeft);

	connect(m_titleEdit, SIGNAL(editingFinished()), this, SLOT(setInstanceTitle()));
	connect(m_titleEdit, SIGNAL(mouseEnter()), this, SLOT(instanceTitleEnter()));
	connect(m_titleEdit, SIGNAL(mouseLeave()), this, SLOT(instanceTitleLeave()));
	connect(m_titleEdit, SIGNAL(editable(bool)), this, SLOT(instanceTitleEditable(bool)));

	setInstanceTitleColors(m_titleEdit, QColor(0xaf, 0xaf, 0xb4), QColor(0x00, 0x00, 0x00)); //b3b3b3, 575757
	m_titleEdit->setAutoFillBackground(true);
	vlo->addWidget(m_titleEdit);

        /* Part Icons */

	if (NoIcon == NULL) {
		NoIcon = new QPixmap(":/resources/images/icons/noicon.png");
	}

	QFrame * iconFrame = new QFrame(mainFrame);
	iconFrame->setObjectName("iconFrame");

	QHBoxLayout * hboxLayout = new QHBoxLayout();
	hboxLayout->setContentsMargins(0, 0, 0, 0);
	hboxLayout->addSpacing(IconSpace);
	m_icon1 = addLabel(hboxLayout, NoIcon);
	m_icon1->setToolTip(tr("Part breadboard view image"));
	m_icon2 = addLabel(hboxLayout, NoIcon);
	m_icon2->setToolTip(tr("Part schematic view image"));
	m_icon3 = addLabel(hboxLayout, NoIcon);
	m_icon3->setToolTip(tr("Part pcb view image"));

	QVBoxLayout * versionLayout = new QVBoxLayout();

	QHBoxLayout * subVersionLayout = new QHBoxLayout();
	m_partVersion = new QLabel();
	m_partVersion->setObjectName("infoViewPartVersion");
	m_partVersion->setToolTip(tr("Part version number"));
    m_partVersion->setOpenExternalLinks(false);
    m_partVersion->setAlignment(Qt::AlignLeft | Qt::AlignTop);
    connect(m_partVersion, SIGNAL(linkActivated(const QString &)), this, SLOT(clickObsolete(const QString &)));
	subVersionLayout->addWidget(m_partVersion, 0, Qt::AlignLeft);
	subVersionLayout->addStretch(1);
	versionLayout->addLayout(subVersionLayout);

    QHBoxLayout * cbLayout = new QHBoxLayout();
	
	m_lockCheckbox = new QCheckBox(tr("Locked"));
	m_lockCheckbox->setObjectName("infoViewLockCheckbox");
	m_lockCheckbox->setToolTip(tr("Change the locked state of the part in this view. A locked part can't be moved."));
	connect(m_lockCheckbox, SIGNAL(clicked(bool)), this, SLOT(changeLock(bool)));
	cbLayout->addWidget(m_lockCheckbox);

	m_stickyCheckbox = new QCheckBox(tr("Sticky"));
	m_stickyCheckbox->setObjectName("infoViewLockCheckbox");
	m_stickyCheckbox->setToolTip(tr("Change the \"sticky\" state of the part in this view. When a sticky part is moved, objects on top of it also move."));
	connect(m_stickyCheckbox, SIGNAL(clicked(bool)), this, SLOT(changeSticky(bool)));
	cbLayout->addWidget(m_stickyCheckbox);

    versionLayout->addLayout(cbLayout);

	hboxLayout->addLayout(versionLayout);
	
	hboxLayout->addSpacerItem(new QSpacerItem(IconSpace, 1, QSizePolicy::Expanding));
	iconFrame->setLayout(hboxLayout);
	vlo->addWidget(iconFrame);

	m_partUrl = new TagLabel(this);
	m_partUrl->setWordWrap(false);
	m_partUrl->setObjectName("infoViewPartUrl");
	m_partUrl->setOpenExternalLinks(true);
	vlo->addWidget(m_partUrl);

	m_partTitle = new TagLabel(this);
	m_partTitle->setWordWrap(true);
	m_partTitle->setObjectName("infoViewPartTitle");
	m_partTitle->setOpenExternalLinks(true);
	vlo->addWidget(m_partTitle);

	m_proplabel = new QLabel(tr("Properties"), NULL);
	m_proplabel->setObjectName("expandableViewLabel");
	vlo->addWidget(m_proplabel);

	m_propFrame = new QFrame(this);
	m_propFrame->setObjectName("infoViewPropertyFrame");
	m_propLayout = new QGridLayout(m_propFrame);
	m_propLayout->setSpacing(0);
	m_propLayout->setContentsMargins(0, 0, 0, 0);
	m_propFrame->setLayout(m_propLayout);
	vlo->addWidget(m_propFrame);

	m_taglabel = new QLabel(tr("Tags"), NULL);
	m_taglabel->setObjectName("expandableViewLabel");
	vlo->addWidget(m_taglabel);

	m_tagsTextLabel = new TagLabel(this);
	m_tagsTextLabel->setWordWrap(true);
	m_tagsTextLabel->setObjectName("tagsValue");
	vlo->addWidget(m_tagsTextLabel);

	m_connLabel = new QLabel(tr("Connections"), NULL);
	m_connLabel->setObjectName("expandableViewLabel");
	vlo->addWidget(m_connLabel);

	m_connFrame = new QFrame(this);
	m_connFrame->setObjectName("connectionsFrame");

    QGridLayout * connLayout = new QGridLayout(m_connFrame);
	connLayout->setSpacing(0);
	connLayout->setContentsMargins(0, 0, 0, 0);
	m_connFrame->setLayout(connLayout);

	QLabel * descrLabel = new QLabel(tr("conn."), this);
	descrLabel->setObjectName("connectionsLabel");
	m_connDescr = new QLabel(this);
	m_connDescr->setObjectName("connectionsValue");
    connLayout->addWidget(descrLabel, 0, 0);
    connLayout->addWidget(m_connDescr, 0, 1);

	QLabel * nameLabel = new QLabel(tr("name"), this);
	nameLabel->setObjectName("connectionsLabel");
	m_connName = new QLabel(this);
	m_connName->setObjectName("connectionsValue");
    connLayout->addWidget(nameLabel, 1, 0);
    connLayout->addWidget(m_connName, 1, 1);

	QLabel * typeLabel = new QLabel(tr("type"), this);
	typeLabel->setObjectName("connectionsLabel");
	m_connType = new QLabel(this);
	m_connType->setObjectName("connectionsValue");
	connLayout->addWidget(typeLabel, 2, 0);
    connLayout->addWidget(m_connType, 2, 1);

	vlo->addWidget(m_connFrame);

	vlo->addSpacerItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding));

	mainFrame->setLayout(vlo);

	this->setWidget(mainFrame);

	m_currentItem = NULL;
	m_currentSwappingEnabled = false;

}