def __init__(self):
global downloads_list_file
QMainWindow.__init__(self)
self.setWindowIcon(QIcon(":/quartz.png"))
self.setWindowTitle("Quartz Browser - "+__version__)
# Window Properties
self.history = []
self.downloads = []
self.confirm_before_quit = True
# Create required directories
for folder in [configdir, icon_dir, thumbnails_dir]:
if not os.path.exists(folder):
os.mkdir(folder)
# Import and Apply Settings
self.setAttribute(Qt.WA_DeleteOnClose)
self.settings = QSettings(1, 0, "quartz-browser","Quartz", self)
self.opensettings()
self.websettings = QWebSettings.globalSettings()
self.websettings.setAttribute(QWebSettings.DnsPrefetchEnabled, True)
self.websettings.setMaximumPagesInCache(10)
self.websettings.setIconDatabasePath(icon_dir)
self.websettings.setAttribute(QWebSettings.JavascriptCanOpenWindows, True)
self.websettings.setAttribute(QWebSettings.JavascriptCanCloseWindows, True)
if webkit.enable_adblock:
self.websettings.setUserStyleSheetUrl(QUrl.fromLocalFile(program_dir + 'userContent.css'))
# Import Downloads and Bookmarks
self.dwnldsmodel = DownloadsModel(self.downloads, QApplication.instance())
self.dwnldsmodel.deleteDownloadsRequested.connect(self.deleteDownloads)
imported_downloads = importDownloads(downloads_list_file)
for [filepath, url, totalsize, timestamp] in imported_downloads:
try : # Check if downloads.txt is valid
tymstamp = float(timestamp)
except :
self.downloads = []
exportDownloads(downloads_list_file, [])
print("Error in importing Downloads.")
break
old_download = Download(networkmanager)
old_download.loadDownload(filepath, url, totalsize, timestamp)
old_download.datachanged.connect(self.dwnldsmodel.datachanged)
self.downloads.append(old_download)
self.bookmarks = importBookmarks(configdir+"bookmarks.txt")
self.favourites = importFavourites(configdir + 'favourites.txt')
# Find and set icon theme name
for theme_name in ['Adwaita', 'Gnome', 'Tango']:
if os.path.exists('/usr/share/icons/' + theme_name):
QIcon.setThemeName(theme_name)
break
self.initUI()
self.resize(1024,714)
评论列表
文章目录