mirror of
https://github.com/fergalmoran/picard.git
synced 2026-01-05 16:13:59 +00:00
Use icons for counters in status bar
This commit is contained in:
81
picard/ui/infostatus.py
Normal file
81
picard/ui/infostatus.py
Normal file
@@ -0,0 +1,81 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Picard, the next-generation MusicBrainz tagger
|
||||
# Copyright (C) 2008 Philipp Wolfer
|
||||
#
|
||||
# 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 2
|
||||
# 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, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from PyQt4.QtGui import QIcon
|
||||
from picard import config
|
||||
from picard.util import icontheme
|
||||
from picard.ui.ui_infostatus import Ui_InfoStatus
|
||||
|
||||
|
||||
class InfoStatus(QtGui.QWidget, Ui_InfoStatus):
|
||||
|
||||
def __init__(self, parent):
|
||||
QtGui.QWidget.__init__(self, parent)
|
||||
Ui_InfoStatus.__init__(self)
|
||||
self.setupUi(self)
|
||||
|
||||
self._size = QtCore.QSize(16, 16)
|
||||
self._create_icons()
|
||||
self._init_labels()
|
||||
|
||||
def _init_labels(self):
|
||||
size = self._size
|
||||
self.label1.setPixmap(self.icon_file.pixmap(size))
|
||||
self.label2.setPixmap(self.icon_cd.pixmap(size))
|
||||
self.label3.setPixmap(self.icon_file_pending.pixmap(size))
|
||||
self.label4.setPixmap(self.icon_web.pixmap(size, QIcon.Disabled))
|
||||
self._init_tooltips()
|
||||
|
||||
def _create_icons(self):
|
||||
self.icon_cd = icontheme.lookup('media-optical')
|
||||
self.icon_file = QtGui.QIcon(":/images/file.png")
|
||||
self.icon_file_pending = QtGui.QIcon(":/images/file-pending.png")
|
||||
self.icon_web = icontheme.lookup('lookup-musicbrainz')
|
||||
|
||||
def _init_tooltips(self):
|
||||
t1 = _("Files")
|
||||
t2 = _("Albums")
|
||||
t3 = _("Pending files")
|
||||
t4 = _("Pending requests")
|
||||
self.val1.setToolTip(t1)
|
||||
self.label1.setToolTip(t1)
|
||||
self.val2.setToolTip(t2)
|
||||
self.label2.setToolTip(t2)
|
||||
self.val3.setToolTip(t3)
|
||||
self.label3.setToolTip(t3)
|
||||
self.val4.setToolTip(t4)
|
||||
self.label4.setToolTip(t4)
|
||||
|
||||
def setFiles(self, num):
|
||||
self.val1.setText(unicode(num))
|
||||
|
||||
def setAlbums(self, num):
|
||||
self.val2.setText(unicode(num))
|
||||
|
||||
def setPendingFiles(self, num):
|
||||
self.val3.setText(unicode(num))
|
||||
|
||||
def setPendingRequests(self, num):
|
||||
if num <= 0:
|
||||
enabled = QIcon.Disabled
|
||||
else:
|
||||
enabled = QIcon.Normal
|
||||
self.label4.setPixmap(self.icon_web.pixmap(self._size, enabled))
|
||||
self.val4.setText(unicode(num))
|
||||
@@ -34,6 +34,7 @@ from picard.ui.filebrowser import FileBrowser
|
||||
from picard.ui.tagsfromfilenames import TagsFromFileNamesDialog
|
||||
from picard.ui.options.dialog import OptionsDialog
|
||||
from picard.ui.infodialog import FileInfoDialog, AlbumInfoDialog
|
||||
from picard.ui.infostatus import InfoStatus
|
||||
from picard.ui.passworddialog import PasswordDialog
|
||||
from picard.util import icontheme, webbrowser2, find_existing_path
|
||||
from picard.util.cdrom import get_cdrom_drives
|
||||
@@ -208,12 +209,12 @@ class MainWindow(QtGui.QMainWindow):
|
||||
def create_statusbar(self):
|
||||
"""Creates a new status bar."""
|
||||
self.statusBar().showMessage(_("Ready"))
|
||||
self.tagger_counts_label = QtGui.QLabel()
|
||||
self.infostatus = InfoStatus(self)
|
||||
self.listening_label = QtGui.QLabel()
|
||||
self.listening_label.setVisible(False)
|
||||
self.listening_label.setToolTip(_("Picard listens on a port to integrate with your browser and downloads release"
|
||||
" information when you click the \"Tagger\" buttons on the MusicBrainz website"))
|
||||
self.statusBar().addPermanentWidget(self.tagger_counts_label)
|
||||
self.statusBar().addPermanentWidget(self.infostatus)
|
||||
self.statusBar().addPermanentWidget(self.listening_label)
|
||||
self.tagger.tagger_stats_changed.connect(self.update_statusbar_stats)
|
||||
self.tagger.listen_port_changed.connect(self.update_statusbar_listen_port)
|
||||
@@ -221,17 +222,10 @@ class MainWindow(QtGui.QMainWindow):
|
||||
|
||||
def update_statusbar_stats(self):
|
||||
"""Updates the status bar information."""
|
||||
self.tagger_counts_label.setText(_(
|
||||
" Files: %(files)d, "
|
||||
"Albums: %(albums)d, "
|
||||
"Pending files: %(pfiles)d, "
|
||||
"Pending web lookups: %(web)d ")
|
||||
% {
|
||||
"files": len(self.tagger.files),
|
||||
"pfiles": File.num_pending_files,
|
||||
"albums": len(self.tagger.albums),
|
||||
"web": self.tagger.xmlws.num_pending_web_requests,
|
||||
})
|
||||
self.infostatus.setFiles(len(self.tagger.files))
|
||||
self.infostatus.setAlbums(len(self.tagger.albums))
|
||||
self.infostatus.setPendingFiles(File.num_pending_files)
|
||||
self.infostatus.setPendingRequests(self.tagger.xmlws.num_pending_web_requests)
|
||||
|
||||
def update_statusbar_listen_port(self, listen_port):
|
||||
self.listening_label.setVisible(True)
|
||||
|
||||
101
picard/ui/ui_infostatus.py
Normal file
101
picard/ui/ui_infostatus.py
Normal file
@@ -0,0 +1,101 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Form implementation generated from reading ui file 'ui/infostatus.ui'
|
||||
#
|
||||
# Created: Thu Jun 27 18:02:21 2013
|
||||
# by: PyQt4 UI code generator 4.9.3
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
try:
|
||||
_fromUtf8 = QtCore.QString.fromUtf8
|
||||
except AttributeError:
|
||||
_fromUtf8 = lambda s: s
|
||||
|
||||
class Ui_InfoStatus(object):
|
||||
def setupUi(self, InfoStatus):
|
||||
InfoStatus.setObjectName(_fromUtf8("InfoStatus"))
|
||||
InfoStatus.resize(350, 24)
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(InfoStatus.sizePolicy().hasHeightForWidth())
|
||||
InfoStatus.setSizePolicy(sizePolicy)
|
||||
InfoStatus.setMinimumSize(QtCore.QSize(0, 0))
|
||||
self.horizontalLayout = QtGui.QHBoxLayout(InfoStatus)
|
||||
self.horizontalLayout.setSpacing(2)
|
||||
self.horizontalLayout.setMargin(0)
|
||||
self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
|
||||
self.val1 = QtGui.QLabel(InfoStatus)
|
||||
self.val1.setMinimumSize(QtCore.QSize(50, 0))
|
||||
self.val1.setText(_fromUtf8(""))
|
||||
self.val1.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
|
||||
self.val1.setObjectName(_fromUtf8("val1"))
|
||||
self.horizontalLayout.addWidget(self.val1)
|
||||
self.label1 = QtGui.QLabel(InfoStatus)
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Preferred)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.label1.sizePolicy().hasHeightForWidth())
|
||||
self.label1.setSizePolicy(sizePolicy)
|
||||
self.label1.setFrameShape(QtGui.QFrame.NoFrame)
|
||||
self.label1.setTextFormat(QtCore.Qt.AutoText)
|
||||
self.label1.setScaledContents(False)
|
||||
self.label1.setMargin(1)
|
||||
self.label1.setObjectName(_fromUtf8("label1"))
|
||||
self.horizontalLayout.addWidget(self.label1)
|
||||
self.val2 = QtGui.QLabel(InfoStatus)
|
||||
self.val2.setMinimumSize(QtCore.QSize(50, 0))
|
||||
self.val2.setText(_fromUtf8(""))
|
||||
self.val2.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
|
||||
self.val2.setObjectName(_fromUtf8("val2"))
|
||||
self.horizontalLayout.addWidget(self.val2)
|
||||
self.label2 = QtGui.QLabel(InfoStatus)
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Preferred)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.label2.sizePolicy().hasHeightForWidth())
|
||||
self.label2.setSizePolicy(sizePolicy)
|
||||
self.label2.setText(_fromUtf8(""))
|
||||
self.label2.setObjectName(_fromUtf8("label2"))
|
||||
self.horizontalLayout.addWidget(self.label2)
|
||||
self.val3 = QtGui.QLabel(InfoStatus)
|
||||
self.val3.setMinimumSize(QtCore.QSize(50, 0))
|
||||
self.val3.setText(_fromUtf8(""))
|
||||
self.val3.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
|
||||
self.val3.setObjectName(_fromUtf8("val3"))
|
||||
self.horizontalLayout.addWidget(self.val3)
|
||||
self.label3 = QtGui.QLabel(InfoStatus)
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Preferred)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.label3.sizePolicy().hasHeightForWidth())
|
||||
self.label3.setSizePolicy(sizePolicy)
|
||||
self.label3.setText(_fromUtf8(""))
|
||||
self.label3.setObjectName(_fromUtf8("label3"))
|
||||
self.horizontalLayout.addWidget(self.label3)
|
||||
self.val4 = QtGui.QLabel(InfoStatus)
|
||||
self.val4.setMinimumSize(QtCore.QSize(50, 0))
|
||||
self.val4.setText(_fromUtf8(""))
|
||||
self.val4.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
|
||||
self.val4.setObjectName(_fromUtf8("val4"))
|
||||
self.horizontalLayout.addWidget(self.val4)
|
||||
self.label4 = QtGui.QLabel(InfoStatus)
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Preferred)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.label4.sizePolicy().hasHeightForWidth())
|
||||
self.label4.setSizePolicy(sizePolicy)
|
||||
self.label4.setText(_fromUtf8(""))
|
||||
self.label4.setScaledContents(False)
|
||||
self.label4.setObjectName(_fromUtf8("label4"))
|
||||
self.horizontalLayout.addWidget(self.label4)
|
||||
|
||||
self.retranslateUi(InfoStatus)
|
||||
QtCore.QMetaObject.connectSlotsByName(InfoStatus)
|
||||
|
||||
def retranslateUi(self, InfoStatus):
|
||||
InfoStatus.setWindowTitle(_("Form"))
|
||||
|
||||
167
ui/infostatus.ui
Normal file
167
ui/infostatus.ui
Normal file
@@ -0,0 +1,167 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>InfoStatus</class>
|
||||
<widget class="QWidget" name="InfoStatus">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>350</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="val1">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label1">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::AutoText</enum>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="val2">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="val3">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="val4">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label4">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user