mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 02:36:34 +01:00
[Portable] Portable mode can now be enabled with commandline option
It is not needed to rebuild for Portable mode. However, it is still possible to enforce portable mode with PORTABLE_BUILD build option.
This commit is contained in:
parent
a1f9b784d7
commit
29b6b93dd4
@ -45,6 +45,7 @@ void CommandLineOptions::showHelp()
|
||||
"\n"
|
||||
" -p=PROFILE or --profile=PROFILE start with specified profile \n"
|
||||
" -ne or --no-extensions start without extensions\n"
|
||||
" -po or --portable start in portable mode\n"
|
||||
"\n"
|
||||
" Options to control running QupZilla:\n"
|
||||
" -nt or --new-tab open new tab\n"
|
||||
@ -157,6 +158,12 @@ void CommandLineOptions::parseActions()
|
||||
m_actions.append(pair);
|
||||
}
|
||||
|
||||
if (arg.startsWith(QLatin1String("-po")) || arg.startsWith(QLatin1String("--portable"))) {
|
||||
ActionPair pair;
|
||||
pair.action = Qz::CL_StartPortable;
|
||||
m_actions.append(pair);
|
||||
}
|
||||
|
||||
if (arg.startsWith(QLatin1String("-fs")) || arg.startsWith(QLatin1String("--fullscreen"))) {
|
||||
ActionPair pair;
|
||||
pair.action = Qz::CL_ToggleFullScreen;
|
||||
|
@ -73,10 +73,6 @@
|
||||
#include <QTimer>
|
||||
#include <QDir>
|
||||
|
||||
#if defined(PORTABLE_BUILD) && !defined(NO_SYSTEM_DATAPATH)
|
||||
#define NO_SYSTEM_DATAPATH
|
||||
#endif
|
||||
|
||||
#if QT_VERSION < 0x050000
|
||||
#include "qwebkitversion.h"
|
||||
#endif
|
||||
@ -105,6 +101,7 @@ MainApplication::MainApplication(int &argc, char** argv)
|
||||
, m_dbWriter(new DatabaseWriter(this))
|
||||
, m_uaManager(new UserAgentManager)
|
||||
, m_isPrivateSession(false)
|
||||
, m_isPortable(false)
|
||||
, m_isClosing(false)
|
||||
, m_isStateChanged(false)
|
||||
, m_isRestoring(false)
|
||||
@ -128,23 +125,6 @@ MainApplication::MainApplication(int &argc, char** argv)
|
||||
DATADIR.append(QLatin1String("../Resources/"));
|
||||
#endif
|
||||
|
||||
#ifdef PORTABLE_BUILD
|
||||
PROFILEDIR = DATADIR + "profiles/";
|
||||
#else
|
||||
bool confPathExists = QDir(QDir::homePath() + "/.config/qupzilla").exists();
|
||||
bool homePathExists = QDir(QDir::homePath() + "/.qupzilla").exists();
|
||||
|
||||
if (homePathExists && !confPathExists) {
|
||||
PROFILEDIR = QDir::homePath() + "/.qupzilla/";
|
||||
}
|
||||
else {
|
||||
PROFILEDIR = QDir::homePath() + "/.config/qupzilla/";
|
||||
}
|
||||
#endif
|
||||
|
||||
TRANSLATIONSDIR = DATADIR + "locale/";
|
||||
THEMESDIR = DATADIR + "themes/";
|
||||
|
||||
setWindowIcon(QIcon(":icons/exeicons/qupzilla-window.png"));
|
||||
bool noAddons = false;
|
||||
bool newInstance = false;
|
||||
@ -163,6 +143,9 @@ MainApplication::MainApplication(int &argc, char** argv)
|
||||
case Qz::CL_StartWithProfile:
|
||||
startProfile = pair.text;
|
||||
break;
|
||||
case Qz::CL_StartPortable:
|
||||
m_isPortable = true;
|
||||
break;
|
||||
case Qz::CL_NewTab:
|
||||
messages.append(QLatin1String("ACTION:NewTab"));
|
||||
m_postLaunchActions.append(OpenNewTab);
|
||||
@ -205,13 +188,28 @@ MainApplication::MainApplication(int &argc, char** argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (isPortable()) {
|
||||
std::cout << "QupZilla: Running in Portable Mode." << std::endl;
|
||||
PROFILEDIR = DATADIR + "profiles/";
|
||||
}
|
||||
else {
|
||||
bool confPathExists = QDir(QDir::homePath() + "/.config/qupzilla").exists();
|
||||
bool homePathExists = QDir(QDir::homePath() + "/.qupzilla").exists();
|
||||
|
||||
if (homePathExists && !confPathExists) {
|
||||
PROFILEDIR = QDir::homePath() + "/.qupzilla/";
|
||||
}
|
||||
else {
|
||||
PROFILEDIR = QDir::homePath() + "/.config/qupzilla/";
|
||||
}
|
||||
}
|
||||
|
||||
TRANSLATIONSDIR = DATADIR + "locale/";
|
||||
THEMESDIR = DATADIR + "themes/";
|
||||
|
||||
// Don't start single application in private browsing
|
||||
if (!m_isPrivateSession) {
|
||||
#ifndef PORTABLE_BUILD
|
||||
QString appId = "QupZillaWebBrowser";
|
||||
#else
|
||||
QString appId = "QupZillaWebBrowserPortable";
|
||||
#endif
|
||||
QString appId = isPortable() ? "QupZillaWebBrowserPortable" : "QupZillaWebBrowser";
|
||||
|
||||
if (newInstance) {
|
||||
if (startProfile.isEmpty() || startProfile == QLatin1String("default")) {
|
||||
@ -337,14 +335,14 @@ void MainApplication::postLaunch()
|
||||
connect(this, SIGNAL(messageReceived(QString)), this, SLOT(receiveAppMessage(QString)));
|
||||
connect(this, SIGNAL(aboutToQuit()), this, SLOT(saveSettings()));
|
||||
|
||||
#ifndef PORTABLE_BUILD
|
||||
Settings settings;
|
||||
bool alwaysCheckDefaultBrowser = settings.value("Web-Browser-Settings/CheckDefaultBrowser", DEFAULT_CHECK_DEFAULTBROWSER).toBool();
|
||||
if (alwaysCheckDefaultBrowser) {
|
||||
alwaysCheckDefaultBrowser = checkDefaultWebBrowser();
|
||||
settings.setValue("Web-Browser-Settings/CheckDefaultBrowser", alwaysCheckDefaultBrowser);
|
||||
if (!isPortable()) {
|
||||
Settings settings;
|
||||
bool alwaysCheckDefaultBrowser = settings.value("Web-Browser-Settings/CheckDefaultBrowser", DEFAULT_CHECK_DEFAULTBROWSER).toBool();
|
||||
if (alwaysCheckDefaultBrowser) {
|
||||
alwaysCheckDefaultBrowser = checkDefaultWebBrowser();
|
||||
settings.setValue("Web-Browser-Settings/CheckDefaultBrowser", alwaysCheckDefaultBrowser);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void MainApplication::loadSettings()
|
||||
@ -510,6 +508,15 @@ bool MainApplication::isPrivateSession() const
|
||||
return m_isPrivateSession;
|
||||
}
|
||||
|
||||
bool MainApplication::isPortable() const
|
||||
{
|
||||
#ifdef PORTABLE_BUILD
|
||||
return true;
|
||||
#else
|
||||
return m_isPortable;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool MainApplication::isStartingAfterCrash() const
|
||||
{
|
||||
return m_startingAfterCrash;
|
||||
|
@ -85,6 +85,7 @@ public:
|
||||
bool isClosing() const;
|
||||
bool isRestoring() const;
|
||||
bool isPrivateSession() const;
|
||||
bool isPortable() const;
|
||||
bool isStartingAfterCrash() const;
|
||||
int windowCount() const;
|
||||
QString currentLanguageFile() const;
|
||||
@ -197,6 +198,7 @@ private:
|
||||
QString m_activeThemePath;
|
||||
|
||||
bool m_isPrivateSession;
|
||||
bool m_isPortable;
|
||||
bool m_isClosing;
|
||||
bool m_isStateChanged;
|
||||
bool m_isRestoring;
|
||||
|
@ -71,6 +71,7 @@ enum CommandLineAction {
|
||||
CL_ToggleFullScreen,
|
||||
CL_StartPrivateBrowsing,
|
||||
CL_StartNewInstance,
|
||||
CL_StartPortable,
|
||||
CL_ExitAction
|
||||
};
|
||||
|
||||
@ -128,12 +129,6 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(Qz::NewTabPositionFlags)
|
||||
#define DEFAULT_DOWNLOAD_USE_NATIVE_DIALOG true
|
||||
#endif
|
||||
|
||||
#ifdef PORTABLE_BUILD
|
||||
#define DEFAULT_ENABLE_PLUGINS false
|
||||
#else
|
||||
#define DEFAULT_ENABLE_PLUGINS true
|
||||
#endif
|
||||
|
||||
#define QTWEBKIT_FROM_2_2 \
|
||||
(QT_VERSION >= 0x050000 || (QTWEBKIT_VERSION >= QTWEBKIT_VERSION_CHECK(2, 2, 0)))
|
||||
|
||||
|
@ -422,11 +422,7 @@ QString QupZillaSchemeReply::configPage()
|
||||
QString KDEIntegration = tr("Disabled");
|
||||
#endif
|
||||
|
||||
#ifdef PORTABLE_BUILD
|
||||
QString portableBuild = tr("<b>Enabled</b>");
|
||||
#else
|
||||
QString portableBuild = tr("Disabled");
|
||||
#endif
|
||||
QString portableBuild = mApp->isPortable() ? tr("<b>Enabled</b>") : tr("Disabled");
|
||||
|
||||
cPage.replace(QLatin1String("%BUILD-CONFIG-TEXT%"),
|
||||
QString("<dt>%1</dt><dd>%2<dd>").arg(tr("Debug build"), debugBuild) +
|
||||
|
@ -83,7 +83,7 @@ void Plugins::loadSettings()
|
||||
{
|
||||
Settings settings;
|
||||
settings.beginGroup("Plugin-Settings");
|
||||
m_pluginsEnabled = settings.value("EnablePlugins", DEFAULT_ENABLE_PLUGINS).toBool();
|
||||
m_pluginsEnabled = settings.value("EnablePlugins", !mApp->isPortable()).toBool();
|
||||
m_allowedPlugins = settings.value("AllowedPlugins", QStringList()).toStringList();
|
||||
settings.endGroup();
|
||||
|
||||
@ -165,11 +165,14 @@ void Plugins::loadAvailablePlugins()
|
||||
m_pluginsLoaded = true;
|
||||
|
||||
QStringList dirs;
|
||||
dirs << mApp->DATADIR + "plugins/"
|
||||
// Portable build: Load only plugins from DATADIR/plugins/ directory.
|
||||
// Loaded plugins are saved with relative path, instead of absolute for
|
||||
// normal build.
|
||||
#ifndef PORTABLE_BUILD
|
||||
dirs << mApp->DATADIR + "plugins/";
|
||||
|
||||
// Portable build: Load only plugins from DATADIR/plugins/ directory.
|
||||
// Loaded plugins are saved with relative path, instead of absolute for
|
||||
// normal build.
|
||||
|
||||
if (!mApp->isPortable()) {
|
||||
dirs
|
||||
#if defined(QZ_WS_X11) && !defined(NO_SYSTEM_DATAPATH)
|
||||
#ifdef USE_LIBPATH
|
||||
<< USE_LIBPATH "qupzilla/"
|
||||
@ -177,9 +180,8 @@ void Plugins::loadAvailablePlugins()
|
||||
<< "/usr/lib/qupzilla/"
|
||||
#endif
|
||||
#endif
|
||||
<< mApp->PROFILEDIR + "plugins/"
|
||||
#endif
|
||||
;
|
||||
<< mApp->PROFILEDIR + "plugins/";
|
||||
}
|
||||
|
||||
foreach (const QString &dir, dirs) {
|
||||
QDir pluginsDir = QDir(dir);
|
||||
|
@ -40,7 +40,7 @@ PluginsManager::PluginsManager(QWidget* parent)
|
||||
//Application Extensions
|
||||
Settings settings;
|
||||
settings.beginGroup("Plugin-Settings");
|
||||
bool appPluginsEnabled = settings.value("EnablePlugins", DEFAULT_ENABLE_PLUGINS).toBool();
|
||||
bool appPluginsEnabled = settings.value("EnablePlugins", !mApp->isPortable()).toBool();
|
||||
settings.endGroup();
|
||||
|
||||
ui->allowAppPlugins->setChecked(appPluginsEnabled);
|
||||
@ -115,11 +115,12 @@ void PluginsManager::save()
|
||||
if (item->checkState() == Qt::Checked) {
|
||||
const Plugins::Plugin plugin = item->data(Qt::UserRole + 10).value<Plugins::Plugin>();
|
||||
|
||||
#ifndef PORTABLE_BUILD
|
||||
allowedPlugins.append(plugin.fullPath);
|
||||
#else
|
||||
allowedPlugins.append(mApp->DATADIR + "plugins/" + plugin.fileName);
|
||||
#endif
|
||||
if (!mApp->isPortable()) {
|
||||
allowedPlugins.append(plugin.fullPath);
|
||||
}
|
||||
else {
|
||||
allowedPlugins.append(mApp->DATADIR + "plugins/" + plugin.fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user