mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge from trunk
This commit is contained in:
commit
9cf4fd7c0d
@ -24,9 +24,10 @@ class Economist(BasicNewsRecipe):
|
|||||||
oldest_article = 7.0
|
oldest_article = 7.0
|
||||||
cover_url = 'http://www.economist.com/images/covers/currentcoverus_large.jpg'
|
cover_url = 'http://www.economist.com/images/covers/currentcoverus_large.jpg'
|
||||||
remove_tags = [dict(name=['script', 'noscript', 'title', 'iframe', 'cf_floatingcontent']),
|
remove_tags = [dict(name=['script', 'noscript', 'title', 'iframe', 'cf_floatingcontent']),
|
||||||
dict(attrs={'class':['dblClkTrk']})]
|
dict(attrs={'class':['dblClkTrk', 'ec-article-info']})]
|
||||||
remove_tags_before = dict(name=lambda tag: tag.name=='title' and tag.parent.name=='body')
|
keep_only_tags = [dict(id='ec-article-body')]
|
||||||
needs_subscription = True
|
needs_subscription = True
|
||||||
|
no_stylesheets = True
|
||||||
preprocess_regexps = [(re.compile('</html>.*', re.DOTALL),
|
preprocess_regexps = [(re.compile('</html>.*', re.DOTALL),
|
||||||
lambda x:'</html>')]
|
lambda x:'</html>')]
|
||||||
|
|
||||||
@ -87,7 +88,7 @@ class Economist(BasicNewsRecipe):
|
|||||||
continue
|
continue
|
||||||
a = tag.find('a', href=True)
|
a = tag.find('a', href=True)
|
||||||
if a is not None:
|
if a is not None:
|
||||||
url=a['href'].replace('displaystory', 'PrinterFriendly').strip()
|
url=a['href'].split('?')[0]+'/print'
|
||||||
if url.startswith('Printer'):
|
if url.startswith('Printer'):
|
||||||
url = '/'+url
|
url = '/'+url
|
||||||
if url.startswith('/'):
|
if url.startswith('/'):
|
||||||
|
@ -17,8 +17,9 @@ class Economist(BasicNewsRecipe):
|
|||||||
oldest_article = 7.0
|
oldest_article = 7.0
|
||||||
cover_url = 'http://www.economist.com/images/covers/currentcoverus_large.jpg'
|
cover_url = 'http://www.economist.com/images/covers/currentcoverus_large.jpg'
|
||||||
remove_tags = [dict(name=['script', 'noscript', 'title', 'iframe', 'cf_floatingcontent']),
|
remove_tags = [dict(name=['script', 'noscript', 'title', 'iframe', 'cf_floatingcontent']),
|
||||||
dict(attrs={'class':['dblClkTrk']})]
|
dict(attrs={'class':['dblClkTrk', 'ec-article-info']})]
|
||||||
remove_tags_before = dict(name=lambda tag: tag.name=='title' and tag.parent.name=='body')
|
keep_only_tags = [dict(id='ec-article-body')]
|
||||||
|
no_stylesheets = True
|
||||||
preprocess_regexps = [(re.compile('</html>.*', re.DOTALL),
|
preprocess_regexps = [(re.compile('</html>.*', re.DOTALL),
|
||||||
lambda x:'</html>')]
|
lambda x:'</html>')]
|
||||||
|
|
||||||
@ -88,19 +89,20 @@ class Economist(BasicNewsRecipe):
|
|||||||
br = browser()
|
br = browser()
|
||||||
ret = br.open(url)
|
ret = br.open(url)
|
||||||
raw = ret.read()
|
raw = ret.read()
|
||||||
url = br.geturl().replace('displaystory', 'PrinterFriendly').strip()
|
url = br.geturl().split('?')[0]+'/print'
|
||||||
root = html.fromstring(raw)
|
root = html.fromstring(raw)
|
||||||
matches = root.xpath('//*[@class = "article-section"]')
|
matches = root.xpath('//*[@class = "ec-article-info"]')
|
||||||
feedtitle = 'Miscellaneous'
|
feedtitle = 'Miscellaneous'
|
||||||
if matches:
|
if matches:
|
||||||
feedtitle = string.capwords(html.tostring(matches[0], method='text',
|
feedtitle = string.capwords(html.tostring(matches[-1], method='text',
|
||||||
encoding=unicode))
|
encoding=unicode).split('|')[-1].strip())
|
||||||
return (i, feedtitle, url, title, description, author, published)
|
return (i, feedtitle, url, title, description, author, published)
|
||||||
|
|
||||||
def eco_article_found(self, req, result):
|
def eco_article_found(self, req, result):
|
||||||
from calibre.web.feeds import Article
|
from calibre.web.feeds import Article
|
||||||
i, feedtitle, link, title, description, author, published = result
|
i, feedtitle, link, title, description, author, published = result
|
||||||
self.log('Found print version for article:', title)
|
self.log('Found print version for article:', title, 'in', feedtitle,
|
||||||
|
'at', link)
|
||||||
|
|
||||||
a = Article(i, title, link, author, description, published, '')
|
a = Article(i, title, link, author, description, published, '')
|
||||||
|
|
||||||
|
43
resources/recipes/reptantes.recipe
Normal file
43
resources/recipes/reptantes.recipe
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
|
||||||
|
__license__ = 'GPL v3'
|
||||||
|
__copyright__ = '2010, Darko Miletic <darko.miletic at gmail.com>'
|
||||||
|
'''
|
||||||
|
www.reptantes.com.ar
|
||||||
|
'''
|
||||||
|
|
||||||
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
|
||||||
|
class Reptantes(BasicNewsRecipe):
|
||||||
|
title = 'Reptantes'
|
||||||
|
__author__ = 'Darko Miletic'
|
||||||
|
description = u"cada vez que te haces acupuntura, tu muñeco vudú sufre en algún lado"
|
||||||
|
oldest_article = 130
|
||||||
|
max_articles_per_feed = 100
|
||||||
|
language = 'es'
|
||||||
|
encoding = 'utf-8'
|
||||||
|
no_stylesheets = True
|
||||||
|
use_embedded_content = False
|
||||||
|
publication_type = 'blog'
|
||||||
|
extra_css = ' body{font-family: "Palatino Linotype",serif} h2{text-align: center; color:#BE7F8D} img{margin-bottom: 2em} '
|
||||||
|
|
||||||
|
conversion_options = {
|
||||||
|
'comment' : description
|
||||||
|
, 'tags' : 'literatura'
|
||||||
|
, 'publisher': 'Hernan Racnati'
|
||||||
|
, 'language' : language
|
||||||
|
}
|
||||||
|
|
||||||
|
feeds = [(u'Posts', u'http://www.reptantes.com.ar/?feed=rss2')]
|
||||||
|
|
||||||
|
keep_only_tags = [dict(attrs={'id':'content'})]
|
||||||
|
remove_tags = [dict(attrs={'class':'iLikeThis'})]
|
||||||
|
remove_tags_before = dict(name='h2')
|
||||||
|
remove_tags_after = dict(attrs={'class':'iLikeThis'})
|
||||||
|
|
||||||
|
|
||||||
|
def preprocess_html(self, soup):
|
||||||
|
for item in soup.findAll(style=True):
|
||||||
|
del item['style']
|
||||||
|
return self.adeify_images(soup)
|
||||||
|
|
||||||
|
|
@ -21,7 +21,7 @@ class Smh_au(BasicNewsRecipe):
|
|||||||
language = 'en_AU'
|
language = 'en_AU'
|
||||||
remove_empty_feeds = True
|
remove_empty_feeds = True
|
||||||
masthead_url = 'http://images.smh.com.au/2010/02/02/1087188/smh-620.jpg'
|
masthead_url = 'http://images.smh.com.au/2010/02/02/1087188/smh-620.jpg'
|
||||||
publication_type = 'newspaper'
|
publication_type = 'newspaper'
|
||||||
extra_css = ' h1{font-family: Georgia,"Times New Roman",Times,serif } body{font-family: Arial,Helvetica,sans-serif} .cT-imageLandscape{font-size: x-small} '
|
extra_css = ' h1{font-family: Georgia,"Times New Roman",Times,serif } body{font-family: Arial,Helvetica,sans-serif} .cT-imageLandscape{font-size: x-small} '
|
||||||
|
|
||||||
conversion_options = {
|
conversion_options = {
|
||||||
@ -47,7 +47,7 @@ class Smh_au(BasicNewsRecipe):
|
|||||||
for itimg in soup.findAll('img',src=True):
|
for itimg in soup.findAll('img',src=True):
|
||||||
if itimg['src'].endswith('frontpage.jpg'):
|
if itimg['src'].endswith('frontpage.jpg'):
|
||||||
self.cover_url = itimg['src']
|
self.cover_url = itimg['src']
|
||||||
|
|
||||||
for item in soup.findAll(attrs={'class':'cN-storyHeadlineLead cfix'}):
|
for item in soup.findAll(attrs={'class':'cN-storyHeadlineLead cfix'}):
|
||||||
description = ''
|
description = ''
|
||||||
title_prefix = ''
|
title_prefix = ''
|
||||||
@ -65,4 +65,4 @@ class Smh_au(BasicNewsRecipe):
|
|||||||
,'url' :url
|
,'url' :url
|
||||||
,'description':description
|
,'description':description
|
||||||
})
|
})
|
||||||
return [(soup.head.title.string, articles)]
|
return [(self.tag_to_string(soup.find('title')), articles)]
|
||||||
|
@ -706,15 +706,22 @@ OptionRecommendation(name='timestamp',
|
|||||||
for rec in group:
|
for rec in group:
|
||||||
setattr(self.opts, rec.option.name, rec.recommended_value)
|
setattr(self.opts, rec.option.name, rec.recommended_value)
|
||||||
|
|
||||||
for x in input_profiles():
|
def set_profile(profiles, which):
|
||||||
if x.short_name == self.opts.input_profile:
|
attr = which + '_profile'
|
||||||
self.opts.input_profile = x
|
sval = getattr(self.opts, attr)
|
||||||
break
|
for x in profiles():
|
||||||
|
if x.short_name == sval:
|
||||||
|
setattr(self.opts, attr, x)
|
||||||
|
return
|
||||||
|
self.log.warn(
|
||||||
|
'Profile (%s) %r is no longer available, using default'%(which, sval))
|
||||||
|
for x in profiles():
|
||||||
|
if x.short_name == 'default':
|
||||||
|
setattr(self.opts, attr, x)
|
||||||
|
break
|
||||||
|
|
||||||
for x in output_profiles():
|
set_profile(input_profiles, 'input')
|
||||||
if x.short_name == self.opts.output_profile:
|
set_profile(output_profiles, 'output')
|
||||||
self.opts.output_profile = x
|
|
||||||
break
|
|
||||||
|
|
||||||
self.read_user_metadata()
|
self.read_user_metadata()
|
||||||
self.opts.no_inline_navbars = self.opts.output_profile.supports_mobi_indexing \
|
self.opts.no_inline_navbars = self.opts.output_profile.supports_mobi_indexing \
|
||||||
|
@ -99,6 +99,8 @@ def _config():
|
|||||||
help=_('Limit max simultaneous jobs to number of CPUs'))
|
help=_('Limit max simultaneous jobs to number of CPUs'))
|
||||||
c.add_opt('tag_browser_hidden_categories', default=set(),
|
c.add_opt('tag_browser_hidden_categories', default=set(),
|
||||||
help=_('tag browser categories not to display'))
|
help=_('tag browser categories not to display'))
|
||||||
|
c.add_opt('gui_layout', choices=['wide', 'narrow'],
|
||||||
|
help=_('The layout of the user interface'), default='narrow')
|
||||||
return ConfigProxy(c)
|
return ConfigProxy(c)
|
||||||
|
|
||||||
config = _config()
|
config = _config()
|
||||||
@ -125,6 +127,11 @@ def available_width():
|
|||||||
desktop = QCoreApplication.instance().desktop()
|
desktop = QCoreApplication.instance().desktop()
|
||||||
return desktop.availableGeometry().width()
|
return desktop.availableGeometry().width()
|
||||||
|
|
||||||
|
try:
|
||||||
|
is_widescreen = float(available_width())/available_height() > 1.4
|
||||||
|
except:
|
||||||
|
is_widescreen = True
|
||||||
|
|
||||||
def extension(path):
|
def extension(path):
|
||||||
return os.path.splitext(path)[1][1:].lower()
|
return os.path.splitext(path)[1][1:].lower()
|
||||||
|
|
||||||
|
@ -10,10 +10,11 @@ Module to implement the Cover Flow feature
|
|||||||
import sys, os, time
|
import sys, os, time
|
||||||
|
|
||||||
from PyQt4.Qt import QImage, QSizePolicy, QTimer, QDialog, Qt, QSize, \
|
from PyQt4.Qt import QImage, QSizePolicy, QTimer, QDialog, Qt, QSize, \
|
||||||
QStackedLayout
|
QStackedLayout, QLabel
|
||||||
|
|
||||||
from calibre import plugins
|
from calibre import plugins
|
||||||
from calibre.gui2 import config, available_height, available_width
|
from calibre.gui2 import config, available_height, available_width
|
||||||
|
|
||||||
pictureflow, pictureflowerror = plugins['pictureflow']
|
pictureflow, pictureflowerror = plugins['pictureflow']
|
||||||
|
|
||||||
if pictureflow is not None:
|
if pictureflow is not None:
|
||||||
@ -78,12 +79,15 @@ if pictureflow is not None:
|
|||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
pictureflow.PictureFlow.__init__(self, parent,
|
pictureflow.PictureFlow.__init__(self, parent,
|
||||||
config['cover_flow_queue_length']+1)
|
config['cover_flow_queue_length']+1)
|
||||||
self.setMinimumSize(QSize(10, 10))
|
self.setMinimumSize(QSize(300, 150))
|
||||||
self.setFocusPolicy(Qt.WheelFocus)
|
self.setFocusPolicy(Qt.WheelFocus)
|
||||||
self.setSizePolicy(QSizePolicy(QSizePolicy.Expanding,
|
self.setSizePolicy(QSizePolicy(QSizePolicy.Expanding,
|
||||||
QSizePolicy.Expanding))
|
QSizePolicy.Expanding))
|
||||||
self.setZoomFactor(150)
|
self.setZoomFactor(150)
|
||||||
|
|
||||||
|
def sizeHint(self):
|
||||||
|
return self.minimumSize()
|
||||||
|
|
||||||
def wheelEvent(self, ev):
|
def wheelEvent(self, ev):
|
||||||
ev.accept()
|
ev.accept()
|
||||||
if ev.delta() < 0:
|
if ev.delta() < 0:
|
||||||
@ -107,56 +111,49 @@ class CoverFlowMixin(object):
|
|||||||
self.cover_flow_sync_timer.timeout.connect(self.cover_flow_do_sync)
|
self.cover_flow_sync_timer.timeout.connect(self.cover_flow_do_sync)
|
||||||
self.cover_flow_sync_flag = True
|
self.cover_flow_sync_flag = True
|
||||||
self.cover_flow = CoverFlow(parent=self)
|
self.cover_flow = CoverFlow(parent=self)
|
||||||
self.cover_flow.setVisible(False)
|
|
||||||
if not config['separate_cover_flow']:
|
|
||||||
self.cb_layout.addWidget(self.cover_flow)
|
|
||||||
self.cover_flow.currentChanged.connect(self.sync_listview_to_cf)
|
self.cover_flow.currentChanged.connect(self.sync_listview_to_cf)
|
||||||
self.library_view.selectionModel().currentRowChanged.connect(
|
self.library_view.selectionModel().currentRowChanged.connect(
|
||||||
self.sync_cf_to_listview)
|
self.sync_cf_to_listview)
|
||||||
self.db_images = DatabaseImages(self.library_view.model())
|
self.db_images = DatabaseImages(self.library_view.model())
|
||||||
self.cover_flow.setImages(self.db_images)
|
self.cover_flow.setImages(self.db_images)
|
||||||
ah, aw = available_height(), available_width()
|
else:
|
||||||
self._cb_layout_is_horizontal = float(aw)/ah >= 1.4
|
self.cover_flow = QLabel('<p>'+_('Cover browser could not be loaded')
|
||||||
self.cb_layout.setDirection(self.cb_layout.LeftToRight if
|
+'<br>'+pictureflowerror)
|
||||||
self._cb_layout_is_horizontal else
|
self.cover_flow.setWordWrap(True)
|
||||||
self.cb_layout.TopToBottom)
|
|
||||||
|
|
||||||
def toggle_cover_flow_visibility(self, show):
|
|
||||||
if config['separate_cover_flow']:
|
if config['separate_cover_flow']:
|
||||||
if show:
|
self.cb_splitter.button.clicked.connect(self.toggle_cover_browser)
|
||||||
d = QDialog(self)
|
if CoverFlow is not None:
|
||||||
ah, aw = available_height(), available_width()
|
self.cover_flow.stop.connect(self.hide_cover_browser)
|
||||||
d.resize(int(aw/1.5), ah-60)
|
|
||||||
d._layout = QStackedLayout()
|
|
||||||
d.setLayout(d._layout)
|
|
||||||
d.setWindowTitle(_('Browse by covers'))
|
|
||||||
d.layout().addWidget(self.cover_flow)
|
|
||||||
self.cover_flow.setVisible(True)
|
|
||||||
self.cover_flow.setFocus(Qt.OtherFocusReason)
|
|
||||||
d.show()
|
|
||||||
d.finished.connect(self.sidebar.external_cover_flow_finished)
|
|
||||||
self.cf_dialog = d
|
|
||||||
else:
|
|
||||||
cfd = getattr(self, 'cf_dialog', None)
|
|
||||||
if cfd is not None:
|
|
||||||
self.cover_flow.setVisible(False)
|
|
||||||
cfd.hide()
|
|
||||||
self.cf_dialog = None
|
|
||||||
else:
|
else:
|
||||||
if show:
|
self.cb_splitter.insertWidget(self.cb_splitter.side_index, self.cover_flow)
|
||||||
self.cover_flow.setVisible(True)
|
if CoverFlow is not None:
|
||||||
self.cover_flow.setFocus(Qt.OtherFocusReason)
|
self.cover_flow.stop.connect(self.cb_splitter.hide_side_pane)
|
||||||
else:
|
self.cb_splitter.button.toggled.connect(self.cover_browser_toggled)
|
||||||
self.cover_flow.setVisible(False)
|
|
||||||
|
|
||||||
def toggle_cover_flow(self, show):
|
def toggle_cover_browser(self):
|
||||||
if show:
|
cbd = getattr(self, 'cb_dialog', None)
|
||||||
self.cover_flow.setCurrentSlide(self.library_view.currentIndex().row())
|
if cbd is not None:
|
||||||
self.library_view.setCurrentIndex(
|
self.hide_cover_browser()
|
||||||
self.library_view.currentIndex())
|
|
||||||
self.cover_flow_sync_timer.start(500)
|
|
||||||
self.library_view.scroll_to_row(self.library_view.currentIndex().row())
|
|
||||||
else:
|
else:
|
||||||
|
self.show_cover_browser()
|
||||||
|
|
||||||
|
def cover_browser_toggled(self, *args):
|
||||||
|
if self.cb_splitter.button.isChecked():
|
||||||
|
self.cover_browser_shown()
|
||||||
|
else:
|
||||||
|
self.cover_browser_hidden()
|
||||||
|
|
||||||
|
def cover_browser_shown(self):
|
||||||
|
self.cover_flow.setFocus(Qt.OtherFocusReason)
|
||||||
|
if CoverFlow is not None:
|
||||||
|
self.cover_flow.setCurrentSlide(self.library_view.currentIndex().row())
|
||||||
|
self.cover_flow_sync_timer.start(500)
|
||||||
|
self.library_view.setCurrentIndex(
|
||||||
|
self.library_view.currentIndex())
|
||||||
|
self.library_view.scroll_to_row(self.library_view.currentIndex().row())
|
||||||
|
|
||||||
|
def cover_browser_hidden(self):
|
||||||
|
if CoverFlow is not None:
|
||||||
self.cover_flow_sync_timer.stop()
|
self.cover_flow_sync_timer.stop()
|
||||||
idx = self.library_view.model().index(self.cover_flow.currentSlide(), 0)
|
idx = self.library_view.model().index(self.cover_flow.currentSlide(), 0)
|
||||||
if idx.isValid():
|
if idx.isValid():
|
||||||
@ -164,7 +161,28 @@ class CoverFlowMixin(object):
|
|||||||
sm.select(idx, sm.ClearAndSelect|sm.Rows)
|
sm.select(idx, sm.ClearAndSelect|sm.Rows)
|
||||||
self.library_view.setCurrentIndex(idx)
|
self.library_view.setCurrentIndex(idx)
|
||||||
self.library_view.scroll_to_row(idx.row())
|
self.library_view.scroll_to_row(idx.row())
|
||||||
self.toggle_cover_flow_visibility(show)
|
|
||||||
|
|
||||||
|
def show_cover_browser(self):
|
||||||
|
d = QDialog(self)
|
||||||
|
ah, aw = available_height(), available_width()
|
||||||
|
d.resize(int(aw/1.5), ah-60)
|
||||||
|
d._layout = QStackedLayout()
|
||||||
|
d.setLayout(d._layout)
|
||||||
|
d.setWindowTitle(_('Browse by covers'))
|
||||||
|
d.layout().addWidget(self.cover_flow)
|
||||||
|
self.cover_flow.setVisible(True)
|
||||||
|
self.cover_flow.setFocus(Qt.OtherFocusReason)
|
||||||
|
d.show()
|
||||||
|
self.cb_splitter.button.set_state_to_hide()
|
||||||
|
d.finished.connect(self.cb_splitter.button.set_state_to_show)
|
||||||
|
self.cb_dialog = d
|
||||||
|
|
||||||
|
def hide_cover_browser(self):
|
||||||
|
cbd = getattr(self, 'cb_dialog', None)
|
||||||
|
if cbd is not None:
|
||||||
|
cbd.accept()
|
||||||
|
self.cb_dialog = None
|
||||||
|
|
||||||
def sync_cf_to_listview(self, current, previous):
|
def sync_cf_to_listview(self, current, previous):
|
||||||
if self.cover_flow_sync_flag and self.cover_flow.isVisible() and \
|
if self.cover_flow_sync_flag and self.cover_flow.isVisible() and \
|
||||||
|
@ -391,16 +391,14 @@ class DeviceMenu(QMenu): # {{{
|
|||||||
default_account = (dest, False, False, I('mail.svg'),
|
default_account = (dest, False, False, I('mail.svg'),
|
||||||
_('Email to')+' '+account)
|
_('Email to')+' '+account)
|
||||||
action1 = DeviceAction(dest, False, False, I('mail.svg'),
|
action1 = DeviceAction(dest, False, False, I('mail.svg'),
|
||||||
_('Email to')+' '+account, self)
|
_('Email to')+' '+account)
|
||||||
action2 = DeviceAction(dest, True, False, I('mail.svg'),
|
action2 = DeviceAction(dest, True, False, I('mail.svg'),
|
||||||
_('Email to')+' '+account, self)
|
_('Email to')+' '+account+ _(' and delete from library'))
|
||||||
map(self.email_to_menu.addAction, (action1, action2))
|
map(self.email_to_menu.addAction, (action1, action2))
|
||||||
map(self._memory.append, (action1, action2))
|
map(self._memory.append, (action1, action2))
|
||||||
self.email_to_menu.addSeparator()
|
self.email_to_menu.addSeparator()
|
||||||
self.connect(action1, SIGNAL('a_s(QAction)'),
|
action1.a_s.connect(self.action_triggered)
|
||||||
self.action_triggered)
|
action2.a_s.connect(self.action_triggered)
|
||||||
self.connect(action2, SIGNAL('a_s(QAction)'),
|
|
||||||
self.action_triggered)
|
|
||||||
|
|
||||||
basic_actions = [
|
basic_actions = [
|
||||||
('main:', False, False, I('reader.svg'),
|
('main:', False, False, I('reader.svg'),
|
||||||
|
@ -7,12 +7,16 @@ __docformat__ = 'restructuredtext en'
|
|||||||
|
|
||||||
import functools
|
import functools
|
||||||
|
|
||||||
from PyQt4.Qt import QMenu, Qt, pyqtSignal, QToolButton, QIcon
|
from PyQt4.Qt import QMenu, Qt, pyqtSignal, QToolButton, QIcon, QStackedWidget, \
|
||||||
|
QWidget, QHBoxLayout, QToolBar, QSize, QSizePolicy
|
||||||
|
|
||||||
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
|
from calibre.constants import isosx, __appname__
|
||||||
from calibre.gui2 import config
|
from calibre.gui2 import config, is_widescreen
|
||||||
|
from calibre.gui2.library.views import BooksView, DeviceBooksView
|
||||||
|
from calibre.gui2.widgets import Splitter
|
||||||
|
from calibre.gui2.tag_view import TagBrowserWidget
|
||||||
|
|
||||||
_keep_refs = []
|
_keep_refs = []
|
||||||
|
|
||||||
@ -282,3 +286,116 @@ class LibraryViewMixin(object): # {{{
|
|||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
class LibraryWidget(Splitter): # {{{
|
||||||
|
|
||||||
|
def __init__(self, parent):
|
||||||
|
orientation = Qt.Vertical if config['gui_layout'] == 'narrow' and \
|
||||||
|
not is_widescreen else Qt.Horizontal
|
||||||
|
#orientation = Qt.Vertical
|
||||||
|
idx = 0 if orientation == Qt.Vertical else 1
|
||||||
|
Splitter.__init__(self, 'cover_browser_splitter', _('Cover Browser'),
|
||||||
|
I('cover_flow.svg'),
|
||||||
|
orientation=orientation, parent=parent,
|
||||||
|
connect_button=not config['separate_cover_flow'],
|
||||||
|
side_index=idx, initial_side_size=400, initial_show=False)
|
||||||
|
parent.library_view = BooksView(parent)
|
||||||
|
parent.library_view.setObjectName('library_view')
|
||||||
|
self.addWidget(parent.library_view)
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
class Stack(QStackedWidget): # {{{
|
||||||
|
|
||||||
|
def __init__(self, parent):
|
||||||
|
QStackedWidget.__init__(self, parent)
|
||||||
|
|
||||||
|
parent.cb_splitter = LibraryWidget(parent)
|
||||||
|
self.tb_widget = TagBrowserWidget(parent)
|
||||||
|
parent.tb_splitter = Splitter('tag_browser_splitter',
|
||||||
|
_('Tag Browser'), I('tags.svg'),
|
||||||
|
parent=parent, side_index=0, initial_side_size=200)
|
||||||
|
parent.tb_splitter.addWidget(self.tb_widget)
|
||||||
|
parent.tb_splitter.addWidget(parent.cb_splitter)
|
||||||
|
parent.tb_splitter.setCollapsible(parent.tb_splitter.other_index, False)
|
||||||
|
|
||||||
|
self.addWidget(parent.tb_splitter)
|
||||||
|
for x in ('memory', 'card_a', 'card_b'):
|
||||||
|
name = x+'_view'
|
||||||
|
w = DeviceBooksView(parent)
|
||||||
|
setattr(parent, name, w)
|
||||||
|
self.addWidget(w)
|
||||||
|
w.setObjectName(name)
|
||||||
|
|
||||||
|
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
class SideBar(QToolBar): # {{{
|
||||||
|
|
||||||
|
|
||||||
|
def __init__(self, splitters, jobs_button, parent=None):
|
||||||
|
QToolBar.__init__(self, _('Side bar'), parent)
|
||||||
|
self.setOrientation(Qt.Vertical)
|
||||||
|
self.setMovable(False)
|
||||||
|
self.setFloatable(False)
|
||||||
|
self.setToolButtonStyle(Qt.ToolButtonIconOnly)
|
||||||
|
self.setIconSize(QSize(48, 48))
|
||||||
|
self.spacer = QWidget(self)
|
||||||
|
self.spacer.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Expanding)
|
||||||
|
for s in splitters:
|
||||||
|
self.addWidget(s.button)
|
||||||
|
self.addWidget(self.spacer)
|
||||||
|
self.addWidget(jobs_button)
|
||||||
|
|
||||||
|
for ch in self.children():
|
||||||
|
if isinstance(ch, QToolButton):
|
||||||
|
ch.setCursor(Qt.PointingHandCursor)
|
||||||
|
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
class LayoutMixin(object): # {{{
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.setupUi(self)
|
||||||
|
self.setWindowTitle(__appname__)
|
||||||
|
|
||||||
|
if config['gui_layout'] == 'narrow':
|
||||||
|
from calibre.gui2.status import StatusBar
|
||||||
|
self.status_bar = StatusBar(self)
|
||||||
|
self.stack = Stack(self)
|
||||||
|
self.bd_splitter = Splitter('book_details_splitter',
|
||||||
|
_('Book Details'), I('book.svg'),
|
||||||
|
orientation=Qt.Vertical, parent=self, side_index=1)
|
||||||
|
self._layout_mem = [QWidget(self), QHBoxLayout()]
|
||||||
|
self._layout_mem[0].setLayout(self._layout_mem[1])
|
||||||
|
l = self._layout_mem[1]
|
||||||
|
l.addWidget(self.stack)
|
||||||
|
self.sidebar = SideBar([getattr(self, x+'_splitter')
|
||||||
|
for x in ('bd', 'tb', 'cb')], self.jobs_button, parent=self)
|
||||||
|
l.addWidget(self.sidebar)
|
||||||
|
self.bd_splitter.addWidget(self._layout_mem[0])
|
||||||
|
self.bd_splitter.addWidget(self.status_bar)
|
||||||
|
self.bd_splitter.setCollapsible((self.bd_splitter.side_index+1)%2, False)
|
||||||
|
self.centralwidget.layout().addWidget(self.bd_splitter)
|
||||||
|
|
||||||
|
def finalize_layout(self):
|
||||||
|
m = self.library_view.model()
|
||||||
|
if m.rowCount(None) > 0:
|
||||||
|
self.library_view.set_current_row(0)
|
||||||
|
m.current_changed(self.library_view.currentIndex(),
|
||||||
|
self.library_view.currentIndex())
|
||||||
|
|
||||||
|
|
||||||
|
def save_layout_state(self):
|
||||||
|
for x in ('library', 'memory', 'card_a', 'card_b'):
|
||||||
|
getattr(self, x+'_view').save_state()
|
||||||
|
|
||||||
|
for x in ('cb', 'tb', 'bd'):
|
||||||
|
getattr(self, x+'_splitter').save_state()
|
||||||
|
|
||||||
|
def read_layout_settings(self):
|
||||||
|
# View states are restored automatically when set_database is called
|
||||||
|
|
||||||
|
for x in ('cb', 'tb', 'bd'):
|
||||||
|
getattr(self, x+'_splitter').restore_state()
|
||||||
|
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
@ -26,6 +26,15 @@ class BooksView(QTableView): # {{{
|
|||||||
|
|
||||||
def __init__(self, parent, modelcls=BooksModel):
|
def __init__(self, parent, modelcls=BooksModel):
|
||||||
QTableView.__init__(self, parent)
|
QTableView.__init__(self, parent)
|
||||||
|
|
||||||
|
self.setDragEnabled(True)
|
||||||
|
self.setDragDropOverwriteMode(False)
|
||||||
|
self.setDragDropMode(self.DragDrop)
|
||||||
|
self.setAlternatingRowColors(True)
|
||||||
|
self.setSelectionBehavior(self.SelectRows)
|
||||||
|
self.setShowGrid(False)
|
||||||
|
self.setWordWrap(False)
|
||||||
|
|
||||||
self.rating_delegate = RatingDelegate(self)
|
self.rating_delegate = RatingDelegate(self)
|
||||||
self.timestamp_delegate = DateDelegate(self)
|
self.timestamp_delegate = DateDelegate(self)
|
||||||
self.pubdate_delegate = PubDateDelegate(self)
|
self.pubdate_delegate = PubDateDelegate(self)
|
||||||
@ -434,6 +443,18 @@ class BooksView(QTableView): # {{{
|
|||||||
self.scrollTo(self.model().index(row, i))
|
self.scrollTo(self.model().index(row, i))
|
||||||
break
|
break
|
||||||
|
|
||||||
|
def set_current_row(self, row, select=True):
|
||||||
|
if row > -1:
|
||||||
|
h = self.horizontalHeader()
|
||||||
|
for i in range(h.count()):
|
||||||
|
if not h.isSectionHidden(i):
|
||||||
|
index = self.model().index(row, i)
|
||||||
|
self.setCurrentIndex(index)
|
||||||
|
if select:
|
||||||
|
sm = self.selectionModel()
|
||||||
|
sm.select(index, sm.ClearAndSelect|sm.Rows)
|
||||||
|
break
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
self._model.close()
|
self._model.close()
|
||||||
|
|
||||||
|
@ -169,6 +169,12 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="search_restriction">
|
<widget class="QComboBox" name="search_restriction">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>150</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Books display will be restricted to those matching the selected saved search</string>
|
<string>Books display will be restricted to those matching the selected saved search</string>
|
||||||
</property>
|
</property>
|
||||||
@ -304,270 +310,6 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="Splitter" name="vertical_splitter">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>100</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<widget class="QWidget" name="layoutWidget">
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QStackedWidget" name="stack">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
|
||||||
<horstretch>100</horstretch>
|
|
||||||
<verstretch>100</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="currentIndex">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<widget class="QWidget" name="library">
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
|
||||||
<item>
|
|
||||||
<widget class="Splitter" name="horizontal_splitter">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<widget class="QWidget" name="layoutWidget">
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="TagsView" name="tags_view">
|
|
||||||
<property name="tabKeyNavigation">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="alternatingRowColors">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="animated">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="headerHidden">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="popularity">
|
|
||||||
<property name="text">
|
|
||||||
<string>Sort by &popularity</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="tag_match">
|
|
||||||
<property name="currentIndex">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Match any</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Match all</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="edit_categories">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Create, edit, and delete user categories</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Manage &user categories</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<widget class="QWidget" name="">
|
|
||||||
<layout class="QVBoxLayout" name="cb_layout">
|
|
||||||
<item>
|
|
||||||
<widget class="BooksView" name="library_view">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
|
||||||
<horstretch>100</horstretch>
|
|
||||||
<verstretch>10</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="acceptDrops">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="dragEnabled">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="dragDropOverwriteMode">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="dragDropMode">
|
|
||||||
<enum>QAbstractItemView::DragDrop</enum>
|
|
||||||
</property>
|
|
||||||
<property name="alternatingRowColors">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="selectionBehavior">
|
|
||||||
<enum>QAbstractItemView::SelectRows</enum>
|
|
||||||
</property>
|
|
||||||
<property name="showGrid">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="wordWrap">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<widget class="QWidget" name="main_memory">
|
|
||||||
<layout class="QGridLayout">
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="DeviceBooksView" name="memory_view">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
|
||||||
<horstretch>100</horstretch>
|
|
||||||
<verstretch>10</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="acceptDrops">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="dragEnabled">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="dragDropOverwriteMode">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="dragDropMode">
|
|
||||||
<enum>QAbstractItemView::DragDrop</enum>
|
|
||||||
</property>
|
|
||||||
<property name="alternatingRowColors">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="selectionBehavior">
|
|
||||||
<enum>QAbstractItemView::SelectRows</enum>
|
|
||||||
</property>
|
|
||||||
<property name="showGrid">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="wordWrap">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<widget class="QWidget" name="card_a_memory">
|
|
||||||
<layout class="QGridLayout">
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="DeviceBooksView" name="card_a_view">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
|
||||||
<horstretch>10</horstretch>
|
|
||||||
<verstretch>10</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="acceptDrops">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="dragEnabled">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="dragDropOverwriteMode">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="dragDropMode">
|
|
||||||
<enum>QAbstractItemView::DragDrop</enum>
|
|
||||||
</property>
|
|
||||||
<property name="alternatingRowColors">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="selectionBehavior">
|
|
||||||
<enum>QAbstractItemView::SelectRows</enum>
|
|
||||||
</property>
|
|
||||||
<property name="showGrid">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="wordWrap">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<widget class="QWidget" name="card_b_memory">
|
|
||||||
<layout class="QGridLayout">
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="DeviceBooksView" name="card_b_view">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
|
||||||
<horstretch>10</horstretch>
|
|
||||||
<verstretch>10</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="acceptDrops">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="dragEnabled">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="dragDropOverwriteMode">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="dragDropMode">
|
|
||||||
<enum>QAbstractItemView::DragDrop</enum>
|
|
||||||
</property>
|
|
||||||
<property name="alternatingRowColors">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="selectionBehavior">
|
|
||||||
<enum>QAbstractItemView::SelectRows</enum>
|
|
||||||
</property>
|
|
||||||
<property name="showGrid">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="wordWrap">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="SideBar" name="sidebar" native="true">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>30</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<widget class="StatusBar" name="status_bar" native="true"/>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QToolBar" name="tool_bar">
|
<widget class="QToolBar" name="tool_bar">
|
||||||
@ -804,26 +546,11 @@
|
|||||||
</action>
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
|
||||||
<class>BooksView</class>
|
|
||||||
<extends>QTableView</extends>
|
|
||||||
<header>calibre/gui2/library/views.h</header>
|
|
||||||
</customwidget>
|
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>LocationView</class>
|
<class>LocationView</class>
|
||||||
<extends>QListView</extends>
|
<extends>QListView</extends>
|
||||||
<header>widgets.h</header>
|
<header>widgets.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
<customwidget>
|
|
||||||
<class>DeviceBooksView</class>
|
|
||||||
<extends>QTableView</extends>
|
|
||||||
<header>calibre/gui2/library/views.h</header>
|
|
||||||
</customwidget>
|
|
||||||
<customwidget>
|
|
||||||
<class>TagsView</class>
|
|
||||||
<extends>QTreeView</extends>
|
|
||||||
<header>calibre/gui2/tag_view.h</header>
|
|
||||||
</customwidget>
|
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>SearchBox2</class>
|
<class>SearchBox2</class>
|
||||||
<extends>QComboBox</extends>
|
<extends>QComboBox</extends>
|
||||||
@ -834,24 +561,6 @@
|
|||||||
<extends>QComboBox</extends>
|
<extends>QComboBox</extends>
|
||||||
<header>calibre.gui2.search_box</header>
|
<header>calibre.gui2.search_box</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
<customwidget>
|
|
||||||
<class>StatusBar</class>
|
|
||||||
<extends>QWidget</extends>
|
|
||||||
<header>calibre/gui2/status.h</header>
|
|
||||||
<container>1</container>
|
|
||||||
</customwidget>
|
|
||||||
<customwidget>
|
|
||||||
<class>Splitter</class>
|
|
||||||
<extends>QSplitter</extends>
|
|
||||||
<header>calibre/gui2/widgets.h</header>
|
|
||||||
<container>1</container>
|
|
||||||
</customwidget>
|
|
||||||
<customwidget>
|
|
||||||
<class>SideBar</class>
|
|
||||||
<extends>QWidget</extends>
|
|
||||||
<header>calibre/gui2/sidebar.h</header>
|
|
||||||
<container>1</container>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../../../resources/images.qrc"/>
|
<include location="../../../resources/images.qrc"/>
|
||||||
|
@ -713,8 +713,9 @@ void PictureFlowPrivate::render()
|
|||||||
QPainter painter;
|
QPainter painter;
|
||||||
painter.begin(&buffer);
|
painter.begin(&buffer);
|
||||||
|
|
||||||
QFont font("Arial", FONT_SIZE);
|
QFont font = QFont();
|
||||||
font.setBold(true);
|
font.setBold(true);
|
||||||
|
font.setPointSize(FONT_SIZE);
|
||||||
painter.setFont(font);
|
painter.setFont(font);
|
||||||
painter.setPen(Qt::white);
|
painter.setPen(Qt::white);
|
||||||
//painter.setPen(QColor(255,255,255,127));
|
//painter.setPen(QColor(255,255,255,127));
|
||||||
@ -763,8 +764,9 @@ void PictureFlowPrivate::render()
|
|||||||
QPainter painter;
|
QPainter painter;
|
||||||
painter.begin(&buffer);
|
painter.begin(&buffer);
|
||||||
|
|
||||||
QFont font("Arial", FONT_SIZE);
|
QFont font = QFont();
|
||||||
font.setBold(true);
|
font.setBold(true);
|
||||||
|
font.setPointSize(FONT_SIZE);
|
||||||
painter.setFont(font);
|
painter.setFont(font);
|
||||||
|
|
||||||
int leftTextIndex = (step>0) ? centerIndex : centerIndex-1;
|
int leftTextIndex = (step>0) ? centerIndex : centerIndex-1;
|
||||||
|
@ -7,6 +7,7 @@ Created on 10 Jun 2010
|
|||||||
class SearchRestrictionMixin(object):
|
class SearchRestrictionMixin(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
self.search_restriction.activated[str].connect(self.apply_search_restriction)
|
||||||
self.library_view.model().count_changed_signal.connect(self.restriction_count_changed)
|
self.library_view.model().count_changed_signal.connect(self.restriction_count_changed)
|
||||||
self.search_restriction.setSizeAdjustPolicy(self.search_restriction.AdjustToMinimumContentsLengthWithIcon)
|
self.search_restriction.setSizeAdjustPolicy(self.search_restriction.AdjustToMinimumContentsLengthWithIcon)
|
||||||
self.search_restriction.setMinimumContentsLength(10)
|
self.search_restriction.setMinimumContentsLength(10)
|
||||||
|
@ -1,147 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
|
||||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
|
||||||
__docformat__ = 'restructuredtext en'
|
|
||||||
|
|
||||||
from functools import partial
|
|
||||||
|
|
||||||
from PyQt4.Qt import QToolBar, Qt, QIcon, QSizePolicy, QWidget, \
|
|
||||||
QSize, QToolButton
|
|
||||||
|
|
||||||
from calibre.gui2 import dynamic
|
|
||||||
|
|
||||||
class SideBar(QToolBar):
|
|
||||||
|
|
||||||
toggle_texts = {
|
|
||||||
'book_info' : (_('Show Book Details'), _('Hide Book Details')),
|
|
||||||
'tag_browser' : (_('Show Tag Browser'), _('Hide Tag Browser')),
|
|
||||||
'cover_browser': (_('Show Cover Browser'), _('Hide Cover Browser')),
|
|
||||||
}
|
|
||||||
toggle_icons = {
|
|
||||||
'book_info' : 'book.svg',
|
|
||||||
'tag_browser' : 'tags.svg',
|
|
||||||
'cover_browser': 'cover_flow.svg',
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
|
||||||
QToolBar.__init__(self, _('Side bar'), parent)
|
|
||||||
self.setOrientation(Qt.Vertical)
|
|
||||||
self.setMovable(False)
|
|
||||||
self.setFloatable(False)
|
|
||||||
self.setToolButtonStyle(Qt.ToolButtonIconOnly)
|
|
||||||
self.setIconSize(QSize(48, 48))
|
|
||||||
|
|
||||||
for ac in ('book_info', 'tag_browser', 'cover_browser'):
|
|
||||||
action = self.addAction(QIcon(I(self.toggle_icons[ac])),
|
|
||||||
self.toggle_texts[ac][1], getattr(self, '_toggle_'+ac))
|
|
||||||
setattr(self, 'action_toggle_'+ac, action)
|
|
||||||
w = self.widgetForAction(action)
|
|
||||||
w.setCheckable(True)
|
|
||||||
setattr(self, 'show_'+ac, partial(getattr(self, '_toggle_'+ac),
|
|
||||||
show=True))
|
|
||||||
setattr(self, 'hide_'+ac, partial(getattr(self, '_toggle_'+ac),
|
|
||||||
show=False))
|
|
||||||
|
|
||||||
|
|
||||||
self.spacer = QWidget(self)
|
|
||||||
self.spacer.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Expanding)
|
|
||||||
self.addWidget(self.spacer)
|
|
||||||
|
|
||||||
self.show_cover_browser = partial(self._toggle_cover_browser, show=True)
|
|
||||||
self.hide_cover_browser = partial(self._toggle_cover_browser,
|
|
||||||
show=False)
|
|
||||||
for ch in self.children():
|
|
||||||
if isinstance(ch, QToolButton):
|
|
||||||
ch.setCursor(Qt.PointingHandCursor)
|
|
||||||
|
|
||||||
def initialize(self, jobs_button, cover_browser, toggle_cover_browser,
|
|
||||||
cover_browser_error, vertical_splitter, horizontal_splitter):
|
|
||||||
self.cover_browser, self.do_toggle_cover_browser = cover_browser, \
|
|
||||||
toggle_cover_browser
|
|
||||||
if self.cover_browser is None:
|
|
||||||
self.action_toggle_cover_browser.setEnabled(False)
|
|
||||||
self.action_toggle_cover_browser.setText(
|
|
||||||
_('Cover browser could not be loaded: ') + cover_browser_error)
|
|
||||||
else:
|
|
||||||
self.cover_browser.stop.connect(self.hide_cover_browser)
|
|
||||||
self._toggle_cover_browser(dynamic.get('cover_flow_visible', False))
|
|
||||||
|
|
||||||
self.horizontal_splitter = horizontal_splitter
|
|
||||||
self.vertical_splitter = vertical_splitter
|
|
||||||
|
|
||||||
tb_state = dynamic.get('tag_browser_state', None)
|
|
||||||
if tb_state is not None:
|
|
||||||
self.horizontal_splitter.restoreState(tb_state)
|
|
||||||
tb_last_open_state = dynamic.get('tag_browser_last_open_state', None)
|
|
||||||
if tb_last_open_state is not None and \
|
|
||||||
not self.horizontal_splitter.is_side_index_hidden:
|
|
||||||
self.horizontal_splitter.restoreState(tb_last_open_state)
|
|
||||||
|
|
||||||
bi_state = dynamic.get('book_info_state', None)
|
|
||||||
if bi_state is not None:
|
|
||||||
self.vertical_splitter.restoreState(bi_state)
|
|
||||||
bi_last_open_state = dynamic.get('book_info_last_open_state', None)
|
|
||||||
if bi_last_open_state is not None and \
|
|
||||||
not self.vertical_splitter.is_side_index_hidden:
|
|
||||||
self.vertical_splitter.restoreState(bi_last_open_state)
|
|
||||||
|
|
||||||
self.horizontal_splitter.initialize(name='tag_browser')
|
|
||||||
self.vertical_splitter.initialize(name='book_info')
|
|
||||||
self.view_status_changed('book_info', not
|
|
||||||
self.vertical_splitter.is_side_index_hidden)
|
|
||||||
self.view_status_changed('tag_browser', not
|
|
||||||
self.horizontal_splitter.is_side_index_hidden)
|
|
||||||
self.vertical_splitter.state_changed.connect(partial(self.view_status_changed,
|
|
||||||
'book_info'), type=Qt.QueuedConnection)
|
|
||||||
self.horizontal_splitter.state_changed.connect(partial(self.view_status_changed,
|
|
||||||
'tag_browser'), type=Qt.QueuedConnection)
|
|
||||||
self.addWidget(jobs_button)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def view_status_changed(self, name, visible):
|
|
||||||
action = getattr(self, 'action_toggle_'+name)
|
|
||||||
texts = self.toggle_texts[name]
|
|
||||||
action.setText(texts[int(visible)])
|
|
||||||
w = self.widgetForAction(action)
|
|
||||||
w.setCheckable(True)
|
|
||||||
w.setChecked(visible)
|
|
||||||
|
|
||||||
def location_changed(self, location):
|
|
||||||
is_lib = location == 'library'
|
|
||||||
for ac in ('cover_browser', 'tag_browser'):
|
|
||||||
ac = getattr(self, 'action_toggle_'+ac)
|
|
||||||
ac.setEnabled(is_lib)
|
|
||||||
self.widgetForAction(ac).setVisible(is_lib)
|
|
||||||
|
|
||||||
def save_state(self):
|
|
||||||
dynamic.set('cover_flow_visible', self.is_cover_browser_visible)
|
|
||||||
dynamic.set('tag_browser_state',
|
|
||||||
str(self.horizontal_splitter.saveState()))
|
|
||||||
dynamic.set('book_info_state',
|
|
||||||
str(self.vertical_splitter.saveState()))
|
|
||||||
|
|
||||||
|
|
||||||
@property
|
|
||||||
def is_cover_browser_visible(self):
|
|
||||||
return self.cover_browser is not None and self.cover_browser.isVisible()
|
|
||||||
|
|
||||||
def _toggle_cover_browser(self, show=None):
|
|
||||||
if show is None:
|
|
||||||
show = not self.is_cover_browser_visible
|
|
||||||
self.do_toggle_cover_browser(show)
|
|
||||||
self.view_status_changed('cover_browser', show)
|
|
||||||
|
|
||||||
def external_cover_flow_finished(self, *args):
|
|
||||||
self.view_status_changed('cover_browser', False)
|
|
||||||
|
|
||||||
def _toggle_tag_browser(self, show=None):
|
|
||||||
self.horizontal_splitter.toggle_side_index()
|
|
||||||
|
|
||||||
def _toggle_book_info(self, show=None):
|
|
||||||
self.vertical_splitter.toggle_side_index()
|
|
||||||
|
|
||||||
|
|
@ -10,9 +10,11 @@ Browsing book collection by tags.
|
|||||||
from itertools import izip
|
from itertools import izip
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from PyQt4.Qt import Qt, QTreeView, QApplication, pyqtSignal, \
|
from PyQt4.Qt import Qt, QTreeView, QApplication, pyqtSignal, QCheckBox, \
|
||||||
QFont, QSize, QIcon, QPoint, \
|
QFont, QSize, QIcon, QPoint, QVBoxLayout, QComboBox, \
|
||||||
QAbstractItemModel, QVariant, QModelIndex, QMenu
|
QAbstractItemModel, QVariant, QModelIndex, QMenu, \
|
||||||
|
QPushButton, QWidget
|
||||||
|
|
||||||
from calibre.gui2 import config, NONE
|
from calibre.gui2 import config, NONE
|
||||||
from calibre.utils.config import prefs
|
from calibre.utils.config import prefs
|
||||||
from calibre.library.field_metadata import TagsIcons
|
from calibre.library.field_metadata import TagsIcons
|
||||||
@ -597,6 +599,7 @@ class TagsModel(QAbstractItemModel): # {{{
|
|||||||
class TagBrowserMixin(object): # {{{
|
class TagBrowserMixin(object): # {{{
|
||||||
|
|
||||||
def __init__(self, db):
|
def __init__(self, db):
|
||||||
|
self.library_view.model().count_changed_signal.connect(self.tags_view.recount)
|
||||||
self.tags_view.set_database(self.library_view.model().db,
|
self.tags_view.set_database(self.library_view.model().db,
|
||||||
self.tag_match, self.popularity)
|
self.tag_match, self.popularity)
|
||||||
self.tags_view.tags_marked.connect(self.search.search_from_tags)
|
self.tags_view.tags_marked.connect(self.search.search_from_tags)
|
||||||
@ -606,6 +609,8 @@ class TagBrowserMixin(object): # {{{
|
|||||||
self.tags_view.saved_search_edit.connect(self.do_saved_search_edit)
|
self.tags_view.saved_search_edit.connect(self.do_saved_search_edit)
|
||||||
self.tags_view.tag_item_renamed.connect(self.do_tag_item_renamed)
|
self.tags_view.tag_item_renamed.connect(self.do_tag_item_renamed)
|
||||||
self.tags_view.search_item_renamed.connect(self.saved_search.clear_to_help)
|
self.tags_view.search_item_renamed.connect(self.saved_search.clear_to_help)
|
||||||
|
self.edit_categories.clicked.connect(lambda x:
|
||||||
|
self.do_user_categories_edit())
|
||||||
|
|
||||||
def do_user_categories_edit(self, on_category=None):
|
def do_user_categories_edit(self, on_category=None):
|
||||||
d = TagCategories(self, self.library_view.model().db, on_category)
|
d = TagCategories(self, self.library_view.model().db, on_category)
|
||||||
@ -633,3 +638,29 @@ class TagBrowserMixin(object): # {{{
|
|||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
class TagBrowserWidget(QWidget): # {{{
|
||||||
|
|
||||||
|
def __init__(self, parent):
|
||||||
|
QWidget.__init__(self, parent)
|
||||||
|
self._layout = QVBoxLayout()
|
||||||
|
self.setLayout(self._layout)
|
||||||
|
|
||||||
|
parent.tags_view = TagsView(parent)
|
||||||
|
self._layout.addWidget(parent.tags_view)
|
||||||
|
|
||||||
|
parent.popularity = QCheckBox(parent)
|
||||||
|
parent.popularity.setText(_('Sort by &popularity'))
|
||||||
|
self._layout.addWidget(parent.popularity)
|
||||||
|
|
||||||
|
parent.tag_match = QComboBox(parent)
|
||||||
|
for x in (_('Match any'), _('Match all')):
|
||||||
|
parent.tag_match.addItem(x)
|
||||||
|
parent.tag_match.setCurrentIndex(0)
|
||||||
|
self._layout.addWidget(parent.tag_match)
|
||||||
|
|
||||||
|
parent.edit_categories = QPushButton(_('Manage &user categories'), parent)
|
||||||
|
self._layout.addWidget(parent.edit_categories)
|
||||||
|
|
||||||
|
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ from calibre.gui2 import warning_dialog, choose_files, error_dialog, \
|
|||||||
Dispatcher, gprefs, \
|
Dispatcher, gprefs, \
|
||||||
max_available_height, config, info_dialog, \
|
max_available_height, config, info_dialog, \
|
||||||
GetMetadata
|
GetMetadata
|
||||||
from calibre.gui2.cover_flow import pictureflowerror, CoverFlowMixin
|
from calibre.gui2.cover_flow import CoverFlowMixin
|
||||||
from calibre.gui2.widgets import ProgressIndicator, IMAGE_EXTENSIONS
|
from calibre.gui2.widgets import ProgressIndicator, IMAGE_EXTENSIONS
|
||||||
from calibre.gui2.wizard import move_library
|
from calibre.gui2.wizard import move_library
|
||||||
from calibre.gui2.dialogs.scheduler import Scheduler
|
from calibre.gui2.dialogs.scheduler import Scheduler
|
||||||
@ -57,7 +57,7 @@ from calibre.ebooks.BeautifulSoup import BeautifulSoup, Tag, NavigableString
|
|||||||
from calibre.library.database2 import LibraryDatabase2
|
from calibre.library.database2 import LibraryDatabase2
|
||||||
from calibre.library.caches import CoverCache
|
from calibre.library.caches import CoverCache
|
||||||
from calibre.gui2.dialogs.confirm_delete import confirm
|
from calibre.gui2.dialogs.confirm_delete import confirm
|
||||||
from calibre.gui2.init import ToolbarMixin, LibraryViewMixin
|
from calibre.gui2.init import ToolbarMixin, LibraryViewMixin, LayoutMixin
|
||||||
from calibre.gui2.search_box import SearchBoxMixin, SavedSearchBoxMixin
|
from calibre.gui2.search_box import SearchBoxMixin, SavedSearchBoxMixin
|
||||||
from calibre.gui2.search_restriction_mixin import SearchRestrictionMixin
|
from calibre.gui2.search_restriction_mixin import SearchRestrictionMixin
|
||||||
from calibre.gui2.tag_view import TagBrowserMixin
|
from calibre.gui2.tag_view import TagBrowserMixin
|
||||||
@ -106,7 +106,7 @@ class SystemTrayIcon(QSystemTrayIcon): # {{{
|
|||||||
|
|
||||||
class Main(MainWindow, Ui_MainWindow, DeviceMixin, ToolbarMixin,
|
class Main(MainWindow, Ui_MainWindow, DeviceMixin, ToolbarMixin,
|
||||||
TagBrowserMixin, CoverFlowMixin, LibraryViewMixin, SearchBoxMixin,
|
TagBrowserMixin, CoverFlowMixin, LibraryViewMixin, SearchBoxMixin,
|
||||||
SavedSearchBoxMixin, SearchRestrictionMixin):
|
SavedSearchBoxMixin, SearchRestrictionMixin, LayoutMixin):
|
||||||
'The main GUI'
|
'The main GUI'
|
||||||
|
|
||||||
def set_default_thumbnail(self, height):
|
def set_default_thumbnail(self, height):
|
||||||
@ -143,8 +143,15 @@ class Main(MainWindow, Ui_MainWindow, DeviceMixin, ToolbarMixin,
|
|||||||
self.check_messages_timer.start(1000)
|
self.check_messages_timer.start(1000)
|
||||||
|
|
||||||
Ui_MainWindow.__init__(self)
|
Ui_MainWindow.__init__(self)
|
||||||
self.setupUi(self)
|
|
||||||
self.setWindowTitle(__appname__)
|
# Jobs Button {{{
|
||||||
|
self.job_manager = JobManager()
|
||||||
|
self.jobs_dialog = JobsDialog(self, self.job_manager)
|
||||||
|
self.jobs_button = JobsButton()
|
||||||
|
self.jobs_button.initialize(self.jobs_dialog, self.job_manager)
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
LayoutMixin.__init__(self)
|
||||||
|
|
||||||
self.restriction_count_of_books_in_view = 0
|
self.restriction_count_of_books_in_view = 0
|
||||||
self.restriction_count_of_books_in_library = 0
|
self.restriction_count_of_books_in_library = 0
|
||||||
@ -153,11 +160,8 @@ class Main(MainWindow, Ui_MainWindow, DeviceMixin, ToolbarMixin,
|
|||||||
self.progress_indicator = ProgressIndicator(self)
|
self.progress_indicator = ProgressIndicator(self)
|
||||||
self.verbose = opts.verbose
|
self.verbose = opts.verbose
|
||||||
self.get_metadata = GetMetadata()
|
self.get_metadata = GetMetadata()
|
||||||
self.read_settings()
|
|
||||||
self.job_manager = JobManager()
|
|
||||||
self.emailer = Emailer()
|
self.emailer = Emailer()
|
||||||
self.emailer.start()
|
self.emailer.start()
|
||||||
self.jobs_dialog = JobsDialog(self, self.job_manager)
|
|
||||||
self.upload_memory = {}
|
self.upload_memory = {}
|
||||||
self.delete_memory = {}
|
self.delete_memory = {}
|
||||||
self.conversion_jobs = {}
|
self.conversion_jobs = {}
|
||||||
@ -269,12 +273,9 @@ class Main(MainWindow, Ui_MainWindow, DeviceMixin, ToolbarMixin,
|
|||||||
|
|
||||||
if self.system_tray_icon.isVisible() and opts.start_in_tray:
|
if self.system_tray_icon.isVisible() and opts.start_in_tray:
|
||||||
self.hide_windows()
|
self.hide_windows()
|
||||||
self.stack.setCurrentIndex(0)
|
|
||||||
self.cover_cache = CoverCache(self.library_path)
|
self.cover_cache = CoverCache(self.library_path)
|
||||||
self.cover_cache.start()
|
self.cover_cache.start()
|
||||||
self.library_view.model().cover_cache = self.cover_cache
|
self.library_view.model().cover_cache = self.cover_cache
|
||||||
self.connect(self.edit_categories, SIGNAL('clicked()'), self.do_user_categories_edit)
|
|
||||||
self.search_restriction.activated[str].connect(self.apply_search_restriction)
|
|
||||||
self.library_view.model().count_changed_signal.connect \
|
self.library_view.model().count_changed_signal.connect \
|
||||||
(self.location_view.count_changed)
|
(self.location_view.count_changed)
|
||||||
if not gprefs.get('quick_start_guide_added', False):
|
if not gprefs.get('quick_start_guide_added', False):
|
||||||
@ -296,8 +297,6 @@ class Main(MainWindow, Ui_MainWindow, DeviceMixin, ToolbarMixin,
|
|||||||
type=Qt.QueuedConnection)
|
type=Qt.QueuedConnection)
|
||||||
|
|
||||||
########################### Tags Browser ##############################
|
########################### Tags Browser ##############################
|
||||||
|
|
||||||
self.library_view.model().count_changed_signal.connect(self.tags_view.recount)
|
|
||||||
TagBrowserMixin.__init__(self, db)
|
TagBrowserMixin.__init__(self, db)
|
||||||
|
|
||||||
######################### Search Restriction ##########################
|
######################### Search Restriction ##########################
|
||||||
@ -311,17 +310,6 @@ class Main(MainWindow, Ui_MainWindow, DeviceMixin, ToolbarMixin,
|
|||||||
self.height())
|
self.height())
|
||||||
self.resize(self.width(), self._calculated_available_height)
|
self.resize(self.width(), self._calculated_available_height)
|
||||||
|
|
||||||
# Jobs Button {{{
|
|
||||||
self.jobs_button = JobsButton()
|
|
||||||
self.jobs_button.initialize(self.jobs_dialog, self.job_manager)
|
|
||||||
# }}}
|
|
||||||
|
|
||||||
####################### Side Bar ###############################
|
|
||||||
|
|
||||||
self.sidebar.initialize(self.jobs_button, self.cover_flow,
|
|
||||||
self.toggle_cover_flow, pictureflowerror,
|
|
||||||
self.vertical_splitter, self.horizontal_splitter)
|
|
||||||
|
|
||||||
|
|
||||||
if config['autolaunch_server']:
|
if config['autolaunch_server']:
|
||||||
from calibre.library.server.main import start_threaded_server
|
from calibre.library.server.main import start_threaded_server
|
||||||
@ -347,6 +335,8 @@ class Main(MainWindow, Ui_MainWindow, DeviceMixin, ToolbarMixin,
|
|||||||
self._add_filesystem_book = Dispatcher(self.__add_filesystem_book)
|
self._add_filesystem_book = Dispatcher(self.__add_filesystem_book)
|
||||||
self.keyboard_interrupt.connect(self.quit, type=Qt.QueuedConnection)
|
self.keyboard_interrupt.connect(self.quit, type=Qt.QueuedConnection)
|
||||||
|
|
||||||
|
self.read_settings()
|
||||||
|
self.finalize_layout()
|
||||||
|
|
||||||
def resizeEvent(self, ev):
|
def resizeEvent(self, ev):
|
||||||
MainWindow.resizeEvent(self, ev)
|
MainWindow.resizeEvent(self, ev)
|
||||||
@ -1842,7 +1832,9 @@ class Main(MainWindow, Ui_MainWindow, DeviceMixin, ToolbarMixin,
|
|||||||
page = 0 if location == 'library' else 1 if location == 'main' else 2 if location == 'carda' else 3
|
page = 0 if location == 'library' else 1 if location == 'main' else 2 if location == 'carda' else 3
|
||||||
self.stack.setCurrentIndex(page)
|
self.stack.setCurrentIndex(page)
|
||||||
self.status_bar.reset_info()
|
self.status_bar.reset_info()
|
||||||
self.sidebar.location_changed(location)
|
for x in ('tb', 'cb'):
|
||||||
|
splitter = getattr(self, x+'_splitter')
|
||||||
|
splitter.button.setEnabled(location == 'library')
|
||||||
if location == 'library':
|
if location == 'library':
|
||||||
self.action_edit.setEnabled(True)
|
self.action_edit.setEnabled(True)
|
||||||
self.action_merge.setEnabled(True)
|
self.action_merge.setEnabled(True)
|
||||||
@ -1945,14 +1937,12 @@ class Main(MainWindow, Ui_MainWindow, DeviceMixin, ToolbarMixin,
|
|||||||
if geometry is not None:
|
if geometry is not None:
|
||||||
self.restoreGeometry(geometry)
|
self.restoreGeometry(geometry)
|
||||||
self.read_toolbar_settings()
|
self.read_toolbar_settings()
|
||||||
|
self.read_layout_settings()
|
||||||
|
|
||||||
def write_settings(self):
|
def write_settings(self):
|
||||||
config.set('main_window_geometry', self.saveGeometry())
|
config.set('main_window_geometry', self.saveGeometry())
|
||||||
dynamic.set('sort_history', self.library_view.model().sort_history)
|
dynamic.set('sort_history', self.library_view.model().sort_history)
|
||||||
self.sidebar.save_state()
|
self.save_layout_state()
|
||||||
for view in ('library_view', 'memory_view', 'card_a_view',
|
|
||||||
'card_b_view'):
|
|
||||||
getattr(self, view).save_state()
|
|
||||||
|
|
||||||
def restart(self):
|
def restart(self):
|
||||||
self.quit(restart=True)
|
self.quit(restart=True)
|
||||||
|
@ -4,16 +4,18 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
|||||||
Miscellaneous widgets used in the GUI
|
Miscellaneous widgets used in the GUI
|
||||||
'''
|
'''
|
||||||
import re, os, traceback
|
import re, os, traceback
|
||||||
|
|
||||||
from PyQt4.Qt import QListView, QIcon, QFont, QLabel, QListWidget, \
|
from PyQt4.Qt import QListView, QIcon, QFont, QLabel, QListWidget, \
|
||||||
QListWidgetItem, QTextCharFormat, QApplication, \
|
QListWidgetItem, QTextCharFormat, QApplication, \
|
||||||
QSyntaxHighlighter, QCursor, QColor, QWidget, \
|
QSyntaxHighlighter, QCursor, QColor, QWidget, \
|
||||||
QPixmap, QPalette, QSplitterHandle, \
|
QPixmap, QPalette, QSplitterHandle, QToolButton, \
|
||||||
QAbstractListModel, QVariant, Qt, SIGNAL, pyqtSignal, \
|
QAbstractListModel, QVariant, Qt, SIGNAL, pyqtSignal, \
|
||||||
QRegExp, QSettings, QSize, QModelIndex, QSplitter, \
|
QRegExp, QSettings, QSize, QModelIndex, QSplitter, \
|
||||||
QAbstractButton, QPainter, QLineEdit, QComboBox, \
|
QAbstractButton, QPainter, QLineEdit, QComboBox, \
|
||||||
QMenu, QStringListModel, QCompleter, QStringList
|
QMenu, QStringListModel, QCompleter, QStringList, \
|
||||||
|
QTimer
|
||||||
|
|
||||||
from calibre.gui2 import NONE, error_dialog, pixmap_to_data, dynamic
|
from calibre.gui2 import NONE, error_dialog, pixmap_to_data, gprefs
|
||||||
|
|
||||||
from calibre.gui2.filename_pattern_ui import Ui_Form
|
from calibre.gui2.filename_pattern_ui import Ui_Form
|
||||||
from calibre import fit_image, human_readable
|
from calibre import fit_image, human_readable
|
||||||
@ -927,6 +929,7 @@ class SplitterHandle(QSplitterHandle):
|
|||||||
self.double_clicked.connect(splitter.double_clicked,
|
self.double_clicked.connect(splitter.double_clicked,
|
||||||
type=Qt.QueuedConnection)
|
type=Qt.QueuedConnection)
|
||||||
self.highlight = False
|
self.highlight = False
|
||||||
|
self.setToolTip(_('Drag to resize')+' '+splitter.label)
|
||||||
|
|
||||||
def splitter_moved(self, *args):
|
def splitter_moved(self, *args):
|
||||||
oh = self.highlight
|
oh = self.highlight
|
||||||
@ -944,20 +947,62 @@ class SplitterHandle(QSplitterHandle):
|
|||||||
def mouseDoubleClickEvent(self, ev):
|
def mouseDoubleClickEvent(self, ev):
|
||||||
self.double_clicked.emit(self)
|
self.double_clicked.emit(self)
|
||||||
|
|
||||||
|
class LayoutButton(QToolButton):
|
||||||
|
|
||||||
|
def __init__(self, icon, text, splitter, parent=None):
|
||||||
|
QToolButton.__init__(self, parent)
|
||||||
|
self.label = text
|
||||||
|
self.setIcon(QIcon(icon))
|
||||||
|
self.setCheckable(True)
|
||||||
|
|
||||||
|
self.splitter = splitter
|
||||||
|
splitter.state_changed.connect(self.update_state)
|
||||||
|
|
||||||
|
def set_state_to_show(self, *args):
|
||||||
|
self.setChecked(False)
|
||||||
|
label =_('Show')
|
||||||
|
self.setText(label + ' ' + self.label)
|
||||||
|
|
||||||
|
def set_state_to_hide(self, *args):
|
||||||
|
self.setChecked(True)
|
||||||
|
label = _('Hide')
|
||||||
|
self.setText(label + ' ' + self.label)
|
||||||
|
|
||||||
|
def update_state(self, *args):
|
||||||
|
if self.splitter.is_side_index_hidden:
|
||||||
|
self.set_state_to_show()
|
||||||
|
else:
|
||||||
|
self.set_state_to_hide()
|
||||||
|
|
||||||
class Splitter(QSplitter):
|
class Splitter(QSplitter):
|
||||||
|
|
||||||
state_changed = pyqtSignal(object)
|
state_changed = pyqtSignal(object)
|
||||||
|
|
||||||
def __init__(self, *args):
|
def __init__(self, name, label, icon, initial_show=True,
|
||||||
QSplitter.__init__(self, *args)
|
initial_side_size=120, connect_button=True,
|
||||||
|
orientation=Qt.Horizontal, side_index=0, parent=None):
|
||||||
|
QSplitter.__init__(self, parent)
|
||||||
|
self.resize_timer = QTimer(self)
|
||||||
|
self.resize_timer.setSingleShot(True)
|
||||||
|
self.desired_side_size = initial_side_size
|
||||||
|
self.desired_show = initial_show
|
||||||
|
self.resize_timer.setInterval(5)
|
||||||
|
self.resize_timer.timeout.connect(self.do_resize)
|
||||||
|
self.setOrientation(orientation)
|
||||||
|
self.side_index = side_index
|
||||||
|
self._name = name
|
||||||
|
self.label = label
|
||||||
|
self.initial_side_size = initial_side_size
|
||||||
|
self.initial_show = initial_show
|
||||||
self.splitterMoved.connect(self.splitter_moved, type=Qt.QueuedConnection)
|
self.splitterMoved.connect(self.splitter_moved, type=Qt.QueuedConnection)
|
||||||
|
self.button = LayoutButton(icon, label, self)
|
||||||
|
if connect_button:
|
||||||
|
self.button.clicked.connect(self.double_clicked)
|
||||||
|
|
||||||
def createHandle(self):
|
def createHandle(self):
|
||||||
return SplitterHandle(self.orientation(), self)
|
return SplitterHandle(self.orientation(), self)
|
||||||
|
|
||||||
def initialize(self, name=None):
|
def initialize(self):
|
||||||
if name is not None:
|
|
||||||
self._name = name
|
|
||||||
for i in range(self.count()):
|
for i in range(self.count()):
|
||||||
h = self.handle(i)
|
h = self.handle(i)
|
||||||
if h is not None:
|
if h is not None:
|
||||||
@ -965,40 +1010,115 @@ class Splitter(QSplitter):
|
|||||||
self.state_changed.emit(not self.is_side_index_hidden)
|
self.state_changed.emit(not self.is_side_index_hidden)
|
||||||
|
|
||||||
def splitter_moved(self, *args):
|
def splitter_moved(self, *args):
|
||||||
|
self.desired_side_size = self.side_index_size
|
||||||
self.state_changed.emit(not self.is_side_index_hidden)
|
self.state_changed.emit(not self.is_side_index_hidden)
|
||||||
|
|
||||||
@property
|
|
||||||
def side_index(self):
|
|
||||||
return 0 if self.orientation() == Qt.Horizontal else 1
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_side_index_hidden(self):
|
def is_side_index_hidden(self):
|
||||||
sizes = list(self.sizes())
|
sizes = list(self.sizes())
|
||||||
return sizes[self.side_index] == 0
|
return sizes[self.side_index] == 0
|
||||||
|
|
||||||
def toggle_side_index(self):
|
@property
|
||||||
self.double_clicked(None)
|
def save_name(self):
|
||||||
|
ori = 'horizontal' if self.orientation() == Qt.Horizontal \
|
||||||
|
else 'vertical'
|
||||||
|
return self._name + '_' + ori
|
||||||
|
|
||||||
def double_clicked(self, handle):
|
def print_sizes(self):
|
||||||
visible = not self.is_side_index_hidden
|
if self.count() > 1:
|
||||||
sizes = list(self.sizes())
|
print self.save_name, 'side:', self.side_index_size, 'other:',
|
||||||
if 0 in sizes:
|
print list(self.sizes())[self.other_index]
|
||||||
idx = sizes.index(0)
|
|
||||||
sizes[idx] = 80
|
|
||||||
else:
|
|
||||||
sizes[self.side_index] = 0
|
|
||||||
|
|
||||||
if visible:
|
@dynamic_property
|
||||||
dynamic.set(self._name + '_last_open_state', str(self.saveState()))
|
def side_index_size(self):
|
||||||
|
def fget(self):
|
||||||
|
if self.count() < 2: return 0
|
||||||
|
return self.sizes()[self.side_index]
|
||||||
|
|
||||||
|
def fset(self, val):
|
||||||
|
if self.count() < 2: return
|
||||||
|
if val == 0 and not self.is_side_index_hidden:
|
||||||
|
self.save_state()
|
||||||
|
sizes = list(self.sizes())
|
||||||
|
for i in range(len(sizes)):
|
||||||
|
sizes[i] = val if i == self.side_index else 10
|
||||||
self.setSizes(sizes)
|
self.setSizes(sizes)
|
||||||
|
total = sum(self.sizes())
|
||||||
|
sizes = list(self.sizes())
|
||||||
|
for i in range(len(sizes)):
|
||||||
|
sizes[i] = val if i == self.side_index else total-val
|
||||||
|
self.setSizes(sizes)
|
||||||
|
self.initialize()
|
||||||
|
|
||||||
|
return property(fget=fget, fset=fset)
|
||||||
|
|
||||||
|
def do_resize(self, *args):
|
||||||
|
orig = self.desired_side_size
|
||||||
|
QSplitter.resizeEvent(self, self._resize_ev)
|
||||||
|
if orig > 20 and self.desired_show:
|
||||||
|
c = 0
|
||||||
|
while abs(self.side_index_size - orig) > 10 and c < 5:
|
||||||
|
self.apply_state(self.get_state(), save_desired=False)
|
||||||
|
c += 1
|
||||||
|
|
||||||
|
def resizeEvent(self, ev):
|
||||||
|
if self.resize_timer.isActive():
|
||||||
|
self.resize_timer.stop()
|
||||||
|
self._resize_ev = ev
|
||||||
|
self.resize_timer.start()
|
||||||
|
|
||||||
|
def get_state(self):
|
||||||
|
if self.count() < 2: return (False, 200)
|
||||||
|
return (self.desired_show, self.desired_side_size)
|
||||||
|
|
||||||
|
def apply_state(self, state, save_desired=True):
|
||||||
|
if state[0]:
|
||||||
|
self.side_index_size = state[1]
|
||||||
|
if save_desired:
|
||||||
|
self.desired_side_size = self.side_index_size
|
||||||
else:
|
else:
|
||||||
state = dynamic.get(self._name+ '_last_open_state', None)
|
self.side_index_size = 0
|
||||||
if state is not None:
|
self.desired_show = state[0]
|
||||||
self.restoreState(state)
|
|
||||||
else:
|
|
||||||
self.setSizes(sizes)
|
|
||||||
self.initialize()
|
|
||||||
|
|
||||||
|
def default_state(self):
|
||||||
|
return (self.initial_show, self.initial_side_size)
|
||||||
|
|
||||||
|
# Public API {{{
|
||||||
|
|
||||||
|
def save_state(self):
|
||||||
|
if self.count() > 1:
|
||||||
|
gprefs[self.save_name+'_state'] = self.get_state()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def other_index(self):
|
||||||
|
return (self.side_index+1)%2
|
||||||
|
|
||||||
|
def restore_state(self):
|
||||||
|
if self.count() > 1:
|
||||||
|
state = gprefs.get(self.save_name+'_state',
|
||||||
|
self.default_state())
|
||||||
|
self.apply_state(state, save_desired=False)
|
||||||
|
self.desired_side_size = state[1]
|
||||||
|
|
||||||
|
def toggle_side_pane(self, hide=None):
|
||||||
|
if hide is None:
|
||||||
|
action = 'show' if self.is_side_index_hidden else 'hide'
|
||||||
|
else:
|
||||||
|
action = 'hide' if hide else 'show'
|
||||||
|
getattr(self, action+'_side_pane')()
|
||||||
|
|
||||||
|
def show_side_pane(self):
|
||||||
|
if self.count() < 2 or not self.is_side_index_hidden:
|
||||||
|
return
|
||||||
|
self.apply_state((True, self.desired_side_size))
|
||||||
|
|
||||||
|
def hide_side_pane(self):
|
||||||
|
if self.count() < 2 or self.is_side_index_hidden:
|
||||||
|
return
|
||||||
|
self.apply_state((False, self.desired_side_size))
|
||||||
|
|
||||||
|
def double_clicked(self, *args):
|
||||||
|
self.toggle_side_pane()
|
||||||
|
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
@ -96,14 +96,14 @@ class Kobo(Device):
|
|||||||
class Booq(Device):
|
class Booq(Device):
|
||||||
name = 'Booq Reader'
|
name = 'Booq Reader'
|
||||||
manufacturer = 'Booq'
|
manufacturer = 'Booq'
|
||||||
output_profile = 'prs505'
|
output_profile = 'sony'
|
||||||
output_format = 'EPUB'
|
output_format = 'EPUB'
|
||||||
id = 'booq'
|
id = 'booq'
|
||||||
|
|
||||||
class TheBook(Device):
|
class TheBook(Device):
|
||||||
name = 'The Book'
|
name = 'The Book'
|
||||||
manufacturer = 'Augen'
|
manufacturer = 'Augen'
|
||||||
output_profile = 'prs505'
|
output_profile = 'sony'
|
||||||
output_format = 'EPUB'
|
output_format = 'EPUB'
|
||||||
id = 'thebook'
|
id = 'thebook'
|
||||||
|
|
||||||
|
@ -621,7 +621,7 @@ class ResultCache(SearchQueryParser):
|
|||||||
self.first_sort = False
|
self.first_sort = False
|
||||||
fcmp = self.seriescmp \
|
fcmp = self.seriescmp \
|
||||||
if field == 'series' and \
|
if field == 'series' and \
|
||||||
tweaks['title_sorting'] == 'library_order' \
|
tweaks['title_series_sorting'] == 'library_order' \
|
||||||
else \
|
else \
|
||||||
functools.partial(self.cmp, self.FIELD_MAP[field],
|
functools.partial(self.cmp, self.FIELD_MAP[field],
|
||||||
subsort=subsort, asstr=as_string)
|
subsort=subsort, asstr=as_string)
|
||||||
|
@ -1842,6 +1842,8 @@ books_series_link feeds
|
|||||||
os.remove(self.dbpath)
|
os.remove(self.dbpath)
|
||||||
shutil.copyfile(dest, self.dbpath)
|
shutil.copyfile(dest, self.dbpath)
|
||||||
self.connect()
|
self.connect()
|
||||||
|
self.field_metadata.remove_dynamic_categories()
|
||||||
|
self.field_metadata.remove_custom_fields()
|
||||||
self.initialize_dynamic()
|
self.initialize_dynamic()
|
||||||
self.refresh()
|
self.refresh()
|
||||||
if os.path.exists(dest):
|
if os.path.exists(dest):
|
||||||
|
@ -379,6 +379,17 @@ class FieldMetadata(dict):
|
|||||||
self._add_search_terms_to_map(key, [key])
|
self._add_search_terms_to_map(key, [key])
|
||||||
self.custom_label_to_key_map[label] = key
|
self.custom_label_to_key_map[label] = key
|
||||||
|
|
||||||
|
def remove_custom_fields(self):
|
||||||
|
for key in self.get_custom_fields():
|
||||||
|
del self._tb_cats[key]
|
||||||
|
|
||||||
|
def remove_dynamic_categories(self):
|
||||||
|
for key in list(self._tb_cats.keys()):
|
||||||
|
val = self._tb_cats[key]
|
||||||
|
if val['is_category'] and val['kind'] in ('user', 'search'):
|
||||||
|
del self._tb_cats[key]
|
||||||
|
|
||||||
|
|
||||||
def add_user_category(self, label, name):
|
def add_user_category(self, label, name):
|
||||||
if label in self._tb_cats:
|
if label in self._tb_cats:
|
||||||
raise ValueError('Duplicate user field [%s]'%(label))
|
raise ValueError('Duplicate user field [%s]'%(label))
|
||||||
|
@ -137,7 +137,7 @@ class Feed(object):
|
|||||||
|
|
||||||
def populate_from_preparsed_feed(self, title, articles, oldest_article=7,
|
def populate_from_preparsed_feed(self, title, articles, oldest_article=7,
|
||||||
max_articles_per_feed=100):
|
max_articles_per_feed=100):
|
||||||
self.title = title if title else _('Unknown feed')
|
self.title = unicode(title if title else _('Unknown feed'))
|
||||||
self.description = ''
|
self.description = ''
|
||||||
self.image_url = None
|
self.image_url = None
|
||||||
self.articles = []
|
self.articles = []
|
||||||
|
@ -65,6 +65,7 @@ class NavBarTemplate(Template):
|
|||||||
text = 'This article was downloaded by '
|
text = 'This article was downloaded by '
|
||||||
p = PT(text, STRONG(__appname__), A(url, href=url), style='text-align:left')
|
p = PT(text, STRONG(__appname__), A(url, href=url), style='text-align:left')
|
||||||
p[0].tail = ' from '
|
p[0].tail = ' from '
|
||||||
|
navbar.append(p)
|
||||||
navbar.append(BR())
|
navbar.append(BR())
|
||||||
navbar.append(BR())
|
navbar.append(BR())
|
||||||
else:
|
else:
|
||||||
@ -111,6 +112,7 @@ class TouchscreenNavBarTemplate(Template):
|
|||||||
text = 'This article was downloaded by '
|
text = 'This article was downloaded by '
|
||||||
p = PT(text, STRONG(__appname__), A(url, href=url), style='text-align:left')
|
p = PT(text, STRONG(__appname__), A(url, href=url), style='text-align:left')
|
||||||
p[0].tail = ' from '
|
p[0].tail = ' from '
|
||||||
|
navbar.append(p)
|
||||||
navbar.append(BR())
|
navbar.append(BR())
|
||||||
navbar.append(BR())
|
navbar.append(BR())
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user