mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add option to turn off reflections in the cover browser (Preferences->Look & Feel->Cover Browser)
This commit is contained in:
parent
f9a5cab366
commit
71e77b85d7
@ -22,91 +22,94 @@ from calibre.utils.date import UNDEFINED_DATE
|
|||||||
|
|
||||||
# Setup gprefs {{{
|
# Setup gprefs {{{
|
||||||
gprefs = JSONConfig('gui')
|
gprefs = JSONConfig('gui')
|
||||||
|
defs = gprefs.defaults
|
||||||
|
|
||||||
if isosx:
|
if isosx:
|
||||||
gprefs.defaults['action-layout-menubar'] = (
|
defs['action-layout-menubar'] = (
|
||||||
'Add Books', 'Edit Metadata', 'Convert Books',
|
'Add Books', 'Edit Metadata', 'Convert Books',
|
||||||
'Choose Library', 'Save To Disk', 'Preferences',
|
'Choose Library', 'Save To Disk', 'Preferences',
|
||||||
'Help',
|
'Help',
|
||||||
)
|
)
|
||||||
gprefs.defaults['action-layout-menubar-device'] = (
|
defs['action-layout-menubar-device'] = (
|
||||||
'Add Books', 'Edit Metadata', 'Convert Books',
|
'Add Books', 'Edit Metadata', 'Convert Books',
|
||||||
'Location Manager', 'Send To Device',
|
'Location Manager', 'Send To Device',
|
||||||
'Save To Disk', 'Preferences', 'Help',
|
'Save To Disk', 'Preferences', 'Help',
|
||||||
)
|
)
|
||||||
gprefs.defaults['action-layout-toolbar'] = (
|
defs['action-layout-toolbar'] = (
|
||||||
'Add Books', 'Edit Metadata', None, 'Convert Books', 'View', None,
|
'Add Books', 'Edit Metadata', None, 'Convert Books', 'View', None,
|
||||||
'Choose Library', 'Donate', None, 'Fetch News', 'Store', 'Save To Disk',
|
'Choose Library', 'Donate', None, 'Fetch News', 'Store', 'Save To Disk',
|
||||||
'Connect Share', None, 'Remove Books',
|
'Connect Share', None, 'Remove Books',
|
||||||
)
|
)
|
||||||
gprefs.defaults['action-layout-toolbar-device'] = (
|
defs['action-layout-toolbar-device'] = (
|
||||||
'Add Books', 'Edit Metadata', None, 'Convert Books', 'View',
|
'Add Books', 'Edit Metadata', None, 'Convert Books', 'View',
|
||||||
'Send To Device', None, None, 'Location Manager', None, None,
|
'Send To Device', None, None, 'Location Manager', None, None,
|
||||||
'Fetch News', 'Store', 'Save To Disk', 'Connect Share', None,
|
'Fetch News', 'Store', 'Save To Disk', 'Connect Share', None,
|
||||||
'Remove Books',
|
'Remove Books',
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
gprefs.defaults['action-layout-menubar'] = ()
|
defs['action-layout-menubar'] = ()
|
||||||
gprefs.defaults['action-layout-menubar-device'] = ()
|
defs['action-layout-menubar-device'] = ()
|
||||||
gprefs.defaults['action-layout-toolbar'] = (
|
defs['action-layout-toolbar'] = (
|
||||||
'Add Books', 'Edit Metadata', None, 'Convert Books', 'View', None,
|
'Add Books', 'Edit Metadata', None, 'Convert Books', 'View', None,
|
||||||
'Store', 'Donate', 'Fetch News', 'Help', None,
|
'Store', 'Donate', 'Fetch News', 'Help', None,
|
||||||
'Remove Books', 'Choose Library', 'Save To Disk',
|
'Remove Books', 'Choose Library', 'Save To Disk',
|
||||||
'Connect Share', 'Preferences',
|
'Connect Share', 'Preferences',
|
||||||
)
|
)
|
||||||
gprefs.defaults['action-layout-toolbar-device'] = (
|
defs['action-layout-toolbar-device'] = (
|
||||||
'Add Books', 'Edit Metadata', None, 'Convert Books', 'View',
|
'Add Books', 'Edit Metadata', None, 'Convert Books', 'View',
|
||||||
'Send To Device', None, None, 'Location Manager', None, None,
|
'Send To Device', None, None, 'Location Manager', None, None,
|
||||||
'Fetch News', 'Save To Disk', 'Store', 'Connect Share', None,
|
'Fetch News', 'Save To Disk', 'Store', 'Connect Share', None,
|
||||||
'Remove Books', None, 'Help', 'Preferences',
|
'Remove Books', None, 'Help', 'Preferences',
|
||||||
)
|
)
|
||||||
|
|
||||||
gprefs.defaults['action-layout-toolbar-child'] = ()
|
defs['action-layout-toolbar-child'] = ()
|
||||||
|
|
||||||
gprefs.defaults['action-layout-context-menu'] = (
|
defs['action-layout-context-menu'] = (
|
||||||
'Edit Metadata', 'Send To Device', 'Save To Disk',
|
'Edit Metadata', 'Send To Device', 'Save To Disk',
|
||||||
'Connect Share', 'Copy To Library', None,
|
'Connect Share', 'Copy To Library', None,
|
||||||
'Convert Books', 'View', 'Open Folder', 'Show Book Details',
|
'Convert Books', 'View', 'Open Folder', 'Show Book Details',
|
||||||
'Similar Books', 'Tweak ePub', None, 'Remove Books',
|
'Similar Books', 'Tweak ePub', None, 'Remove Books',
|
||||||
)
|
)
|
||||||
|
|
||||||
gprefs.defaults['action-layout-context-menu-device'] = (
|
defs['action-layout-context-menu-device'] = (
|
||||||
'View', 'Save To Disk', None, 'Remove Books', None,
|
'View', 'Save To Disk', None, 'Remove Books', None,
|
||||||
'Add To Library', 'Edit Collections',
|
'Add To Library', 'Edit Collections',
|
||||||
)
|
)
|
||||||
|
|
||||||
gprefs.defaults['action-layout-context-menu-cover-browser'] = (
|
defs['action-layout-context-menu-cover-browser'] = (
|
||||||
'Edit Metadata', 'Send To Device', 'Save To Disk',
|
'Edit Metadata', 'Send To Device', 'Save To Disk',
|
||||||
'Connect Share', 'Copy To Library', None,
|
'Connect Share', 'Copy To Library', None,
|
||||||
'Convert Books', 'View', 'Open Folder', 'Show Book Details',
|
'Convert Books', 'View', 'Open Folder', 'Show Book Details',
|
||||||
'Similar Books', 'Tweak ePub', None, 'Remove Books',
|
'Similar Books', 'Tweak ePub', None, 'Remove Books',
|
||||||
)
|
)
|
||||||
|
|
||||||
gprefs.defaults['show_splash_screen'] = True
|
defs['show_splash_screen'] = True
|
||||||
gprefs.defaults['toolbar_icon_size'] = 'medium'
|
defs['toolbar_icon_size'] = 'medium'
|
||||||
gprefs.defaults['automerge'] = 'ignore'
|
defs['automerge'] = 'ignore'
|
||||||
gprefs.defaults['toolbar_text'] = 'always'
|
defs['toolbar_text'] = 'always'
|
||||||
gprefs.defaults['font'] = None
|
defs['font'] = None
|
||||||
gprefs.defaults['tags_browser_partition_method'] = 'first letter'
|
defs['tags_browser_partition_method'] = 'first letter'
|
||||||
gprefs.defaults['tags_browser_collapse_at'] = 100
|
defs['tags_browser_collapse_at'] = 100
|
||||||
gprefs.defaults['tag_browser_dont_collapse'] = []
|
defs['tag_browser_dont_collapse'] = []
|
||||||
gprefs.defaults['edit_metadata_single_layout'] = 'default'
|
defs['edit_metadata_single_layout'] = 'default'
|
||||||
gprefs.defaults['default_author_link'] = 'http://en.wikipedia.org/w/index.php?search={author}'
|
defs['default_author_link'] = 'http://en.wikipedia.org/w/index.php?search={author}'
|
||||||
gprefs.defaults['preserve_date_on_ctl'] = True
|
defs['preserve_date_on_ctl'] = True
|
||||||
gprefs.defaults['manual_add_auto_convert'] = False
|
defs['manual_add_auto_convert'] = False
|
||||||
gprefs.defaults['cb_fullscreen'] = False
|
defs['cb_fullscreen'] = False
|
||||||
gprefs.defaults['worker_max_time'] = 0
|
defs['worker_max_time'] = 0
|
||||||
gprefs.defaults['show_files_after_save'] = True
|
defs['show_files_after_save'] = True
|
||||||
gprefs.defaults['auto_add_path'] = None
|
defs['auto_add_path'] = None
|
||||||
gprefs.defaults['auto_add_check_for_duplicates'] = False
|
defs['auto_add_check_for_duplicates'] = False
|
||||||
gprefs.defaults['blocked_auto_formats'] = []
|
defs['blocked_auto_formats'] = []
|
||||||
gprefs.defaults['auto_add_auto_convert'] = True
|
defs['auto_add_auto_convert'] = True
|
||||||
gprefs.defaults['ui_style'] = 'calibre' if iswindows or isosx else 'system'
|
defs['ui_style'] = 'calibre' if iswindows or isosx else 'system'
|
||||||
gprefs.defaults['tag_browser_old_look'] = False
|
defs['tag_browser_old_look'] = False
|
||||||
gprefs.defaults['book_list_tooltips'] = True
|
defs['book_list_tooltips'] = True
|
||||||
gprefs.defaults['bd_show_cover'] = True
|
defs['bd_show_cover'] = True
|
||||||
gprefs.defaults['bd_overlay_cover_size'] = False
|
defs['bd_overlay_cover_size'] = False
|
||||||
gprefs.defaults['tags_browser_category_icons'] = {}
|
defs['tags_browser_category_icons'] = {}
|
||||||
|
defs['cover_browser_reflections'] = True
|
||||||
|
del defs
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
NONE = QVariant() #: Null value to return from the data function of item models
|
NONE = QVariant() #: Null value to return from the data function of item models
|
||||||
|
@ -106,6 +106,8 @@ if pictureflow is not None:
|
|||||||
self.setContextMenuPolicy(Qt.DefaultContextMenu)
|
self.setContextMenuPolicy(Qt.DefaultContextMenu)
|
||||||
if hasattr(self, 'setSubtitleFont'):
|
if hasattr(self, 'setSubtitleFont'):
|
||||||
self.setSubtitleFont(QFont(rating_font()))
|
self.setSubtitleFont(QFont(rating_font()))
|
||||||
|
if not gprefs['cover_browser_reflections']:
|
||||||
|
self.setShowReflections(False)
|
||||||
|
|
||||||
def set_context_menu(self, cm):
|
def set_context_menu(self, cm):
|
||||||
self.context_menu = cm
|
self.context_menu = cm
|
||||||
|
@ -340,6 +340,9 @@ public:
|
|||||||
int currentSlide() const;
|
int currentSlide() const;
|
||||||
void setCurrentSlide(int index);
|
void setCurrentSlide(int index);
|
||||||
|
|
||||||
|
bool showReflections() const;
|
||||||
|
void setShowReflections(bool show);
|
||||||
|
|
||||||
int getTarget() const;
|
int getTarget() const;
|
||||||
|
|
||||||
void showPrevious();
|
void showPrevious();
|
||||||
@ -378,6 +381,7 @@ private:
|
|||||||
int slideHeight;
|
int slideHeight;
|
||||||
int fontSize;
|
int fontSize;
|
||||||
int queueLength;
|
int queueLength;
|
||||||
|
bool doReflections;
|
||||||
|
|
||||||
int centerIndex;
|
int centerIndex;
|
||||||
SlideInfo centerSlide;
|
SlideInfo centerSlide;
|
||||||
@ -416,6 +420,7 @@ PictureFlowPrivate::PictureFlowPrivate(PictureFlow* w, int queueLength_)
|
|||||||
slideWidth = 200;
|
slideWidth = 200;
|
||||||
slideHeight = 200;
|
slideHeight = 200;
|
||||||
fontSize = 10;
|
fontSize = 10;
|
||||||
|
doReflections = true;
|
||||||
|
|
||||||
centerIndex = 0;
|
centerIndex = 0;
|
||||||
queueLength = queueLength_;
|
queueLength = queueLength_;
|
||||||
@ -494,6 +499,15 @@ void PictureFlowPrivate::setCurrentSlide(int index)
|
|||||||
widget->emitcurrentChanged(centerIndex);
|
widget->emitcurrentChanged(centerIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PictureFlowPrivate::showReflections() const {
|
||||||
|
return doReflections;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PictureFlowPrivate::setShowReflections(bool show) {
|
||||||
|
doReflections = show;
|
||||||
|
triggerRender();
|
||||||
|
}
|
||||||
|
|
||||||
void PictureFlowPrivate::showPrevious()
|
void PictureFlowPrivate::showPrevious()
|
||||||
{
|
{
|
||||||
if(step >= 0)
|
if(step >= 0)
|
||||||
@ -584,7 +598,7 @@ void PictureFlowPrivate::resetSlides()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static QImage prepareSurface(QImage img, int w, int h)
|
static QImage prepareSurface(QImage img, int w, int h, bool doReflections)
|
||||||
{
|
{
|
||||||
img = img.scaled(w, h, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
img = img.scaled(w, h, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||||
|
|
||||||
@ -602,19 +616,21 @@ static QImage prepareSurface(QImage img, int w, int h)
|
|||||||
for(int y = 0; y < h; y++)
|
for(int y = 0; y < h; y++)
|
||||||
result.setPixel(y, x, img.pixel(x, y));
|
result.setPixel(y, x, img.pixel(x, y));
|
||||||
|
|
||||||
// create the reflection
|
if (doReflections) {
|
||||||
int ht = hs - h;
|
// create the reflection
|
||||||
for(int x = 0; x < w; x++)
|
int ht = hs - h;
|
||||||
for(int y = 0; y < ht; y++)
|
for(int x = 0; x < w; x++)
|
||||||
{
|
for(int y = 0; y < ht; y++)
|
||||||
QRgb color = img.pixel(x, img.height()-y-1);
|
{
|
||||||
//QRgb565 color = img.scanLine(img.height()-y-1) + x*sizeof(QRgb565); //img.pixel(x, img.height()-y-1);
|
QRgb color = img.pixel(x, img.height()-y-1);
|
||||||
int a = qAlpha(color);
|
//QRgb565 color = img.scanLine(img.height()-y-1) + x*sizeof(QRgb565); //img.pixel(x, img.height()-y-1);
|
||||||
int r = qRed(color) * a / 256 * (ht - y) / ht * 3/5;
|
int a = qAlpha(color);
|
||||||
int g = qGreen(color) * a / 256 * (ht - y) / ht * 3/5;
|
int r = qRed(color) * a / 256 * (ht - y) / ht * 3/5;
|
||||||
int b = qBlue(color) * a / 256 * (ht - y) / ht * 3/5;
|
int g = qGreen(color) * a / 256 * (ht - y) / ht * 3/5;
|
||||||
result.setPixel(h+y, x, qRgb(r, g, b));
|
int b = qBlue(color) * a / 256 * (ht - y) / ht * 3/5;
|
||||||
}
|
result.setPixel(h+y, x, qRgb(r, g, b));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -652,12 +668,12 @@ QImage* PictureFlowPrivate::surface(int slideIndex)
|
|||||||
painter.setBrush(QBrush());
|
painter.setBrush(QBrush());
|
||||||
painter.drawRect(2, 2, slideWidth-3, slideHeight-3);
|
painter.drawRect(2, 2, slideWidth-3, slideHeight-3);
|
||||||
painter.end();
|
painter.end();
|
||||||
blankSurface = prepareSurface(blankSurface, slideWidth, slideHeight);
|
blankSurface = prepareSurface(blankSurface, slideWidth, slideHeight, doReflections);
|
||||||
}
|
}
|
||||||
return &blankSurface;
|
return &blankSurface;
|
||||||
}
|
}
|
||||||
|
|
||||||
surfaceCache.insert(slideIndex, new QImage(prepareSurface(img, slideWidth, slideHeight)));
|
surfaceCache.insert(slideIndex, new QImage(prepareSurface(img, slideWidth, slideHeight, doReflections)));
|
||||||
return surfaceCache[slideIndex];
|
return surfaceCache[slideIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1196,6 +1212,13 @@ QImage PictureFlow::slide(int index) const
|
|||||||
return d->slide(index);
|
return d->slide(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PictureFlow::showReflections() const {
|
||||||
|
return d->showReflections();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PictureFlow::setShowReflections(bool show) {
|
||||||
|
d->setShowReflections(show);
|
||||||
|
}
|
||||||
|
|
||||||
void PictureFlow::setImages(FlowImages *images)
|
void PictureFlow::setImages(FlowImages *images)
|
||||||
{
|
{
|
||||||
|
@ -121,6 +121,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
void setSlideSize(QSize size);
|
void setSlideSize(QSize size);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Turn the reflections on/off.
|
||||||
|
*/
|
||||||
|
void setShowReflections(bool show);
|
||||||
|
bool showReflections() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Returns the font used to render subtitles
|
Returns the font used to render subtitles
|
||||||
*/
|
*/
|
||||||
|
@ -51,6 +51,10 @@ public :
|
|||||||
|
|
||||||
int currentSlide() const;
|
int currentSlide() const;
|
||||||
|
|
||||||
|
bool showReflections() const;
|
||||||
|
|
||||||
|
void setShowReflections(bool show);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void setCurrentSlide(int index);
|
void setCurrentSlide(int index);
|
||||||
|
@ -110,6 +110,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
r('bd_overlay_cover_size', gprefs)
|
r('bd_overlay_cover_size', gprefs)
|
||||||
|
|
||||||
r('cover_flow_queue_length', config, restart_required=True)
|
r('cover_flow_queue_length', config, restart_required=True)
|
||||||
|
r('cover_browser_reflections', gprefs)
|
||||||
|
|
||||||
def get_esc_lang(l):
|
def get_esc_lang(l):
|
||||||
if l == 'en':
|
if l == 'en':
|
||||||
@ -289,6 +290,8 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
self.update_font_display()
|
self.update_font_display()
|
||||||
gui.tags_view.reread_collapse_parameters()
|
gui.tags_view.reread_collapse_parameters()
|
||||||
gui.library_view.refresh_book_details()
|
gui.library_view.refresh_book_details()
|
||||||
|
if gui.cover_flow is not None:
|
||||||
|
gui.cover_flow.setShowReflections(gprefs['cover_browser_reflections'])
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
from calibre.gui2 import Application
|
from calibre.gui2 import Application
|
||||||
|
@ -496,10 +496,7 @@ a few top-level elements.</string>
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="5" column="0" colspan="2">
|
||||||
<widget class="QSpinBox" name="opt_cover_flow_queue_length"/>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="0" colspan="2">
|
|
||||||
<spacer name="verticalSpacer_4">
|
<spacer name="verticalSpacer_4">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
@ -512,14 +509,17 @@ a few top-level elements.</string>
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0" colspan="2">
|
<item row="1" column="1">
|
||||||
|
<widget class="QSpinBox" name="opt_cover_flow_queue_length"/>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0" colspan="2">
|
||||||
<widget class="QCheckBox" name="opt_cb_fullscreen">
|
<widget class="QCheckBox" name="opt_cb_fullscreen">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>When showing cover browser in separate window, show it &fullscreen</string>
|
<string>When showing cover browser in separate window, show it &fullscreen</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0" colspan="2">
|
<item row="4" column="0" colspan="2">
|
||||||
<widget class="QLabel" name="fs_help_msg">
|
<widget class="QLabel" name="fs_help_msg">
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true">margin-left: 1.5em</string>
|
<string notr="true">margin-left: 1.5em</string>
|
||||||
@ -532,6 +532,13 @@ a few top-level elements.</string>
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QCheckBox" name="opt_cover_browser_reflections">
|
||||||
|
<property name="text">
|
||||||
|
<string>Show &reflections in the cover browser</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user