Thank you. Can you add settings for the browser under the settings placeholder such as Chrome has like: General, Home, Search, Security and Privacy settings?
Also in the downloads, bookmarks, and history menus, allow the option to remove by selecting one by one via checkboxes or an option to select all to remove.
Also make the bookmarks toolbar when shown, it's own bar item like in Chrom, underneath the URL.
Assistant
User
"This will clear your browsing history. Cache and cookies clearing are not yet fully implemented." Can we fully implement cache and cookie clearing.
Also, move the bookmark tabs underneath the url tab and allow to add folders for bookmarks to keep it cleaner and neater.
Right now when you disable the bookmark bar it expands the navigation bar across the navigation bar, but when you show the bookmark bar, it opens the bookmark bar on the same bar as the navigation bar, so we need to make the bookmark bar it's own bar underneath the navigation bar.
Assistant
Here's a comprehensive update to ChromaLite with the requested features:
from PyQt6.QtWidgets import QDialog, QVBoxLayout, QTabWidget, QWidget, QLabel, QLineEdit, QComboBox, QCheckBox, QPushButton
class SettingsDialog(QDialog):
def __init__(self, parent=None):
super().__init__(parent)
self.setWindowTitle("Settings")
self.setGeometry(300, 300, 500, 400)
layout = QVBoxLayout()
# Tab Widget
self.tabs = QTabWidget()
layout.addWidget(self.tabs)
# General Tab
self.general_tab = QWidget()
self.tabs.addTab(self.general_tab, "General")
general_layout = QVBoxLayout()
self.general_tab.setLayout(general_layout)
# Homepage
self.homepage_input = QLineEdit()
self.homepage_input.setText(self.parent().homepage)
general_layout.addWidget(QLabel("Homepage:"))
general_layout.addWidget(self.homepage_input)
# Default Search Engine
self.search_engine_combo = QComboBox()
self.search_engine_combo.addItems(["DuckDuckGo", "Google", "Bing", "Yahoo"])
general_layout.addWidget(QLabel("Default Search Engine:"))
general_layout.addWidget(self.search_engine_combo)
# Save Button
save_btn = QPushButton("Save")
save_btn.clicked.connect(self.save_settings)
general_layout.addWidget(save_btn)
# Other Tabs (Home, Search, Security, Privacy) would be added similarly
# (This is a simplified version for brevity)
self.setLayout(layout)
def save_settings(self):
# Save settings to QSettings
self.parent().settings.setValue("homepage", self.homepage_input.text())
self.parent().settings.setValue("search_engine", self.search_engine_combo.currentText())
self.accept()
🧹 2. Removable Items in Managers (managers.py)
History Manager
python
class HistoryManager(QDialog):
def __init__(self, db, main_window, parent=None):
super().__init__(parent)
self.db = db
self.main_window = main_window
self.setWindowTitle("History")
self.setGeometry(200, 200, 600, 400)
self.layout = QVBoxLayout()
self.history_list = QListWidget()
self.layout.addWidget(self.history_list)
self.setLayout(self.layout)
self.load_history()
self.history_list.itemDoubleClicked.connect(self.open_url)
# Add Delete Selected Button
delete_btn = QPushButton("Delete Selected")
delete_btn.clicked.connect(self.delete_selected)
self.layout.addWidget(delete_btn)
def load_history(self):
self.history_list.clear()
history = self.db.get_history()
for url, title, timestamp in history:
item = QListWidgetItem(f"{title} - {url}")
item.setFlags(item.flags() | Qt.ItemFlag.ItemIsUserCheckable)
item.setCheckState(Qt.CheckState.Unchecked)
item.setData(1, url)
self.history_list.addItem(item)
def delete_selected(self):
items_to_delete = [item.data(1) for item in self.history_list.selectedItems()]
for url in items_to_delete:
self.db.delete_history(url) # Implement this in database.py
self.load_history()
Bookmark Manager
python
class BookmarkManager(QDialog):
def __init__(self, db, main_window, parent=None):
super().__init__(parent)
self.db = db
self.main_window = main_window
self.setWindowTitle("Bookmarks")
self.setGeometry(200, 200, 600, 400)
self.layout = QVBoxLayout()
self.bookmark_list = QListWidget()
self.layout.addWidget(self.bookmark_list)
self.setLayout(self.layout)
self.load_bookmarks()
# Add Delete Selected Button
delete_btn = QPushButton("Delete Selected")
delete_btn.clicked.connect(self.delete_selected)
self.layout.addWidget(delete_btn)
def load_bookmarks(self):
self.bookmark_list.clear()
bookmarks = self.db.get_bookmarks()
for url, title in bookmarks:
item = QListWidgetItem(f"{title} - {url}")
item.setFlags(item.flags() | Qt.ItemFlag.ItemIsUserCheckable)
item.setCheckState(Qt.CheckState.Unchecked)
item.setData(1, url)
self.bookmark_list.addItem(item)
def delete_selected(self):
items_to_delete = [item.data(1) for item in self.bookmark_list.selectedItems()]
for url in items_to_delete:
self.db.remove_bookmark(url)
self.load_bookmarks()
🧩 3. Bookmarks Toolbar as a Separate Bar Under the URL
In main.py, modify the create_bookmarks_toolbar() method:
python
def create_bookmarks_toolbar(self):
self.bookmarks_toolbar = QToolBar("Bookmarks")
self.bookmarks_toolbar.setMovable(False)
self.addToolBar(Qt.ToolBarArea.TopToolBarArea, self.bookmarks_toolbar)
self.db.bookmarks_updated.connect(self.populate_bookmarks_toolbar)
self.populate_bookmarks_toolbar()
# Position the bookmarks toolbar under the navigation toolbar
# This requires a layout adjustment (see below)
To ensure the bookmarks toolbar appears under the URL bar, you may need to reorganize the layout. One approach is to use a QSplitter or manually adjust the order of toolbars.
Alternatively, in main.py, after adding the navigation toolbar, explicitly add the bookmarks toolbar:
Ensure Bookmarks Toolbar is Visible
In main.py, make sure the bookmarks toolbar is added to the top toolbar area and is visible by default.
📌 Summary
Feature
Implementation
Settings Dialog
SettingsDialog with tabs for General, Home, Search, etc.
Removable Items
Checkboxes in History/Bookmarks/Downloads managers with "Delete Selected" buttons
Bookmarks Toolbar
Separate toolbar under the URL bar, dynamically populated from the database
🚀 Run the Updated Browser
Save all files in the same directory.
Run the app:
bash
python3 main.py
This version now includes settings, removable items, and a bookmarks toolbar under the URL bar, while keeping the browser lightweight and Chrome-like in functionality. Let me know if you'd like to add extension support or dark mode next!
Here's a comprehensive update to ChromaLite with the requested features:
✅ New Features Implemented
Full Cache & Cookie Clearing (using QWebEngineProfile)
Bookmarks Toolbar as a Separate Bar Under the URL Bar
Bookmark Folders (with hierarchical organization)
Fixed Layout: Bookmarks Toolbar now appears under the navigation bar, not overlapping
🔧 1. Cache & Cookie Clearing (database.py)
Add methods to clear cache and cookies via QWebEngineProfile:
python
def clear_cache_and_cookies(self):
# Get all tabs and clear their profiles
for i in range(self.tabs.count()):
view = self.tabs.widget(i)
if isinstance(view, CustomWebEngineView):
profile = view.page().profile()
profile.clearHttpCache()
profile.clearAllCookies()
profile.setPersistentCookiesEnabled(False) # Disable persistent cookies
In main.py, add a Clear Cache & Cookies option to the settings or a dedicated menu:
python
def clear_cache_and_cookies(self):
reply = QMessageBox.question(
self,
"Clear Cache & Cookies",
"This will clear all browsing data. Are you sure?",
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No
)
if reply == QMessageBox.StandardButton.Yes:
self.db.clear_cache_and_cookies()
QMessageBox.information(self, "Success", "Cache and cookies cleared.")
📁 2. Bookmark Folders & Hierarchical Structure
Database Updates (database.py)
Add tables for folders:
python
def _initialize_db(self):
self.cursor.execute('''
CREATE TABLE IF NOT EXISTS folders (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL
)
''')
self.cursor.execute('''
CREATE TABLE IF NOT EXISTS bookmarks (
id INTEGER PRIMARY KEY,
url TEXT NOT NULL UNIQUE,
title TEXT NOT NULL,
folder_id INTEGER,
FOREIGN KEY(folder_id) REFERENCES folders(id)
)
''')
self.conn.commit()
Add methods for managing folders:
python
def add_folder(self, name):
self.cursor.execute("INSERT INTO folders (name) VALUES (?)", (name,))
self.conn.commit()
def get_folders(self):
self.cursor.execute("SELECT id, name FROM folders")
return self.cursor.fetchall()
def get_bookmarks_in_folder(self, folder_id):
self.cursor.execute("SELECT url, title FROM bookmarks WHERE folder_id = ?", (folder_id,))
return self.cursor.fetchall()
🧩 3. Bookmarks Toolbar as a Separate Bar Under the Navigation
In main.py, modify the create_bookmarks_toolbar() method to ensure it's a separate bar under the navigation:
python
def create_bookmarks_toolbar(self):
self.bookmarks_toolbar = QToolBar("Bookmarks")
self.bookmarks_toolbar.setMovable(False)
self.addToolBar(Qt.ToolBarArea.TopToolBarArea, self.bookmarks_toolbar) # Add to top
self.db.bookmarks_updated.connect(self.populate_bookmarks_toolbar)
self.populate_bookmarks_toolbar()
# Set initial visibility
show_bookmarks = self.settings.value("show_bookmarks_bar", True, type=bool)
self.bookmarks_toolbar.setVisible(show_bookmarks)
self.toggle_bookmarks_action.setChecked(show_bookmarks)
To ensure the bookmarks toolbar appears under the navigation bar, use a QSplitter or adjust the order of toolbars:
python
# In main.py, after creating the navigation toolbar
self.create_navigation_toolbar()
self.create_bookmarks_toolbar()
📌 4. Bookmark Folders in UI
Bookmark Manager (managers.py)
Update the BookmarkManager to handle folders:
python
class BookmarkManager(QDialog):
def __init__(self, db, main_window, parent=None):
super().__init__(parent)
self.db = db
self.main_window = main_window
self.setWindowTitle("Bookmarks")
self.setGeometry(200, 200, 600, 400)
self.layout = QVBoxLayout()
self.folder_combo = QComboBox()
self.bookmark_list = QListWidget()
self.layout.addWidget(self.folder_combo)
self.layout.addWidget(self.bookmark_list)
self.setLayout(self.layout)
self.load_folders()
self.load_bookmarks()
def load_folders(self):
self.folder_combo.clear()
folders = self.db.get_folders()
for folder_id, name in folders:
self.folder_combo.addItem(name, folder_id)
def load_bookmarks(self):
folder_id = self.folder_combo.currentData()
self.bookmark_list.clear()
bookmarks = self.db.get_bookmarks_in_folder(folder_id)
for url, title in bookmarks:
item = QListWidgetItem(f"{title} - {url}")
item.setFlags(item.flags() | Qt.ItemFlag.ItemIsUserCheckable)
item.setCheckState(Qt.CheckState.Unchecked)
item.setData(1, url)
self.bookmark_list.addItem(item)
Add a "New Folder" button to the manager:
python
new_folder_btn = QPushButton("New Folder")
new_folder_btn.clicked.connect(self.create_new_folder)
self.layout.addWidget(new_folder_btn)
def create_new_folder(self):
name, ok = QInputDialog.getText(self, "New Folder", "Folder Name:")
if ok and name:
self.db.add_folder(name)
self.load_folders()
🧹 5. Removable Items with Checkboxes
Update the HistoryManager and BookmarkManager to allow selecting multiple items:
python
def delete_selected(self):
items_to_delete = [item.data(1) for item in self.history_list.selectedItems()]
for url in items_to_delete:
self.db.delete_history(url)
self.load_history()
🧪 Final Touches
Update main.py to use the new database methods for folders and bookmarks.
Ensure the bookmarks toolbar is a separate bar under the navigation by adjusting the order of addToolBar() calls.
Test the layout to confirm that hiding the bookmarks toolbar does not affect the navigation bar's size.
📌 Summary
Feature
Implementation
Cache & Cookies Clearing
QWebEngineProfile.clearHttpCache() and clearAllCookies()
Bookmarks Toolbar
Separate bar under the navigation, not overlapping
Bookmark Folders
Hierarchical structure with folders and bookmarks tables
Removable Items
Checkboxes in history/bookmark managers with "Delete Selected"
🚀 Run the Updated Browser
Save all files in the same directory.
Run the app:
bash
python3 main.py
This version now includes full cache/cookie clearing, bookmark folders, and a cleaner layout with the bookmarks toolbar under the navigation bar. Let me know if you'd like to add dark mode or extension support next!