Пример #1
0
void PopupMenu::closeUp()
{
  if(isVisible())
  {
    DEBUG_PRST_ROUTES(stderr, "PopupMenu::closeUp() this:%p closing\n", this);
    close();
  }
  
  QAction* act = menuAction();
  if(act)
  {
    DEBUG_PRST_ROUTES(stderr, "PopupMenu::closeUp() this:%p menuAction:%p\n", this, act);
    const int sz = act->associatedWidgets().size();
    for(int i = 0; i < sz; ++i)
    {
      DEBUG_PRST_ROUTES(stderr, "   associated widget#:%d\n", i);
      if(PopupMenu* pup = qobject_cast<PopupMenu*>(act->associatedWidgets().at(i)))
      {
        DEBUG_PRST_ROUTES(stderr, "   associated popup:%p\n", pup);
        DEBUG_PRST_ROUTES(stderr, "   closing...\n");
        pup->closeUp();
      }
    }
  }
}
/*
    Checks if an expanded toolbar has to wait for this popup to close before
    the toolbar collapses. This is true if
    1) the popup has the toolbar in its parent chain,
    2) the popup is a menu whose menuAction is somewhere in the toolbar.
*/
static bool waitForPopup(QToolBar *tb, QWidget *popup)
{
    if (popup == 0 || popup->isHidden())
        return false;

    QWidget *w = popup;
    while (w != 0) {
        if (w == tb)
            return true;
        w = w->parentWidget();
    }

    QMenu *menu = qobject_cast<QMenu*>(popup);
    if (menu == 0)
        return false;

    QAction *action = menu->menuAction();
    QList<QWidget*> widgets = action->associatedWidgets();
    for (int i = 0; i < widgets.count(); ++i) {
        if (waitForPopup(tb, widgets.at(i)))
            return true;
    }

    return false;
}
Пример #3
0
QList<QWidget*> QActionProto::associatedWidgets() const
{
  QAction *item = qscriptvalue_cast<QAction*>(thisObject());
  if (item)
    return item->associatedWidgets();
  return QList<QWidget*>();
}
Пример #4
0
int Action::associatedWidgets(lua_State * L) // const : QList<QWidget *>
{	
    QAction* obj = QtObject<QAction>::check( L, 1);
	QList<QWidget *> r = obj->associatedWidgets();
	lua_newtable( L );
	int t = lua_gettop( L );
	for( int i = 0; i < r.size(); ++i )
	{
		Util::push( L, i + 1 );
        QtObject<QWidget>::create( L, r[i] );
        lua_rawset( L, t );
	}
	return 1;
}
Пример #5
0
GUIPluginBase::~GUIPluginBase()
{
    qDebug("--GUIPluginBase::~GUIPluginBase()");

    //unload();

    if (m_menu) {
        QAction *action = m_menu->menuAction();
        QList<QWidget *> widgetList = action->associatedWidgets();
        foreach(QWidget *widget, widgetList) {
            widget->removeAction(action);
        }

        QList<QGraphicsWidget *> graphicsWidgetList = action->associatedGraphicsWidgets();
        foreach(QGraphicsWidget *graphicsWidget, graphicsWidgetList) {
            graphicsWidget->removeAction(action);
        }