Fix #1397183 [Stand Alone Comments - Editor OK button & cell highlight](https://bugs.launchpad.net/calibre/+bug/1397183)

This commit is contained in:
Kovid Goyal 2014-11-28 12:04:15 +05:30
parent 261eae0758
commit c049cdfe8d
2 changed files with 16 additions and 12 deletions

View File

@ -5,7 +5,7 @@ __license__ = 'GPL v3'
from PyQt5.Qt import Qt, QDialog, QDialogButtonBox from PyQt5.Qt import Qt, QDialog, QDialogButtonBox
from calibre.gui2 import gprefs from calibre.gui2 import gprefs, Application
from calibre.gui2.dialogs.comments_dialog_ui import Ui_CommentsDialog from calibre.gui2.dialogs.comments_dialog_ui import Ui_CommentsDialog
from calibre.library.comments import comments_to_html from calibre.library.comments import comments_to_html
@ -23,7 +23,7 @@ class CommentsDialog(QDialog, Ui_CommentsDialog):
self.textbox.html = comments_to_html(text) if text else '' self.textbox.html = comments_to_html(text) if text else ''
self.textbox.wyswyg_dirtied() self.textbox.wyswyg_dirtied()
# self.textbox.setTabChangesFocus(True) # self.textbox.setTabChangesFocus(True)
self.buttonBox.button(QDialogButtonBox.Ok).setText(_('&OK')) self.buttonBox.button(QDialogButtonBox.Ok).setText(_('O&K'))
self.buttonBox.button(QDialogButtonBox.Cancel).setText(_('&Cancel')) self.buttonBox.button(QDialogButtonBox.Cancel).setText(_('&Cancel'))
if column_name: if column_name:
@ -48,3 +48,9 @@ class CommentsDialog(QDialog, Ui_CommentsDialog):
self.save_geometry() self.save_geometry()
return QDialog.closeEvent(self, ev) return QDialog.closeEvent(self, ev)
if __name__ == '__main__':
app = Application([])
d = CommentsDialog(None, 'testing', 'Comments')
d.exec_()
del d
del app

View File

@ -416,17 +416,15 @@ class CcCommentsDelegate(QStyledItemDelegate): # {{{
else option.widget.style() else option.widget.style()
self.document.setHtml(option.text) self.document.setHtml(option.text)
option.text = u'' option.text = u''
if hasattr(QStyle, 'CE_ItemViewItem'): style.drawPrimitive(QStyle.PE_PanelItemViewItem, option, painter, widget=option.widget)
style.drawControl(QStyle.CE_ItemViewItem, option, painter)
ctx = QAbstractTextDocumentLayout.PaintContext() ctx = QAbstractTextDocumentLayout.PaintContext()
ctx.palette = option.palette # .setColor(QPalette.Text, QColor("red")); ctx.palette = option.palette
if hasattr(QStyle, 'SE_ItemViewItemText'): textRect = style.subElementRect(QStyle.SE_ItemViewItemText, option)
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, option) painter.save()
painter.save() painter.translate(textRect.topLeft())
painter.translate(textRect.topLeft()) painter.setClipRect(textRect.translated(-textRect.topLeft()))
painter.setClipRect(textRect.translated(-textRect.topLeft())) self.document.documentLayout().draw(painter, ctx)
self.document.documentLayout().draw(painter, ctx) painter.restore()
painter.restore()
def createEditor(self, parent, option, index): def createEditor(self, parent, option, index):
m = index.model() m = index.model()