Beispiel #1
0
void
MacMenu::popup(qlonglong key, int idx, int x, int y)
{
    QMenuBar *menu = menuBar(key);
    if (!menu) return;

    QMenu *pop;
    for (int i = 0; i < menu->actions().count(); ++i)
    {
        if (!(pop = menu->actions().at(i)->menu()))
            continue;

        if (i == idx) {
            if (!pop->isVisible())
            {
                connect (pop, SIGNAL(aboutToHide()), this, SLOT(menuClosed()));
                XBAR_SEND( MSG("setOpenPopup") << idx );
                pop->popup(QPoint(x,y));
            }
            else
            {
                XBAR_SEND( MSG("setOpenPopup") << -1000 );
                pop->hide();
            }
        }
        else
            pop->hide();
    }
}
Beispiel #2
0
QT_END_NAMESPACE
#endif

void tst_QMenu::focus()
{
    QMenu menu;
    menu.addAction("One");
    menu.addAction("Two");
    menu.addAction("Three");

#ifdef Q_OS_MAC
    if (!qt_tab_all_widgets())
        QSKIP("Computer is currently set up to NOT tab to all widgets,"
             " this test assumes you can tab to all widgets");
#endif

    QWidget window;
    QPushButton button("Push me", &window);
    window.show();
    qApp->setActiveWindow(&window);

    QVERIFY(button.hasFocus());
    QCOMPARE(QApplication::focusWidget(), (QWidget *)&button);
    QCOMPARE(QApplication::activeWindow(), &window);
    menu.show();
    QVERIFY(button.hasFocus());
    QCOMPARE(QApplication::focusWidget(), (QWidget *)&button);
    QCOMPARE(QApplication::activeWindow(), &window);
    menu.hide();
    QVERIFY(button.hasFocus());
    QCOMPARE(QApplication::focusWidget(), (QWidget *)&button);
    QCOMPARE(QApplication::activeWindow(), &window);
}
QVBoxLayout * MENU_KERNEL::CREATE_NEW_MENU_COLUMN ( QLayout * layout,QList<QMenu *> * action_menu,QLayout * parent_layout,int index)
{
    if ( layout NE NULL ) {
         action_menu->clear();
    }

    QFrame      * container          = new QFrame ( this ) ;
    QVBoxLayout * vertical_layout    = new QVBoxLayout ( container );

    container->setLayout ( vertical_layout );

    if ( M_KERNEL_MENU_SECENEGI[index].is_visible EQ true AND ( M_KERNEL_MENU_SECENEGI [ index ].menu_column_visibility EQ MENU_HERYERDE OR M_KERNEL_MENU_SECENEGI[index].menu_column_visibility EQ MENU_SAYFADA) ) {
         parent_layout->addWidget ( container );
        if (M_KERNEL_MENU_SECENEGI [ index ].num_of_childs EQ 0 )  {
            container->hide();
            QHBoxLayout * box_layout = static_cast< QHBoxLayout * > ( parent_layout ) ;
            box_layout->addSpacerItem ( new QSpacerItem ( 40,20,QSizePolicy::Expanding,QSizePolicy::Fixed ) );
        }
    }
    else {
        container->hide();
    }

    QMenu * menu = new QMenu ( M_KERNEL_MENU_SECENEGI[index].text_to_display );
    *action_menu << menu;

    if ( M_KERNEL_MENU_SECENEGI[index].is_visible EQ true AND ( M_KERNEL_MENU_SECENEGI [ index ].menu_column_visibility EQ MENU_HERYERDE OR M_KERNEL_MENU_SECENEGI[index].menu_column_visibility EQ MENU_TOPMENUDE) ) {
         this->menuBar()->addMenu ( menu );
    }

    SET_WIDGET_DEFAULTS( action_menu->last(),index );
    menu->hide();

    QVBoxLayout * menu_header_vertical_layout  = ADD_FRAME ( vertical_layout,container,MENU_HEADER_ITEM,index );
    QVBoxLayout * menu_body_vertical_layout    = ADD_FRAME ( vertical_layout,container,MENU_BODY_ITEM  ,index );

    if ( M_KERNEL_MENU_SECENEGI[index].num_of_childs NE 0 ) {
        ADD_MENU_KERNEL_LABEL ( menu_header_vertical_layout,MENU_HEADER_ITEM,M_KERNEL_MENU_SECENEGI [index].tab_str + M_KERNEL_MENU_SECENEGI[index].text_to_display,index);
    }
    else {
        ADD_MENU_KERNEL_BUTTON ( menu_header_vertical_layout,MENU_HEADER_ITEM,M_KERNEL_MENU_SECENEGI[index].tab_str + M_KERNEL_MENU_SECENEGI[index].text_to_display,index);
    }

    return menu_body_vertical_layout;
}
Beispiel #4
0
QT_END_NAMESPACE
#endif

void tst_QMenu::focus()
{
    QMenu menu;
    menu.addAction("One");
    menu.addAction("Two");
    menu.addAction("Three");
    bool fullKeyboardControl = true;

#ifdef Q_WS_MAC
    fullKeyboardControl = qt_tab_all_widgets;
#endif

    if (!fullKeyboardControl)
        QSKIP("Computer is currently set up to NOT tab to all widgets,"
             " this test assumes you can tab to all widgets", SkipAll);

    QWidget window;
    QPushButton button("Push me", &window);
    window.show();
    qApp->setActiveWindow(&window);

    QVERIFY(button.hasFocus());
    QCOMPARE(QApplication::focusWidget(), (QWidget *)&button);
    QCOMPARE(QApplication::activeWindow(), &window);
    menu.show();
#if 0
    QVERIFY(!button.hasFocus());
    QCOMPARE(QApplication::focusWidget(), &menu);
    QCOMPARE(QApplication::activeWindow(), &window);
#else
    QVERIFY(button.hasFocus());
    QCOMPARE(QApplication::focusWidget(), (QWidget *)&button);
    QCOMPARE(QApplication::activeWindow(), &window);
#endif
    menu.hide();
    QVERIFY(button.hasFocus());
    QCOMPARE(QApplication::focusWidget(), (QWidget *)&button);
    QCOMPARE(QApplication::activeWindow(), &window);
}
Beispiel #5
0
		bool HelpViewer::eventFilter(QObject*, QEvent* e) 
		{
			/////////////////////////////////////////////
			// Prevent opening a menu entry when obtaining whats this info for a menu entry
			/////////////////////////////////////////////
			if (ignore_event_)
			{
				if (e->type() == QEvent::MouseButtonRelease)
				{
					ignore_event_ = false;
					getMainControl()->menuBar()->hide();
					getMainControl()->menuBar()->show();
					return true;
				}

				return false;
			}
			
			/////////////////////////////////////////////
			// Show Documentation if F1 is pressed
			/////////////////////////////////////////////
			if (e->type() == QEvent::KeyPress)
			{
				QKeyEvent* ke = (QKeyEvent*) e;
				if (ke->key() != Qt::Key_F1 ||
 						ke->modifiers() != Qt::NoModifier)
				{
					return false;
				}

				if (ke->key() == Qt::Key_Escape) 
				{
					if (whats_this_mode_)
					{
						exitWhatsThisMode();
						return true;
					}
				}

				showDocumentationForObject();
				return true;
			}

			/////////////////////////////////////////////
			// now react only in whats this mode and if a mouse button is pressed
			/////////////////////////////////////////////
			if (!whats_this_mode_ ||
					e->type() != QEvent::MouseButtonPress)
			{
				return false;
			}

			/////////////////////////////////////////////
			// exit whats this mode with right mouse click
			/////////////////////////////////////////////
			QMouseEvent* me = (QMouseEvent*) e;
			if (me->button() != Qt::LeftButton)
			{
				exitWhatsThisMode();
				return true;
			}

			if (me->button() != Qt::LeftButton) return false;
		
			QPoint point = QCursor::pos();
			QWidget* widget = qApp->widgetAt(point);
			QMenu* menu = 0;
			QMenuBar* menu_bar = 0;
			
			if (widget != 0) 
			{
				menu     = dynamic_cast<QMenu*>(widget);
				menu_bar = dynamic_cast<QMenuBar*>(widget);
			}

			if (menu_bar != 0) return false;

			bool shown_docu = showDocumentationForObject();

			if (menu != 0)
			{
				if (shown_docu)
				{
					menu->hide();
				}
				else
				{
					return false;
				}
			}

			return true;
		}