urlLineEditPointer->clearFocus();
// Get the current domain settings name.
- QString ¤tDomainSettingsName = tabWidgetPointer->getDomainSettingsName();
+ QString currentDomainSettingsName = tabWidgetPointer->getDomainSettingsName();
// Run the commands according to the current domain settings status.
if (currentDomainSettingsName == QStringLiteral("")) // Domain settings are not currently applied.
if (abs(currentZoomFactorDouble - defaultZoomFactorDouble ) > 0.01)
zoomFactorInt = DomainsDatabase::CUSTOM;
+ // Update the current domain settings name.
+ currentDomainSettingsName = currentUrl.host();
+
// Add the domain.
- DomainsDatabase::addDomain(currentUrl.host(), javaScriptInt, localStorageInt, domStorageInt, userAgentDatabaseString, ultraPrivacyInt, ultraListInt, easyPrivacyInt, easyListInt,
+ DomainsDatabase::addDomain(currentDomainSettingsName, javaScriptInt, localStorageInt, domStorageInt, userAgentDatabaseString, ultraPrivacyInt, ultraListInt, easyPrivacyInt, easyListInt,
fanboysAnnoyanceListInt, zoomFactorInt, currentZoomFactorDouble);
- // Apply the domain settings.
- tabWidgetPointer->applyDomainSettingsAndReload();
+ // Apply the domain settings in all windows.
+ applyDomainSettingsInAllWindows();
}
// Create the domain settings dialog pointer.
DomainSettingsDialog *domainSettingsDialogPointer = new DomainSettingsDialog(this, DomainSettingsDialog::EDIT_DOMAIN, currentDomainSettingsName);
- // Reload the tabs when domain settings are updated.
- connect(domainSettingsDialogPointer, SIGNAL(domainSettingsUpdated()), tabWidgetPointer, SLOT(applyDomainSettingsAndReload()));
+ // Apply the domain settings in all windows when domain settings are updated.
+ connect(domainSettingsDialogPointer, SIGNAL(domainSettingsUpdated()), this, SLOT(applyDomainSettingsInAllWindows()));
// Show the dialog.
domainSettingsDialogPointer->show();
}
+void BrowserWindow::applyDomainSettingsInAllWindows() const
+{
+ // Apply the domain settings in all windows.
+ runMethodInAllWindows(QLatin1String("applyDomainSettingsInThisWindow"));
+}
+
+void BrowserWindow::applyDomainSettingsInThisWindow()
+{
+ // Apply domain settings and reload the tabs.
+ tabWidgetPointer->applyDomainSettingsAndReload();
+}
+
void BrowserWindow::back() const
{
// Remove the focus from the URL line edit.
void BrowserWindow::populateBookmarksInAllWindows() const
{
- // Get a list of all the registered service names.
- QStringList registeredServiceNames = QDBusConnection::sessionBus().interface()->registeredServiceNames().value();
-
- // Get a list of all the Privacy Browser windows, which will be `com.stoutner.privacybrowser-` with the PID appended.
- QStringList privacyBrowserServiceNames = registeredServiceNames.filter("com.stoutner.privacybrowser");
-
- // Repopulate the bookmarks in each window.
- for (QString privacyBrowserServiceName : privacyBrowserServiceNames)
- {
- // Prepare the D-Bus message.
- QDBusMessage dBusMessage = QDBusMessage::createMethodCall(privacyBrowserServiceName, "/privacybrowser/MainWindow_1", "com.stoutner.privacybrowser.BrowserWindow", "populateBookmarksInThisWindow");
-
- // Make it so.
- QDBusConnection::sessionBus().send(dBusMessage);
- }
+ // Populate the bookmarks in all windows.
+ runMethodInAllWindows(QLatin1String("populateBookmarksInThisWindow"));
}
void BrowserWindow::populateBookmarksInThisWindow()
urlLineEditPointer->setText(tabWidgetPointer->getCurrentTabUrl());
}
+void BrowserWindow::runMethodInAllWindows(const QString &methodString) const
+{
+ // Get a list of all the registered service names.
+ QStringList registeredServiceNames = QDBusConnection::sessionBus().interface()->registeredServiceNames().value();
+
+ // Get a list of all the Privacy Browser windows, which will be `com.stoutner.privacybrowser-` with the PID appended.
+ QStringList privacyBrowserServiceNames = registeredServiceNames.filter("com.stoutner.privacybrowser");
+
+ // Reapply domain settings in each window.
+ for (QString privacyBrowserServiceName : privacyBrowserServiceNames)
+ {
+ // Prepare the D-Bus message.
+ QDBusMessage dBusMessage = QDBusMessage::createMethodCall(privacyBrowserServiceName, "/privacybrowser/MainWindow_1", "com.stoutner.privacybrowser.BrowserWindow", methodString);
+
+ // Make it so.
+ QDBusConnection::sessionBus().send(dBusMessage);
+ }
+}
+
void BrowserWindow::showBookmarkContextMenu(const QPoint &point)
{
// Get the bookmark action.
DomainSettingsDialog *domainSettingsDialogPointer = new DomainSettingsDialog(this);
// Reload the tabs when domain settings are updated.
- connect(domainSettingsDialogPointer, SIGNAL(domainSettingsUpdated()), tabWidgetPointer, SLOT(applyDomainSettingsAndReload()));
+ connect(domainSettingsDialogPointer, SIGNAL(domainSettingsUpdated()), this, SLOT(applyDomainSettingsInAllWindows()));
// Show the dialog.
domainSettingsDialogPointer->show();
// Apply the settings handled by KConfig.
connect(settingsDialogPointer, SIGNAL(spellCheckLanguagesUpdated()), tabWidgetPointer, SLOT(applySpellCheckLanguages()));
connect(settingsDialogPointer, SIGNAL(settingsChanged(QString)), tabWidgetPointer, SLOT(applyApplicationSettings()));
+ //connect(settingsDialogPointer, SIGNAL(settingsChanged(QString)), this, SLOT(applyDomainSettingsInAllWindows()));
connect(settingsDialogPointer, SIGNAL(settingsChanged(QString)), tabWidgetPointer, SLOT(applyDomainSettingsAndReload()));
}
// Update the blocked requests action background color.
if (blockedRequestsVector[PrivacyWebEngineView::TOTAL] > 0)
- urlToolBarPointer->setStyleSheet(QLatin1String("QToolButton#blocked_requests { background-color: tomato; }"));
+ urlToolBarPointer->setStyleSheet(QLatin1String("QToolButton#blocked_requests { background-color: tomato; border-radius: 5px; padding: 4px; }"));
else
urlToolBarPointer->setStyleSheet(QLatin1String("QToolButton#blocked_requests { background-color: transparent; }"));
+
+ // Restore the domain settings indicator.
+ if (domainSettingsApplied)
+ urlLineEditPointer->setPalette(positiveBackgroundPalette);
+ else
+ urlLineEditPointer->setPalette(normalBackgroundPalette);
}
void BrowserWindow::updateCookiesAction(const int numberOfCookies) const
void BrowserWindow::updateDomainSettingsIndicator(const bool status)
{
+ // Store the domain settings applied status.
+ domainSettingsApplied = status;
+
// Set the domain palette according to the status.
- if (status)
+ if (domainSettingsApplied)
urlLineEditPointer->setPalette(positiveBackgroundPalette);
else
urlLineEditPointer->setPalette(normalBackgroundPalette);
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Privacy Browser PC. If not, see <http://www.gnu.org/licenses/>.
+ * along with Privacy Browser PC. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef BROWSER_WINDOW_H
public Q_SLOTS:
// The public slots.
+ void applyDomainSettingsInThisWindow(); // This is public so that the domain settings can be reapplied over D-Bus when changed by another instance of Privacy Browser.
void populateBookmarksInThisWindow(); // This is public so that the bookmarks can be repopulated over D-Bus when changed by another instance of Privacy Browser.
private Q_SLOTS:
// The private slots.
void addOrEditDomainSettings();
+ void applyDomainSettingsInAllWindows() const;
void back() const;
void clearUrlLineEditFocus() const;
void decrementZoom();
void refresh() const;
void reloadAndBypassCache() const;
void restoreUrlText() const;
+ void runMethodInAllWindows(const QString &methodString) const;
void showBookmarkContextMenu(const QPoint &point);
void showCookiesDialog();
void showDomainSettingsDialog();
double defaultZoomFactorDouble;
QAction *developerToolsActionPointer;
QAction *domStorageActionPointer;
+ bool domainSettingsApplied = false;
QAction *easyPrivacyActionPointer;
QAction *easyListActionPointer;
QAction *fanboysAnnoyanceListPointer;