From 0f20f1ce77332b1f9e4a4dc4b122982f336b47c9 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 11 May 2013 22:24:21 +0530 Subject: [PATCH] Make the calibre item view focus settable from python --- src/calibre/gui2/__init__.py | 1 + src/qtcurve/style/qtcurve.cpp | 6 +++++- src/qtcurve/style/qtcurve.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py index 5fcde65ff5..369746cec7 100644 --- a/src/calibre/gui2/__init__.py +++ b/src/calibre/gui2/__init__.py @@ -873,6 +873,7 @@ class Application(QApplication): v = pcache[v] icon_map[type('')(getattr(style, 'SP_'+k))] = v style.setProperty(u'calibre_icon_map', icon_map) + style.setProperty(u'calibre_item_view_focus', True) self.__icon_map_memory_ = icon_map def setup_styles(self, force_calibre_style): diff --git a/src/qtcurve/style/qtcurve.cpp b/src/qtcurve/style/qtcurve.cpp index 53e5a4247c..46a9b91a87 100644 --- a/src/qtcurve/style/qtcurve.cpp +++ b/src/qtcurve/style/qtcurve.cpp @@ -964,6 +964,7 @@ Style::Style() itsAnimateStep(0), itsTitlebarHeight(0), calibre_icon_map(QHash()), + calibre_item_view_focus(0), is_kde_session(0), itsPos(-1, -1), itsHoverWidget(0L), @@ -3696,6 +3697,9 @@ bool Style::event(QEvent *event) { ++i; } return true; + } else if (e->propertyName() == QString("calibre_item_view_focus")) { + calibre_item_view_focus = property("calibre_item_view_focus").toBool(); + return true; } } return BASE_STYLE::event(event); @@ -4784,7 +4788,7 @@ void Style::drawPrimitive(PrimitiveElement element, const QStyleOption *option, if(widget && ::qobject_cast(widget)) r2.adjust(0, 2, 0, 0); - if(1 || FOCUS_STANDARD==opts.focus) // Changed by Kovid, as the underline focus does not work well in item views + if(calibre_item_view_focus || FOCUS_STANDARD==opts.focus) // Changed by Kovid, as the underline focus does not work well in item views { // Taken from QWindowsStyle... painter->save(); diff --git a/src/qtcurve/style/qtcurve.h b/src/qtcurve/style/qtcurve.h index 43cd882c2f..84dfbdd145 100644 --- a/src/qtcurve/style/qtcurve.h +++ b/src/qtcurve/style/qtcurve.h @@ -355,6 +355,7 @@ class Style : public QCommonStyle mutable QList itsMdiButtons[2]; // 0=left, 1=right mutable int itsTitlebarHeight; QHash calibre_icon_map; + bool calibre_item_view_focus; bool is_kde_session; // Required for Q3Header hover...