← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~patrick-zakweb/openlp/bug-936281 into lp:openlp

 

mohij has proposed merging lp:~patrick-zakweb/openlp/bug-936281 into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)

For more details, see:
https://code.launchpad.net/~patrick-zakweb/openlp/bug-936281/+merge/132614

This branch add a logic, that changes the alternate-background-color in the application wide stylesheet conditionally, dependent on whether the alternate-background-color is similar to the inactive-selected-color. As proposed in a recent mailing list discussion.
This partially fixes bug #936281.
Tested on Kubuntu 12.04 and Windows XP SP3.
-- 
https://code.launchpad.net/~patrick-zakweb/openlp/bug-936281/+merge/132614
Your team OpenLP Core is requested to review the proposed merge of lp:~patrick-zakweb/openlp/bug-936281 into lp:openlp.
=== modified file 'openlp/core/__init__.py'
--- openlp/core/__init__.py	2012-10-21 14:07:57 +0000
+++ openlp/core/__init__.py	2012-11-01 19:39:25 +0000
@@ -60,7 +60,7 @@
 
 
 log = logging.getLogger()
-application_stylesheet = u"""
+nt_repair_stylesheet = u"""
 QMainWindow::separator
 {
   border: none;
@@ -128,8 +128,41 @@
             if FirstTimeForm(screens).exec_() == QtGui.QDialog.Accepted:
                 Settings().setValue(u'general/has run wizard',
                     QtCore.QVariant(True))
+        # Correct stylesheet bugs
+        application_stylesheet = u""
+        inactive_selected_color = self.palette().color(QtGui.QPalette.Inactive,
+            QtGui.QPalette.Highlight)
+        alternate_base_color = self.palette().color(QtGui.QPalette.Active,
+            QtGui.QPalette.AlternateBase)
+        base_color = self.palette().color(QtGui.QPalette.Active,
+            QtGui.QPalette.Base)
+        if abs(inactive_selected_color.red() - \
+            alternate_base_color.red()) + \
+            abs(inactive_selected_color.green() - \
+            alternate_base_color.green()) + \
+            abs(inactive_selected_color.blue() - \
+            alternate_base_color.blue()) < 100:
+                hue,  saturation,  value,  alpha = \
+                alternate_base_color.getHslF ()
+                if base_color.lightness() < \
+                    inactive_selected_color.lightness():
+                        value = inactive_selected_color.lightnessF() - 0.2
+                        if value < 0.0:
+                            value = 0.0
+                else:
+                    value = inactive_selected_color.lightnessF() + 0.2
+                    if value > 1.0:
+                        value = 1.0
+                alternate_base_color.setHsvF(hue,  saturation,  value,  alpha)
+                alternate_background_repair_stylesheet = \
+                u"* {alternate-background-color: " + \
+                alternate_base_color.name() + ";}\n"
+                application_stylesheet += alternate_background_repair_stylesheet
         if os.name == u'nt':
+            application_stylesheet += nt_repair_stylesheet
+        if application_stylesheet:
             self.setStyleSheet(application_stylesheet)
+        # show the splashscreen
         show_splash = Settings().value(
             u'general/show splash', QtCore.QVariant(True)).toBool()
         if show_splash:


Follow ups