Commit 83b4c545 authored by Jonah Brüchert's avatar Jonah Brüchert 🌳

Open in non-private tabs model

* also raise window to the front
parent 9f04c924
......@@ -32,7 +32,7 @@ include(KDECompilerSettings NO_POLICY_SCOPE)
################# Find dependencies #################
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Core Quick Test Gui Svg QuickControls2 Sql)
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Kirigami2 Purpose I18n Config CoreAddons DBusAddons)
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Kirigami2 Purpose I18n Config CoreAddons DBusAddons WindowSystem)
# Necessary to support QtWebEngine installed in a different prefix than the rest of Qt (e.g flatpak)
find_package(Qt5WebEngine REQUIRED)
......
......@@ -32,6 +32,7 @@ target_link_libraries(angelfish
KF5::ConfigCore
KF5::ConfigGui
KF5::DBusAddons
KF5::WindowSystem
)
install(TARGETS angelfish ${KF5_INSTALL_TARGETS_DEFAULT_ARGS})
......
......@@ -150,6 +150,7 @@ Kirigami.ApplicationWindow {
ListWebView {
id: regularTabs
objectName: "regularTabsObject"
anchors.fill: parent
activeTabs: rootPage.initialized && !rootPage.privateMode
}
......
......@@ -26,6 +26,7 @@
#include <KLocalizedContext>
#include <KLocalizedString>
#include <KDBusService>
#include <KWindowSystem>
#include "bookmarkshistorymodel.h"
#include "browsermanager.h"
......@@ -73,15 +74,27 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
if (!parser.positionalArguments().isEmpty()) {
const QString initialUrl = QUrl::fromUserInput(parser.positionalArguments().constFirst()).toString();
const auto *webbrowserWindow = engine.rootObjects().first();
auto *webbrowserWindow = qobject_cast<QQuickWindow *>(engine.rootObjects().first());
if (!webbrowserWindow) {
qWarning() << "No webbrowser window is open, can't open the url";
return;
}
// Can be normal or private web view, whatever is open right now;
const auto *currentListWebView = webbrowserWindow->property("tabs").value<QObject *>();
auto *currentTabsModel = currentListWebView->property("tabsModel").value<TabsModel *>();
currentTabsModel->newTab(initialUrl);
const auto *pageStack = webbrowserWindow->property("pageStack").value<QObject *>();
const auto *initialPage = pageStack->property("initialPage").value<QObject *>();
// This should be initialPage->findChild<TabsModel *>(QStringLiteral("regularTabsObject")), for some reason
// it doesn't find our tabsModel.
const auto children = initialPage->children();
auto *regularTabs = *std::find_if(children.cbegin(), children.cend(), [](const QObject *child) {
return child->objectName() == QStringLiteral("regularTabsObject");
});
auto *tabsModel = regularTabs->property("tabsModel").value<TabsModel *>();
// Open new tab with requested url
tabsModel->newTab(initialUrl);
// Move window to the front
KWindowSystem::raiseWindow(webbrowserWindow->winId());
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment