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