Esempio n. 1
0
void YaEventNotifier::update()
{
	updateSkippedList();

	eventNotifierFrame_->setEvent(currentEventId(), currentEvent());
	eventNotifierFrame_->setEventCounter(skipped_ids_.count() + 1, GlobalEventQueue::instance()->ids().count());

	if (shouldBeVisible())
		show();
	else
		hide();

	emit visibilityChanged();
}
Esempio n. 2
0
void GRMapCanvas::addLayer( GRMapLayer* layer )
{

    //TODO: here need a symbol to paint the layer
    GRSymbol *sym;
    QColor *fill;
    int red, green, blue;
    int d = layer->featureType();
    switch (  d )
    {
    case GR::WKBPoint:
    case GR::WKBMultiPoint:
        sym = new GRMarkerSymbol();
        break;
    case GR::WKBLineString:
    case GR::WKBMultiLineString:
        sym = new GRLineSymbol();
        break;
    case GR::WKBPolygon:
    case GR::WKBMultiPolygon:
        sym = new GRPolygonSymbol();
        red = 1 + ( int )( 255.0 * rand() / ( RAND_MAX + 1.0 ) );
        green =	1 + ( int )( 255.0 * rand() / ( RAND_MAX + 1.0 ) );
        blue = 1 + ( int )( 255.0 * rand() / ( RAND_MAX + 1.0 ) );
        fill = new QColor( red, green, blue );
        sym->setFillColor( *fill );
        break;
    }
    red = 1 + ( int )( 255.0 * rand() / ( RAND_MAX + 1.0 ) );
    green =	1 + ( int )( 255.0 * rand() / ( RAND_MAX + 1.0 ) );
    blue = 1 + ( int )( 255.0 * rand() / ( RAND_MAX + 1.0 ) );
    sym->setColor( QColor( red, green, blue ) );
    sym->setLineWidth( 1 );
    layers[layer->getLayerID()] = layer;
    // update the extent if warranted
    if ( layers.size() == 1 )
    {
        fullExtent = layer->extent();
        fullExtent.scale( 1.1 );
        currentExtent = fullExtent;
    }
    updateFullExtent( layer->extent() );
    incrementZpos();
    layer->setZ( layers.size() - 1 );
    updateZpos();
    zOrder.push_back( layer->getLayerID() );
    connect( layer, SIGNAL( visibilityChanged() ), this, SLOT( layerStateChange() ) );
    dirty = true;
}
Esempio n. 3
0
void ModelItem::sendAttributeChanges()
{
    emit valueChanged();

    emit enabledChanged();
    emit selectedChanged();
    emit opacityChanged();
    emit visibilityChanged();

    emit brushChanged();
    emit fontChanged();
    emit penChanged();

    emit posChanged(true, true);
}
bool S60VideoWidgetDisplay::eventFilter(QObject *object, QEvent *e)
{
    if (object == m_widget) {
        switch (e->type()) {
        case QEvent::ParentChange:
            if (QWidget *parent = m_widget->parentWidget())
                parent->setProperty("_q_DummyWindowSurface", true);
            break;
        case QEvent::WinIdChange:
            m_widget->setWindowBackgroundColor();
            emit windowHandleChanged(windowHandle());
            break;
        case QEvent::Resize:
            emit displayRectChanged(extentRect(), clipRect());
            break;
#ifndef VIDEOOUTPUT_GRAPHICS_SURFACES
        case QEvent::Move:
            // TODO: this is insufficient - we also need to respond to changes in
            // the position of ancestor widgets
            emit displayRectChanged(extentRect(), clipRect());
            break;
#endif
        case QEvent::Show:
            emit windowHandleChanged(windowHandle());
            emit visibilityChanged(true);
            break;
        case QEvent::Hide:
            emit visibilityChanged(false);
            break;
        default:
            // Do nothing
            break;
        }
    }
    return false;
}
Esempio n. 5
0
void UPacketView::createPacketListGroupBox()
{
    packetListGroupBox_ = new QGroupBox(tr("Packet List"),this);
    packetList_ = new UPacketInfoList(this);
    packetList_->setSortingEnabled(true);
    packetListModel_ = new UPacketInfoListModel(&packetInfos_,&currentDisplayScheme_,this);
    packetInfoProxyModel_ = new UPacketInfoListProxyModel(this);
    packetInfoProxyModel_->setSourceModel(packetListModel_);
    packetList_->setModel(packetInfoProxyModel_);
    
    displayList_ = new UPacketDisplayList(&savedDisplaySchemes_,this);

    silentModePushButton_ = new QPushButton(tr("Silent Mode"),this);
    silentModePushButton_->setCheckable(true);
    silentModePushButton_->setChecked(silentMode_);
    showSendPacketsButton_ = new QPushButton(tr("Show Send"),this);
    showSendPacketsButton_->setCheckable(true);
    showSendPacketsButton_->setChecked(currentDisplayScheme_.showSendPackets);
    showRecvPacketsButton_ = new QPushButton(tr("Show Recv"),this);
    showRecvPacketsButton_->setCheckable(true);
    showRecvPacketsButton_->setChecked(currentDisplayScheme_.showRecvPackets);
    showOnlySelectedButton_ = new QPushButton(tr("Show Only Selected"),this);
    showOnlySelectedButton_->setCheckable(true);
    showOnlySelectedButton_->setChecked(showOnlySelectedPackets_);
    
    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget(displayList_,30);
    mainLayout->addWidget(packetList_,100);
    UFlowLayout *bottomLayout = new UFlowLayout;
    bottomLayout->addWidget(silentModePushButton_);
    bottomLayout->addWidget(showSendPacketsButton_);
    bottomLayout->addWidget(showRecvPacketsButton_);
    bottomLayout->addWidget(showOnlySelectedButton_);

    mainLayout->addLayout(bottomLayout,0);
    packetListGroupBox_->setLayout(mainLayout);

    connect(packetList_,SIGNAL(visibilityChanged()),this,SLOT(updateFilters()));
    connect(packetListModel_,SIGNAL(saveSettingsRequested()),this,SLOT(saveSettings()));
    connect(silentModePushButton_,SIGNAL(toggled(bool)),this,SLOT(setSilentMode(bool)));
    connect(showOnlySelectedButton_,SIGNAL(toggled(bool)),this,SLOT(setShowOnlySelectedPackets(bool)));
    connect(showSendPacketsButton_,SIGNAL(toggled(bool)),this,SLOT(setShowSendPackets(bool)));
    connect(showRecvPacketsButton_,SIGNAL(toggled(bool)),this,SLOT(setShowRecvPackets(bool)));
    connect(displayList_,SIGNAL(saveSchemeRequested(const QString &)),this,SLOT(saveScheme(const QString &)));
    connect(displayList_,SIGNAL(loadSchemeRequested(const QString &)),this,SLOT(loadScheme(const QString &)));

}
bool FormWindow::qt_invoke( int _id, QUObject* _o )
{
    switch ( _id - staticMetaObject()->slotOffset() ) {
    case 0: widgetChanged((QObject*)static_QUType_ptr.get(_o+1)); break;
    case 1: currentToolChanged(); break;
    case 2: visibilityChanged(); break;
    case 3: modificationChanged((bool)static_QUType_bool.get(_o+1)); break;
    case 4: invalidCheckedSelections(); break;
    case 5: updatePropertiesTimerDone(); break;
    case 6: showPropertiesTimerDone(); break;
    case 7: selectionChangedTimerDone(); break;
    case 8: windowsRepaintWorkaroundTimerTimeout(); break;
    default:
	return QWidget::qt_invoke( _id, _o );
    }
    return TRUE;
}
Esempio n. 7
0
CharmWindow::CharmWindow( const QString& name, QWidget* parent )
    : QMainWindow( parent )
    , m_openCharmAction( new QAction( tr( "Open Charm" ), this ) )
    , m_showAction( new QAction( this ) )
    , m_showHideAction( new QAction( this ) )
{
    setWindowName( name );
    connect( m_openCharmAction, SIGNAL(triggered(bool)), SLOT(showView()) );
    connect( m_showAction, SIGNAL(triggered(bool)), SLOT(showView()) );
    connect( m_showHideAction, SIGNAL(triggered(bool)), SLOT(showHideView()) );
    connect( this, SIGNAL(visibilityChanged(bool)), SLOT(handleOpenCharm(bool)) );
    connect( this, SIGNAL(visibilityChanged(bool)), SLOT(handleShow(bool)) );
    connect( this, SIGNAL(visibilityChanged(bool)), SLOT(handleShowHide(bool)) );
    m_toolBar = addToolBar( "Toolbar" );
    m_toolBar->setMovable( false );

    emit visibilityChanged( false );
}
Esempio n. 8
0
void QQuickWindowAttached::windowChange(QQuickWindow *window)
{
    if (window != m_window) {
        QQuickWindow* oldWindow = m_window;
        m_window = window;

        if (oldWindow)
            oldWindow->disconnect(this);

        emit windowChanged();

        if (!oldWindow || !window || window->visibility() != oldWindow->visibility())
            emit visibilityChanged();
        if (!oldWindow || !window || window->isActive() != oldWindow->isActive())
            emit activeChanged();
        if (!oldWindow || !window || window->activeFocusItem() != oldWindow->activeFocusItem())
            emit activeFocusItemChanged();
        emit contentItemChanged();
        if (!oldWindow || !window || window->width() != oldWindow->width())
            emit widthChanged();
        if (!oldWindow || !window || window->height() != oldWindow->height())
            emit heightChanged();

        if (!window)
            return;

        // QQuickWindowQmlImpl::visibilityChanged also exists, and window might even
        // be QQuickWindowQmlImpl, but that's not what we are connecting to.
        // So this is actual window state rather than a buffered or as-requested one.
        // If we used the metaobject connect syntax there would be a warning:
        // QMetaObjectPrivate::indexOfSignalRelative - QMetaObject::indexOfSignal:
        // signal visibilityChanged(QWindow::Visibility) from QQuickWindow redefined in QQuickWindowQmlImpl
        connect(window, &QQuickWindow::visibilityChanged,
                this, &QQuickWindowAttached::visibilityChanged);
        connect(window, &QQuickWindow::activeChanged,
                this, &QQuickWindowAttached::activeChanged);
        connect(window, &QQuickWindow::activeFocusItemChanged,
                this, &QQuickWindowAttached::activeFocusItemChanged);
        connect(window, &QQuickWindow::widthChanged,
                this, &QQuickWindowAttached::widthChanged);
        connect(window, &QQuickWindow::heightChanged,
                this, &QQuickWindowAttached::heightChanged);
    }
}
Esempio n. 9
0
ContactListItem::ContactListItem(Contact* contact)
{
	m_contact = contact;
	m_group = 0;
	
	setEditable(false);
	setDragEnabled(true);
	setDropEnabled(false);

	setText(m_contact->nickname());

	if (m_contact->isPhone())
	{
		setIcon(QIcon(":icons/phone.png"));

		setDragEnabled(false);
	}
	else if (m_contact->isConference())
	{
		setIcon(QIcon(":icons/msg_conference.png"));

		setDragEnabled(false);
	}
	else
	{
//		checkVisibility();

		connect(m_contact, SIGNAL(statusChanged(OnlineStatus)), this, SLOT(update()));
		connect(m_contact, SIGNAL(groupChanged(bool)), this, SLOT(changeGroup(bool)));
		connect(m_contact, SIGNAL(visibilityChanged()), this, SLOT(update()));
		connect(m_contact, SIGNAL(ignoredChanged()), this, SLOT(update()));
	}
	QFont f = font();
	/*if (!m_contact->isIgnored())
		f.setPointSize(9);
	setFont(f);*/
	setSizeHint(QSize(sizeHint().width(), 52));

	connect(m_contact, SIGNAL(renamed(QString)), this, SLOT(update()));
	connect(m_contact, SIGNAL(destroyed(QObject*)), this, SLOT(destroyItem()));
}
Esempio n. 10
0
void Cursor::dispatchEvents()
{
    if (m_new_position != m_position|| m_content_height_changed) {
        bool emit_x_changed = m_new_position.x() != m_position.x();
        bool emit_y_changed = m_new_position.y() != m_position.y();
        m_position = m_new_position;
        if (emit_x_changed)
            emit xChanged();
        if (emit_y_changed || m_content_height_changed)
            emit yChanged();
    }

    if (m_new_visibillity != m_visible) {
        m_visible = m_new_visibillity;
        emit visibilityChanged();
    }

    if (m_new_blinking != m_blinking) {
        m_blinking = m_new_blinking;
        emit blinkingChanged();
    }
}
Esempio n. 11
0
  CEAbstractEditor::CEAbstractEditor(CrystallographyExtension *ext)
    : CEAbstractDockWidget(ext),
      m_isLocked(false)
  {
    connect(this, SIGNAL(invalidInput()),
            this, SLOT(markAsInvalid()));
    connect(this, SIGNAL(validInput()),
            this, SLOT(markAsValid()));

    connect(m_ext, SIGNAL(cellChanged()),
            this, SLOT(refreshEditor()));

    connect(this, SIGNAL(visibilityChanged()),
            m_ext, SLOT(refreshActions()));

    connect(this, SIGNAL(editStarted()),
            m_ext, SLOT(lockEditors()));
    connect(this, SIGNAL(editAccepted()),
            m_ext, SLOT(unlockEditors()));
    connect(this, SIGNAL(editRejected()),
            m_ext, SLOT(unlockEditors()));

  }
Esempio n. 12
0
void SideBar::expand()
{
	KILE_DEBUG();
	if(!isMinimized()) {
		return;
	}

	KILE_DEBUG() << "directional size = " << m_directionalSize;
	if(m_orientation == Qt::Horizontal) {
		setMinimumHeight(0);
		setMaximumHeight(QWIDGETSIZE_MAX);
		m_tabStack->resize(m_tabStack->width(), m_directionalSize);
	}
	else if(m_orientation == Qt::Vertical) {
		setMinimumWidth(0);
		setMaximumWidth(QWIDGETSIZE_MAX);
		m_tabStack->resize(m_directionalSize, m_tabStack->height());
	}

	m_tabStack->setVisible(true);
	m_minimized = false;

	emit visibilityChanged(true);
}
Esempio n. 13
0
/*! \reimp */
bool QDockWidget::event(QEvent *event)
{
    Q_D(QDockWidget);

    QMainWindow *win = qobject_cast<QMainWindow*>(parentWidget());
    QMainWindowLayout *layout = qt_mainwindow_layout(win);

    switch (event->type()) {
#ifndef QT_NO_ACTION
    case QEvent::Hide:
        if (layout != 0)
            layout->keepSize(this);
        d->toggleViewAction->setChecked(false);
        emit visibilityChanged(false);
        break;
    case QEvent::Show: {
        d->toggleViewAction->setChecked(true);
        const QPoint parentTopLeft = isWindow() ?
            QApplication::desktop()->availableGeometry(this).topLeft() : QPoint(0, 0);
        emit visibilityChanged(geometry().right() >= parentTopLeft.x() && geometry().bottom() >= parentTopLeft.y());
}
        break;
#endif
    case QEvent::ApplicationLayoutDirectionChange:
    case QEvent::LayoutDirectionChange:
    case QEvent::StyleChange:
    case QEvent::ParentChange:
        d->updateButtons();
        break;
    case QEvent::ZOrderChange: {
        bool onTop = false;
        if (win != 0) {
            const QObjectList &siblings = win->children();
            onTop = siblings.count() > 0 && siblings.last() == (QObject*)this;
        }
        if (!isFloating() && layout != 0 && onTop)
            layout->raise(this);
        break;
    }
    case QEvent::WindowActivate:
    case QEvent::WindowDeactivate:
        update(qobject_cast<QDockWidgetLayout *>(this->layout())->titleArea());
        break;
    case QEvent::ContextMenu:
        if (d->state) {
            event->accept();
            return true;
        }
        break;
        // return true after calling the handler since we don't want
        // them to be passed onto the default handlers
    case QEvent::MouseButtonPress:
        if (d->mousePressEvent(static_cast<QMouseEvent *>(event)))
            return true;
        break;
    case QEvent::MouseButtonDblClick:
        if (d->mouseDoubleClickEvent(static_cast<QMouseEvent *>(event)))
            return true;
        break;
    case QEvent::MouseMove:
        if (d->mouseMoveEvent(static_cast<QMouseEvent *>(event)))
            return true;
        break;
    case QEvent::MouseButtonRelease:
        if (d->mouseReleaseEvent(static_cast<QMouseEvent *>(event)))
            return true;
        break;
    case QEvent::NonClientAreaMouseMove:
    case QEvent::NonClientAreaMouseButtonPress:
    case QEvent::NonClientAreaMouseButtonRelease:
    case QEvent::NonClientAreaMouseButtonDblClick:
        d->nonClientAreaMouseEvent(static_cast<QMouseEvent*>(event));
        return true;
    case QEvent::Move:
        d->moveEvent(static_cast<QMoveEvent*>(event));
        break;
    case QEvent::Resize:
        // if the mainwindow is plugging us, we don't want to update undocked geometry
        if (isFloating() && layout != 0 && layout->pluggingWidget != this)
            d->undockedGeometry = geometry();
        break;
    default:
        break;
    }
    return QWidget::event(event);
}
/*! \reimp */
bool QToolBar::event(QEvent *event)
{
    Q_D(QToolBar);

    switch (event->type()) {
    case QEvent::Timer:
        if (d->waitForPopupTimer.timerId() == static_cast<QTimerEvent*>(event)->timerId()) {
            QWidget *w = QApplication::activePopupWidget();
            if (!waitForPopup(this, w)) {
                d->waitForPopupTimer.stop();
                if (!this->underMouse())
                    d->layout->setExpanded(false);
            }
        }
        break;
    case QEvent::Hide:
        if (!isHidden())
            break;
    // fallthrough intended
    case QEvent::Show:
        d->toggleViewAction->setChecked(event->type() == QEvent::Show);
        emit visibilityChanged(event->type() == QEvent::Show);
#if defined(Q_WS_MAC)
        if (toolbarInUnifiedToolBar(this)) {
            // I can static_cast because I did the qobject_cast in the if above, therefore
            // we must have a QMainWindowLayout here.
            QMainWindowLayout *mwLayout = static_cast<QMainWindowLayout *>(parentWidget()->layout());
            mwLayout->fixSizeInUnifiedToolbar(this);
            mwLayout->syncUnifiedToolbarVisibility();
        }
#  if !defined(QT_MAC_USE_COCOA)
    // Fall through
    case QEvent::LayoutRequest: {
        // There's currently no way to invalidate the size and let
        // HIToolbar know about it. This forces a re-check.
        int earlyResult = -1;
        if (QMainWindow *mainWindow = qobject_cast<QMainWindow *>(parentWidget())) {
            bool needUpdate = true;
            if (event->type() == QEvent::LayoutRequest) {
                QSize oldSizeHint = sizeHint();
                earlyResult = QWidget::event(event) ? 1 : 0;
                needUpdate = oldSizeHint != sizeHint();
            }

            if (needUpdate) {
                OSWindowRef windowRef = qt_mac_window_for(mainWindow);
                if (toolbarInUnifiedToolBar(this)
                        && macWindowToolbarIsVisible(windowRef))   {
                    DisableScreenUpdates();
                    macWindowToolbarShow(this, false);
                    macWindowToolbarShow(this, true);
                    EnableScreenUpdates();
                }
            }

            if (earlyResult != -1)
                return earlyResult;
        }
    }
#  endif // !QT_MAC_USE_COCOA
#endif // Q_WS_MAC
    break;
    case QEvent::ParentChange:
        d->layout->checkUsePopupMenu();
#if defined(Q_WS_MAC)
        if (parentWidget() && parentWidget()->isWindow())
            qt_mac_updateToolBarButtonHint(parentWidget());
#endif
        break;

    case QEvent::MouseButtonPress: {
        if (d->mousePressEvent(static_cast<QMouseEvent*>(event)))
            return true;
        break;
    }
    case QEvent::MouseButtonRelease:
        if (d->mouseReleaseEvent(static_cast<QMouseEvent*>(event)))
            return true;
        break;
    case QEvent::HoverEnter:
    case QEvent::HoverLeave:
        // there's nothing special to do here and we don't want to update the whole widget
        return true;
    case QEvent::HoverMove: {
#ifndef QT_NO_CURSOR
        QHoverEvent *e = static_cast<QHoverEvent*>(event);
        QStyleOptionToolBar opt;
        initStyleOption(&opt);
        if (style()->subElementRect(QStyle::SE_ToolBarHandle, &opt, this).contains(e->pos()))
            setCursor(Qt::SizeAllCursor);
        else
            unsetCursor();
#endif
        break;
    }
    case QEvent::MouseMove:
        if (d->mouseMoveEvent(static_cast<QMouseEvent*>(event)))
            return true;
        break;
#ifdef Q_WS_WINCE
    case QEvent::ContextMenu:
    {
        QContextMenuEvent* contextMenuEvent = static_cast<QContextMenuEvent*>(event);
        QWidget* child = childAt(contextMenuEvent->pos());
        QAbstractButton* button = qobject_cast<QAbstractButton*>(child);
        if (button)
            button->setDown(false);
    }
    break;
#endif
    case QEvent::Leave:
        if (d->state != 0 && d->state->dragging) {
#ifdef Q_OS_WIN
            // This is a workaround for loosing the mouse on Vista.
            QPoint pos = QCursor::pos();
            QMouseEvent fake(QEvent::MouseMove, mapFromGlobal(pos), pos, Qt::NoButton,
                             QApplication::mouseButtons(), QApplication::keyboardModifiers());
            d->mouseMoveEvent(&fake);
#endif
        } else {
            if (!d->layout->expanded)
                break;

            QWidget *w = QApplication::activePopupWidget();
            if (waitForPopup(this, w)) {
                d->waitForPopupTimer.start(POPUP_TIMER_INTERVAL, this);
                break;
            }

            d->waitForPopupTimer.stop();
            d->layout->setExpanded(false);
            break;
        }
    default:
        break;
    }
    return QWidget::event(event);
}
Esempio n. 15
0
void TaxNodeSignalSender::VisibilityChanged(bool visible)
{
    if ( sendSignals )
        emit visibilityChanged(node, visible);
}
Esempio n. 16
0
void PlaylistDock::hideEvent(QHideEvent * /* event */)
{
    qDebug("PlaylistDock::hideEvent");
    emit visibilityChanged(false);
}
Esempio n. 17
0
void PlaylistDock::showEvent(QShowEvent * /* event */)
{
    qDebug("PlaylistDock::showEvent");
    emit visibilityChanged(true);
}
Esempio n. 18
0
void FindAndReplace::showEvent( QShowEvent * event )
{
    emit visibilityChanged( true );
    highlighter->rehighlight();
    QWidget::showEvent( event );
}
Esempio n. 19
0
void VCDockArea::hideEvent(QHideEvent* event)
{
    Q_UNUSED(event);
    emit visibilityChanged(false);
}
Esempio n. 20
0
void VCDockArea::showEvent(QShowEvent* event)
{
    Q_UNUSED(event);
    emit visibilityChanged(true);
}
Esempio n. 21
0
void QUmlConnectorObject::setVisibility(QtUml::VisibilityKind visibility)
{
    qmodelingelementproperty_cast<QUmlConnector *>(this)->setVisibility(visibility);
    emit visibilityChanged(this->visibility());
}
Esempio n. 22
0
void HUD::showEvent(QShowEvent* event)
{
    Q_UNUSED(event);
    emit visibilityChanged(true);
}
Esempio n. 23
0
 /**
  * This is implemented to send a signal when visibility changes
  *
  * @param event
  */
 void AdvancedStretchDialog::hideEvent(QHideEvent *event) {
   QDialog::hideEvent(event);
   emit visibilityChanged();
 }
Esempio n. 24
0
 /**
  * This is implemented to send a signal when visibility changes
  *
  * @param event
  */
 void AdvancedStretchDialog::showEvent(QShowEvent *event) {
   QDialog::showEvent(event);
   emit visibilityChanged();
 }
Esempio n. 25
0
void HUD::hideEvent(QHideEvent* event)
{
    Q_UNUSED(event);
    emit visibilityChanged(false);
}
void StatusIndicatorMenuWindow::displayActive()
{
    emit visibilityChanged(true);
    sceneManager()->appearSceneWindow(menuWidget);
}
void StatusIndicatorMenuWindow::hideWindow()
{
    hide();
    emit visibilityChanged(false);
}
Esempio n. 28
0
void QtDockRegion::addView(IView& view)
{
	auto qMainWindow = qtWindow_.window();
	assert(qMainWindow != nullptr);

	auto findIt = dockWidgetMap_.find(&view);
	if (findIt != dockWidgetMap_.end())
	{
		// already added into the dockWidget
		return;
	}
	// IView will not control qWidget's life-cycle after this call.
	auto qtFramework = get<IQtFramework>();
	assert(qtFramework != nullptr);
	auto qWidget = qtFramework->toQWidget(view);
	if (qWidget == nullptr)
	{
		return;
	}
	auto centralWidget = qMainWindow->centralWidget();
	if (centralWidget != nullptr)
	{
		centralWidget->layout()->addWidget(qWidget);
	}
	qWidget->setSizePolicy(qDockWidget_.sizePolicy());
	qWidget->setMinimumSize(qDockWidget_.minimumSize());
	qWidget->setMaximumSize(qDockWidget_.maximumSize());
	qWidget->setSizeIncrement(qDockWidget_.sizeIncrement());
	qWidget->setBaseSize(qDockWidget_.baseSize());
	qWidget->resize(qWidget->baseSize());

	auto qDockWidget = new NGTDockWidget(&view);
	qDockWidget->setObjectName(view.id());
	IView* pView = &view;
	QtWindow* pWindow = &qtWindow_;
	QObject::connect(qDockWidget, &QDockWidget::visibilityChanged, [qDockWidget, pWindow](bool visible) {
		qDockWidget->visibilityChanged(visible);
		if (visible)
		{
			if (pWindow->isLoadingPreferences())
			{
				return;
			}
			QCoreApplication::postEvent(qDockWidget, new QEvent(QEvent::FocusIn));
		}

	});

	if (qtWindow_.isReady())
	{
		bool isOk = qMainWindow->restoreDockWidget(qDockWidget);
		if (!isOk)
		{
			setDefaultPreferenceForDockWidget(qDockWidget);
		}
		QmlView* qmlView = dynamic_cast<QmlView*>(pView);
		if (qmlView != nullptr)
		{
			if (qDockWidget->isVisible() && qDockWidget->getVisibility())
			{
				qmlView->setNeedsToLoad(true);
			}
		}
	}
	else
	{
		needToRestorePreference_.push_back(std::make_pair(qDockWidget, pView));
	}
	qDockWidget->setWidget(qWidget);

	std::string actionId("View.");
	actionId += view.title();

	auto action = qtFramework->createAction(actionId.c_str(), view.title(), "View", [pView, qDockWidget](IAction*) {
		qDockWidget->show();
		qDockWidget->raise();
		pView->focusInEvent();
	});
	auto application = get<IUIApplication>();
	assert(application != nullptr);
	application->addAction(*action);

	dockWidgetMap_[&view] = std::make_pair(std::unique_ptr<QDockWidget>(qDockWidget), std::move(action));
}
Esempio n. 29
0
/*! \reimp */
bool QDockWidget::event(QEvent *event)
{
    Q_D(QDockWidget);

    QMainWindow *win = qobject_cast<QMainWindow*>(parentWidget());
    QMainWindowLayout *layout = qt_mainwindow_layout(win);

    switch (event->type()) {
#ifndef QT_NO_ACTION
    case QEvent::Hide:
        if (layout != 0)
            layout->keepSize(this);
        d->toggleViewAction->setChecked(false);
        emit visibilityChanged(false);
        break;
    case QEvent::Show:
        d->toggleViewAction->setChecked(true);
        emit visibilityChanged(geometry().right() >= 0 && geometry().bottom() >= 0);
        break;
#endif
    case QEvent::ApplicationLayoutDirectionChange:
    case QEvent::LayoutDirectionChange:
    case QEvent::StyleChange:
    case QEvent::ParentChange:
        d->updateButtons();
        break;
    case QEvent::ZOrderChange: {
        bool onTop = false;
        if (win != 0) {
            const QObjectList &siblings = win->children();
            onTop = siblings.count() > 0 && siblings.last() == (QObject*)this;
        }
        if (!isFloating() && layout != 0 && onTop)
            layout->raise(this);
        break;
    }
    case QEvent::WindowActivate:
    case QEvent::WindowDeactivate:
        update(qobject_cast<QDockWidgetLayout *>(this->layout())->titleArea());
        break;
    case QEvent::ContextMenu:
        if (d->state) {
            event->accept();
            return true;
        }
        break;
        // return true after calling the handler since we don't want
        // them to be passed onto the default handlers
    case QEvent::MouseButtonPress:
        if (d->mousePressEvent(static_cast<QMouseEvent *>(event)))
            return true;
        break;
    case QEvent::MouseButtonDblClick:
        if (d->mouseDoubleClickEvent(static_cast<QMouseEvent *>(event)))
            return true;
        break;
    case QEvent::MouseMove:
        if (d->mouseMoveEvent(static_cast<QMouseEvent *>(event)))
            return true;
        break;
#ifdef Q_OS_WIN
    case QEvent::Leave:
        if (d->state != 0 && d->state->dragging && !d->state->nca) {
            // This is a workaround for loosing the mouse on Vista.
            QPoint pos = QCursor::pos();
            QMouseEvent fake(QEvent::MouseMove, mapFromGlobal(pos), pos, Qt::NoButton,
                             QApplication::mouseButtons(), QApplication::keyboardModifiers());
            d->mouseMoveEvent(&fake);
        }
        break;
#endif
    case QEvent::MouseButtonRelease:
        if (d->mouseReleaseEvent(static_cast<QMouseEvent *>(event)))
            return true;
        break;
    case QEvent::NonClientAreaMouseMove:
    case QEvent::NonClientAreaMouseButtonPress:
    case QEvent::NonClientAreaMouseButtonRelease:
    case QEvent::NonClientAreaMouseButtonDblClick:
        d->nonClientAreaMouseEvent(static_cast<QMouseEvent*>(event));
        return true;
    case QEvent::Move:
        d->moveEvent(static_cast<QMoveEvent*>(event));
        break;
    case QEvent::Resize:
        // if the mainwindow is plugging us, we don't want to update undocked geometry
        if (isFloating() && layout != 0 && layout->pluggingWidget != this)
            d->undockedGeometry = geometry();
        break;
    default:
        break;
    }
    return QWidget::event(event);
}
Esempio n. 30
0
void FindAndReplace::hideEvent( QHideEvent * event )
{
    emit visibilityChanged( false );
    highlighter->clearHighlight();
    QWidget::hideEvent( event );
}