From 53d4f00c3697f19bc7a86d4b349f8984561b0b4c Mon Sep 17 00:00:00 2001 From: nowrep Date: Sat, 1 Sep 2012 15:59:27 +0200 Subject: [PATCH] Added option to start new instance of browser with --no-remote option - however, new instance cannot be started for default profile closes #541 --- CHANGELOG | 1 + src/lib/app/commandlineoptions.cpp | 12 +++++++----- src/lib/app/mainapplication.cpp | 17 ++++++++++++++++- src/lib/app/qz_namespace.h | 1 + 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c1bbfd359..ca28d6791 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -18,6 +18,7 @@ Version 1.3.5 * new scheme handler for file protocol allows browsing through directories * new option to show loading progress in address bar * new option to hide close button on tabs + * new option to start new instance with --no-remote option * fixed visibility of navigation bar in fullscreen * fixed bad position of add tab button when there is a lot of tabs * fixed gui with RTL languages diff --git a/src/lib/app/commandlineoptions.cpp b/src/lib/app/commandlineoptions.cpp index 5ab86c375..db6f5b9c2 100644 --- a/src/lib/app/commandlineoptions.cpp +++ b/src/lib/app/commandlineoptions.cpp @@ -50,6 +50,7 @@ void CommandLineOptions::showHelp() " -nw or --new-window open new window\n" " -pb or --private-browsing start private browsing\n" " -dm or --download-manager show download manager\n" + " -nr or --no-remote open new instance\n" " -ct=URL or --current-tab=URL open URL in current tab\n" " -ow=URL or --open-window=URL open URL in new window\n" "\n" @@ -121,35 +122,36 @@ void CommandLineOptions::parseActions() if (arg.startsWith("-ne") || arg.startsWith("--no-extensions")) { ActionPair pair; pair.action = Qz::CL_StartWithoutAddons; - pair.text = ""; m_actions.append(pair); } if (arg.startsWith("-nt") || arg.startsWith("--new-tab")) { ActionPair pair; pair.action = Qz::CL_NewTab; - pair.text = ""; m_actions.append(pair); } if (arg.startsWith("-nw") || arg.startsWith("--new-window")) { ActionPair pair; pair.action = Qz::CL_NewWindow; - pair.text = ""; m_actions.append(pair); } if (arg.startsWith("-dm") || arg.startsWith("--download-manager")) { ActionPair pair; pair.action = Qz::CL_ShowDownloadManager; - pair.text = ""; m_actions.append(pair); } if (arg.startsWith("-pb") || arg.startsWith("--private-browsing")) { ActionPair pair; pair.action = Qz::CL_StartPrivateBrowsing; - pair.text = ""; + m_actions.append(pair); + } + + if (arg.startsWith("-nr") || arg.startsWith("--no-remote")) { + ActionPair pair; + pair.action = Qz::CL_StartNewInstance; m_actions.append(pair); } diff --git a/src/lib/app/mainapplication.cpp b/src/lib/app/mainapplication.cpp index 828193d94..fa292f7e2 100644 --- a/src/lib/app/mainapplication.cpp +++ b/src/lib/app/mainapplication.cpp @@ -113,6 +113,7 @@ MainApplication::MainApplication(int &argc, char** argv) setWindowIcon(QIcon(":icons/exeicons/qupzilla-window.png")); bool noAddons = false; + bool newInstance = false; QUrl startUrl; QStringList messages; QString startProfile; @@ -142,6 +143,9 @@ MainApplication::MainApplication(int &argc, char** argv) case Qz::CL_StartPrivateBrowsing: m_isPrivateSession = true; break; + case Qz::CL_StartNewInstance: + newInstance = true; + break; case Qz::CL_OpenUrlInCurrentTab: startUrl = QUrl::fromUserInput(pair.text); messages.append("ACTION:OpenUrlInCurrentTab" + pair.text); @@ -165,7 +169,18 @@ MainApplication::MainApplication(int &argc, char** argv) // Don't start single application in private browsing if (!m_isPrivateSession) { - setAppId("QupZillaWebBrowser"); + QString appId = "QupZillaWebBrowser"; + + if (newInstance) { + if (startProfile.isEmpty() || startProfile == "default") { + std::cout << "New instance cannot be started with default profile!" << std::endl; + } + else { + appId.append(startProfile); + } + } + + setAppId(appId); } if (messages.isEmpty()) { diff --git a/src/lib/app/qz_namespace.h b/src/lib/app/qz_namespace.h index 12cfb93e5..73afb100f 100644 --- a/src/lib/app/qz_namespace.h +++ b/src/lib/app/qz_namespace.h @@ -54,6 +54,7 @@ enum CommandLineAction { CL_NewWindow, CL_ShowDownloadManager, CL_StartPrivateBrowsing, + CL_StartNewInstance, CL_ExitAction };