mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
Command line option to open url in current tab.
-ct=URL or --current-tab=URL
This commit is contained in:
parent
7c7c1787bc
commit
79a548b365
@ -50,6 +50,7 @@ void CommandLineOptions::showHelp()
|
|||||||
" -nw or --new-window open new window\n"
|
" -nw or --new-window open new window\n"
|
||||||
" -pb or --private-browsing start private browsing\n"
|
" -pb or --private-browsing start private browsing\n"
|
||||||
" -dm or --download-manager show download manager\n"
|
" -dm or --download-manager show download manager\n"
|
||||||
|
" -ct=URL or --current-tab=URL open URL in current tab\n"
|
||||||
"\n"
|
"\n"
|
||||||
" QupZilla is a new, fast and secure web browser\n"
|
" QupZilla is a new, fast and secure web browser\n"
|
||||||
" based on WebKit core (http://webkit.org) and\n"
|
" based on WebKit core (http://webkit.org) and\n"
|
||||||
@ -147,6 +148,15 @@ void CommandLineOptions::parseActions()
|
|||||||
pair.text = "";
|
pair.text = "";
|
||||||
m_actions.append(pair);
|
m_actions.append(pair);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (arg.startsWith("-ct") || arg.startsWith("--current-tab")) {
|
||||||
|
arg.remove("-ct=");
|
||||||
|
arg.remove("--current-tab=");
|
||||||
|
ActionPair pair;
|
||||||
|
pair.action = Qz::CL_OpenUrlInCurrentTab;
|
||||||
|
pair.text = arg;
|
||||||
|
m_actions.append(pair);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &url = arguments.last();
|
const QString &url = arguments.last();
|
||||||
|
@ -158,6 +158,11 @@ MainApplication::MainApplication(int &argc, char** argv)
|
|||||||
messages.append("ACTION:StartPrivateBrowsing");
|
messages.append("ACTION:StartPrivateBrowsing");
|
||||||
m_postLaunchActions.append(PrivateBrowsing);
|
m_postLaunchActions.append(PrivateBrowsing);
|
||||||
break;
|
break;
|
||||||
|
case Qz::CL_OpenUrlInCurrentTab:
|
||||||
|
startUrl = QUrl::fromUserInput(pair.text);
|
||||||
|
messages.append("ACTION:OpenUrlInCurrentTab" + pair.text);
|
||||||
|
m_postLaunchActions.append(PrivateBrowsing);
|
||||||
|
break;
|
||||||
case Qz::CL_OpenUrl:
|
case Qz::CL_OpenUrl:
|
||||||
startUrl = QUrl::fromUserInput(pair.text);
|
startUrl = QUrl::fromUserInput(pair.text);
|
||||||
messages.append("URL:" + pair.text);
|
messages.append("URL:" + pair.text);
|
||||||
@ -448,6 +453,8 @@ void MainApplication::sendMessages(Qz::AppMessageType mes, bool state)
|
|||||||
void MainApplication::receiveAppMessage(QString message)
|
void MainApplication::receiveAppMessage(QString message)
|
||||||
{
|
{
|
||||||
QWidget* actWin = getWindow();
|
QWidget* actWin = getWindow();
|
||||||
|
QUrl actUrl;
|
||||||
|
|
||||||
if (message.startsWith("URL:")) {
|
if (message.startsWith("URL:")) {
|
||||||
QUrl url = QUrl::fromUserInput(message.mid(4));
|
QUrl url = QUrl::fromUserInput(message.mid(4));
|
||||||
addNewTab(url);
|
addNewTab(url);
|
||||||
@ -457,7 +464,6 @@ void MainApplication::receiveAppMessage(QString message)
|
|||||||
QString text = message.mid(7);
|
QString text = message.mid(7);
|
||||||
if (text == "NewTab") {
|
if (text == "NewTab") {
|
||||||
addNewTab();
|
addNewTab();
|
||||||
actWin = getWindow();
|
|
||||||
}
|
}
|
||||||
else if (text == "NewWindow") {
|
else if (text == "NewWindow") {
|
||||||
actWin = makeNewWindow(Qz::BW_NewWindow);
|
actWin = makeNewWindow(Qz::BW_NewWindow);
|
||||||
@ -468,19 +474,27 @@ void MainApplication::receiveAppMessage(QString message)
|
|||||||
}
|
}
|
||||||
else if (text == "StartPrivateBrowsing") {
|
else if (text == "StartPrivateBrowsing") {
|
||||||
sendMessages(Qz::AM_StartPrivateBrowsing, true);
|
sendMessages(Qz::AM_StartPrivateBrowsing, true);
|
||||||
actWin = getWindow();
|
}
|
||||||
|
else if (text.startsWith("OpenUrlInCurrentTab")) {
|
||||||
|
actUrl = QUrl::fromUserInput(text.remove("OpenUrlInCurrentTab"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!actWin && !isClosing()) { // It can only occur if download manager window was still open
|
if (!actWin && !isClosing()) { // It can only occur if download manager window was still open
|
||||||
makeNewWindow(Qz::BW_NewWindow);
|
makeNewWindow(Qz::BW_NewWindow, actUrl);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QupZilla* qz = qobject_cast<QupZilla*>(actWin);
|
||||||
|
|
||||||
actWin->setWindowState(actWin->windowState() & ~Qt::WindowMinimized);
|
actWin->setWindowState(actWin->windowState() & ~Qt::WindowMinimized);
|
||||||
actWin->raise();
|
actWin->raise();
|
||||||
actWin->activateWindow();
|
actWin->activateWindow();
|
||||||
actWin->setFocus();
|
actWin->setFocus();
|
||||||
|
|
||||||
|
if (qz && !actUrl.isEmpty()) {
|
||||||
|
qz->loadAddress(actUrl);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainApplication::addNewTab(const QUrl &url)
|
void MainApplication::addNewTab(const QUrl &url)
|
||||||
|
@ -47,6 +47,7 @@ enum BrowserWindow {
|
|||||||
enum CommandLineAction {
|
enum CommandLineAction {
|
||||||
CL_NoAction,
|
CL_NoAction,
|
||||||
CL_OpenUrl,
|
CL_OpenUrl,
|
||||||
|
CL_OpenUrlInCurrentTab,
|
||||||
CL_StartWithProfile,
|
CL_StartWithProfile,
|
||||||
CL_StartWithoutAddons,
|
CL_StartWithoutAddons,
|
||||||
CL_NewTab,
|
CL_NewTab,
|
||||||
|
Loading…
Reference in New Issue
Block a user