void tst_QToolBar::visibilityChanged() { QMainWindow mw; QToolBar tb; QSignalSpy spy(&tb, SIGNAL(visibilityChanged(bool))); mw.addToolBar(&tb); mw.show(); QCOMPARE(spy.count(), 1); QCOMPARE(spy.at(0).at(0).toBool(), true); spy.clear(); tb.hide(); QCOMPARE(spy.count(), 1); QCOMPARE(spy.at(0).at(0).toBool(), false); spy.clear(); tb.hide(); QCOMPARE(spy.count(), 0); tb.show(); QCOMPARE(spy.count(), 1); QCOMPARE(spy.at(0).at(0).toBool(), true); spy.clear(); tb.show(); QCOMPARE(spy.count(), 0); }
void FullscreenSpacerLabel::mouseMoveEvent (QMouseEvent *event) { MainWindow *wnd = Core::Instance ().GetReallyMainWindow (); if (wnd && (wnd->windowState () == Qt::WindowFullScreen)) { QMenuBar *menu = wnd->findChild<QMenuBar*> ("MenuBar_"); if (!menu) { qWarning () << Q_FUNC_INFO << "menu is null"; return; } QToolBar *toolbar = wnd->findChild<QToolBar*> ("MainToolbar_"); if (!toolbar) { qWarning () << Q_FUNC_INFO << "toolbar is null"; return; } LeechCraft::TabWidget *tabwidget = wnd->GetTabWidget (); if (!tabwidget) { qWarning () << Q_FUNC_INFO << "tabwidget is null"; return; } QToolBar *bar = Core::Instance ().GetToolBar (tabwidget->currentIndex ()); if (!bar) { qWarning () << Q_FUNC_INFO << "bar is null"; return; } const bool asButton = XmlSettingsManager::Instance ()->property ("ShowMenuBarAsButton").toBool (); if (event->y () < 5) { if (asButton) menu->hide (); else if (menu->isHidden ()) menu->show (); if (toolbar->isHidden ()) toolbar->show (); if (bar && bar->isHidden ()) bar->show (); } else { if (!menu->isHidden ()) menu->hide (); if (!toolbar->isHidden ()) toolbar->hide (); if (bar && !bar->isHidden ()) bar->hide (); } } }
Buttons() { QIcon icon; icon.addFile(":/[email protected]"); QPushButton *button = new QPushButton(this); button->setIcon(icon); button->setText("16@2x"); QTabBar *tab = new QTabBar(this); tab->addTab(QIcon(":/qticon16.png"), "16@1x"); tab->addTab(QIcon(":/[email protected]"), "16@2x"); tab->addTab(QIcon(":/qticon16.png"), ""); tab->addTab(QIcon(":/[email protected]"), ""); tab->move(10, 100); tab->show(); QToolBar *toolBar = new QToolBar(this); toolBar->addAction(QIcon(":/qticon16.png"), "16"); toolBar->addAction(QIcon(":/[email protected]"), "16@2x"); toolBar->addAction(QIcon(":/qticon32.png"), "32"); toolBar->addAction(QIcon(":/[email protected]"), "32@2x"); toolBar->move(10, 200); toolBar->show(); }
void QtTrader::createGUI () { QMenuBar *menuBar = new QMenuBar(); setMenuBar(menuBar); QMenu *menu = new QMenu("&Help"); QAction* a = new QAction(QIcon(":icons/info"), tr("&About"), this); a->setIconVisibleInMenu(true); connect(a, SIGNAL(activated()), this, SLOT(about())); menu->addAction(a); menuBar->addMenu(menu); statusBar()->showMessage(tr("Ready"), 2000); QSettings settings(g_settings); settings.beginGroup("plugins"); QStringList value = settings.value("gui").toStringList(); settings.endGroup(); QToolBar* toolbar = new QToolBar(); for(int i = 0; i<value.size(); i++){ toolbar->addAction(value.at(i), this, SLOT(pluginLoader())); } toolbar->show(); toolbar->setObjectName("MainToolbar"); addToolBar(toolbar); setUnifiedTitleAndToolBarOnMac(true); }
void ViewerTab::setRotoInterface(NodeGui* n) { assert(n); std::map<NodeGui*,RotoGui*>::iterator it = _imp->rotoNodes.find(n); if ( it != _imp->rotoNodes.end() ) { if (_imp->currentRoto.first == n) { return; } ///remove any existing roto gui if (_imp->currentRoto.first != NULL) { removeRotoInterface(_imp->currentRoto.first, false,true); } ///Add the widgets QToolBar* toolBar = it->second->getToolBar(); _imp->viewerLayout->insertWidget(0, toolBar); { QMutexLocker l(&_imp->visibleToolbarsMutex); if (_imp->leftToolbarVisible) { toolBar->show(); } } ///If there's a tracker add it right after the tracker int index; if (_imp->currentTracker.second) { index = _imp->mainLayout->indexOf( _imp->currentTracker.second->getButtonsBar() ); assert(index != -1); if (index >= 0) { ++index; } } else { index = _imp->mainLayout->indexOf(_imp->viewerContainer); } assert(index >= 0); if (index >= 0) { QWidget* buttonsBar = it->second->getCurrentButtonsBar(); assert(buttonsBar); if (buttonsBar) { _imp->mainLayout->insertWidget(index,buttonsBar); { QMutexLocker l(&_imp->visibleToolbarsMutex); if (_imp->topToolbarVisible) { buttonsBar->show(); } } } } QObject::connect( it->second,SIGNAL(roleChanged(int,int)),this,SLOT(onRotoRoleChanged(int,int)) ); _imp->currentRoto.first = n; _imp->currentRoto.second = it->second; _imp->viewer->redraw(); } }
/** * Funcion encargada de crear la GUI. * @b NOTA: esta funcion hace parte del motor de creacion de GUI en base a archivos XML. */ void sbgui::GUIMdiMainWindow::crearGUI() { if( parser ) { QStringList nombres = parser->obtenerNombres(); HashMenu menusInfo = parser->obtenerMenus(); for(uint i = 0; i < nombres.count(); i++) { QToolBar *toolBarTmp = new QToolBar(this, nombres[i]); moveDockWindow(toolBarTmp, Qt::DockTop); toolBarTmp->show(); QStringList *strlistTmp = menusInfo.find((nombres)[i]); if (strlistTmp == 0) { std::cout << "GADMainWindow::crearGUI(): Error" << std::endl; return; } for (uint j = 0; j < strlistTmp->count(); j+=3) { QAction *actTmp = new QAction(toolBarTmp, (*strlistTmp)[j]); connect( actTmp, SIGNAL( activated() ) , this, SLOT( slotPrincipal() ) ); // FIXME: colocar la ruta bien. QPixmap pm( sbqpack::GUIDATADIR + (*strlistTmp)[j+1]); if ( ! pm.isNull() ) actTmp->setIconSet( pm ); actTmp->setToolTip( (*strlistTmp)[j+2] ); actTmp->addTo(toolBarTmp); } } } }
/*! * \en * Constuct object * \_en * \ru * Создает объект * \_ru */ aReportBrowser::aReportBrowser( QWidget *parent, const char *name, WFlags f ) :QMainWindow( parent, name, f ) { QAction *a; QToolBar *t = new QToolBar( this, "ReportTool" ); a = new QAction( QPixmap::fromMimeSource("print.png"), tr("Print"), QKeySequence("Ctrl+P"), t, tr("Print report") ); a->addTo( t ); connect( a, SIGNAL( activated() ), this, SLOT( print() ) ); a = new QAction( QPixmap::fromMimeSource("filesave.png"), tr("Save As"), QKeySequence("Ctrl+S"), t, tr("Save report to file") ); a->addTo( t ); connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); t->show(); textBrowser = new QTextBrowser( this, "textBrowser" ); textBrowser->setTextFormat( QTextBrowser::RichText ); textBrowser->setFocus(); // textBrowser->showMaximized(); setCentralWidget( textBrowser ); // if ( layout() ) delete layout(); // QGridLayout *l = new QGridLayout( this ); // l->addWidget( textBrowser, 1, 0 ); languageChange(); }
void tst_QToolBar::actionTriggered() { QToolBar tb; connect(&tb, SIGNAL(actionTriggered(QAction *)), SLOT(slot(QAction *))); QAction action1(0); QAction action2(0); QAction action3(0); QAction action4(0); tb.addAction(&action1); tb.addAction(&action2); tb.addAction(&action3); tb.addAction(&action4); tb.show(); #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&tb); #endif QList<QToolBarExtension *> extensions = tb.findChildren<QToolBarExtension *>(); QRect rect01; QRect rect02; QRect rect03; QRect rect04; QMenu *popupMenu; if (extensions.size() != 0) { QToolBarExtension *extension = extensions.at(0); if (extension->isVisible()) { QRect rect0 = extension->geometry(); QTest::mouseClick( extension, Qt::LeftButton, 0, rect0.center(), -1 ); QApplication::processEvents(); popupMenu = qobject_cast<QMenu *>(extension->menu()); rect01 = popupMenu->actionGeometry(&action1); rect02 = popupMenu->actionGeometry(&action2); rect03 = popupMenu->actionGeometry(&action3); rect04 = popupMenu->actionGeometry(&action4); } } QRect rect1 = tb.actionGeometry(&action1); QRect rect2 = tb.actionGeometry(&action2); QRect rect3 = tb.actionGeometry(&action3); QRect rect4 = tb.actionGeometry(&action4); QAbstractButton *button1; QAbstractButton *button2; QAbstractButton *button3; QAbstractButton *button4; if (!rect01.isValid()) { button1 = qobject_cast<QAbstractButton *>(tb.childAt(rect1.center())); QVERIFY(button1 != 0); } if (!rect02.isValid()) { button2 = qobject_cast<QAbstractButton *>(tb.childAt(rect2.center())); QVERIFY(button2 != 0); } if (!rect03.isValid()) { button3 = qobject_cast<QAbstractButton *>(tb.childAt(rect3.center())); QVERIFY(button3 != 0); } if (!rect04.isValid()) { button4 = qobject_cast<QAbstractButton *>(tb.childAt(rect4.center())); QVERIFY(button4 != 0); } ::triggered = 0; if (!rect01.isValid()) QTest::mouseClick(button1, Qt::LeftButton); else QTest::mouseClick(popupMenu, Qt::LeftButton, 0, rect01.center(), -1 ); QCOMPARE(::triggered, &action1); ::triggered = 0; if (!rect02.isValid()) QTest::mouseClick(button2, Qt::LeftButton); else QTest::mouseClick(popupMenu, Qt::LeftButton, 0, rect02.center(), -1 ); QCOMPARE(::triggered, &action2); ::triggered = 0; if (!rect03.isValid()) QTest::mouseClick(button3, Qt::LeftButton); else QTest::mouseClick(popupMenu, Qt::LeftButton, 0, rect03.center(), -1 ); QCOMPARE(::triggered, &action3); ::triggered = 0; if (!rect04.isValid()) QTest::mouseClick(button4, Qt::LeftButton); else QTest::mouseClick(popupMenu, Qt::LeftButton, 0, rect04.center(), -1 ); QCOMPARE(::triggered, &action4); }
void tst_QToolBar::actionGeometry() { QToolBar tb; QAction action1(0); QAction action2(0); QAction action3(0); QAction action4(0); tb.addAction(&action1); tb.addAction(&action2); tb.addAction(&action3); tb.addAction(&action4); tb.show(); #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&tb); #endif QList<QToolBarExtension *> extensions = tb.findChildren<QToolBarExtension *>(); QRect rect01; QRect rect02; QRect rect03; QRect rect04; QMenu *popupMenu; if (extensions.size() != 0) { QToolBarExtension *extension = extensions.at(0); if (extension->isVisible()) { QRect rect0 = extension->geometry(); QTest::mouseClick( extension, Qt::LeftButton, 0, rect0.center(), -1 ); QApplication::processEvents(); popupMenu = qobject_cast<QMenu *>(extension->menu()); rect01 = popupMenu->actionGeometry(&action1); rect02 = popupMenu->actionGeometry(&action2); rect03 = popupMenu->actionGeometry(&action3); rect04 = popupMenu->actionGeometry(&action4); } } QRect rect1 = tb.actionGeometry(&action1); QRect rect2 = tb.actionGeometry(&action2); QRect rect3 = tb.actionGeometry(&action3); QRect rect4 = tb.actionGeometry(&action4); QVERIFY(rect1.isValid()); QVERIFY(!rect1.isNull()); QVERIFY(!rect1.isEmpty()); QVERIFY(rect2.isValid()); QVERIFY(!rect2.isNull()); QVERIFY(!rect2.isEmpty()); QVERIFY(rect3.isValid()); QVERIFY(!rect3.isNull()); QVERIFY(!rect3.isEmpty()); QVERIFY(rect4.isValid()); QVERIFY(!rect4.isNull()); QVERIFY(!rect4.isEmpty()); if (rect01.isValid()) QCOMPARE(popupMenu->actionAt(rect01.center()), &action1); else QCOMPARE(tb.actionAt(rect1.center()), &action1); if (rect02.isValid()) QCOMPARE(popupMenu->actionAt(rect02.center()), &action2); else QCOMPARE(tb.actionAt(rect2.center()), &action2); if (rect03.isValid()) QCOMPARE(popupMenu->actionAt(rect03.center()), &action3); else QCOMPARE(tb.actionAt(rect3.center()), &action3); if (rect04.isValid()) QCOMPARE(popupMenu->actionAt(rect04.center()), &action4); else QCOMPARE(tb.actionAt(rect4.center()), &action4); }