void TabWidget::moveTab(QWidget* what,TabWidget *where){ TabWidget* from = dynamic_cast<TabWidget*>(what->parentWidget()); if(!from){ return; } if(from == where){ /*We check that even if it is the same TabWidget, it really exists.*/ bool found = false; for (int i =0; i < from->count(); ++i) { if (what == from->tabAt(i)) { found = true; break; } } if (found) { return; } //it wasn't found somehow } from->removeTab(what); assert(where); where->appendTab(what); what->setParent(where); where->getGui()->getApp()->triggerAutoSave(); }
/*! * Обработка успешной синхронизации настроек с сервером. * * Открываются и закрепляются все ранее закреплённые разговоры. */ void StateCache::synced() { m_tabs = m_settings->value(m_key).toStringList(); const int policy = ChatClient::channels()->policy(); if (policy & ServerFeed::MainChannelPolicy && m_tabs.isEmpty() && m_settings->value(SETTINGS_AUTO_JOIN).toBool()) m_tabs.append(SimpleID::encode(ChatClient::channels()->mainId())); TabWidget *tabs = TabWidget::i(); if (!tabs) return; foreach (const QString &text, m_tabs) { const QByteArray id = decode(text); if (Channel::isCompatibleId(id)) join(id); } if (!m_tabs.isEmpty() && restoreLastTalk()) return; if (policy & ServerFeed::ForcedJoinPolicy) return; if (!tabs->channelsCount()) tabs->tab("list"); tabs->closePage("progress"); tabs->closePage("welcome"); }
WebView *TabWidget::webView(int index) const { QWidget *widget = this->widget(index); if (WebViewWithSearch *webViewWithSearch = qobject_cast<WebViewWithSearch*>(widget)) { return webViewWithSearch->m_webView; } else if (widget) { // optimization to delay creating the first webview if (count() == 1) { TabWidget *that = const_cast<TabWidget*>(this); that->setUpdatesEnabled(false); LocationBar *currentLocationBar = qobject_cast<LocationBar*>(m_locationBars->widget(0)); bool giveBackFocus = currentLocationBar->hasFocus(); m_locationBars->removeWidget(currentLocationBar); m_locationBars->addWidget(new QWidget()); that->newTab(); that->closeTab(0); QWidget *newEmptyLineEdit = m_locationBars->widget(0); m_locationBars->removeWidget(newEmptyLineEdit); newEmptyLineEdit->deleteLater(); m_locationBars->addWidget(currentLocationBar); currentLocationBar->setWebView(currentWebView()); if (giveBackFocus) currentLocationBar->setFocus(); that->setUpdatesEnabled(true); that->m_swappedDelayedWidget = true; return currentWebView(); } } return 0; }
void GuiPrivate::notifyGuiClosing() { ///This is to workaround an issue that when destroying a widget it calls the focusOut() handler hence can ///cause bad pointer dereference to the Gui object since we're destroying it. std::list<TabWidgetI*> tabs = _gui->getApp()->getTabWidgetsSerialization(); for (std::list<TabWidgetI*>::iterator it = tabs.begin(); it != tabs.end(); ++it) { TabWidget* tab = dynamic_cast<TabWidget*>(*it); if (!tab) { continue; } tab->discardGuiPointer(); for (int i = 0; i < tab->count(); ++i) { tab->tabAt(i)->notifyGuiClosingPublic(); } } const NodesGuiList allNodes = _nodeGraphArea->getAllActiveNodes(); // we do not need this list anymore, avoid using it _gui->getApp()->clearSettingsPanels(); for (NodesGuiList::const_iterator it = allNodes.begin(); it != allNodes.end(); ++it) { DockablePanel* panel = (*it)->getSettingPanel(); if (panel) { panel->onGuiClosing(); } } _lastFocusedGraph = 0; }
void Gui::createGroupGui(const NodePtr & group, CreateNodeReason reason) { boost::shared_ptr<NodeGroup> isGrp = boost::dynamic_pointer_cast<NodeGroup>( group->getEffectInstance()->shared_from_this() ); assert(isGrp); boost::shared_ptr<NodeCollection> collection = boost::dynamic_pointer_cast<NodeCollection>(isGrp); assert(collection); TabWidget* where = 0; if (_imp->_lastFocusedGraph) { TabWidget* isTab = dynamic_cast<TabWidget*>( _imp->_lastFocusedGraph->parentWidget() ); if (isTab) { where = isTab; } else { QMutexLocker k(&_imp->_panesMutex); assert( !_imp->_panes.empty() ); where = _imp->_panes.front(); } } QGraphicsScene* scene = new QGraphicsScene(this); scene->setItemIndexMethod(QGraphicsScene::NoIndex); NodeGraph* nodeGraph = new NodeGraph(this, collection, scene, this); nodeGraph->setObjectName( QString::fromUtf8(group->getLabel().c_str()) ); _imp->_groups.push_back(nodeGraph); if ( where && reason == eCreateNodeReasonUserCreate && !getApp()->isCreatingPythonGroup() ) { where->appendTab(nodeGraph, nodeGraph); QTimer::singleShot( 25, nodeGraph, SLOT(centerOnAllNodes()) ); } else { nodeGraph->setVisible(false); } }
TabWidget* GuiPrivate::getOnly1NonFloatingPane(int & count) const { count = 0; std::list<TabWidgetI*> tabs = _gui->getApp()->getTabWidgetsSerialization(); if ( tabs.empty() ) { return NULL; } TabWidget* firstNonFloating = 0; for (std::list<TabWidgetI*>::const_iterator it = tabs.begin(); it != tabs.end(); ++it) { TabWidget* isWidget = dynamic_cast<TabWidget*>(*it); assert(isWidget); if (!isWidget) { continue; } if ( !isWidget->isFloatingWindowChild() ) { if (!firstNonFloating) { firstNonFloating = isWidget; } ++count; } } ///there should always be at least 1 non floating window assert(firstNonFloating); return firstNonFloating; }
void Gui::ensureScriptEditorVisible() { // Ensure that the script editor is visible TabWidget* pane = _imp->_scriptEditor->getParentPane(); if (pane != 0) { pane->setCurrentWidget(_imp->_scriptEditor); } else { pane = _imp->_nodeGraphArea->getParentPane(); if (!pane) { std::list<TabWidget*> tabs; { QMutexLocker k(&_imp->_panesMutex); tabs = _imp->_panes; } if ( tabs.empty() ) { return; } pane = tabs.front(); } assert(pane); pane->moveScriptEditorHere(); } }
void TabWidget::stopDragTab(const QPoint& globalPos) { if (_isFloating && count() == 0) { closeFloatingPane(); } QWidget* draggedPanel = _gui->stopDragPanel(); const std::list<TabWidget*> panes = _gui->getPanes(); bool foundTabWidgetUnderneath = false; for (std::list<TabWidget*>::const_iterator it = panes.begin(); it!=panes.end(); ++it) { if ((*it)->isWithinWidget(globalPos)) { (*it)->appendTab(draggedPanel); foundTabWidgetUnderneath = true; break; } } if (!foundTabWidgetUnderneath) { ///if we reach here that means the mouse is not over any tab widget, then float the panel TabWidget* newTab = new TabWidget(_gui,TabWidget::CLOSABLE); newTab->appendTab(draggedPanel); QPoint windowPos = globalPos; newTab->floatPane(&windowPos); } }
void FloatingWidget::closeEvent(QCloseEvent* e) { emit closed(); TabWidget* w = dynamic_cast<TabWidget*>(_embeddedWidget); if (w) { w->closePane(); } QWidget::closeEvent(e); }
void FloatingWidget::closeEvent(QCloseEvent* e) { TabWidget* embedded = dynamic_cast<TabWidget*>(_embeddedWidget); emit closed(); if (embedded) { embedded->destroyTabs(); } QWidget::closeEvent(e); }
void PanelWidget::leaveEventBase() { TabWidget* parentPane = getParentPane(); if (parentPane) { parentPane->setWidgetMouseOverFocus(this, false); } }
void PyPanel::setPanelLabel(const QString& label) { setLabel( label.toStdString() ); TabWidget* parent = dynamic_cast<TabWidget*>( parentWidget() ); if (parent) { parent->setTabLabel(this, label); } }
void TabWidget::floatCurrentWidget(){ if(!_currentWidget) return; QWidget* w = _currentWidget; removeTab(w); TabWidget* newTab = new TabWidget(_gui,TabWidget::CLOSABLE); newTab->appendTab(w); newTab->floatTab(w); }
void Gui::appendTabToDefaultViewerPane(PanelWidget* tab, ScriptObject* obj) { TabWidget* viewerAnchor = getAnchor(); assert(viewerAnchor); viewerAnchor->appendTab(tab, obj); }
void WorkTabMgr::addChildTab(ChildTab *child, const QString &name, quint32 workTabId) { TabWidget *tabW = getTabWidgetWithTab(workTabId); if(!tabW) return; child->setParentId(workTabId); tabW->addChildTab(child, name); m_children[workTabId].insert(child); }
void StateCache::start() { TabWidget *tabs = TabWidget::i(); if (tabs) { connect(tabs, SIGNAL(pinned(AbstractTab*)), SLOT(pinned(AbstractTab*))); connect(tabs, SIGNAL(unpinned(AbstractTab*)), SLOT(unpinned(AbstractTab*))); connect(tabs, SIGNAL(currentChanged(int)), SLOT(tabIndexChanged(int))); connect(tabs->tabBar(), SIGNAL(tabMoved(int,int)), SLOT(save())); } }
int main(int argc, char *argv[]) { Application app(argc, argv); app.setOrganizationName("XTab"); app.setApplicationName("XTab"); app.setOrganizationDomain("https://github.com/Andersbakken/xtab"); app.setWindowIcon(QIcon(":/terminal.png")); TabWidget window; window.show(); return app.exec(); }
void TabWidget::floatTab(QWidget* tab) { std::vector<QWidget*>::iterator it = std::find(_tabs.begin(),_tabs.end(),tab); if (it != _tabs.end()) { TabWidget* newTab = new TabWidget(_gui,TabWidget::CLOSABLE); removeTab(*it); newTab->appendTab(*it); newTab->floatPane(); if(_tabBar->count() == 0){ _floatButton->setEnabled(false); } } }
void PanelWidget::removeClickFocus() { TabWidget* parentPane = getParentPane(); if (parentPane) { parentPane->setWidgetClickFocus(this, false); } if (_gui) { _gui->setCurrentPanelFocus(0); } }
void NavigationBar::loadHistoryItemInNewTab(const QWebHistoryItem &item) { TabWidget* tabWidget = m_window->tabWidget(); int tabIndex = tabWidget->duplicateTab(tabWidget->currentIndex()); QWebHistory* history = m_window->weView(tabIndex)->page()->history(); history->goToItem(item); if (qzSettings->newTabPosition == Qz::NT_SelectedTab) { tabWidget->setCurrentIndex(tabIndex); } }
void PanelWidget::handleUnCaughtKeyPressEvent(QKeyEvent* e) { if (!_gui) { return; } _gui->setLastKeyPressVisitedClickFocus(_gui->getCurrentPanelFocus() == this); TabWidget* parentPane = getParentPane(); if ( parentPane && parentPane->isFloatingWindowChild() ) { //We have to send the event to the Gui object, because it won't receive it as they are part from different windows qApp->sendEvent(_gui, e); } }
void Gui::createGroupGui(const NodePtr & group, const CreateNodeArgs& args) { NodeGroupPtr isGrp = toNodeGroup( group->getEffectInstance()->shared_from_this() ); assert(isGrp); NodeCollectionPtr collection = boost::dynamic_pointer_cast<NodeCollection>(isGrp); assert(collection); TabWidget* where = 0; if (_imp->_lastFocusedGraph) { TabWidget* isTab = dynamic_cast<TabWidget*>( _imp->_lastFocusedGraph->parentWidget() ); if (isTab) { where = isTab; } else { std::list<TabWidgetI*> panes = getApp()->getTabWidgetsSerialization(); assert( !panes.empty() ); where = dynamic_cast<TabWidget*>(panes.front()); } } QGraphicsScene* scene = new QGraphicsScene(this); scene->setItemIndexMethod(QGraphicsScene::NoIndex); std::string newName = isGrp->getNode()->getFullyQualifiedName(); for (std::size_t i = 0; i < newName.size(); ++i) { if (newName[i] == '.') { newName[i] = '_'; } } newName += "_NodeGraph"; std::string label = tr(" Node Graph").toStdString(); NodeGraph::makeFullyQualifiedLabel(group, &label); NodeGraph* nodeGraph = new NodeGraph(this, collection, newName, scene, this); nodeGraph->setLabel(label); nodeGraph->setObjectName( QString::fromUtf8( group->getLabel().c_str() ) ); _imp->_groups.push_back(nodeGraph); SERIALIZATION_NAMESPACE::NodeSerializationPtr serialization = args.getPropertyUnsafe<SERIALIZATION_NAMESPACE::NodeSerializationPtr>(kCreateNodeArgsPropNodeSerialization); bool showSubGraph = args.getPropertyUnsafe<bool>(kCreateNodeArgsPropSubGraphOpened); if ( showSubGraph && where && !serialization ) { where->appendTab(nodeGraph, nodeGraph); QTimer::singleShot( 25, nodeGraph, SLOT(centerOnAllNodes()) ); } else { nodeGraph->setVisible(false); } }
void WorkTabMgr::AddWorkTab(WorkTab *tab, MainWindow *window, QString label) { window->closeHomeTab(); m_workTabs.insert(tab->getId(), tab); TabWidget *activeWidget = window->getTabView()->getActiveWidget(); tab->setParent(activeWidget); tab->setWindowId(window->getId()); activeWidget->addTab(tab, label, tab->getId()); activeWidget->setTabsClosable(true); return; }
void Gui::minimize() { std::list<TabWidgetI*> panes = getApp()->getTabWidgetsSerialization(); for (std::list<TabWidgetI*>::iterator it = panes.begin(); it != panes.end(); ++it) { TabWidget* pane = dynamic_cast<TabWidget*>(*it); if (!pane) { continue; } pane->show(); } if (!_imp->leftToolBarDisplayedOnHoverOnly) { _imp->_toolBox->show(); } }
QList< QPair<QString, QString> > BookmarkOwner::currentBookmarkList() const { QList< QPair<QString, QString> > bkList; TabWidget *view = rApp->rekonqWindow()->tabWidget(); int tabNumber = view->count(); for (int i = 0; i < tabNumber; ++i) { QPair<QString, QString> item; item.first = view->webWindow(i)->title(); item.second = view->webWindow(i)->url().url(); bkList << item; } return bkList; }
void WorkTabMgr::removeTab(WorkTab *tab) { ChildrenMap::iterator itr = m_children.find(tab->getId()); if(itr != m_children.end()) { for(std::set<ChildTab*>::const_iterator w_itr = (*itr).begin(); w_itr != (*itr).end(); ++w_itr) { TabWidget *tabW = getTabWidgetWithWidget(*w_itr); tabW->removeChildTab(*w_itr); tab->childClosed(*w_itr); } m_children.erase(itr); } m_workTabs.remove(tab->getId()); delete tab; }
//================================================================ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); TabWidget * tw = new TabWidget(this) ; tw->setGeometry(0,60,tw->geometry().width(), tw->geometry().height()) ; FormPage1 * f1 = new FormPage1(tw) ; f1->setLabelText(QString("Pippo")); FormPage1 * f2 = new FormPage1(tw) ; f2->setLabelText(QString("Pluto")); tw->addTab((QWidget*)f1,QString("FormPage1")) ; tw->addTab((QWidget*)f2,QString("FormPage2")) ; }
void Gui::maximize(TabWidget* what) { assert(what); if ( what->isFloatingWindowChild() ) { return; } std::list<TabWidgetI*> panes = getApp()->getTabWidgetsSerialization(); for (std::list<TabWidgetI*>::iterator it = panes.begin(); it != panes.end(); ++it) { TabWidget* pane = dynamic_cast<TabWidget*>(*it); if (!pane) { continue; } //if the widget is not what we want to maximize and it is not floating , hide it if ( (pane != what) && !pane->isFloatingWindowChild() ) { // also if we want to maximize the workshop pane, don't hide the properties pane bool hasProperties = false; for (int i = 0; i < pane->count(); ++i) { QString tabName = pane->tabAt(i)->getWidget()->objectName(); if ( tabName == QString::fromUtf8(kPropertiesBinName) ) { hasProperties = true; break; } } bool hasNodeGraphOrCurveEditor = false; for (int i = 0; i < what->count(); ++i) { QWidget* tab = what->tabAt(i)->getWidget(); assert(tab); NodeGraph* isGraph = dynamic_cast<NodeGraph*>(tab); AnimationModuleEditor* isEditor = dynamic_cast<AnimationModuleEditor*>(tab); if (isGraph || isEditor) { hasNodeGraphOrCurveEditor = true; break; } } if (hasProperties && hasNodeGraphOrCurveEditor) { continue; } pane->hide(); } } _imp->_toolBox->hide(); }
void LocationCompleter::switchToTab(BrowserWindow* window, int tab) { Q_ASSERT(window); Q_ASSERT(tab >= 0); TabWidget* tabWidget = window->tabWidget(); if (window->isActiveWindow() || tabWidget->currentIndex() != tab) { tabWidget->setCurrentIndex(tab); window->show(); window->activateWindow(); window->raise(); } else { tabWidget->webTab()->setFocus(); } }
void TabWidget::splitHorizontally(){ QMutexLocker l(&_tabWidgetStateMutex); Splitter* container = dynamic_cast<Splitter*>(parentWidget()); if(!container){ return; } /*We need to know the position in the container layout of the old tab widget*/ int oldIndex = container->indexOf(this); QList<int> containerSizes = container->sizes(); Splitter* newSplitter = new Splitter(container); newSplitter->setObjectName_mt_safe(container->objectName()+TabWidget::splitHorizontallyTag); newSplitter->setContentsMargins(0, 0, 0, 0); newSplitter->setOrientation(Qt::Horizontal); setVisible(false); setParent(newSplitter); newSplitter->addWidget(this); setVisible(true); _gui->registerSplitter(newSplitter); /*Adding now a new tab*/ TabWidget* newTab = new TabWidget(_gui,TabWidget::CLOSABLE,newSplitter); newTab->setObjectName_mt_safe(objectName()+TabWidget::splitHorizontallyTag); _gui->registerPane(newTab); newSplitter->addWidget(newTab); QSize splitterSize = newSplitter->sizeHint(); QList<int> sizes; sizes << splitterSize.width()/2; sizes << splitterSize.width()/2; newSplitter->setSizes_mt_safe(sizes); /*Inserting back the new splitter at the original index*/ container->insertWidget(oldIndex,newSplitter); ///restore the container original sizes container->setSizes_mt_safe(containerSizes); _userSplits.insert(std::make_pair(newTab,false)); if (!_gui->getApp()->getProject()->isLoadingProject()) { _gui->getApp()->triggerAutoSave(); } }