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 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; }
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 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 FrostEdit::applySettings() { loadStyleSheet(Settings::get("Appearance/StyleSheet", "").toString()); //mSyntaxStyle.load(Settings::get("Appearance/Colorscheme").toString()); //mSettingsMenu->setSyntaxStyle(&mSyntaxStyle); mFont.setFamily(Settings::get("TextEditor/Font", "Lucida Console").toString()); mFont.setPointSize(Settings::get("TextEditor/FontSize", 10).toInt()); for(TabWidgetFrame* tabf: mTabWidgetFrames) { TabWidget* wid =tabf->tabWidget(); for(int i = 0; i < wid->count(); i++) { TextEdit* e = toTextEdit(wid->widget(i)); e->setFont(mFont); mSyntaxStyle.applyToTextEdit(e); } } for(auto i: mOpenDocuments.keys()) { Document* doc = mOpenDocuments[i]; TextEditor::Internal::Highlighter* hilt = doc->getHighlighter(); if(hilt != nullptr) { qDebug() << "Found a highlighter!"; mSyntaxStyle.applyToHighlighter(hilt); hilt->rehighlight(); } } for(int i = 0; i < mApplicationOutput->count(); i++) { Console* c = toConsole(mApplicationOutput->widget(i)); mSyntaxStyle.applyToConsole(c); } mSyntaxStyle.applyToConsole(mCompileOutput); mSyntaxStyle.applyToIssueList(mIssueList); }
/*! * Сохранение списка закреплённых вкладок и их порядка. */ void StateCache::save() { if (!m_settings->isSynced()) return; TabWidget *tabs = TabWidget::i(); for (int i = tabs->count() - 1; i >= 0; --i) { AbstractTab *tab = tabs->widget(i); if (tab->options() & AbstractTab::Pinned) { const QString id = encode(tab->id()); m_tabs.removeAll(id); m_tabs.prepend(id); } } if (ChatClient::channels()->policy() & ServerFeed::ForcedJoinPolicy) { const QString mainId = SimpleID::encode(ChatClient::channels()->mainId()); m_tabs.removeAll(mainId); m_tabs.prepend(mainId); } m_settings->setValue(m_key, m_tabs); }
bool SessionManager::saveYourSession(int index) { kDebug() << "SAVING YOUR OWN SESSION..."; const QString & sessionPath = KStandardDirs::locateLocal("appdata" , QL1S("usersessions/")); const QString & sessionName = QL1S("ses") + QString::number(index); QFile sessionFile(sessionPath + sessionName); if (!sessionFile.open(QFile::WriteOnly | QFile::Truncate)) { kDebug() << "Unable to open session file" << sessionFile.fileName(); return false; } RekonqWindowList wl = rApp->rekonqWindowList(); QDomDocument document("session"); QDomElement session = document.createElement("session"); document.appendChild(session); Q_FOREACH(const QWeakPointer<RekonqWindow> &w, wl) { if (w.data()->isPrivateBrowsingMode()) continue; QDomElement window = document.createElement("window"); int tabInserted = 0; window.setAttribute("name", w.data()->objectName()); TabWidget *tw = w.data()->tabWidget(); for (signed int tabNo = 0; tabNo < tw->count(); tabNo++) { KUrl u = tw->webWindow(tabNo)->url(); tabInserted++; QDomElement tab = document.createElement("tab"); tab.setAttribute("title", tw->webWindow(tabNo)->title()); // redundant, but needed for closedSites() // as there's not way to read out the historyData tab.setAttribute("url", u.url()); if (tw->currentIndex() == tabNo) { tab.setAttribute("currentTab", 1); } if (tw->tabBar()->tabData(tabNo).toBool()) // pinned tab info { tab.setAttribute("pinned", 1); } QByteArray history; QDataStream historyStream(&history, QIODevice::ReadWrite); historyStream << *(tw->webWindow(tabNo)->page()->history()); QDomCDATASection historySection = document.createCDATASection(history.toBase64()); tab.appendChild(historySection); window.appendChild(tab); } if (tabInserted > 0) session.appendChild(window); } QTextStream TextStream(&sessionFile); document.save(TextStream, 2); sessionFile.close(); return true; }
void Gui::wipeLayout() { std::list<TabWidgetI*> panesCpy = getApp()->getTabWidgetsSerialization(); getApp()->clearTabWidgets(); std::list<SerializableWindow*> floatingWidgets = getApp()->getFloatingWindowsSerialization(); FloatingWidget* projectFW = _imp->_projectGui->getPanel()->getFloatingWindow(); for (std::list<SerializableWindow*>::const_iterator it = floatingWidgets.begin(); it != floatingWidgets.end(); ++it) { if (!projectFW || (*it) != projectFW) { FloatingWidget* isFloating = dynamic_cast<FloatingWidget*>(*it); if (isFloating) { isFloating->deleteLater(); } } } getApp()->clearFloatingWindows(); // Re-add the project window if (projectFW) { getApp()->registerFloatingWindow(projectFW); } for (std::list<TabWidgetI*>::iterator it = panesCpy.begin(); it != panesCpy.end(); ++it) { TabWidget* pane = dynamic_cast<TabWidget*>(*it); if (!pane) { continue; } ///Conserve tabs by removing them from the tab widgets. This way they will not be deleted. while ( pane->count() > 0 ) { pane->removeTab(0, false); } //(*it)->setParent(NULL); pane->deleteLater(); } std::list<SplitterI*> splittersCpy = getApp()->getSplittersSerialization(); getApp()->clearSplitters(); for (std::list<SplitterI*>::iterator it = splittersCpy.begin(); it != splittersCpy.end(); ++it) { if (_imp->_leftRightSplitter != *it) { Splitter* isSplitter = dynamic_cast<Splitter*>(*it); if (!isSplitter) { continue; } while ( isSplitter->count() > 0 ) { isSplitter->widget(0)->setParent(NULL); } //(*it)->setParent(NULL); isSplitter->deleteLater(); } } Splitter *newSplitter = new Splitter(Qt::Horizontal,this, _imp->_centralWidget); newSplitter->addWidget(_imp->_toolBox); newSplitter->setObjectName_mt_safe( _imp->_leftRightSplitter->objectName_mt_safe() ); _imp->_mainLayout->removeWidget(_imp->_leftRightSplitter); getApp()->unregisterSplitter(_imp->_leftRightSplitter); _imp->_leftRightSplitter->deleteLater(); _imp->_leftRightSplitter = newSplitter; _imp->_leftRightSplitter->setChildrenCollapsible(false); _imp->_mainLayout->addWidget(newSplitter); getApp()->registerSplitter(newSplitter); // Re-create new menu actions createMenuActions(); } // Gui::wipeLayout