|
@@ -1,4 +1,3 @@
|
|
-# flake8: noqa
|
|
|
|
#
|
|
#
|
|
# Copyright (C) 2011 Michael Pitidis, Hussein Abdulwahid.
|
|
# Copyright (C) 2011 Michael Pitidis, Hussein Abdulwahid.
|
|
#
|
|
#
|
|
@@ -19,28 +18,24 @@
|
|
#
|
|
#
|
|
|
|
|
|
try:
|
|
try:
|
|
- from PyQt5.QtGui import *
|
|
|
|
- from PyQt5.QtCore import *
|
|
|
|
- from PyQt5.QtWidgets import *
|
|
|
|
|
|
+ from PyQt5 import QtWidgets
|
|
except ImportError:
|
|
except ImportError:
|
|
- from PyQt4.QtGui import *
|
|
|
|
- from PyQt4.QtCore import *
|
|
|
|
|
|
+ from PyQt4 import QtGui as QtWidgets
|
|
|
|
|
|
|
|
|
|
-BB = QDialogButtonBox
|
|
|
|
|
|
+class ColorDialog(QtWidgets.QColorDialog):
|
|
|
|
|
|
-class ColorDialog(QColorDialog):
|
|
|
|
def __init__(self, parent=None):
|
|
def __init__(self, parent=None):
|
|
super(ColorDialog, self).__init__(parent)
|
|
super(ColorDialog, self).__init__(parent)
|
|
- self.setOption(QColorDialog.ShowAlphaChannel)
|
|
|
|
|
|
+ self.setOption(QtWidgets.QColorDialog.ShowAlphaChannel)
|
|
# The Mac native dialog does not support our restore button.
|
|
# The Mac native dialog does not support our restore button.
|
|
- self.setOption(QColorDialog.DontUseNativeDialog)
|
|
|
|
- ## Add a restore defaults button.
|
|
|
|
|
|
+ self.setOption(QtWidgets.QColorDialog.DontUseNativeDialog)
|
|
|
|
+ # Add a restore defaults button.
|
|
# The default is set at invocation time, so that it
|
|
# The default is set at invocation time, so that it
|
|
# works across dialogs for different elements.
|
|
# works across dialogs for different elements.
|
|
self.default = None
|
|
self.default = None
|
|
self.bb = self.layout().itemAt(1).widget()
|
|
self.bb = self.layout().itemAt(1).widget()
|
|
- self.bb.addButton(BB.RestoreDefaults)
|
|
|
|
|
|
+ self.bb.addButton(QtWidgets.QDialogButtonBox.RestoreDefaults)
|
|
self.bb.clicked.connect(self.checkRestore)
|
|
self.bb.clicked.connect(self.checkRestore)
|
|
|
|
|
|
def getColor(self, value=None, title=None, default=None):
|
|
def getColor(self, value=None, title=None, default=None):
|
|
@@ -52,6 +47,6 @@ class ColorDialog(QColorDialog):
|
|
return self.currentColor() if self.exec_() else None
|
|
return self.currentColor() if self.exec_() else None
|
|
|
|
|
|
def checkRestore(self, button):
|
|
def checkRestore(self, button):
|
|
- if self.bb.buttonRole(button) & BB.ResetRole and self.default:
|
|
|
|
|
|
+ if self.bb.buttonRole(button) & \
|
|
|
|
+ QtWidgets.QDialogButtonBox.ResetRole and self.default:
|
|
self.setCurrentColor(self.default)
|
|
self.setCurrentColor(self.default)
|
|
-
|
|
|