// Qt toolkit headers.
#include <QClipboard>
#include <QContextMenuEvent>
+#include <QDBusConnection>
+#include <QDBusConnectionInterface>
+#include <QDBusMessage>
#include <QFileDialog>
#include <QInputDialog>
#include <QNetworkCookie>
// Show the custom bookmark context menu when requested.
connect(bookmarksToolBarPointer, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showBookmarkContextMenu(const QPoint&)));
- // Populate the bookmarks.
- populateBookmarks();
+ // Populate the bookmarks in this window.
+ populateBookmarksInThisWindow();
// Populate the UI.
// This must be done here, because otherwise, if a URL is loaded, like a local file, that does not trigger a call to TabWidget::applyDomainSettings, the UI will not be fully populated.
tabWidgetPointer->getCurrentTabFavoritIcon(), folderId);
// Update the displayed bookmarks when a new one is added.
- connect(addBookmarkDialogPointer, SIGNAL(bookmarkAdded()), this, SLOT(populateBookmarks()));
+ connect(addBookmarkDialogPointer, SIGNAL(bookmarkAdded()), this, SLOT(populateBookmarksInAllWindows()));
// Show the dialog.
addBookmarkDialogPointer->show();
AddFolderDialog *addFolderDialogPointer = new AddFolderDialog(tabWidgetPointer->getCurrentTabFavoritIcon(), folderId);
// Update the displayed bookmarks when a folder is added.
- connect(addFolderDialogPointer, SIGNAL(folderAdded()), this, SLOT(populateBookmarks()));
+ connect(addFolderDialogPointer, SIGNAL(folderAdded()), this, SLOT(populateBookmarksInAllWindows()));
// Show the dialog.
addFolderDialogPointer->show();
editFolderDialogPointer->show();
// Process bookmark events.
- connect(editFolderDialogPointer, SIGNAL(folderSaved()), this, SLOT(populateBookmarks()));
+ connect(editFolderDialogPointer, SIGNAL(folderSaved()), this, SLOT(populateBookmarksInAllWindows()));
}
);
BookmarksDatabase::updateFolderContentsDisplayOrder(parentFolderId);
// Repopulate the bookmarks.
- populateBookmarks();
+ populateBookmarksInAllWindows();
}
}
);
BookmarksDialog *bookmarksDialogPointer = new BookmarksDialog(tabWidgetPointer->getCurrentTabTitle(), tabWidgetPointer->getCurrentTabUrl(), tabWidgetPointer->getCurrentTabFavoritIcon());
// Update the displayed bookmarks when edited.
- connect(bookmarksDialogPointer, SIGNAL(bookmarkUpdated()), this, SLOT(populateBookmarks()));
+ connect(bookmarksDialogPointer, SIGNAL(bookmarkUpdated()), this, SLOT(populateBookmarksInAllWindows()));
// Show the dialog.
bookmarksDialogPointer->show();
browserWindowPointer->show();
}
-void BrowserWindow::populateBookmarks()
+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);
+ }
+}
+
+void BrowserWindow::populateBookmarksInThisWindow()
+{
+ qDebug() << "Populating bookmarks.";
+
// Remove all the final bookmark folder menu actions.
for (QPair<QMenu *, QAction *> *finalBookmarkFolderMenuActionPair : finalBookmarkFolderMenuActionList)
{
editBookmarkDialogPointer->show();
// Process bookmark events.
- connect(editBookmarkDialogPointer, SIGNAL(bookmarkSaved()), this, SLOT(populateBookmarks()));
+ connect(editBookmarkDialogPointer, SIGNAL(bookmarkSaved()), this, SLOT(populateBookmarksInAllWindows()));
}
);
BookmarksDatabase::updateFolderContentsDisplayOrder(parentFolderId);
// Repopulate the bookmarks.
- populateBookmarks();
+ populateBookmarksInAllWindows();
}
);
}
}
// Repopulate the bookmarks.
- populateBookmarks();
+ populateBookmarksInAllWindows();
}
void BrowserWindow::toggleDomStorage() const