void tst_QToolBar::task197996_visibility() { QMainWindow mw; QToolBar *toolBar = new QToolBar(&mw); mw.addToolBar(toolBar); toolBar->addAction(new QAction("Foo", &mw)); QAction *pAction = new QAction("Test", &mw); toolBar->addAction(pAction); pAction->setVisible(false); toolBar->setVisible(false); toolBar->setVisible(true); pAction->setVisible(true); mw.show(); QVERIFY(toolBar->widgetForAction(pAction)->isVisible()); toolBar->setVisible(false); pAction->setVisible(false); toolBar->setVisible(true); pAction->setVisible(true); QTest::qWait(100); QVERIFY(toolBar->widgetForAction(pAction)->isVisible()); }
static QToolBar* createToolBar(const QString& name, QWidget* parent, bool visible) { QToolBar* bar = new QToolBar(parent); bar->setObjectName(name); bar->setFloatable(false); bar->setMovable(true); bar->setVisible(visible); return bar; }
void EditorView::addEditor(IEditor *editor) { if (m_editors.contains(editor)) return; m_editors.append(editor); m_container->addWidget(editor->widget()); m_widgetEditorMap.insert(editor->widget(), editor); QToolBar *toolBar = editor->toolBar(); if (toolBar) { toolBar->setVisible(false); // will be made visible in setCurrentEditor m_toolBar->layout()->addWidget(toolBar); } connect(editor, SIGNAL(changed()), this, SLOT(checkEditorStatus())); if (editor == currentEditor()) setCurrentEditor(editor); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), pSettings_(NULL), redValue_(0), greenValue_(0), blueValue_(0), pRedLabel_(NULL), pGreenLabel_(NULL), pBlueLabel_(NULL), pRedValueLabel_(NULL), pGreenValueLabel_(NULL), pBlueValueLabel_(NULL), pRedSlider_(NULL), pGreenSlider_(NULL), pBlueSlider_(NULL) { ui->setupUi(this); QString settingsFilePath = QDir::homePath() + "/.colorsrc"; pSettings_ = new QSettings(settingsFilePath, QSettings::NativeFormat, this); redValue_ = static_cast<uint8_t>(pSettings_->value(redValueKey).toInt()); greenValue_ = static_cast<uint8_t>(pSettings_->value(greenValueKey).toInt()); blueValue_ = static_cast<uint8_t>(pSettings_->value(blueValueKey).toInt()); // hides all main window normal GUI related stuff QObjectList childObjects = children(); foreach (QObject* pChildObject, childObjects) { QToolBar* pToolBar = qobject_cast<QToolBar*>(pChildObject); if (pToolBar) pToolBar->setVisible(false); QStatusBar* pStatusBar = qobject_cast<QStatusBar*>(pChildObject); if (pStatusBar) pStatusBar->setVisible(false); QMenuBar* pMenuBar = qobject_cast<QMenuBar*>(pChildObject); if (pMenuBar) pMenuBar->setVisible(false); }
void MainWindow::createToolBars() { m_tabBar = new QTabBar(); m_tabBar->setDocumentMode(true); m_tabBar->setTabsClosable(true); m_tabBar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); #ifdef Q_OS_MAC m_tabBar->setDrawBase(false); #endif connect(m_tabBar, SIGNAL(currentChanged(int)), this, SLOT(onTabChanged(int))); connect(m_tabBar, SIGNAL(tabCloseRequested(int)), this, SLOT(onTabCloseRequested(int))); QToolBar* toolBar = new QToolBar(tr("Game Tabs")); toolBar->setVisible(false); toolBar->setFloatable(false); toolBar->setMovable(false); toolBar->setAllowedAreas(Qt::TopToolBarArea); toolBar->addWidget(m_tabBar); addToolBar(toolBar); }
void MainWindow::createToolBars() { m_tabBar = new GameTabBar(); m_tabBar->setDocumentMode(true); m_tabBar->setTabsClosable(true); m_tabBar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); connect(m_tabBar, SIGNAL(currentChanged(int)), this, SLOT(onTabChanged(int))); connect(m_tabBar, SIGNAL(tabCloseRequested(int)), this, SLOT(onTabCloseRequested(int))); connect(m_showPreviousTabAct, SIGNAL(triggered()), m_tabBar, SLOT(showPreviousTab())); connect(m_showNextTabAct, SIGNAL(triggered()), m_tabBar, SLOT(showNextTab())); QToolBar* toolBar = new QToolBar(tr("Game Tabs")); toolBar->setVisible(false); toolBar->setFloatable(false); toolBar->setMovable(false); toolBar->setAllowedAreas(Qt::TopToolBarArea); toolBar->addWidget(m_tabBar); addToolBar(toolBar); }
bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*> &_toolBars, uchar tmarker) { QList<QToolBar*> toolBars = _toolBars; int lines; stream >> lines; for (int j = 0; j < lines; ++j) { int pos; stream >> pos; if (pos < 0 || pos >= QInternal::DockCount) return false; int cnt; stream >> cnt; QToolBarAreaLayoutInfo &dock = docks[pos]; QToolBarAreaLayoutLine line(dock.o); for (int k = 0; k < cnt; ++k) { QToolBarAreaLayoutItem item; QString objectName; stream >> objectName; uchar shown; stream >> shown; stream >> item.pos; stream >> item.size; /* 4.3.0 added floating toolbars, but failed to add the ability to restore them. We need to store there geometry (four ints). We cannot change the format in a patch release (4.3.1) by adding ToolBarStateMarkerEx2 to signal extra data. So for now we'll pack it in the two legacy ints we no longer used in Qt4.3.0. In 4.4, we should add ToolBarStateMarkerEx2 and fix this properly. */ QRect rect; bool floating = false; uint geom0, geom1; stream >> geom0; if (tmarker == ToolBarStateMarkerEx) { stream >> geom1; rect = unpackRect(geom0, geom1, &floating); } QToolBar *toolBar = 0; for (int x = 0; x < toolBars.count(); ++x) { if (toolBars.at(x)->objectName() == objectName) { toolBar = toolBars.takeAt(x); break; } } if (toolBar == 0) { continue; } item.widgetItem = new QWidgetItem(toolBar); toolBar->setOrientation(floating ? Qt::Horizontal : dock.o); toolBar->setVisible(shown); toolBar->d_func()->setWindowState(floating, true, rect); line.toolBarItems.append(item); } dock.lines.append(line); }