← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~meths/openlp/trivialfixes into lp:openlp

 

Jon Tibble has proposed merging lp:~meths/openlp/trivialfixes into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)


Fix QColorDialog usage
-- 
https://code.launchpad.net/~meths/openlp/trivialfixes/+merge/27501
Your team OpenLP Core is requested to review the proposed merge of lp:~meths/openlp/trivialfixes into lp:openlp.
=== modified file 'openlp/core/ui/amendthemeform.py'
--- openlp/core/ui/amendthemeform.py	2010-06-09 17:09:32 +0000
+++ openlp/core/ui/amendthemeform.py	2010-06-14 13:41:36 +0000
@@ -239,12 +239,13 @@
         self.previewTheme()
 
     def onFontMainColorPushButtonClicked(self):
-        self.theme.font_main_color = QtGui.QColorDialog.getColor(
-            QtGui.QColor(self.theme.font_main_color), self).name()
-
-        self.FontMainColorPushButton.setStyleSheet(
-            u'background-color: %s' % unicode(self.theme.font_main_color))
-        self.previewTheme()
+        new_color = QtGui.QColorDialog.getColor(
+            QtGui.QColor(self.theme.font_main_color), self)
+        if new_color.isValid():
+            self.theme.font_main_color = new_color.name()
+            self.FontMainColorPushButton.setStyleSheet(
+                u'background-color: %s' % unicode(self.theme.font_main_color))
+            self.previewTheme()
 
     def onFontMainSizeSpinBoxChanged(self):
         if self.theme.font_main_proportion != self.FontMainSizeSpinBox.value():
@@ -332,11 +333,13 @@
         self.previewTheme()
 
     def onFontFooterColorPushButtonClicked(self):
-        self.theme.font_footer_color = QtGui.QColorDialog.getColor(
-            QtGui.QColor(self.theme.font_footer_color), self).name()
-        self.FontFooterColorPushButton.setStyleSheet(
-            'background-color: %s' % unicode(self.theme.font_footer_color))
-        self.previewTheme()
+        new_color = QtGui.QColorDialog.getColor(
+            QtGui.QColor(self.theme.font_footer_color), self)
+        if new_color.isValid():
+            self.theme.font_footer_color = new_color.name()
+            self.FontFooterColorPushButton.setStyleSheet(
+                u'background-color: %s' % unicode(self.theme.font_footer_color))
+            self.previewTheme()
 
     def onFontFooterSizeSpinBoxChanged(self):
         if self.theme.font_footer_proportion != \
@@ -431,24 +434,29 @@
 
     def onColor1PushButtonClicked(self):
         if self.theme.background_type == u'solid':
-            self.theme.background_color = QtGui.QColorDialog.getColor(
-                QtGui.QColor(self.theme.background_color), self).name()
-            self.Color1PushButton.setStyleSheet(
-                u'background-color: %s' % unicode(self.theme.background_color))
+            new_color = QtGui.QColorDialog.getColor(
+                QtGui.QColor(self.theme.background_color), self)
+            if new_color.isValid():
+                self.theme.background_color = new_color.name()
+                self.Color1PushButton.setStyleSheet(u'background-color: %s' %
+                    unicode(self.theme.background_color))
         else:
-            self.theme.background_startColor = QtGui.QColorDialog.getColor(
-                QtGui.QColor(self.theme.background_startColor), self).name()
-            self.Color1PushButton.setStyleSheet(
-                u'background-color: %s' % \
+            new_color = QtGui.QColorDialog.getColor(
+                QtGui.QColor(self.theme.background_startColor), self)
+            if new_color.isValid():
+                self.theme.background_startColor = new_color.name()
+                self.Color1PushButton.setStyleSheet(u'background-color: %s' %
                     unicode(self.theme.background_startColor))
         self.previewTheme()
 
     def onColor2PushButtonClicked(self):
-        self.theme.background_endColor = QtGui.QColorDialog.getColor(
-            QtGui.QColor(self.theme.background_endColor), self).name()
-        self.Color2PushButton.setStyleSheet(
-            u'background-color: %s' % unicode(self.theme.background_endColor))
-        self.previewTheme()
+        new_color = QtGui.QColorDialog.getColor(
+            QtGui.QColor(self.theme.background_endColor), self)
+        if new_color.isValid():
+            self.theme.background_endColor = new_color.name()
+            self.Color2PushButton.setStyleSheet(u'background-color: %s' %
+                unicode(self.theme.background_endColor))
+            self.previewTheme()
 
     #
     #Other Tab
@@ -472,11 +480,13 @@
             self.previewTheme()
 
     def onOutlineColorPushButtonClicked(self):
-        self.theme.display_outline_color = QtGui.QColorDialog.getColor(
-            QtGui.QColor(self.theme.display_outline_color), self).name()
-        self.OutlineColorPushButton.setStyleSheet(
-            u'background-color: %s' % unicode(self.theme.display_outline_color))
-        self.previewTheme()
+        new_color = QtGui.QColorDialog.getColor(
+            QtGui.QColor(self.theme.display_outline_color), self)
+        if new_color.isValid():
+            self.theme.display_outline_color = new_color.name()
+            self.OutlineColorPushButton.setStyleSheet(u'background-color: %s' %
+                unicode(self.theme.display_outline_color))
+            self.previewTheme()
 
     def onShadowCheckBoxChanged(self, value):
         if value == 2:  # checked
@@ -495,11 +505,13 @@
         self.previewTheme()
 
     def onShadowColorPushButtonClicked(self):
-        self.theme.display_shadow_color = QtGui.QColorDialog.getColor(
-            QtGui.QColor(self.theme.display_shadow_color), self).name()
-        self.ShadowColorPushButton.setStyleSheet(
-            u'background-color: %s' % unicode(self.theme.display_shadow_color))
-        self.previewTheme()
+        new_color = QtGui.QColorDialog.getColor(
+            QtGui.QColor(self.theme.display_shadow_color), self)
+        if new_color.isValid():
+            self.theme.display_shadow_color = new_color.name()
+            self.ShadowColorPushButton.setStyleSheet(u'background-color: %s' %
+                unicode(self.theme.display_shadow_color))
+            self.previewTheme()
 
     def onHorizontalComboBoxSelected(self, currentIndex):
         self.theme.display_horizontalAlign = currentIndex

=== modified file 'openlp/plugins/alerts/lib/alertstab.py'
--- openlp/plugins/alerts/lib/alertstab.py	2010-06-06 11:34:35 +0000
+++ openlp/plugins/alerts/lib/alertstab.py	2010-06-14 13:41:36 +0000
@@ -214,11 +214,13 @@
             translate(u'AlertsPlugin.AlertsTab', u'Bottom'))
 
     def onBackgroundColorButtonClicked(self):
-        self.bg_color = QtGui.QColorDialog.getColor(
-            QtGui.QColor(self.bg_color), self).name()
-        self.BackgroundColorButton.setStyleSheet(
-            u'background-color: %s' % self.bg_color)
-        self.updateDisplay()
+        new_color = QtGui.QColorDialog.getColor(
+            QtGui.QColor(self.bg_color), self)
+        if new_color.isValid():
+            self.bg_color = new_color.name()
+            self.BackgroundColorButton.setStyleSheet(
+                u'background-color: %s' % self.bg_color)
+            self.updateDisplay()
 
     def onFontComboBoxClicked(self):
         self.updateDisplay()
@@ -227,11 +229,13 @@
         self.location = location
 
     def onFontColorButtonClicked(self):
-        self.font_color = QtGui.QColorDialog.getColor(
-            QtGui.QColor(self.font_color), self).name()
-        self.FontColorButton.setStyleSheet(
-            u'background-color: %s' % self.font_color)
-        self.updateDisplay()
+        new_color = QtGui.QColorDialog.getColor(
+            QtGui.QColor(self.font_color), self)
+        if new_color.isValid():
+            self.font_color = new_color.name()
+            self.FontColorButton.setStyleSheet(
+                u'background-color: %s' % self.font_color)
+            self.updateDisplay()
 
     def onTimeoutSpinBoxChanged(self):
         self.timeout = self.TimeoutSpinBox.value()


Follow ups