# ============================================================ # Tab Counter - plugin for Falkon # Copyright (C) 2020 Juraj Oravec # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # ============================================================ from PySide2 import QtWidgets class Button(QtWidgets.QLabel): window = None allTabs = 0 loadedTabs = 0 def __init__(self, window): super().__init__() self.window = window self.setFrameStyle(QtWidgets.QFrame.StyledPanel) self.updateText() self.window.tabWidget().changed.connect(self.updateText) def id(self): return "tab-counter-button" def name(self): return "Tab Counter" def updateText(self): self.ubdateCounts() self.setText("%d/%d" % (self.loadedTabs, self.allTabs)) def ubdateCounts(self): tabs = self.window.tabWidget().allTabs() self.allTabs = len(tabs) self.loadedTabs = 0 for tab in tabs: if tab.isRestored(): self.loadedTabs += 1