8
8
9
9
import re , os , sys , datetime , sqlite3
10
10
import pyperclip as pc
11
- from PyQt5 import QtGui
12
- from PyQt5 import QtCore
13
- from PyQt5 .QtGui import *
14
- from PyQt5 .QtCore import *
15
- from PyQt5 .QtWidgets import *
11
+ from PyQt5 import QtGui , QtCore
12
+ from PyQt5 .QtGui import QIcon , QFont , QPainter , QPixmap
13
+ from PyQt5 .QtCore import QUrl , QObject , pyqtSlot , QEventLoop , QPointF , Qt , QSize
14
+ from PyQt5 .QtWidgets import (QTabWidget , QLineEdit , QLabel , QToolBar , QMessageBox , QDialogButtonBox ,
15
+ QDialog , QProgressDialog , QProgressBar , QWidget , QPushButton , QListWidget , QGridLayout ,
16
+ QMainWindow , QVBoxLayout , QShortcut , QMenu , QAction , QFileDialog , QApplication )
16
17
from PyQt5 .QtWebEngineWidgets import *
17
- from PyQt5 .QtPrintSupport import *
18
+ from PyQt5 .QtPrintSupport import QPrinter , QPrintDialog , QPrintPreviewDialog
18
19
19
20
20
21
@@ -118,61 +119,91 @@ class HistoryWindow(QWidget):
118
119
def __init__ (self ):
119
120
super ().__init__ ()
120
121
121
- titleFont = QFont ("sans-serif" , 16 )
122
+ titleFont = QFont ("PT Sans" , 16 )
123
+ btnFont = QFont ("Roboto" , 0 )
124
+
122
125
titleLbl = QLabel ("History" )
123
126
titleLbl .setStyleSheet ("""
124
- margin:5px 5px 5px 5px ;
127
+ margin-top:7px ;
125
128
""" )
126
129
titleLbl .setFont (titleFont )
127
130
128
131
clearBtn = QPushButton ("Clear" )
129
132
clearBtn .setObjectName ("ClearButnHistory" )
130
- clearBtn .setFont (textFont )
133
+ clearBtn .setFont (btnFont )
131
134
clearBtn .setStyleSheet (
132
135
"""
133
136
QPushButton#ClearButnHistory{
134
137
border:1px solid transparent;
135
138
border-radius: 7px;
136
- background-color: #C9D2F1;
137
- padding: 2px 5px 5px 2px;
138
- margin-top:5px;
139
+ border-color:#ccc;
140
+ margin-top:6px;
139
141
margin-left:80px;
140
142
margin-right:10px;
141
- margin-bottom: 5px;
143
+ padding: 5px 5px 5px 5px;
142
144
font-size:12pt;
143
- font-family:sans-serif;
145
+ color:#000;
146
+ background-color:transparent;
144
147
}
148
+
145
149
QPushButton#ClearButnHistory:hover{
146
- background-color:#ced3e2;
150
+ background-color:#2681f2;
151
+ border-color:#dae0e5;
152
+ color: #fff;
147
153
}
154
+
148
155
QPushButton#ClearButnHistory:pressed{
149
- background-color:#ccc;
150
- }
151
-
156
+ background-color:#0c63ce;
157
+ }
152
158
"""
153
159
)
154
160
clearBtn .clicked .connect (self .clearHistory )
155
161
156
162
self .historyList = QListWidget ()
157
- self .historyList .verticalScrollBar ().setEnabled (False )
163
+ self .historyList .horizontalScrollBar ().setEnabled (False )
164
+ self .historyList .verticalScrollBar ().setStyleSheet (
165
+ """
166
+ QScrollBar:vertical {
167
+ background: transparent;
168
+ width:8px;
169
+ }
170
+
171
+ QScrollBar::handle:vertical {
172
+ background: gray;
173
+ min-width: 5px;
174
+ border: 1px solid gray;
175
+ border-radius: 4px;
176
+ }
177
+ QScrollBar::add-line:vertical{
178
+ background:none;
179
+ }
180
+ QScrollBar::sub-line:vertical{
181
+ background:none;
182
+ }
183
+ """
184
+ )
158
185
159
186
self .fillHistoryList ()
160
187
161
188
self .historyList .itemClicked .connect (self .goClickedLink )
162
189
self .historyList .setStyleSheet (
163
190
"""
164
191
QListWidget::item{
165
- padding-top: 5px;
166
- padding-bottom: 5px;
192
+ padding-top: 8px;
193
+ padding-bottom: 8px;
194
+ margin-top: 2px;
195
+ margin-bottom: 2px;
167
196
}
168
197
169
198
QListWidget::item:hover{
170
- background-color:#ccc ;
199
+ background-color:#E5E5E5 ;
171
200
}
172
201
173
202
QListWidget{
174
203
border: 1px solid transparent;
175
204
border-top: 1px solid gray;
205
+ padding-left:5px;
206
+ padding-right:5px;
176
207
}
177
208
""" )
178
209
@@ -253,6 +284,7 @@ def initAddressBar(self):
253
284
class SSLIcon (QLabel ):
254
285
def __init__ (self ):
255
286
super ().__init__ ()
287
+ self .InitSSLIcon ()
256
288
257
289
def InitSSLIcon (self ):
258
290
self .setObjectName ("SSLIcon" )
@@ -430,7 +462,6 @@ def __init__(self, *args, **kwargs):
430
462
431
463
# Shows ssl security icon
432
464
self .httpsicon = SSLIcon ()
433
- self .httpsicon .InitSSLIcon ()
434
465
435
466
# Add http icon to the navbar bar
436
467
self .navbar .addWidget (self .httpsicon )
@@ -470,6 +501,11 @@ def __init__(self, *args, **kwargs):
470
501
newTabAction .setToolTip ("Add a new tab" )
471
502
context_menu .addAction (newTabAction )
472
503
504
+ # New window action
505
+ newWindowAction = QAction ("New window" , self )
506
+ newWindowAction .triggered .connect (self .CreateNewWindow )
507
+ context_menu .addAction (newWindowAction )
508
+
473
509
# Close tab action
474
510
CloseTabAction = QAction ("Close tab" , self )
475
511
CloseTabAction .setIcon (QIcon (os .path .join ("Images" , "closetab.png" )))
@@ -664,6 +700,10 @@ def NavigateDuckDuckGo(self):
664
700
self .add_new_tab (QtCore .QUrl ("https://www.duckduckgo.com/" ), "DuckDuckGo" )
665
701
666
702
703
+ # Define open a new window
704
+ def CreateNewWindow (self ):
705
+ window = mainWindow ()
706
+ window .show ()
667
707
668
708
# Copy url of currently viewed page to clipboard
669
709
def CopySiteLink (self ):
@@ -956,8 +996,8 @@ def updateHistory(self):
956
996
957
997
def openHistory (self ):
958
998
self .historyWindow = HistoryWindow ()
959
- self .historyWindow .setWindowFlags (Qt .FramelessWindowHint | Qt .Popup )
960
- self .historyWindow .setGeometry (self .tabs .currentWidget ().frameGeometry ().width ()/ 2 + 300 , 87 , 500 , 500 )
999
+ self .historyWindow .setWindowFlags (Qt .FramelessWindowHint | Qt .Popup )
1000
+ self .historyWindow .setGeometry (int ( self .tabs .currentWidget ().frameGeometry ().width ()/ 2 + 300 ) , 87 , 500 , 500 )
961
1001
radiusx = 10.0
962
1002
radiusy = 5.0
963
1003
path = QtGui .QPainterPath ()
@@ -968,12 +1008,12 @@ def openHistory(self):
968
1008
969
1009
self .historyWindow .setStyleSheet (
970
1010
"""
971
- background-color:#fff;
972
- """ )
1011
+ background-color:#fdfdfd;
1012
+ """
1013
+ )
973
1014
self .historyWindow .show ()
974
1015
975
1016
def openSiteHistoryClicked (self , url ,* args ):
976
- # self.add_new_tab(url, title)
977
1017
self .tabs .currentWidget ().load (url )
978
1018
979
1019
@@ -1010,14 +1050,15 @@ def __init__(self, parent=None, *args, **kwargs):
1010
1050
1011
1051
def main ():
1012
1052
app = QApplication (sys .argv )
1053
+
1054
+ # Disable shortcut in context menu
1013
1055
app .styleHints ().setShowShortcutsInContextMenus (False )
1014
1056
1015
1057
# Set the window name
1016
1058
QApplication .setApplicationName ("Simple Web Browser" )
1017
1059
1018
1060
# Set the window icon
1019
1061
QApplication .setWindowIcon (QIcon (os .path .join ("Icons" , "browser.png" )))
1020
- app .styleHints ().showShortcutsInContextMenus ()
1021
1062
1022
1063
# App styles
1023
1064
app .setStyleSheet ("""
@@ -1239,11 +1280,9 @@ def main():
1239
1280
1240
1281
""" )
1241
1282
1242
-
1243
-
1244
- #e6e6e6 background color
1245
1283
window = mainWindow ()
1246
1284
window .show ()
1285
+
1247
1286
try :
1248
1287
sys .exit (app .exec_ ())
1249
1288
0 commit comments