Skip to content

Commit

Permalink
Updated history
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Jun 26, 2021
1 parent 4ae9f89 commit 8efe1b8
Showing 1 changed file with 71 additions and 32 deletions.
103 changes: 71 additions & 32 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@

import re, os, sys, datetime, sqlite3
import pyperclip as pc
from PyQt5 import QtGui
from PyQt5 import QtCore
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5 import QtGui, QtCore
from PyQt5.QtGui import QIcon, QFont, QPainter, QPixmap
from PyQt5.QtCore import QUrl, QObject, pyqtSlot, QEventLoop, QPointF, Qt, QSize
from PyQt5.QtWidgets import (QTabWidget, QLineEdit, QLabel, QToolBar, QMessageBox, QDialogButtonBox,
QDialog, QProgressDialog, QProgressBar, QWidget, QPushButton, QListWidget, QGridLayout,
QMainWindow, QVBoxLayout, QShortcut, QMenu, QAction, QFileDialog, QApplication)
from PyQt5.QtWebEngineWidgets import *
from PyQt5.QtPrintSupport import *
from PyQt5.QtPrintSupport import QPrinter, QPrintDialog, QPrintPreviewDialog



Expand Down Expand Up @@ -118,61 +119,91 @@ class HistoryWindow(QWidget):
def __init__(self):
super().__init__()

titleFont = QFont("sans-serif", 16)
titleFont = QFont("PT Sans", 16)
btnFont = QFont("Roboto", 0)

titleLbl = QLabel("History")
titleLbl.setStyleSheet("""
margin:5px 5px 5px 5px;
margin-top:7px;
""")
titleLbl.setFont(titleFont)

clearBtn = QPushButton("Clear")
clearBtn.setObjectName("ClearButnHistory")
clearBtn.setFont(textFont)
clearBtn.setFont(btnFont)
clearBtn.setStyleSheet(
"""
QPushButton#ClearButnHistory{
border:1px solid transparent;
border-radius: 7px;
background-color: #C9D2F1;
padding: 2px 5px 5px 2px;
margin-top:5px;
border-color:#ccc;
margin-top:6px;
margin-left:80px;
margin-right:10px;
margin-bottom:5px;
padding: 5px 5px 5px 5px;
font-size:12pt;
font-family:sans-serif;
color:#000;
background-color:transparent;
}
QPushButton#ClearButnHistory:hover{
background-color:#ced3e2;
background-color:#2681f2;
border-color:#dae0e5;
color: #fff;
}
QPushButton#ClearButnHistory:pressed{
background-color:#ccc;
}
background-color:#0c63ce;
}
"""
)
clearBtn.clicked.connect(self.clearHistory)

self.historyList = QListWidget()
self.historyList.verticalScrollBar().setEnabled(False)
self.historyList.horizontalScrollBar().setEnabled(False)
self.historyList.verticalScrollBar().setStyleSheet(
"""
QScrollBar:vertical {
background: transparent;
width:8px;
}
QScrollBar::handle:vertical {
background: gray;
min-width: 5px;
border: 1px solid gray;
border-radius: 4px;
}
QScrollBar::add-line:vertical{
background:none;
}
QScrollBar::sub-line:vertical{
background:none;
}
"""
)

self.fillHistoryList()

self.historyList.itemClicked.connect(self.goClickedLink)
self.historyList.setStyleSheet(
"""
QListWidget::item{
padding-top: 5px;
padding-bottom: 5px;
padding-top: 8px;
padding-bottom: 8px;
margin-top: 2px;
margin-bottom: 2px;
}
QListWidget::item:hover{
background-color:#ccc;
background-color:#E5E5E5;
}
QListWidget{
border: 1px solid transparent;
border-top: 1px solid gray;
padding-left:5px;
padding-right:5px;
}
""")

Expand Down Expand Up @@ -253,6 +284,7 @@ def initAddressBar(self):
class SSLIcon(QLabel):
def __init__(self):
super().__init__()
self.InitSSLIcon()

def InitSSLIcon(self):
self.setObjectName("SSLIcon")
Expand Down Expand Up @@ -430,7 +462,6 @@ def __init__(self, *args, **kwargs):

# Shows ssl security icon
self.httpsicon = SSLIcon()
self.httpsicon.InitSSLIcon()

# Add http icon to the navbar bar
self.navbar.addWidget(self.httpsicon)
Expand Down Expand Up @@ -470,6 +501,11 @@ def __init__(self, *args, **kwargs):
newTabAction.setToolTip("Add a new tab")
context_menu.addAction(newTabAction)

# New window action
newWindowAction = QAction("New window", self)
newWindowAction.triggered.connect(self.CreateNewWindow)
context_menu.addAction(newWindowAction)

# Close tab action
CloseTabAction = QAction("Close tab", self)
CloseTabAction.setIcon(QIcon(os.path.join("Images", "closetab.png")))
Expand Down Expand Up @@ -664,6 +700,10 @@ def NavigateDuckDuckGo(self):
self.add_new_tab(QtCore.QUrl("https://www.duckduckgo.com/"), "DuckDuckGo")


# Define open a new window
def CreateNewWindow(self):
window = mainWindow()
window.show()

# Copy url of currently viewed page to clipboard
def CopySiteLink(self):
Expand Down Expand Up @@ -956,8 +996,8 @@ def updateHistory(self):

def openHistory(self):
self.historyWindow = HistoryWindow()
self.historyWindow.setWindowFlags(Qt.FramelessWindowHint|Qt.Popup)
self.historyWindow.setGeometry(self.tabs.currentWidget().frameGeometry().width()/2+300, 87, 500, 500)
self.historyWindow.setWindowFlags(Qt.FramelessWindowHint | Qt.Popup)
self.historyWindow.setGeometry(int(self.tabs.currentWidget().frameGeometry().width()/2+300), 87, 500, 500)
radiusx = 10.0
radiusy = 5.0
path = QtGui.QPainterPath()
Expand All @@ -968,12 +1008,12 @@ def openHistory(self):

self.historyWindow.setStyleSheet(
"""
background-color:#fff;
""")
background-color:#fdfdfd;
"""
)
self.historyWindow.show()

def openSiteHistoryClicked(self, url,*args):
# self.add_new_tab(url, title)
self.tabs.currentWidget().load(url)


Expand Down Expand Up @@ -1010,14 +1050,15 @@ def __init__(self, parent=None, *args, **kwargs):

def main():
app = QApplication(sys.argv)

# Disable shortcut in context menu
app.styleHints().setShowShortcutsInContextMenus(False)

# Set the window name
QApplication.setApplicationName("Simple Web Browser")

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

# App styles
app.setStyleSheet("""
Expand Down Expand Up @@ -1239,11 +1280,9 @@ def main():
""")



#e6e6e6 background color
window = mainWindow()
window.show()

try:
sys.exit(app.exec_())

Expand Down

0 comments on commit 8efe1b8

Please sign in to comment.