mirror of
https://invent.kde.org/network/falkon.git
synced 2024-09-21 17:52:10 +02:00
Private browsing now opens new browser window (in own process)
- closes #415
This commit is contained in:
parent
209395a003
commit
38ef828b82
29
src/lib/3rdparty/qtsingleapplication.cpp
vendored
29
src/lib/3rdparty/qtsingleapplication.cpp
vendored
|
@ -159,8 +159,9 @@ void QtSingleApplication::sysInit(const QString &appId)
|
|||
|
||||
QtSingleApplication::QtSingleApplication(int &argc, char** argv, bool GUIenabled)
|
||||
: QApplication(argc, argv, GUIenabled)
|
||||
, peer(0)
|
||||
, actWin(0)
|
||||
{
|
||||
sysInit();
|
||||
}
|
||||
|
||||
|
||||
|
@ -172,6 +173,8 @@ QtSingleApplication::QtSingleApplication(int &argc, char** argv, bool GUIenabled
|
|||
|
||||
QtSingleApplication::QtSingleApplication(const QString &appId, int &argc, char** argv)
|
||||
: QApplication(argc, argv)
|
||||
, peer(0)
|
||||
, actWin(0)
|
||||
{
|
||||
sysInit(appId);
|
||||
}
|
||||
|
@ -184,8 +187,9 @@ QtSingleApplication::QtSingleApplication(const QString &appId, int &argc, char**
|
|||
*/
|
||||
QtSingleApplication::QtSingleApplication(int &argc, char** argv, Type type)
|
||||
: QApplication(argc, argv, type)
|
||||
, peer(0)
|
||||
, actWin(0)
|
||||
{
|
||||
sysInit();
|
||||
}
|
||||
|
||||
|
||||
|
@ -198,6 +202,8 @@ QtSingleApplication::QtSingleApplication(int &argc, char** argv, Type type)
|
|||
*/
|
||||
QtSingleApplication::QtSingleApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE cmap)
|
||||
: QApplication(dpy, visual, cmap)
|
||||
, peer(0)
|
||||
, actWin(0)
|
||||
{
|
||||
sysInit();
|
||||
}
|
||||
|
@ -211,6 +217,8 @@ QtSingleApplication::QtSingleApplication(Display* dpy, Qt::HANDLE visual, Qt::HA
|
|||
*/
|
||||
QtSingleApplication::QtSingleApplication(Display* dpy, int &argc, char** argv, Qt::HANDLE visual, Qt::HANDLE cmap)
|
||||
: QApplication(dpy, argc, argv, visual, cmap)
|
||||
, peer(0)
|
||||
, actWin(0)
|
||||
{
|
||||
sysInit();
|
||||
}
|
||||
|
@ -224,6 +232,8 @@ QtSingleApplication::QtSingleApplication(Display* dpy, int &argc, char** argv, Q
|
|||
*/
|
||||
QtSingleApplication::QtSingleApplication(Display* dpy, const QString &appId, int argc, char** argv, Qt::HANDLE visual, Qt::HANDLE cmap)
|
||||
: QApplication(dpy, argc, argv, visual, cmap)
|
||||
, peer(0)
|
||||
, actWin(0)
|
||||
{
|
||||
sysInit(appId);
|
||||
}
|
||||
|
@ -246,10 +256,15 @@ bool QtSingleApplication::isRunning()
|
|||
#ifdef Q_OS_HAIKU
|
||||
return false;
|
||||
#else
|
||||
return peer->isClient();
|
||||
return (peer && peer->isClient());
|
||||
#endif
|
||||
}
|
||||
|
||||
void QtSingleApplication::setAppId(const QString &id)
|
||||
{
|
||||
sysInit(id);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Tries to send the text \a message to the currently running
|
||||
|
@ -269,7 +284,7 @@ bool QtSingleApplication::sendMessage(const QString &message, int timeout)
|
|||
#ifdef Q_OS_HAIKU
|
||||
return false;
|
||||
#else
|
||||
return peer->sendMessage(message, timeout);
|
||||
return (peer && peer->sendMessage(message, timeout));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -280,7 +295,7 @@ bool QtSingleApplication::sendMessage(const QString &message, int timeout)
|
|||
*/
|
||||
QString QtSingleApplication::id() const
|
||||
{
|
||||
return peer->applicationId();
|
||||
return (peer ? peer->applicationId() : "");
|
||||
}
|
||||
|
||||
|
||||
|
@ -299,6 +314,10 @@ QString QtSingleApplication::id() const
|
|||
void QtSingleApplication::setActivationWindow(QWidget* aw, bool activateOnMessage)
|
||||
{
|
||||
actWin = aw;
|
||||
if (!peer) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (activateOnMessage) {
|
||||
connect(peer, SIGNAL(messageReceived(const QString &)), this, SLOT(activateWindow()));
|
||||
}
|
||||
|
|
1
src/lib/3rdparty/qtsingleapplication.h
vendored
1
src/lib/3rdparty/qtsingleapplication.h
vendored
|
@ -80,6 +80,7 @@ public:
|
|||
#endif
|
||||
|
||||
bool isRunning();
|
||||
void setAppId(const QString &id);
|
||||
QString id() const;
|
||||
|
||||
void setActivationWindow(QWidget* aw, bool activateOnMessage = true);
|
||||
|
|
|
@ -54,18 +54,20 @@
|
|||
#endif
|
||||
#include <QWebSecurityOrigin>
|
||||
#include <QNetworkDiskCache>
|
||||
#include <QDir>
|
||||
#include <QDesktopServices>
|
||||
#include <QSettings>
|
||||
#include <QTimer>
|
||||
#include <QTranslator>
|
||||
#include <QSettings>
|
||||
#include <QProcess>
|
||||
#include <QDebug>
|
||||
#include <QTimer>
|
||||
#include <QDir>
|
||||
|
||||
#if defined(PORTABLE_BUILD) && !defined(NO_SYSTEM_DATAPATH)
|
||||
#define NO_SYSTEM_DATAPATH
|
||||
#endif
|
||||
|
||||
MainApplication::MainApplication(int &argc, char** argv)
|
||||
: QtSingleApplication("QupZillaWebBrowser", argc, argv)
|
||||
: QtSingleApplication(argc, argv)
|
||||
, m_cookiemanager(0)
|
||||
, m_browsingLibrary(0)
|
||||
, m_historymodel(0)
|
||||
|
@ -80,6 +82,7 @@ MainApplication::MainApplication(int &argc, char** argv)
|
|||
, m_desktopNotifications(0)
|
||||
, m_searchEnginesManager(0)
|
||||
, m_dbWriter(new DatabaseWriter(this))
|
||||
, m_isPrivateSession(false)
|
||||
, m_isClosing(false)
|
||||
, m_isStateChanged(false)
|
||||
, m_isRestoring(false)
|
||||
|
@ -135,8 +138,7 @@ MainApplication::MainApplication(int &argc, char** argv)
|
|||
m_postLaunchActions.append(OpenDownloadManager);
|
||||
break;
|
||||
case Qz::CL_StartPrivateBrowsing:
|
||||
messages.append("ACTION:StartPrivateBrowsing");
|
||||
m_postLaunchActions.append(PrivateBrowsing);
|
||||
m_isPrivateSession = true;
|
||||
break;
|
||||
case Qz::CL_OpenUrlInCurrentTab:
|
||||
startUrl = QUrl::fromUserInput(pair.text);
|
||||
|
@ -156,6 +158,11 @@ MainApplication::MainApplication(int &argc, char** argv)
|
|||
}
|
||||
}
|
||||
|
||||
// Don't start single application in private browsing
|
||||
if (!m_isPrivateSession) {
|
||||
setAppId("QupZillaWebBrowser");
|
||||
}
|
||||
|
||||
if (messages.isEmpty()) {
|
||||
messages.append(" ");
|
||||
}
|
||||
|
@ -201,11 +208,6 @@ MainApplication::MainApplication(int &argc, char** argv)
|
|||
|
||||
Settings::createSettings(m_activeProfil + "settings.ini");
|
||||
|
||||
Settings settings;
|
||||
m_startingAfterCrash = settings.value("SessionRestore/isRunning", false).toBool();
|
||||
bool checkUpdates = settings.value("Web-Browser-Settings/CheckUpdates", DEFAULT_CHECK_UPDATES).toBool();
|
||||
settings.setValue("SessionRestore/isRunning", true);
|
||||
|
||||
translateApp();
|
||||
|
||||
QupZilla* qupzilla = new QupZilla(Qz::BW_FirstAppWindow, startUrl);
|
||||
|
@ -224,8 +226,15 @@ MainApplication::MainApplication(int &argc, char** argv)
|
|||
m_plugins->loadPlugins();
|
||||
}
|
||||
|
||||
if (checkUpdates) {
|
||||
new Updater(qupzilla);
|
||||
if (!m_isPrivateSession) {
|
||||
Settings settings;
|
||||
m_startingAfterCrash = settings.value("SessionRestore/isRunning", false).toBool();
|
||||
bool checkUpdates = settings.value("Web-Browser-Settings/CheckUpdates", DEFAULT_CHECK_UPDATES).toBool();
|
||||
settings.setValue("SessionRestore/isRunning", true);
|
||||
|
||||
if (checkUpdates) {
|
||||
new Updater(qupzilla);
|
||||
}
|
||||
}
|
||||
|
||||
QTimer::singleShot(0, this, SLOT(postLaunch()));
|
||||
|
@ -236,10 +245,6 @@ MainApplication::MainApplication(int &argc, char** argv)
|
|||
|
||||
void MainApplication::postLaunch()
|
||||
{
|
||||
if (m_postLaunchActions.contains(PrivateBrowsing)) {
|
||||
togglePrivateBrowsingMode(true);
|
||||
}
|
||||
|
||||
if (m_postLaunchActions.contains(OpenDownloadManager)) {
|
||||
downManager()->show();
|
||||
}
|
||||
|
@ -303,7 +308,11 @@ void MainApplication::loadSettings()
|
|||
|
||||
//Web browsing settings
|
||||
settings.beginGroup("Web-Browser-Settings");
|
||||
m_websettings->enablePersistentStorage(m_activeProfil);
|
||||
|
||||
if (!m_isPrivateSession) {
|
||||
m_websettings->enablePersistentStorage(m_activeProfil);
|
||||
m_websettings->setAttribute(QWebSettings::LocalStorageEnabled, settings.value("HTML5StorageEnabled", true).toBool());
|
||||
}
|
||||
m_websettings->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
|
||||
m_websettings->setAttribute(QWebSettings::PluginsEnabled, settings.value("allowFlash", true).toBool());
|
||||
m_websettings->setAttribute(QWebSettings::JavascriptEnabled, settings.value("allowJavaScript", true).toBool());
|
||||
|
@ -315,7 +324,6 @@ void MainApplication::loadSettings()
|
|||
m_websettings->setAttribute(QWebSettings::ZoomTextOnly, settings.value("zoomTextOnly", false).toBool());
|
||||
m_websettings->setAttribute(QWebSettings::PrintElementBackgrounds, settings.value("PrintElementBackground", true).toBool());
|
||||
m_websettings->setAttribute(QWebSettings::XSSAuditingEnabled, settings.value("XSSAuditing", false).toBool());
|
||||
m_websettings->setAttribute(QWebSettings::LocalStorageEnabled, settings.value("HTML5StorageEnabled", true).toBool());
|
||||
m_websettings->setMaximumPagesInCache(settings.value("maximumCachedPages", 3).toInt());
|
||||
m_websettings->setDefaultTextEncoding(settings.value("DefaultEncoding", m_websettings->defaultTextEncoding()).toString());
|
||||
|
||||
|
@ -353,6 +361,11 @@ void MainApplication::loadSettings()
|
|||
// Allows to load files from qrc: scheme in qupzilla: pages
|
||||
QWebSecurityOrigin::addLocalScheme("qupzilla");
|
||||
|
||||
if (m_isPrivateSession) {
|
||||
m_websettings->setAttribute(QWebSettings::PrivateBrowsingEnabled, true);
|
||||
history()->setSaving(false);
|
||||
}
|
||||
|
||||
if (m_downloadManager) {
|
||||
m_downloadManager->loadSettings();
|
||||
}
|
||||
|
@ -418,15 +431,6 @@ QList<QupZilla*> MainApplication::mainWindows()
|
|||
return list;
|
||||
}
|
||||
|
||||
void MainApplication::togglePrivateBrowsingMode(bool state)
|
||||
{
|
||||
webSettings()->setAttribute(QWebSettings::PrivateBrowsingEnabled, state);
|
||||
history()->setSaving(!state);
|
||||
cookieJar()->turnPrivateJar(state);
|
||||
|
||||
emit message(Qz::AM_CheckPrivateBrowsing, state);
|
||||
}
|
||||
|
||||
void MainApplication::sendMessages(Qz::AppMessageType mes, bool state)
|
||||
{
|
||||
emit message(mes, state);
|
||||
|
@ -454,9 +458,6 @@ void MainApplication::receiveAppMessage(QString message)
|
|||
downManager()->show();
|
||||
actWin = downManager();
|
||||
}
|
||||
else if (text == "StartPrivateBrowsing") {
|
||||
sendMessages(Qz::AM_StartPrivateBrowsing, true);
|
||||
}
|
||||
else if (text.startsWith("OpenUrlInCurrentTab")) {
|
||||
actUrl = QUrl::fromUserInput(text.remove("OpenUrlInCurrentTab"));
|
||||
}
|
||||
|
@ -534,6 +535,11 @@ void MainApplication::connectDatabase()
|
|||
db.setDatabaseName(m_activeProfil + "browsedata.db");
|
||||
qWarning("Cannot find SQLite database file! Copying and using the defaults!");
|
||||
}
|
||||
|
||||
if (m_isPrivateSession) {
|
||||
db.setConnectOptions("QSQLITE_OPEN_READONLY");
|
||||
}
|
||||
|
||||
if (!db.open()) {
|
||||
qWarning("Cannot open SQLite database! Continuing without database....");
|
||||
}
|
||||
|
@ -583,6 +589,10 @@ void MainApplication::quitApplication()
|
|||
|
||||
void MainApplication::saveSettings()
|
||||
{
|
||||
if (m_isPrivateSession) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_isClosing = true;
|
||||
m_networkmanager->disconnectObjects();
|
||||
|
||||
|
@ -730,6 +740,41 @@ DesktopNotificationsFactory* MainApplication::desktopNotifications()
|
|||
return m_desktopNotifications;
|
||||
}
|
||||
|
||||
void MainApplication::startPrivateBrowsing()
|
||||
{
|
||||
QStringList args;
|
||||
foreach(const QString & arg, arguments()) {
|
||||
if (arg.startsWith("-")) {
|
||||
args.append(arg);
|
||||
}
|
||||
}
|
||||
|
||||
args.append("--private-browsing");
|
||||
|
||||
if (!QProcess::startDetached(applicationFilePath(), args)) {
|
||||
qWarning() << "MainApplication: Cannot start new browser process for private browsing!" << applicationFilePath() << args;
|
||||
}
|
||||
}
|
||||
|
||||
QUrl MainApplication::userStyleSheet(const QString &filePath) const
|
||||
{
|
||||
QString userStyle;
|
||||
|
||||
QFile file(filePath);
|
||||
if (!filePath.isEmpty() && file.open(QFile::ReadOnly)) {
|
||||
userStyle = file.readAll();
|
||||
userStyle.remove("\n");
|
||||
file.close();
|
||||
}
|
||||
|
||||
userStyle.append(AdBlockManager::instance()->elementHidingRules() + "{ display:none !important;}");
|
||||
|
||||
QString encodedStyle = userStyle.toAscii().toBase64();
|
||||
QString dataString = QString("data:text/css;charset=utf-8;base64,%1").arg(encodedStyle);
|
||||
|
||||
return QUrl(dataString);
|
||||
}
|
||||
|
||||
void MainApplication::aboutToCloseWindow(QupZilla* window)
|
||||
{
|
||||
if (!window) {
|
||||
|
@ -754,8 +799,7 @@ static const int sessionVersion = 0x0003;
|
|||
|
||||
bool MainApplication::saveStateSlot()
|
||||
{
|
||||
if (m_websettings->testAttribute(QWebSettings::PrivateBrowsingEnabled) ||
|
||||
m_isRestoring || m_mainWindows.count() == 0) {
|
||||
if (m_isPrivateSession || m_isRestoring || m_mainWindows.count() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -794,7 +838,7 @@ bool MainApplication::saveStateSlot()
|
|||
|
||||
bool MainApplication::restoreStateSlot(QupZilla* window)
|
||||
{
|
||||
if (m_postLaunchActions.contains(PrivateBrowsing)) {
|
||||
if (m_isPrivateSession) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -844,25 +888,6 @@ bool MainApplication::restoreStateSlot(QupZilla* window)
|
|||
return true;
|
||||
}
|
||||
|
||||
QUrl MainApplication::userStyleSheet(const QString &filePath) const
|
||||
{
|
||||
QString userStyle;
|
||||
|
||||
QFile file(filePath);
|
||||
if (!filePath.isEmpty() && file.open(QFile::ReadOnly)) {
|
||||
userStyle = file.readAll();
|
||||
userStyle.remove("\n");
|
||||
file.close();
|
||||
}
|
||||
|
||||
userStyle.append(AdBlockManager::instance()->elementHidingRules() + "{ display:none !important;}");
|
||||
|
||||
QString encodedStyle = userStyle.toAscii().toBase64();
|
||||
QString dataString = QString("data:text/css;charset=utf-8;base64,%1").arg(encodedStyle);
|
||||
|
||||
return QUrl(dataString);
|
||||
}
|
||||
|
||||
bool MainApplication::checkSettingsDir()
|
||||
{
|
||||
/*
|
||||
|
|
|
@ -72,14 +72,13 @@ public:
|
|||
inline static MainApplication* getInstance() { return static_cast<MainApplication*>(QCoreApplication::instance()); }
|
||||
inline QString currentProfilePath() { return m_activeProfil; }
|
||||
inline QString currentLanguage() { return m_activeLanguage; }
|
||||
inline bool isPrivateSession() { return m_isPrivateSession; }
|
||||
inline bool isClosing() { return m_isClosing; }
|
||||
inline bool isStartingAfterCrash() { return m_startingAfterCrash; }
|
||||
inline int windowCount() { return m_mainWindows.count(); }
|
||||
|
||||
bool checkSettingsDir();
|
||||
|
||||
void togglePrivateBrowsingMode(bool state);
|
||||
|
||||
QupZilla* getWindow();
|
||||
CookieManager* cookieManager();
|
||||
BrowsingLibrary* browsingLibrary();
|
||||
|
@ -109,6 +108,8 @@ public slots:
|
|||
void setStateChanged();
|
||||
void addNewTab(const QUrl &url = QUrl());
|
||||
|
||||
void startPrivateBrowsing();
|
||||
|
||||
signals:
|
||||
void message(Qz::AppMessageType mes, bool state);
|
||||
|
||||
|
@ -149,6 +150,7 @@ private:
|
|||
QString m_activeLanguage;
|
||||
QString m_activeThemePath;
|
||||
|
||||
bool m_isPrivateSession;
|
||||
bool m_isClosing;
|
||||
bool m_isStateChanged;
|
||||
bool m_isRestoring;
|
||||
|
|
|
@ -108,6 +108,10 @@ QupZilla::QupZilla(Qz::BrowserWindow type, QUrl startUrl)
|
|||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
setWindowTitle(tr("QupZilla"));
|
||||
|
||||
if (mApp->isPrivateSession()) {
|
||||
setProperty("private", QVariant(true));
|
||||
}
|
||||
|
||||
m_isStarting = true;
|
||||
|
||||
setupUi();
|
||||
|
@ -450,9 +454,8 @@ void QupZilla::setupMenu()
|
|||
m_menuTools->addAction(QIcon::fromTheme("edit-clear"), tr("Clear Recent &History"), this, SLOT(showClearPrivateData()));
|
||||
m_actionPrivateBrowsing = new QAction(tr("&Private Browsing"), this);
|
||||
m_actionPrivateBrowsing->setShortcut(QKeySequence("Ctrl+Shift+P"));
|
||||
m_actionPrivateBrowsing->setCheckable(true);
|
||||
m_actionPrivateBrowsing->setChecked(mApp->webSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled));
|
||||
connect(m_actionPrivateBrowsing, SIGNAL(triggered(bool)), this, SLOT(startPrivate(bool)));
|
||||
m_actionPrivateBrowsing->setVisible(!mApp->isPrivateSession());
|
||||
connect(m_actionPrivateBrowsing, SIGNAL(triggered(bool)), mApp, SLOT(startPrivateBrowsing()));
|
||||
m_menuTools->addAction(m_actionPrivateBrowsing);
|
||||
m_menuTools->addSeparator();
|
||||
#if !defined(Q_WS_X11) && !defined(Q_WS_MAC)
|
||||
|
@ -581,8 +584,7 @@ void QupZilla::loadSettings()
|
|||
m_sideBarManager->showSideBar(activeSideBar, false);
|
||||
|
||||
//Private browsing
|
||||
m_actionPrivateBrowsing->setChecked(mApp->webSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled));
|
||||
m_privateBrowsing->setVisible(mApp->webSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled));
|
||||
m_privateBrowsing->setVisible(mApp->isPrivateSession());
|
||||
|
||||
#ifdef Q_WS_WIN
|
||||
if (m_usingTransparentBackground && !makeTransparent) {
|
||||
|
@ -657,7 +659,7 @@ void QupZilla::setWindowTitle(const QString &t)
|
|||
{
|
||||
QString title = t;
|
||||
|
||||
if (mApp->webSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled)) {
|
||||
if (mApp->isPrivateSession()) {
|
||||
title.append(tr(" (Private Browsing)"));
|
||||
}
|
||||
|
||||
|
@ -695,10 +697,6 @@ void QupZilla::receiveMessage(Qz::AppMessageType mes, bool state)
|
|||
m_bookmarksMenuChanged = true;
|
||||
break;
|
||||
|
||||
case Qz::AM_StartPrivateBrowsing:
|
||||
startPrivate(state);
|
||||
break;
|
||||
|
||||
default:
|
||||
qWarning("Unresolved message sent! This could never happen!");
|
||||
break;
|
||||
|
@ -1499,40 +1497,6 @@ void QupZilla::savePageScreen()
|
|||
p->show();
|
||||
}
|
||||
|
||||
void QupZilla::startPrivate(bool state)
|
||||
{
|
||||
static bool askedThisSession = false;
|
||||
|
||||
Settings settings;
|
||||
bool askNow = settings.value("Browser-View-Settings/AskOnPrivate", true).toBool();
|
||||
|
||||
if (state && askNow && !askedThisSession) {
|
||||
QString title = tr("Are you sure you want to turn on private browsing?");
|
||||
QString text1 = tr("When private browsing is turned on, some actions concerning your privacy will be disabled:");
|
||||
|
||||
QStringList actions;
|
||||
actions.append(tr("Webpages are not added to the history."));
|
||||
actions.append(tr("Current cookies cannot be accessed."));
|
||||
actions.append(tr("Your session is not stored."));
|
||||
|
||||
QString text2 = tr("Until you close the window, you can still click the Back and Forward "
|
||||
"buttons to return to the webpages you have opened.");
|
||||
|
||||
QString message = QString(QLatin1String("<b>%1</b><p>%2</p><ul><li>%3</li></ul><p>%4</p>")).arg(title, text1, actions.join(QLatin1String("</li><li>")), text2);
|
||||
|
||||
QMessageBox::StandardButton button = QMessageBox::question(this, tr("Start Private Browsing"),
|
||||
message, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
||||
if (button != QMessageBox::Yes) {
|
||||
m_actionPrivateBrowsing->setChecked(false);
|
||||
return;
|
||||
}
|
||||
|
||||
askedThisSession = true;
|
||||
}
|
||||
|
||||
mApp->togglePrivateBrowsingMode(state);
|
||||
}
|
||||
|
||||
void QupZilla::resizeEvent(QResizeEvent* event)
|
||||
{
|
||||
m_bookmarksToolbar->setMaximumWidth(width());
|
||||
|
|
|
@ -181,7 +181,6 @@ private slots:
|
|||
void zoomOut();
|
||||
void zoomReset();
|
||||
void fullScreen(bool make);
|
||||
void startPrivate(bool state);
|
||||
void changeEncoding();
|
||||
|
||||
void closeWindow();
|
||||
|
|
|
@ -35,7 +35,6 @@ enum AppMessageType {
|
|||
AM_ReloadSettings,
|
||||
AM_HistoryStateChanged,
|
||||
AM_BookmarksChanged,
|
||||
AM_StartPrivateBrowsing
|
||||
};
|
||||
|
||||
enum BrowserWindow {
|
||||
|
|
|
@ -234,7 +234,7 @@ void AutoFillModel::completePage(WebPage* page)
|
|||
void AutoFillModel::post(const QNetworkRequest &request, const QByteArray &outgoingData)
|
||||
{
|
||||
//Dont save in private browsing
|
||||
if (mApp->webSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled)) {
|
||||
if (mApp->isPrivateSession()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ void BookmarkIcon::speedDialChanged()
|
|||
|
||||
void BookmarkIcon::setBookmarkSaved()
|
||||
{
|
||||
setProperty("bookmarked", true);
|
||||
setProperty("bookmarked", QVariant(true));
|
||||
style()->unpolish(this);
|
||||
style()->polish(this);
|
||||
setToolTip(tr("Edit this bookmark"));
|
||||
|
@ -96,7 +96,7 @@ void BookmarkIcon::setBookmarkSaved()
|
|||
|
||||
void BookmarkIcon::setBookmarkDisabled()
|
||||
{
|
||||
setProperty("bookmarked", false);
|
||||
setProperty("bookmarked", QVariant(false));
|
||||
style()->unpolish(this);
|
||||
style()->polish(this);
|
||||
setToolTip(tr("Bookmark this Page"));
|
||||
|
|
|
@ -118,17 +118,11 @@ bool CookieJar::setCookiesFromUrl(const QList<QNetworkCookie> &cookieList, const
|
|||
|
||||
void CookieJar::saveCookies()
|
||||
{
|
||||
if (m_deleteOnClose) {
|
||||
if (m_deleteOnClose || mApp->isPrivateSession()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QList<QNetworkCookie> allCookies;
|
||||
if (m_tempList.isEmpty()) {
|
||||
allCookies = getAllCookies();
|
||||
}
|
||||
else {
|
||||
allCookies = m_tempList;
|
||||
}
|
||||
QList<QNetworkCookie> allCookies = getAllCookies();
|
||||
|
||||
QFile file(m_activeProfil + "cookies.dat");
|
||||
file.open(QIODevice::WriteOnly);
|
||||
|
@ -150,9 +144,10 @@ void CookieJar::saveCookies()
|
|||
|
||||
void CookieJar::restoreCookies()
|
||||
{
|
||||
if (!QFile::exists(m_activeProfil + "cookies.dat")) {
|
||||
if (!QFile::exists(m_activeProfil + "cookies.dat") || mApp->isPrivateSession()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QDateTime now = QDateTime::currentDateTime();
|
||||
|
||||
QList<QNetworkCookie> restoredCookies;
|
||||
|
@ -184,12 +179,7 @@ void CookieJar::restoreCookies()
|
|||
|
||||
void CookieJar::clearCookies()
|
||||
{
|
||||
if (m_tempList.isEmpty()) {
|
||||
setAllCookies(QList<QNetworkCookie>());
|
||||
}
|
||||
else {
|
||||
m_tempList.clear();
|
||||
}
|
||||
setAllCookies(QList<QNetworkCookie>());
|
||||
}
|
||||
|
||||
QList<QNetworkCookie> CookieJar::getAllCookies()
|
||||
|
@ -201,16 +191,3 @@ void CookieJar::setAllCookies(const QList<QNetworkCookie> &cookieList)
|
|||
{
|
||||
QNetworkCookieJar::setAllCookies(cookieList);
|
||||
}
|
||||
|
||||
void CookieJar::turnPrivateJar(bool state)
|
||||
{
|
||||
if (state) {
|
||||
m_tempList = QNetworkCookieJar::allCookies();
|
||||
QNetworkCookieJar::setAllCookies(QList<QNetworkCookie>());
|
||||
}
|
||||
else {
|
||||
QNetworkCookieJar::setAllCookies(m_tempList);
|
||||
m_tempList.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,10 +41,10 @@ public:
|
|||
void clearCookies();
|
||||
|
||||
void setAllowCookies(bool allow);
|
||||
void turnPrivateJar(bool state);
|
||||
|
||||
private:
|
||||
QupZilla* p_QupZilla;
|
||||
|
||||
bool m_allowCookies;
|
||||
bool m_filterTrackingCookie;
|
||||
bool m_allowCookiesFromDomain;
|
||||
|
@ -54,7 +54,6 @@ private:
|
|||
QStringList m_blacklist;
|
||||
|
||||
QString m_activeProfil;
|
||||
QList<QNetworkCookie> m_tempList;
|
||||
};
|
||||
|
||||
#endif // COOKIEJAR_H
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
<style>
|
||||
html {background: #eeeeee;font: 13px/22px "Helvetica Neue", Helvetica, Arial, sans-serif;color: #525c66;}
|
||||
#box {max-width: 500px;margin: 25px auto 0px auto;padding: 0px 40px 0px 40px;border-width: 20px;-webkit-border-image: url(%BOX-BORDER%) 25;}
|
||||
h1 {color: #1a4ba4;font-size: 160%;margin-top: 0px;}
|
||||
.line {width: 400px;height: 25px;text-align: center;border: 1px solid #babcb8;}
|
||||
.line:focus {border-color: #579eea;}
|
||||
.submit {margin-top: 5px;}
|
||||
|
@ -16,13 +17,15 @@ a {color: #1a4ba4;text-decoration: none;font-weight: bold;}
|
|||
<div id="box">
|
||||
<center>
|
||||
|
||||
<img src="%ABOUT-IMG%"">
|
||||
<form action="http://www.google.com/search?client=qupzilla" method="GET">
|
||||
<img src="%ABOUT-IMG%">
|
||||
%PRIVATE-BROWSING%
|
||||
<form action="https://duckduckgo.com/" method="GET">
|
||||
<input type="hidden" name="t" value="qupzilla" />
|
||||
<input class="line" id="inp" class="question" name="q"/> <br/>
|
||||
<input class="submit" type="submit" name="search" value="%BUTTON-LABEL%">
|
||||
<input class="submit" type="submit" value="%BUTTON-LABEL%">
|
||||
</form>
|
||||
|
||||
<p class="bottom">%SEARCH-BY-GOOGLE% | <a href="%WWW%">%ABOUT-QUPZILLA%</a></p>
|
||||
<p class="bottom">%SEARCH-BY% | <a href="%WWW%">%ABOUT-QUPZILLA%</a></p>
|
||||
</center>
|
||||
</div>
|
||||
</body></html>
|
||||
|
|
|
@ -220,7 +220,7 @@ void DownloadManager::handleUnsupportedContent(QNetworkReply* reply, WebPage* pa
|
|||
return;
|
||||
}
|
||||
|
||||
reply->setProperty("downReply", true);
|
||||
reply->setProperty("downReply", QVariant(true));
|
||||
|
||||
DownloadFileHelper* h = new DownloadFileHelper(m_lastDownloadPath, m_downloadPath, m_useNativeDialog, page);
|
||||
connect(h, SIGNAL(itemCreated(QListWidgetItem*, DownloadItem*)), this, SLOT(itemCreated(QListWidgetItem*, DownloadItem*)));
|
||||
|
|
|
@ -246,11 +246,11 @@ void LocationBar::clearIcon()
|
|||
|
||||
void LocationBar::setPrivacy(bool state)
|
||||
{
|
||||
m_siteIcon->setProperty("secured", state);
|
||||
m_siteIcon->setProperty("secured", QVariant(state));
|
||||
m_siteIcon->style()->unpolish(m_siteIcon);
|
||||
m_siteIcon->style()->polish(m_siteIcon);
|
||||
|
||||
setProperty("secured", state);
|
||||
setProperty("secured", QVariant(state));
|
||||
style()->unpolish(this);
|
||||
style()->polish(this);
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ void NetworkManager::loadSettings()
|
|||
Settings settings;
|
||||
settings.beginGroup("Web-Browser-Settings");
|
||||
|
||||
if (settings.value("AllowLocalCache", true).toBool()) {
|
||||
if (settings.value("AllowLocalCache", true).toBool() && !mApp->isPrivateSession()) {
|
||||
QNetworkDiskCache* cache = mApp->networkCache();
|
||||
cache->setMaximumCacheSize(settings.value("MaximumCacheSize", 50).toInt() * 1024 * 1024); //MegaBytes
|
||||
setCache(cache);
|
||||
|
@ -260,7 +260,7 @@ void NetworkManager::authentication(QNetworkReply* reply, QAuthenticator* auth)
|
|||
emit wantsFocus(reply->url());
|
||||
|
||||
//Do not save when private browsing is enabled
|
||||
if (mApp->webSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled)) {
|
||||
if (mApp->isPrivateSession()) {
|
||||
save->setVisible(false);
|
||||
}
|
||||
|
||||
|
|
|
@ -167,10 +167,11 @@ QString QupZillaSchemeReply::startPage()
|
|||
sPage.replace("%ABOUT-IMG%", "qrc:icons/other/about.png");
|
||||
|
||||
sPage.replace("%TITLE%", tr("Start Page"));
|
||||
sPage.replace("%BUTTON-LABEL%", tr("Google Search"));
|
||||
sPage.replace("%SEARCH-BY-GOOGLE%", tr("Search results provided by Google"));
|
||||
sPage.replace("%BUTTON-LABEL%", tr("Search on Web"));
|
||||
sPage.replace("%SEARCH-BY%", tr("Search results provided by DuckDuckGo"));
|
||||
sPage.replace("%WWW%", QupZilla::WIKIADDRESS);
|
||||
sPage.replace("%ABOUT-QUPZILLA%", tr("About QupZilla"));
|
||||
sPage.replace("%PRIVATE-BROWSING%", mApp->isPrivateSession() ? tr("<h1>Private Browsing</h1>") : "");
|
||||
|
||||
return sPage;
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ void SourceViewerSearch::next()
|
|||
m_sourceViewer->sourceEdit()->moveCursor(QTextCursor::Start);
|
||||
}
|
||||
|
||||
ui->lineEdit->setProperty("notfound", !found);
|
||||
ui->lineEdit->setProperty("notfound", QVariant(!found));
|
||||
|
||||
ui->lineEdit->style()->unpolish(ui->lineEdit);
|
||||
ui->lineEdit->style()->polish(ui->lineEdit);
|
||||
|
@ -78,7 +78,7 @@ void SourceViewerSearch::previous()
|
|||
m_sourceViewer->sourceEdit()->moveCursor(QTextCursor::Start);
|
||||
}
|
||||
|
||||
ui->lineEdit->setProperty("notfound", !found);
|
||||
ui->lineEdit->setProperty("notfound", QVariant(!found));
|
||||
|
||||
ui->lineEdit->style()->unpolish(ui->lineEdit);
|
||||
ui->lineEdit->style()->polish(ui->lineEdit);
|
||||
|
|
|
@ -153,7 +153,6 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent)
|
|||
ui->showBackForward->setChecked(settings.value("showBackForwardButtons", true).toBool());
|
||||
ui->showAddTabButton->setChecked(settings.value("showAddTabButton", false).toBool());
|
||||
ui->useTransparentBg->setChecked(settings.value("useTransparentBackground", false).toBool());
|
||||
ui->askOnPrivateBrowsing->setChecked(settings.value("AskOnPrivate", true).toBool());
|
||||
settings.endGroup();
|
||||
#ifdef Q_WS_WIN
|
||||
ui->useTransparentBg->setEnabled(QtWin::isCompositionEnabled());
|
||||
|
@ -757,7 +756,6 @@ void Preferences::saveSettings()
|
|||
settings.setValue("showBackForwardButtons", ui->showBackForward->isChecked());
|
||||
settings.setValue("useTransparentBackground", ui->useTransparentBg->isChecked());
|
||||
settings.setValue("showAddTabButton", ui->showAddTabButton->isChecked());
|
||||
settings.setValue("AskOnPrivate", ui->askOnPrivateBrowsing->isChecked());
|
||||
settings.endGroup();
|
||||
|
||||
//TABS
|
||||
|
|
|
@ -841,13 +841,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="askOnPrivateBrowsing">
|
||||
<property name="text">
|
||||
<string>Ask when entering Private Browsing mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
|
|
|
@ -28,8 +28,7 @@ ClosedTabsManager::ClosedTabsManager()
|
|||
|
||||
void ClosedTabsManager::saveView(WebTab* tab, int position)
|
||||
{
|
||||
if (mApp->webSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled) ||
|
||||
(tab->url().isEmpty() && tab->history()->items().count() == 0)) {
|
||||
if (mApp->isPrivateSession() || (tab->url().isEmpty() && tab->history()->items().count() == 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ IconProvider* IconProvider::instance()
|
|||
|
||||
void IconProvider::saveIcon(WebView* view)
|
||||
{
|
||||
if (mApp->webSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled)) {
|
||||
if (mApp->isPrivateSession()) {
|
||||
// Don't save icons in private mode.
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -158,7 +158,7 @@ void PlainEditWithLines::highlightCurrentLine()
|
|||
QTextEdit::ExtraSelection selection;
|
||||
|
||||
selection.format.setBackground(lineColor);
|
||||
selection.format.setProperty(QTextFormat::FullWidthSelection, true);
|
||||
selection.format.setProperty(QTextFormat::FullWidthSelection, QVariant(true));
|
||||
selection.cursor = textCursor();
|
||||
selection.cursor.clearSelection();
|
||||
selectionsList.append(selection);
|
||||
|
|
|
@ -138,7 +138,7 @@ void SearchToolBar::searchText(const QString &text)
|
|||
}
|
||||
|
||||
|
||||
ui->lineEdit->setProperty("notfound", !found);
|
||||
ui->lineEdit->setProperty("notfound", QVariant(!found));
|
||||
|
||||
ui->lineEdit->style()->unpolish(ui->lineEdit);
|
||||
ui->lineEdit->style()->polish(ui->lineEdit);
|
||||
|
|
|
@ -653,6 +653,10 @@ QList<WebTab*> TabWidget::allTabs(bool withPinned)
|
|||
|
||||
void TabWidget::savePinnedTabs()
|
||||
{
|
||||
if (mApp->isPrivateSession()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QByteArray data;
|
||||
QDataStream stream(&data, QIODevice::WriteOnly);
|
||||
|
||||
|
@ -679,6 +683,10 @@ void TabWidget::savePinnedTabs()
|
|||
|
||||
void TabWidget::restorePinnedTabs()
|
||||
{
|
||||
if (mApp->isPrivateSession()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QFile file(mApp->currentProfilePath() + "pinnedtabs.dat");
|
||||
file.open(QIODevice::ReadOnly);
|
||||
QByteArray sd = file.readAll();
|
||||
|
|
Loading…
Reference in New Issue
Block a user