mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
Remove vanity and move its functionality to the status bar
This commit is contained in:
parent
9370e50d59
commit
7e4673f293
@ -758,10 +758,8 @@ class DeviceMixin(object): # {{{
|
|||||||
self.refresh_ondevice_info (device_connected = True, reset_only = True)
|
self.refresh_ondevice_info (device_connected = True, reset_only = True)
|
||||||
else:
|
else:
|
||||||
self.device_connected = None
|
self.device_connected = None
|
||||||
|
self.status_bar.device_disconnected()
|
||||||
self.location_view.model().update_devices()
|
self.location_view.model().update_devices()
|
||||||
self.vanity.setText(self.vanity_template%\
|
|
||||||
dict(version=self.latest_version, device=' '))
|
|
||||||
self.device_info = ' '
|
|
||||||
if self.current_view() != self.library_view:
|
if self.current_view() != self.library_view:
|
||||||
self.book_details.reset_info()
|
self.book_details.reset_info()
|
||||||
self.location_view.setCurrentIndex(self.location_view.model().index(0))
|
self.location_view.setCurrentIndex(self.location_view.model().index(0))
|
||||||
@ -775,10 +773,7 @@ class DeviceMixin(object): # {{{
|
|||||||
return self.device_job_exception(job)
|
return self.device_job_exception(job)
|
||||||
info, cp, fs = job.result
|
info, cp, fs = job.result
|
||||||
self.location_view.model().update_devices(cp, fs)
|
self.location_view.model().update_devices(cp, fs)
|
||||||
self.device_info = _('Connected ')+info[0]
|
self.status_bar.device_connected(info[0])
|
||||||
self.vanity.setText(self.vanity_template%\
|
|
||||||
dict(version=self.latest_version, device=self.device_info))
|
|
||||||
|
|
||||||
self.device_manager.books(Dispatcher(self.metadata_downloaded))
|
self.device_manager.books(Dispatcher(self.metadata_downloaded))
|
||||||
|
|
||||||
def metadata_downloaded(self, job):
|
def metadata_downloaded(self, job):
|
||||||
|
@ -5,14 +5,15 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import functools
|
import functools, sys, os
|
||||||
|
|
||||||
from PyQt4.Qt import QMenu, Qt, pyqtSignal, QToolButton, QIcon, QStackedWidget, \
|
from PyQt4.Qt import QMenu, Qt, pyqtSignal, QToolButton, QIcon, QStackedWidget, \
|
||||||
QSize, QSizePolicy, QStatusBar, QUrl
|
QSize, QSizePolicy, QStatusBar, QUrl, QLabel
|
||||||
|
|
||||||
from calibre.utils.config import prefs
|
from calibre.utils.config import prefs
|
||||||
from calibre.ebooks import BOOK_EXTENSIONS
|
from calibre.ebooks import BOOK_EXTENSIONS
|
||||||
from calibre.constants import isosx, __appname__, preferred_encoding
|
from calibre.constants import isosx, __appname__, preferred_encoding, \
|
||||||
|
__version__
|
||||||
from calibre.gui2 import config, is_widescreen, open_url
|
from calibre.gui2 import config, is_widescreen, open_url
|
||||||
from calibre.gui2.library.views import BooksView, DeviceBooksView
|
from calibre.gui2.library.views import BooksView, DeviceBooksView
|
||||||
from calibre.gui2.widgets import Splitter
|
from calibre.gui2.widgets import Splitter
|
||||||
@ -366,14 +367,43 @@ class Stack(QStackedWidget): # {{{
|
|||||||
|
|
||||||
class StatusBar(QStatusBar): # {{{
|
class StatusBar(QStatusBar): # {{{
|
||||||
|
|
||||||
|
def __init__(self, parent=None):
|
||||||
|
QStatusBar.__init__(self, parent)
|
||||||
|
self.default_message = __appname__ + ' ' + _('version') + ' ' + \
|
||||||
|
self.get_version() + ' ' + _('created by Kovid Goyal')
|
||||||
|
self.device_string = ''
|
||||||
|
self.update_label = QLabel('')
|
||||||
|
self.update_label.setOpenExternalLinks(True)
|
||||||
|
self.addPermanentWidget(self.update_label)
|
||||||
|
|
||||||
def initialize(self, systray=None):
|
def initialize(self, systray=None):
|
||||||
self.default_message = 'Welcome to calibre'
|
|
||||||
self.systray = systray
|
self.systray = systray
|
||||||
self.notifier = get_notifier(systray)
|
self.notifier = get_notifier(systray)
|
||||||
self.messageChanged.connect(self.message_changed,
|
self.messageChanged.connect(self.message_changed,
|
||||||
type=Qt.QueuedConnection)
|
type=Qt.QueuedConnection)
|
||||||
self.message_changed('')
|
self.message_changed('')
|
||||||
|
|
||||||
|
def device_connected(self, devname):
|
||||||
|
self.device_string = _('Connected ') + devname
|
||||||
|
self.clearMessage()
|
||||||
|
|
||||||
|
def device_disconnected(self):
|
||||||
|
self.device_string = ''
|
||||||
|
self.clearMessage()
|
||||||
|
|
||||||
|
def new_version_available(self, ver, url):
|
||||||
|
msg = (u'<span style="color:red; font-weight: bold">%s: <a href="%s">%s<a></span>') % (
|
||||||
|
_('Update found'), url, ver)
|
||||||
|
self.update_label.setText(msg)
|
||||||
|
self.update_label.setCursor(Qt.PointingHandCursor)
|
||||||
|
|
||||||
|
def get_version(self):
|
||||||
|
dv = os.environ.get('CALIBRE_DEVELOP_FROM', None)
|
||||||
|
v = __version__
|
||||||
|
if getattr(sys, 'frozen', False) and dv and os.path.abspath(dv) in sys.path:
|
||||||
|
v += '*'
|
||||||
|
return v
|
||||||
|
|
||||||
def show_message(self, msg, timeout=0):
|
def show_message(self, msg, timeout=0):
|
||||||
self.showMessage(msg, timeout)
|
self.showMessage(msg, timeout)
|
||||||
if self.notifier is not None and not config['disable_tray_notification']:
|
if self.notifier is not None and not config['disable_tray_notification']:
|
||||||
@ -389,7 +419,10 @@ class StatusBar(QStatusBar): # {{{
|
|||||||
|
|
||||||
def message_changed(self, msg):
|
def message_changed(self, msg):
|
||||||
if not msg or msg.isEmpty() or msg.isNull():
|
if not msg or msg.isEmpty() or msg.isNull():
|
||||||
self.showMessage(self.default_message)
|
extra = ''
|
||||||
|
if self.device_string:
|
||||||
|
extra = ' ..::.. ' + self.device_string
|
||||||
|
self.showMessage(self.default_message + extra)
|
||||||
|
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
@ -119,33 +119,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QVBoxLayout" name="verticalLayout_3"/>
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="vanity">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>16777215</width>
|
|
||||||
<height>90</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="textFormat">
|
|
||||||
<enum>Qt::RichText</enum>
|
|
||||||
</property>
|
|
||||||
<property name="openExternalLinks">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
@ -19,7 +19,7 @@ from PyQt4.Qt import Qt, SIGNAL, QObject, QTimer, \
|
|||||||
QMessageBox, QHelpEvent
|
QMessageBox, QHelpEvent
|
||||||
|
|
||||||
from calibre import prints, patheq
|
from calibre import prints, patheq
|
||||||
from calibre.constants import __version__, __appname__, isosx
|
from calibre.constants import __appname__, isosx
|
||||||
from calibre.ptempfile import PersistentTemporaryFile
|
from calibre.ptempfile import PersistentTemporaryFile
|
||||||
from calibre.utils.config import prefs, dynamic
|
from calibre.utils.config import prefs, dynamic
|
||||||
from calibre.utils.ipc.server import Server
|
from calibre.utils.ipc.server import Server
|
||||||
@ -203,18 +203,7 @@ class Main(MainWindow, Ui_MainWindow, DeviceMixin, ToolbarMixin, # {{{
|
|||||||
self.device_manager.umount_device)
|
self.device_manager.umount_device)
|
||||||
self.eject_action.triggered.connect(self.device_manager.umount_device)
|
self.eject_action.triggered.connect(self.device_manager.umount_device)
|
||||||
|
|
||||||
####################### Vanity ########################
|
#################### Update notification ###################
|
||||||
self.vanity_template = _('<p>For help see the: <a href="%s">User Manual</a>'
|
|
||||||
'<br>')%'http://calibre-ebook.com/user_manual'
|
|
||||||
dv = os.environ.get('CALIBRE_DEVELOP_FROM', None)
|
|
||||||
v = __version__
|
|
||||||
if getattr(sys, 'frozen', False) and dv and os.path.abspath(dv) in sys.path:
|
|
||||||
v += '*'
|
|
||||||
self.vanity_template += _('<b>%s</b>: %s by <b>Kovid Goyal '
|
|
||||||
'%%(version)s</b><br>%%(device)s</p>')%(__appname__, v)
|
|
||||||
self.latest_version = ' '
|
|
||||||
self.vanity.setText(self.vanity_template%dict(version=' ', device=' '))
|
|
||||||
self.device_info = ' '
|
|
||||||
UpdateMixin.__init__(self, opts)
|
UpdateMixin.__init__(self, opts)
|
||||||
|
|
||||||
####################### Setup Toolbar #####################
|
####################### Setup Toolbar #####################
|
||||||
|
@ -49,12 +49,8 @@ class UpdateMixin(object):
|
|||||||
def update_found(self, version):
|
def update_found(self, version):
|
||||||
os = 'windows' if iswindows else 'osx' if isosx else 'linux'
|
os = 'windows' if iswindows else 'osx' if isosx else 'linux'
|
||||||
url = 'http://calibre-ebook.com/download_%s'%os
|
url = 'http://calibre-ebook.com/download_%s'%os
|
||||||
self.latest_version = '<br>' + _('<span style="color:red; font-weight:bold">'
|
self.status_bar.new_version_available(version, url)
|
||||||
'Latest version: <a href="%s">%s</a></span>')%(url, version)
|
|
||||||
self.vanity.setText(self.vanity_template%\
|
|
||||||
(dict(version=self.latest_version,
|
|
||||||
device=self.device_info)))
|
|
||||||
self.vanity.update()
|
|
||||||
if config.get('new_version_notification') and \
|
if config.get('new_version_notification') and \
|
||||||
dynamic.get('update to version %s'%version, True):
|
dynamic.get('update to version %s'%version, True):
|
||||||
if question_dialog(self, _('Update available'),
|
if question_dialog(self, _('Update available'),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user