--- a/eric6/E5Gui/E5Application.py Wed Apr 01 19:50:41 2020 +0200 +++ b/eric6/E5Gui/E5Application.py Fri Apr 03 17:43:01 2020 +0200 @@ -9,6 +9,7 @@ from PyQt5.QtCore import Qt, QCoreApplication +from PyQt5.QtGui import QPalette from PyQt5.QtWidgets import QApplication @@ -21,6 +22,7 @@ Constructor @param argv command line arguments + @type list """ try: QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling) @@ -44,40 +46,47 @@ self.__objectRegistry = {} self.__pluginObjectRegistry = {} - + def registerObject(self, name, objectRef): """ Public method to register an object in the object registry. - @param name name of the object (string) + @param name name of the object + @type str @param objectRef reference to the object + @type any @exception KeyError raised when the given name is already in use """ if name in self.__objectRegistry: raise KeyError('Object "{0}" already registered.'.format(name)) else: self.__objectRegistry[name] = objectRef - + def getObject(self, name): """ Public method to get a reference to a registered object. - @param name name of the object (string) + @param name name of the object + @type str @return reference to the registered object + @type any @exception KeyError raised when the given name is not known """ if name in self.__objectRegistry: return self.__objectRegistry[name] else: raise KeyError('Object "{0}" is not registered.'.format(name)) - + def registerPluginObject(self, name, objectRef, pluginType=None): """ Public method to register a plugin object in the object registry. - @param name name of the plugin object (string) + @param name name of the plugin object + @type str @param objectRef reference to the plugin object - @keyparam pluginType type of the plugin object (string) + @type any + @param pluginType type of the plugin object + @type str @exception KeyError raised when the given name is already in use """ if name in self.__pluginObjectRegistry: @@ -85,22 +94,25 @@ 'Pluginobject "{0}" already registered.'.format(name)) else: self.__pluginObjectRegistry[name] = (objectRef, pluginType) - + def unregisterPluginObject(self, name): """ Public method to unregister a plugin object in the object registry. - @param name name of the plugin object (string) + @param name name of the plugin object + @type str """ if name in self.__pluginObjectRegistry: del self.__pluginObjectRegistry[name] - + def getPluginObject(self, name): """ Public method to get a reference to a registered plugin object. - @param name name of the plugin object (string) + @param name name of the plugin object + @type str @return reference to the registered plugin object + @rtype any @exception KeyError raised when the given name is not known """ if name in self.__pluginObjectRegistry: @@ -108,25 +120,28 @@ else: raise KeyError( 'Pluginobject "{0}" is not registered.'.format(name)) - + def getPluginObjects(self): """ Public method to get a list of (name, reference) pairs of all registered plugin objects. @return list of (name, reference) pairs + @rtype list of (str, any) """ objects = [] for name in self.__pluginObjectRegistry: objects.append((name, self.__pluginObjectRegistry[name][0])) return objects - + def getPluginObjectType(self, name): """ Public method to get the type of a registered plugin object. - @param name name of the plugin object (string) - @return type of the plugin object (string) + @param name name of the plugin object + @type str + @return type of the plugin object + @rtype str @exception KeyError raised when the given name is not known """ if name in self.__pluginObjectRegistry: @@ -134,5 +149,17 @@ else: raise KeyError( 'Pluginobject "{0}" is not registered.'.format(name)) + + def usesDarkPalette(self): + """ + Public method to check, if the application uses a palette with a dark + background. + + @return flag indicating the use of a palette with a dark background + @rtype bool + """ + palette = self.palette() + lightness = palette.color(QPalette.Window).lightness() + return lightness <= 128 e5App = QCoreApplication.instance