MCPcopy Create free account
hub / github.com/KDE/okular / openNewTab

Method openNewTab

shell/shell.cpp:955–1004  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

953}
954
955void Shell::openNewTab(const QUrl &url, const QString &serializedOptions)
956{
957 const int previousActiveTab = m_tabWidget->currentIndex();
958 KParts::ReadWritePart *const activePart = m_tabs[previousActiveTab].part;
959
960 hideWelcomeScreen();
961
962 bool activateTabIfAlreadyOpen;
963 QMetaObject::invokeMethod(activePart, "activateTabIfAlreadyOpenFile", Q_RETURN_ARG(bool, activateTabIfAlreadyOpen));
964
965 if (activateTabIfAlreadyOpen) {
966 const int tabIndex = findTabIndex(url);
967
968 if (tabIndex >= 0) {
969 setActiveTab(tabIndex);
970 m_recent->addUrl(url);
971 return;
972 }
973 }
974
975 // Tabs are hidden when there's only one, so show it
976 if (m_tabs.size() == 1) {
977 m_tabWidget->tabBar()->show();
978 m_nextTabAction->setEnabled(true);
979 m_prevTabAction->setEnabled(true);
980 }
981
982 const int newIndex = m_tabs.size();
983
984 // Make new part
985 m_tabs.append(TabState(m_partFactory->create<KParts::ReadWritePart>(this)));
986 connectPart(m_tabs[newIndex].part);
987
988 // Update GUI
989 KParts::ReadWritePart *const part = m_tabs[newIndex].part;
990 m_tabWidget->addTab(part->widget(), url.fileName());
991 m_tabWidget->setTabToolTip(newIndex, url.fileName());
992
993 applyOptionsToPart(part, serializedOptions);
994
995 setActiveTab(m_tabs.size() - 1);
996
997 if (part->openUrl(url)) {
998 m_recent->addUrl(url);
999 } else {
1000 setActiveTab(previousActiveTab);
1001 closeTab(m_tabs.size() - 1);
1002 m_recent->removeUrl(url);
1003 }
1004}
1005
1006void Shell::applyOptionsToPart(QObject *part, const QString &serializedOptions)
1007{

Callers

nothing calls this directly

Calls 6

TabStateClass · 0.85
showMethod · 0.80
appendMethod · 0.80
sizeMethod · 0.45
fileNameMethod · 0.45
openUrlMethod · 0.45

Tested by

no test coverage detected