Handle OS X installs with invalid palette colors. See #1014900

This commit is contained in:
Kovid Goyal 2012-06-19 09:06:15 +05:30
parent 9da816dcfe
commit 99f410acf8

View File

@ -7,7 +7,7 @@ from urllib import unquote
from PyQt4.Qt import (QVariant, QFileInfo, QObject, SIGNAL, QBuffer, Qt,
QByteArray, QTranslator, QCoreApplication, QThread,
QEvent, QTimer, pyqtSignal, QDateTime, QDesktopServices,
QFileDialog, QFileIconProvider, QSettings,
QFileDialog, QFileIconProvider, QSettings, QColor,
QIcon, QApplication, QDialog, QUrl, QFont, QPalette)
ORG_NAME = 'KovidsBrain'
@ -738,11 +738,18 @@ class Application(QApplication):
def load_calibre_style(self):
# On OS X QtCurve resets the palette, so we preserve it explicitly
orig_pal = QPalette(self.palette())
from calibre.constants import plugins
pi = plugins['progress_indicator'][0]
path = os.path.join(sys.extensions_location, 'calibre_style.'+(
'pyd' if iswindows else 'so'))
pi.load_style(path, 'Calibre')
# On OSX, on some machines, colors can be invalid. See https://bugs.launchpad.net/bugs/1014900
for role in (orig_pal.Button, orig_pal.Window):
c = orig_pal.brush(role).color()
if not c.isValid() or not c.toRgb().isValid():
orig_pal.setColor(role, QColor(u'lightgray'))
self.setPalette(orig_pal)
style = self.style()
icon_map = {}