Commit 1bc28165 authored by Jonah Brüchert's avatar Jonah Brüchert 🌳

Add command line url parameter

parent 24a683e6
......@@ -43,7 +43,7 @@ GenericName[zh_CN]=网页浏览器
GenericName[zh_TW]=網頁瀏覽器
Encoding=UTF-8
Icon=internet-web-browser
Exec=angelfish
Exec=angelfish %u
Type=Application
X-DocPath=angelfish/index.html
Categories=Qt;KDE;Network;WebBrowser;
......
......@@ -62,8 +62,6 @@ ListView {
}
function newTab(url) {
tabsModel.append({pageurl: url});
}
}
......@@ -49,7 +49,6 @@ Kirigami.ApplicationWindow {
function load(url) {
print("Loading url: " + url);
currentWebView.url = url;
//tabs.newTab(url)
}
width: Kirigami.Units.gridUnit * 20
......@@ -163,6 +162,7 @@ Kirigami.ApplicationWindow {
}
Component.onCompleted: {
//contentView.state = "settings"; // For testing
if (!initialUrl.isEmpty)
load(initialUrl)
}
}
......@@ -17,20 +17,35 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
QCoreApplication::setOrganizationDomain("kde.org");
QCoreApplication::setApplicationName("angelfish");
// Command line parser
QCommandLineParser parser;
QCommandLineOption helpOption = parser.addHelpOption();
parser.addPositionalArgument("url", "An url to open", "[url]");
parser.parse(QGuiApplication::arguments());
// QML loading
QQmlApplicationEngine engine;
QtWebEngine::initialize();
// initial url command line parameter
if (!parser.positionalArguments().isEmpty())
engine.rootContext()->setContextProperty("initialUrl", QUrl::fromUserInput(parser.positionalArguments()[0].toUtf8()));
engine.load(QUrl(QStringLiteral("qrc:///webbrowser.qml")));
// Browser managger
AngelFish::BrowserManager *browserManager = new AngelFish::BrowserManager(engine.rootContext());
engine.rootContext()->setContextProperty("browserManager", browserManager);
qmlRegisterUncreatableType<AngelFish::BrowserManager>("org.kde.mobile.angelfish", 1, 0, "BrowserManager", "");
qmlRegisterType<QAbstractListModel>();
// Error handling
if (engine.rootObjects().isEmpty()) {
return -1;
}
int ret = app.exec();
return ret;
}
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