mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
KG updates
This commit is contained in:
commit
f16b736a90
@ -350,3 +350,11 @@ send_news_to_device_location = "main"
|
||||
# work on all operating systems)
|
||||
server_listen_on = '0.0.0.0'
|
||||
|
||||
#: Unified toolbar on OS X
|
||||
# If you enable this option and restart calibre, the toolbar will be 'unified'
|
||||
# with the titlebar as is normal for OS X applications. However, doing this has
|
||||
# various bugs, for instance the minimum width of the toolbar becomes twice
|
||||
# what it should be and it causes other random bugs on some systems, so turn it
|
||||
# on at your own risk!
|
||||
unified_title_toolbar_on_osx = False
|
||||
|
||||
|
@ -249,10 +249,6 @@ class BarsManager(QObject):
|
||||
self.menu_bar = MenuBar(self.location_manager, self.parent())
|
||||
self.parent().setMenuBar(self.menu_bar)
|
||||
|
||||
parent.addToolBar(Qt.TopToolBarArea, self.main_bars[0])
|
||||
parent.addToolBar(Qt.BottomToolBarArea, self.main_bars[1])
|
||||
parent.addToolBar(Qt.BottomToolBarArea, self.child_bars[0])
|
||||
|
||||
self.apply_settings()
|
||||
self.init_bars()
|
||||
|
||||
@ -292,15 +288,12 @@ class BarsManager(QObject):
|
||||
'''
|
||||
showing_device = self.location_manager.has_device
|
||||
main_bar = self.main_bars[1 if showing_device else 0]
|
||||
hidden_bar = self.main_bars[0 if showing_device else 1]
|
||||
self.parent().addToolBar(Qt.BottomToolBarArea, hidden_bar)
|
||||
child_bar = self.child_bars[0]
|
||||
for bar in self.bars:
|
||||
bar.setVisible(False)
|
||||
bar.update_lm_actions()
|
||||
if main_bar.added_actions:
|
||||
main_bar.setVisible(True)
|
||||
self.parent().addToolBar(Qt.TopToolBarArea, main_bar)
|
||||
if child_bar.added_actions:
|
||||
child_bar.setVisible(True)
|
||||
|
||||
|
@ -17,6 +17,7 @@ from calibre.gui2.search_box import SearchBox2, SavedSearchBox
|
||||
from calibre.gui2.throbber import ThrobbingButton
|
||||
from calibre.gui2.bars import BarsManager
|
||||
from calibre.gui2.widgets import ComboBoxWithHelp
|
||||
from calibre.utils.config_base import tweaks
|
||||
from calibre import human_readable
|
||||
|
||||
class LocationManager(QObject): # {{{
|
||||
@ -259,8 +260,15 @@ class MainWindowMixin(object): # {{{
|
||||
self.search_bar = SearchBar(self)
|
||||
self.bars_manager = BarsManager(self.donate_button,
|
||||
self.location_manager, self)
|
||||
for bar in self.bars_manager.main_bars:
|
||||
self.addToolBar(Qt.TopToolBarArea, bar)
|
||||
for bar in self.bars_manager.child_bars:
|
||||
self.addToolBar(Qt.BottomToolBarArea, bar)
|
||||
self.bars_manager.update_bars()
|
||||
self.setUnifiedTitleAndToolBarOnMac(True)
|
||||
# This is disabled because it introduces various toolbar related bugs
|
||||
# The width of the toolbar becomes the sum of both toolbars
|
||||
if tweaks['unified_title_toolbar_on_osx']:
|
||||
self.setUnifiedTitleAndToolBarOnMac(True)
|
||||
|
||||
l = self.centralwidget.layout()
|
||||
l.addWidget(self.search_bar)
|
||||
|
@ -6,6 +6,7 @@ __license__ = 'GPL 3'
|
||||
__copyright__ = '2011, John Schember <john@nachtimwald.com>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import re
|
||||
import urllib
|
||||
from contextlib import closing
|
||||
|
||||
@ -25,6 +26,9 @@ class OReillyStore(BasicStoreConfig, StorePlugin):
|
||||
def open(self, parent=None, detail_item=None, external=False):
|
||||
url = 'http://oreilly.com/ebooks/'
|
||||
|
||||
if detail_item:
|
||||
detail_item = 'https://epoch.oreilly.com/shop/cart.orm?prod=%s.EBOOK&p=CALIBRE' % detail_item
|
||||
|
||||
if external or self.config.get('open_external', False):
|
||||
open_url(QUrl(url_slash_cleaner(detail_item if detail_item else url)))
|
||||
else:
|
||||
@ -45,9 +49,11 @@ class OReillyStore(BasicStoreConfig, StorePlugin):
|
||||
if counter <= 0:
|
||||
break
|
||||
|
||||
id = ''.join(data.xpath('.//div[@class="title"]/a/@href'))
|
||||
if not id:
|
||||
full_id = ''.join(data.xpath('.//div[@class="title"]/a/@href'))
|
||||
mo = re.search('\d+', full_id)
|
||||
if not mo:
|
||||
continue
|
||||
id = mo.group()
|
||||
|
||||
cover_url = ''.join(data.xpath('.//div[@class="bigCover"]//img/@src'))
|
||||
|
||||
@ -55,6 +61,18 @@ class OReillyStore(BasicStoreConfig, StorePlugin):
|
||||
author = ''.join(data.xpath('.//div[@class="author"]/text()'))
|
||||
author = author.split('By ')[-1].strip()
|
||||
|
||||
# Get the detail here because we need to get the ebook id for the detail_item.
|
||||
with closing(br.open(full_id, timeout=timeout)) as nf:
|
||||
idoc = html.fromstring(nf.read())
|
||||
|
||||
price = ''.join(idoc.xpath('(//span[@class="price"])[1]/span//text()'))
|
||||
formats = ', '.join(idoc.xpath('//div[@class="ebook_formats"]//a/text()'))
|
||||
|
||||
eid = ''.join(idoc.xpath('(//a[@class="product_buy_link" and contains(@href, ".EBOOK")])[1]/@href')).strip()
|
||||
mo = re.search('\d+', eid)
|
||||
if mo:
|
||||
id = mo.group()
|
||||
|
||||
counter -= 1
|
||||
|
||||
s = SearchResult()
|
||||
@ -62,17 +80,8 @@ class OReillyStore(BasicStoreConfig, StorePlugin):
|
||||
s.title = title.strip()
|
||||
s.author = author.strip()
|
||||
s.detail_item = id.strip()
|
||||
s.price = price.strip()
|
||||
s.drm = SearchResult.DRM_UNLOCKED
|
||||
s.formats = formats.upper()
|
||||
|
||||
yield s
|
||||
|
||||
def get_details(self, search_result, timeout):
|
||||
br = browser()
|
||||
with closing(br.open(search_result.detail_item, timeout=timeout)) as nf:
|
||||
doc = html.fromstring(nf.read())
|
||||
|
||||
search_result.price = ''.join(doc.xpath('(//span[@class="price"])[1]/span//text()')).strip()
|
||||
search_result.formats = ', '.join(doc.xpath('//div[@class="ebook_formats"]//a/text()')).upper()
|
||||
|
||||
return True
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user