tabCounter/tabcounter/button.py
Juraj Oravec bca6640525
Working prototype
Signed-off-by: Juraj Oravec <sgd.orava@gmail.com>
2020-02-23 22:08:20 +01:00

58 lines
1.6 KiB
Python

# ============================================================
# Tab Counter - plugin for Falkon
# Copyright (C) 2020 Juraj Oravec <sgd.orava@gmail.com>
#
# 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 <http://www.gnu.org/licenses/>.
# ============================================================
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