24
24
connection = sqlite3 .connect ("webBrowserDB.db" )
25
25
26
26
cursor = connection .cursor ()
27
- textFont = QFont ("Century Gothic " , 16 )
27
+ textFont = QFont ("sans-serif " , 14 )
28
28
29
29
class fileErrorDialog (QMessageBox ):
30
30
def __init__ (self , * args , ** kwargs ):
@@ -126,29 +126,44 @@ def __init__(self):
126
126
titleLbl .setFont (titleFont )
127
127
128
128
clearBtn = QPushButton ("Clear" )
129
+ clearBtn .setObjectName ("ClearButnHistory" )
129
130
clearBtn .setFont (textFont )
130
131
clearBtn .setStyleSheet (
131
132
"""
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
+
134
152
"""
135
153
)
136
154
clearBtn .clicked .connect (self .clearHistory )
137
155
138
156
self .historyList = QListWidget ()
157
+ self .historyList .verticalScrollBar ().setEnabled (False )
139
158
140
159
self .fillHistoryList ()
141
160
142
161
self .historyList .itemClicked .connect (self .goClickedLink )
143
162
self .historyList .setStyleSheet (
144
163
"""
145
164
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;
152
167
}
153
168
154
169
QListWidget::item:hover{
@@ -247,29 +262,15 @@ def InitSSLIcon(self):
247
262
class Tabs (QTabWidget ):
248
263
def __init__ (self ):
249
264
super ().__init__ ()
265
+ self .setDocumentMode (True )
250
266
267
+ # Set the tabs closable
268
+ self .setTabsClosable (True )
251
269
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 )
271
272
# Add some styles to the tabs
272
- self .tabs . setStyleSheet ("""
273
+ self .setStyleSheet ("""
273
274
QTabBar{
274
275
background-color:#417294;
275
276
}
@@ -311,15 +312,35 @@ def __init__(self, *args, **kwargs):
311
312
}
312
313
""" )
313
314
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
+
314
338
# Add new tab when tab tab is doubleclicked
315
339
self .tabs .tabBarDoubleClicked .connect (self .tab_open_doubleclick )
316
340
317
341
# To connect to a function when currrent tab has been changed
318
342
self .tabs .currentChanged .connect (self .tab_changed )
319
343
320
- # Set the tabs closable
321
- self .tabs .setTabsClosable (True )
322
-
323
344
# Function to handle tab closing
324
345
self .tabs .tabCloseRequested .connect (self .close_current_tab )
325
346
@@ -491,7 +512,8 @@ def __init__(self, *args, **kwargs):
491
512
context_menu .addSeparator ()
492
513
493
514
#View history
494
- ViewHistory = QAction ("H" , self )
515
+ ViewHistory = QAction ("History" , self )
516
+ ViewHistory .setIcon (QIcon (os .path .join ("Images" , "history.png" )))
495
517
ViewHistory .triggered .connect (self .openHistory )
496
518
ViewHistory .setShortcut ("Ctrl+h" )
497
519
context_menu .addAction (ViewHistory )
@@ -693,7 +715,7 @@ def open_local_file(self):
693
715
directory = "" ,
694
716
filter = "Hypertext Markup Language (*.htm *.html *.mhtml);;All files (*.*)"
695
717
)
696
- if len ( filename ) > 0 :
718
+ if filename :
697
719
try :
698
720
with open (filename , "r" , encoding = "utf8" ) as f :
699
721
opened_file = f .read ()
@@ -946,7 +968,7 @@ def openHistory(self):
946
968
947
969
self .historyWindow .setStyleSheet (
948
970
"""
949
- background-color:#e6e7e8 ;
971
+ background-color:#fff ;
950
972
""" )
951
973
self .historyWindow .show ()
952
974
@@ -994,6 +1016,7 @@ def main():
994
1016
995
1017
# Set the window icon
996
1018
QApplication .setWindowIcon (QIcon (os .path .join ("Icons" , "browser.png" )))
1019
+ app .styleHints ().showShortcutsInContextMenus ()
997
1020
998
1021
# App styles
999
1022
app .setStyleSheet ("""
@@ -1042,15 +1065,15 @@ def main():
1042
1065
QMenu#ContextMenu {
1043
1066
background-color: #fdfdfd;
1044
1067
border: 1px solid transparent;
1045
- font-family: Times, sans-serif;
1068
+ font-family: sans-serif;
1046
1069
border-radius: 6px;
1047
1070
}
1048
1071
1049
1072
QMenu#ContextMenu::item {
1050
1073
background-color: transparent;
1051
1074
font-size: 10pt;
1052
1075
padding-left: 40px;
1053
- /* padding-right: 100px;*/
1076
+ padding-right: 100px;
1054
1077
padding-top:8px;
1055
1078
padding-bottom: 8px;
1056
1079
width: 130px;
@@ -1062,7 +1085,7 @@ def main():
1062
1085
1063
1086
QMenu#ContextMenu::separator {
1064
1087
height: 1px;
1065
- background: #111 ;
1088
+ background-color: gray ;
1066
1089
margin-left: 0%;
1067
1090
margin-right: 0%;
1068
1091
}
0 commit comments