Skip to content

Commit 02421a2

Browse files
author
saminsakur8@gmail.com
committed
Initial commit
1 parent d0fed43 commit 02421a2

File tree

3 files changed

+61
-38
lines changed

3 files changed

+61
-38
lines changed

Images/history.png

6.39 KB
Loading

main.py

Lines changed: 61 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
connection = sqlite3.connect("webBrowserDB.db")
2525

2626
cursor = connection.cursor()
27-
textFont = QFont("Century Gothic", 16)
27+
textFont = QFont("sans-serif", 14)
2828

2929
class fileErrorDialog(QMessageBox):
3030
def __init__(self, *args, **kwargs):
@@ -126,29 +126,44 @@ def __init__(self):
126126
titleLbl.setFont(titleFont)
127127

128128
clearBtn = QPushButton("Clear")
129+
clearBtn.setObjectName("ClearButnHistory")
129130
clearBtn.setFont(textFont)
130131
clearBtn.setStyleSheet(
131132
"""
132-
border:1px solid transparent;
133-
border-radius: 7px;
133+
QPushButton#ClearButnHistory{
134+
border:1px solid transparent;
135+
border-radius: 7px;
136+
background-color: #C9D2F1;
137+
padding: 2px 5px 5px 2px;
138+
margin-top:5px;
139+
margin-left:80px;
140+
margin-right:10px;
141+
margin-bottom:5px;
142+
font-size:12pt;
143+
font-family:sans-serif;
144+
}
145+
QPushButton#ClearButnHistory:hover{
146+
background-color:#ced3e2;
147+
}
148+
QPushButton#ClearButnHistory:pressed{
149+
background-color:#ccc;
150+
}
151+
134152
"""
135153
)
136154
clearBtn.clicked.connect(self.clearHistory)
137155

138156
self.historyList = QListWidget()
157+
self.historyList.verticalScrollBar().setEnabled(False)
139158

140159
self.fillHistoryList()
141160

142161
self.historyList.itemClicked.connect(self.goClickedLink)
143162
self.historyList.setStyleSheet(
144163
"""
145164
QListWidget::item{
146-
padding-top:30px;
147-
padding-left:200px;
148-
}
149-
150-
QListWidget::item:selected{
151-
background-color:#000;
165+
padding-top: 5px;
166+
padding-bottom: 5px;
152167
}
153168
154169
QListWidget::item:hover{
@@ -247,29 +262,15 @@ def InitSSLIcon(self):
247262
class Tabs(QTabWidget):
248263
def __init__(self):
249264
super().__init__()
265+
self.setDocumentMode(True)
250266

267+
# Set the tabs closable
268+
self.setTabsClosable(True)
251269

252-
class mainWindow(QMainWindow):
253-
def __init__(self, *args, **kwargs):
254-
super(mainWindow, self).__init__()
255-
256-
# create tabs
257-
self.tabs = Tabs()
258-
self.tabs.setDocumentMode(True)
259-
self.connection = sqlite3.connect("webBrowserDB.db")
260-
self.cursor = self.connection.cursor()
261-
262-
# create history table
263-
cursor.execute("""CREATE TABLE IF NOT EXISTS "history" (
264-
"id" INTEGER,
265-
"title" TEXT,
266-
"url" TEXT,
267-
"date" TEXT,
268-
PRIMARY KEY("id")
269-
)""")
270-
270+
# St the tabs movable
271+
self.setMovable(True)
271272
# Add some styles to the tabs
272-
self.tabs.setStyleSheet("""
273+
self.setStyleSheet("""
273274
QTabBar{
274275
background-color:#417294;
275276
}
@@ -311,15 +312,35 @@ def __init__(self, *args, **kwargs):
311312
}
312313
""")
313314

315+
316+
317+
class mainWindow(QMainWindow):
318+
def __init__(self, *args, **kwargs):
319+
super(mainWindow, self).__init__()
320+
321+
# Define layout
322+
self.layout = QVBoxLayout()
323+
# create tabs
324+
self.tabs = Tabs()
325+
self.connection = sqlite3.connect("webBrowserDB.db")
326+
self.cursor = self.connection.cursor()
327+
328+
# create history table
329+
cursor.execute("""CREATE TABLE IF NOT EXISTS "history" (
330+
"id" INTEGER,
331+
"title" TEXT,
332+
"url" TEXT,
333+
"date" TEXT,
334+
PRIMARY KEY("id")
335+
)""")
336+
337+
314338
# Add new tab when tab tab is doubleclicked
315339
self.tabs.tabBarDoubleClicked.connect(self.tab_open_doubleclick)
316340

317341
# To connect to a function when currrent tab has been changed
318342
self.tabs.currentChanged.connect(self.tab_changed)
319343

320-
# Set the tabs closable
321-
self.tabs.setTabsClosable(True)
322-
323344
# Function to handle tab closing
324345
self.tabs.tabCloseRequested.connect(self.close_current_tab)
325346

@@ -491,7 +512,8 @@ def __init__(self, *args, **kwargs):
491512
context_menu.addSeparator()
492513

493514
#View history
494-
ViewHistory = QAction("H", self)
515+
ViewHistory = QAction("History", self)
516+
ViewHistory.setIcon(QIcon(os.path.join("Images", "history.png")))
495517
ViewHistory.triggered.connect(self.openHistory)
496518
ViewHistory.setShortcut("Ctrl+h")
497519
context_menu.addAction(ViewHistory)
@@ -693,7 +715,7 @@ def open_local_file(self):
693715
directory="",
694716
filter="Hypertext Markup Language (*.htm *.html *.mhtml);;All files (*.*)"
695717
)
696-
if len(filename) > 0:
718+
if filename:
697719
try:
698720
with open(filename, "r", encoding="utf8") as f:
699721
opened_file = f.read()
@@ -946,7 +968,7 @@ def openHistory(self):
946968

947969
self.historyWindow.setStyleSheet(
948970
"""
949-
background-color:#e6e7e8;
971+
background-color:#fff;
950972
""")
951973
self.historyWindow.show()
952974

@@ -994,6 +1016,7 @@ def main():
9941016

9951017
# Set the window icon
9961018
QApplication.setWindowIcon(QIcon(os.path.join("Icons", "browser.png")))
1019+
app.styleHints().showShortcutsInContextMenus()
9971020

9981021
# App styles
9991022
app.setStyleSheet("""
@@ -1042,15 +1065,15 @@ def main():
10421065
QMenu#ContextMenu {
10431066
background-color: #fdfdfd;
10441067
border: 1px solid transparent;
1045-
font-family: Times, sans-serif;
1068+
font-family: sans-serif;
10461069
border-radius: 6px;
10471070
}
10481071
10491072
QMenu#ContextMenu::item {
10501073
background-color: transparent;
10511074
font-size: 10pt;
10521075
padding-left: 40px;
1053-
/*padding-right: 100px;*/
1076+
padding-right: 100px;
10541077
padding-top:8px;
10551078
padding-bottom: 8px;
10561079
width: 130px;
@@ -1062,7 +1085,7 @@ def main():
10621085
10631086
QMenu#ContextMenu::separator {
10641087
height: 1px;
1065-
background: #111;
1088+
background-color: gray;
10661089
margin-left: 0%;
10671090
margin-right: 0%;
10681091
}

webBrowserDB.db

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)