def __init__(self, parent=None): super().__init__(parent) self._sessionsMetaDataList = [] # QList<SessionMetaData> self._firstBackupSession = DataPaths.currentProfilePath() + '/session.dat.old' self._secondBackupSession = DataPaths.currentProfilePath() + '/session.dat.old1' self._lastActiveSessionPath = '' sessionFileWatcher = QFileSystemWatcher([DataPaths.path(DataPaths.Sessions)], self) sessionFileWatcher.directoryChanged.connect(self._sessionsDirectoryChanged) sessionFileWatcher.directoryChanged.connect(self.sessionsMetaDataChanged) self.loadSettings()
def _optimizeDb(self): gVar.app.setOverrideCursor(Qt.WaitCursor) profilePath = DataPaths.currentProfilePath() sizeBefore = gVar.appTools.fileSizeToString( QFileInfo(profilePath + 'browserdata.db').size()) IconProvider.instance().clearOldIconsInDatabase() sizeAfter = gVar.appTools.fileSizeToString( QFileInfo(profilePath + 'browserdata.db').size()) gVar.app.restoreOverrideCursor() QMessageBox.information( self, _('Database Optimized'), _('Database successfully optimized.<br/><br/><b>Database Size Before: </b>%s<br/><b>Database Size After: </b>%s' ) % # noqa E501 (sizeBefore, sizeAfter))
def loadSettings(self): self._loaded = True settings = Settings() settings.beginGroup('SpeedDial') allPages = settings.value('pages', '') self.setBackgroundImage(settings.value('background', '')) self._backgroundImageSize = settings.value('backsize', 'auto') self._maxPagesInRow = settings.value('pagesrow', 4) self._sizeOfSpeedDials = settings.value('sdsize', 231) self._sdcentered = settings.value('sdcenter', False) settings.endGroup() self.changed(allPages) self._thumbnailsDir = DataPaths.currentProfilePath() + '/thumbnails/' # If needed, create thumbnails directory if not pathexists(self._thumbnailsDir): makedirs(self._thumbnailsDir)
def _saveBookmarks(self): bookmarksMap = {} self._WRITE_FOLDER('bookmark_bar', self._folderToolbar, bookmarksMap) self._WRITE_FOLDER('bookmark_menu', self._folderMenu, bookmarksMap) self._WRITE_FOLDER('other', self._folderUnsorted, bookmarksMap) map_ = {} map_['version'] = self._s_bookmarksVersion map_['roots'] = bookmarksMap data = jdumps(map_) if not data: print( 'Warning: Bookmarks::saveBookmarks() Error serializing bookmarks!' ) return fpath = DataPaths.currentProfilePath() + '/bookmarks.json' with open(fpath, 'wt') as fp: fp.write(data)
def _loadBookmarks(self): bookmarksFile = DataPaths.currentProfilePath() + '/bookmarks.json' backupFile = bookmarksFile + '.old' error = False try: res = jloads(gVar.appTools.readAllFileContents(bookmarksFile)) if type(res) != dict: error = True except ValueError: error = True if error: if pathexists(bookmarksFile): print( 'Warning: Bookmarks::init() Error parsing bookmarks! Using default bookmarks!' ) print( 'Warning: Bookmarks::init() Your bookmarks have been backed up in %s' % backupFile) # Backup the user bookmarks if pathexists(backupFile): remove(backupFile) copy(bookmarksFile, backupFile) # Load default bookmarks content = gVar.appTools.readAllFileContents(':data/bookmarks.json') data = jloads(content) assert (type(data) == dict) self._loadBookmarksFromMap(data['roots']) # Don't forget to save the bookmarks self._autoSaver.changeOccurred() else: self._loadBookmarksFromMap(res['roots'])
def defaultSessionPath(cls): ''' @return: QString ''' return DataPaths.currentProfilePath() + '/session.dat'
def clearCache(cls): profile = DataPaths.currentProfilePath() gVar.appTools.removeRecursively(profile + '/GPUCache') gVar.app.webProfile().clearHttpCache()
def clearWebDatabases(cls): profile = DataPaths.currentProfilePath() gVar.appTools.removeRecursively(profile + '/IndexedDB') gVar.appTools.removeRecursively(profile + '/databases')
def clearLocalStorage(cls): profile = DataPaths.currentProfilePath() gVar.appTools.removeRecursively(profile + '/Local Storage')