示例#1
0
void BitcoinGUI::changeEvent(QEvent *e)
{
    QMainWindow::changeEvent(e);
#ifndef Q_OS_MAC // Ignored on Mac
    if(e->type() == QEvent::WindowStateChange)
    {
        if(clientModel && clientModel->getOptionsModel()->getMinimizeToTray())
        {
            QWindowStateChangeEvent *wsevt = static_cast<QWindowStateChangeEvent*>(e);
            if(!(wsevt->oldState() & Qt::WindowMinimized) && isMinimized())
            {
                QTimer::singleShot(0, this, SLOT(hide()));
                e->ignore();
            }
        }
    }
#endif
}
示例#2
0
bool WindowEventFilter::eventFilter(QObject *watched, QEvent *event)
{
    if (watched != mpWindow)
        return false;
    if (event->type() == QEvent::WindowStateChange) {
        QWindowStateChangeEvent *e = static_cast<QWindowStateChangeEvent*>(event);
        mpWindow->updateGeometry();
        if (mpWindow->windowState().testFlag(Qt::WindowFullScreen) || e->oldState().testFlag(Qt::WindowFullScreen)) {
            emit fullscreenChanged();
        }
        return false;
    }
    if (event->type() ==  QEvent::MouseButtonPress) {
        QMouseEvent *me = static_cast<QMouseEvent*>(event);
        Qt::MouseButton mbt = me->button();
        if (mbt == Qt::LeftButton) {
            gMousePos = me->globalPos();
            iMousePos = me->pos();
        }
        return false;
    }
    if (event->type() == QEvent::MouseButtonRelease) {
        QMouseEvent *me = static_cast<QMouseEvent*>(event);
        Qt::MouseButton mbt = me->button();
        if (mbt != Qt::LeftButton)
            return false;
        iMousePos = QPoint();
        gMousePos = QPoint();
        return false;
    }
    if (event->type() == QEvent::MouseMove) {
        if (iMousePos.isNull() || gMousePos.isNull())
            return false;
        QMouseEvent *me = static_cast<QMouseEvent*>(event);
        int x = mpWindow->pos().x();
        int y = mpWindow->pos().y();
        int dx = me->globalPos().x() - gMousePos.x();
        int dy = me->globalPos().y() - gMousePos.y();
        gMousePos = me->globalPos();
        mpWindow->move(x + dx, y + dy);
        return false;
    }
    return false;
}
示例#3
0
void KviMainWindow::changeEvent(QEvent * e)
{
#ifndef COMPILE_ON_MAC
	// For Qt5 this should be used to minimize to tray
	if(
	    (e->type() == QEvent::WindowStateChange) && (windowState() & Qt::WindowMinimized) && KVI_OPTION_BOOL(KviOption_boolMinimizeInTray) && e->spontaneous())
	{

		if(!trayIcon())
		{
			executeInternalCommand(KVI_INTERNALCOMMAND_TRAYICON_SHOW);
		}
		if(trayIcon())
		{
			QWindowStateChangeEvent * ev = (QWindowStateChangeEvent *)e;
			KVI_OPTION_BOOL(KviOption_boolFrameIsMaximized) = ev->oldState() & Qt::WindowMaximized;
			QTimer::singleShot(0, this, SLOT(hide()));
		}
		return;
	}
#endif
	if(e->type() == QEvent::ActivationChange)
	{
		//WINDOW (DE)ACTIVATION
		// if we have just been activated by the WM
		// then update the active window task bar item
		// It will then reset its highlight state
		// and hopefully make the dock widget work correctly
		// in this case.
		// This will also trigger the OnWindowActivated event :)
		if(isActiveWindow())
		{
			if(g_pActiveWindow)
				windowActivated(g_pActiveWindow, true);
		}
		else
		{
			if(g_pActiveWindow)
				g_pActiveWindow->lostUserFocus();
		}
	}
	KviTalMainWindow::changeEvent(e);
}
示例#4
0
bool QtGameEngine::eventFilter(QObject *object, QEvent *event) {
    // http://doc.trolltech.com/4.7/qevent.html#QEvent
    if (event->type() == QEvent::ActivationChange) {
        if (m_paused) m_paused = false; else m_paused = true;
        qDebug() << "ActivationChangeFiltered: paused ==" << m_paused;
        if (!m_pauseResumeDisabled) {
            if (m_paused) pause(); else resume();
        } else {
            qDebug() << "Ignoring paused/resume since textintputdialog is on.";
        }
        return false;
    }
#ifdef MY_OS_MEEGO
    else if (event->type() == QEvent::WindowStateChange )
    {
        QWindowStateChangeEvent *change = static_cast<QWindowStateChangeEvent *>(event);

        Qt::WindowStates current = windowState();
        Qt::WindowStates old = change->oldState();
        //qDebug() << "widget is minimized in eventFilter?" << isMinimized();

        // did minimized flag change?
        if ((current ^ old) & Qt::WindowMinimized) {
            if (current & Qt::WindowMinimized) {
                // In MeeGo, the gl surface is somehow broken by the QMeegoGraphicsSystem.
                // This is why we must kill the timer, to prevent errors resulting gl painting.
                //qDebug() << "HIDING";
                killTimer(timerid);
                timerid = 0;
            }
        }
        return false;
    }
#endif
    else {
        // Standard event processing
        return QObject::eventFilter(object, event);
    }
    return false;
}
示例#5
0
void MainWindow::changeEvent(QEvent* event) {
    if (event->type() == QEvent::WindowStateChange) {
        QWindowStateChangeEvent* stateChangeEvent = static_cast<QWindowStateChangeEvent*>(event);
        if ((stateChangeEvent->oldState() == Qt::WindowNoState ||
             stateChangeEvent->oldState() == Qt::WindowMaximized) &&
             windowState() == Qt::WindowMinimized) {
            emit windowShown(false);
        } else {
            emit windowShown(true);
        }
        
        if (isFullScreen() != Menu::getInstance()->isOptionChecked(MenuOption::Fullscreen)) {
            Menu::getInstance()->setIsOptionChecked(MenuOption::Fullscreen, isFullScreen());
        }
    } else if (event->type() == QEvent::ActivationChange) {
        if (isActiveWindow()) {
            emit windowShown(true);
        } else {
            emit windowShown(false);
        }
    }
    QMainWindow::changeEvent(event);
}
示例#6
0
void NMainWindow::changeEvent(QEvent *event)
{
    QWidget::changeEvent(event);

    emit focusChanged(isActiveWindow());

    if (windowFlags() & Qt::FramelessWindowHint) {
        setAttribute(Qt::WA_Hover, true);
        return;
    }

    if (event->type() == QEvent::WindowStateChange) {
        QWindowStateChangeEvent *stateEvent = static_cast<QWindowStateChangeEvent *>(event);
        if (stateEvent->oldState() == Qt::WindowNoState && isMaximized()) {
            if (!m_unmaximizedSize.isValid()) {
                m_unmaximizedPos = pos();
                m_unmaximizedSize = size();
            }
        } else if (!isMaximized() && !isMinimized() && !m_isFullScreen) {
            m_unmaximizedSize = QSize();
            m_unmaximizedPos = QPoint();
        }
    }
}
示例#7
0
    // For multitouch - controls
bool QtGameEngine::event(QEvent *event)
{
    switch (event->type()) {
    case QEvent::TouchBegin:
    case QEvent::TouchUpdate:
    case QEvent::TouchEnd:
    {
        touchEventsEnabled = true;
        QList<QTouchEvent::TouchPoint> touchPoints = static_cast<QTouchEvent *>(event)->touchPoints();
        foreach (const QTouchEvent::TouchPoint &touchPoint, touchPoints) {
            int ind = touchPoint.id();
            switch (touchPoint.state()) {
            case Qt::TouchPointPressed:
                {
                    QPoint p = touchPoint.pos().toPoint();
                    runningGame->mouseEvent( MOUSE_DOWN, p.x(), p.y(), ind );
                    continue;
                }
            case Qt::TouchPointMoved:
                {
                    QPoint p = touchPoint.pos().toPoint();
                    runningGame->mouseEvent( MOUSE_MOVE, p.x(), p.y(), ind );
                    continue;
                }
            case Qt::TouchPointReleased:
                {
                    QPoint p = touchPoint.pos().toPoint();
                    runningGame->mouseEvent( MOUSE_UP, p.x(), p.y(), ind );
                    continue;
                }
            default:
            case Qt::TouchPointStationary:
                {
                    // The touch point did NOT move
                    continue;
                }
            }
        }
        event->accept();
        break;
    }
#ifdef MY_OS_MEEGO
    case QEvent::WindowStateChange :
    {
        QWindowStateChangeEvent *change = static_cast<QWindowStateChangeEvent *>(event);

        Qt::WindowStates current = windowState();
        Qt::WindowStates old = change->oldState();

        // did minimized flag change?
        if ((current ^ old) & Qt::WindowMinimized) {
            if (current & Qt::WindowMinimized) {
            }
            else {
                // In MeeGo, we need to re-create the EGL here.
                createEGLUtils();

            }
            //qDebug() << "WindowStateChange : " << m_paused << bool(m_updatesDisabled);
        }
        event->accept();
        break;
    }
#endif
    default:
        return QWidget::event(event);
    }
void QtMainWindowControl::changeEvent(QEvent* event)
{
  if (!controller->shell)
    return QMainWindow::changeEvent(event);

  typedef IShellListener::Events::ShellEventType::ListenerList ListenerList;
  ShellEvent::Pointer shellEvent(new ShellEvent(Shell::Pointer(controller->shell)));
  switch (event->type())
  {
  case QEvent::ActivationChange:
  {
    if (isActiveWindow())
    {
      ListenerList activatedListeners(controller->shellEvents.shellActivated.GetListeners());
      for (ListenerList::iterator listener = activatedListeners.begin();
           listener != activatedListeners.end(); ++listener)
      {
        (*listener)->Execute(shellEvent);
        if (!shellEvent->doit) {
          event->accept();
          return;
        }
      }
    }
    else
    {
      ListenerList deactivatedListeners(controller->shellEvents.shellDeactivated.GetListeners());
      for (ListenerList::iterator listener = deactivatedListeners.begin();
           listener != deactivatedListeners.end(); ++listener)
      {
        (*listener)->Execute(shellEvent);
        if (!shellEvent->doit) {
          event->accept();
          return;
        }
      }
    }
  }
    break;
  case QEvent::WindowStateChange:
  {
    QWindowStateChangeEvent* stateEvent = dynamic_cast<QWindowStateChangeEvent*>(event);
    Qt::WindowStates oldState = stateEvent->oldState();
    if (this->isMinimized() && !(oldState & Qt::WindowMinimized))
    {
      ListenerList iconifiedListeners(controller->shellEvents.shellIconified.GetListeners());
      for (ListenerList::iterator listener = iconifiedListeners.begin();
         listener != iconifiedListeners.end(); ++listener)
      {
        (*listener)->Execute(shellEvent);
        if (!shellEvent->doit) {
          event->accept();
          return;
        }
      }
    }
    else if (oldState & Qt::WindowMinimized && !this->isMinimized())
    {
      ListenerList deiconifiedListeners(controller->shellEvents.shellDeiconified.GetListeners());
      for (ListenerList::iterator listener = deiconifiedListeners.begin();
         listener != deiconifiedListeners.end(); ++listener)
      {
        (*listener)->Execute(shellEvent);
        if (!shellEvent->doit) return;
      }
    }
  }
    break;
  default:
    break;
  }

  QMainWindow::changeEvent(event);
}
示例#9
0
void CWinMain::changeEvent( QEvent* e )
{
	QMainWindow::changeEvent( e );
	switch ( e->type() )
	{
	case QEvent::LanguageChange:
		ui->retranslateUi( this );
		switch ( quazaaSettings.WinMain.ActiveTab )
		{
		case 0:
			ui->actionHome->setChecked( true );
			break;
		case 1:
			ui->actionLibrary->setChecked( true );
			break;
		case 2:
			ui->actionMedia->setChecked( true );
			break;
		case 3:
			ui->actionSearch->setChecked( true );
			break;
		case 4:
			ui->actionTransfers->setChecked( true );
			break;
		case 5:
			ui->actionSecurity->setChecked( true );
			break;
		case 6:
			ui->actionActivity->setChecked( true );
			break;
		case 7:
			ui->actionChat->setChecked( true );
			break;
		case 8:
			ui->actionHostCache->setChecked( true );
			break;
		case 9:
			ui->actionDiscovery->setChecked( true );
			break;
		case 10:
			ui->actionScheduler->setChecked( true );
			break;
		case 11:
			ui->actionGraph->setChecked( true );
			break;
		case 12:
			ui->actionPacketDump->setChecked( true );
			break;
		case 13:
			ui->actionSearchMonitor->setChecked( true );
			break;
		case 14:
			ui->actionHitMonitor->setChecked( true );
			break;
		default:
			ui->actionHome->setChecked( true );
			break;
		}
		break;
	case QEvent::WindowStateChange:
	{
		QWindowStateChangeEvent* event = ( QWindowStateChangeEvent* )e;
		// make sure we only do this for minimize events
		if ( ( event->oldState() != Qt::WindowMinimized ) && isMinimized() && quazaaSettings.System.MinimizeToTray )
		{
			QTimer::singleShot( 0, this, SLOT( hide() ) );
			e->ignore();
		}
	}
	default:
		break;
	}
}