mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-05 00:09:32 -04:00
Apply suggestions from code review
This commit is contained in:
parent
7e0e421af7
commit
dcf7a98e0c
@ -28,41 +28,15 @@ def __qcolor_repr__(self: QColor):
|
||||
if not self.isValid():
|
||||
return '<QColor: invalid>'
|
||||
elif self.spec() == QColor.Rgb:
|
||||
return '<QColor: RGB {}, {}, {}, {}>'.format(
|
||||
self.red(),
|
||||
self.green(),
|
||||
self.blue(),
|
||||
self.alpha()
|
||||
)
|
||||
return f'<QColor: RGBA {self.red()}, {self.green()}, {self.blue()}, {self.alpha()}>'
|
||||
elif self.spec() == QColor.Hsv:
|
||||
return '<QColor: HSV {}, {}, {}, {}>'.format(
|
||||
self.hsvHue(),
|
||||
self.hsvSaturation(),
|
||||
self.value(),
|
||||
self.alpha()
|
||||
)
|
||||
return f'<QColor: HSVA {self.hsvHue()}, {self.hsvSaturation()}, {self.value()}, {self.alpha()}>'
|
||||
elif self.spec() == QColor.Cmyk:
|
||||
return '<QColor: CMYK {}, {}, {}, {}, {}>'.format(
|
||||
self.cyan(),
|
||||
self.magenta(),
|
||||
self.yellow(),
|
||||
self.black(),
|
||||
self.alpha()
|
||||
)
|
||||
return f'<QColor: CMYKA {self.cyan()}, {self.magenta()}, {self.yellow()}, {self.black()}, {self.alpha()}>'
|
||||
elif self.spec() == QColor.Hsl:
|
||||
return '<QColor: HSL {}, {}, {}, {}>'.format(
|
||||
self.hslHue(),
|
||||
self.hslSaturation(),
|
||||
self.lightness(),
|
||||
self.alpha()
|
||||
)
|
||||
return f'<QColor: HSLA {self.hslHue()}, {self.hslSaturation()}, {self.lightness()}, {self.alpha()}>'
|
||||
elif self.spec() == QColor.ExtendedRgb:
|
||||
return '<QColor: Extended RGB {}, {}, {}, {}>'.format(
|
||||
self.redF(),
|
||||
self.greenF(),
|
||||
self.blueF(),
|
||||
self.alphaF()
|
||||
)
|
||||
return f'<QColor: Extended RGBA {self.redF()}, {self.greenF()}, {self.blueF()}, {self.alphaF()}>'
|
||||
|
||||
|
||||
# PyQt doesn't provide __repr__ for QColor, but it's highly desirable!
|
||||
|
Loading…
x
Reference in New Issue
Block a user