diff --git a/imgsrc/edit_copy.svg b/imgsrc/edit-copy.svg
similarity index 100%
rename from imgsrc/edit_copy.svg
rename to imgsrc/edit-copy.svg
diff --git a/imgsrc/edit-cut.svg b/imgsrc/edit-cut.svg
new file mode 100644
index 0000000000..f078b52e04
--- /dev/null
+++ b/imgsrc/edit-cut.svg
@@ -0,0 +1,831 @@
+
+
+
diff --git a/imgsrc/edit-paste.svg b/imgsrc/edit-paste.svg
new file mode 100644
index 0000000000..d22a8bb7dd
--- /dev/null
+++ b/imgsrc/edit-paste.svg
@@ -0,0 +1,3302 @@
+
+
+
\ No newline at end of file
diff --git a/imgsrc/swap.svg b/imgsrc/swap.svg
deleted file mode 100644
index aa62316b34..0000000000
--- a/imgsrc/swap.svg
+++ /dev/null
@@ -1,722 +0,0 @@
-
-
-
diff --git a/resources/images/edit_copy.png b/resources/images/edit-copy.png
similarity index 100%
rename from resources/images/edit_copy.png
rename to resources/images/edit-copy.png
diff --git a/resources/images/edit-cut.png b/resources/images/edit-cut.png
new file mode 100644
index 0000000000..b995283754
Binary files /dev/null and b/resources/images/edit-cut.png differ
diff --git a/resources/images/edit-paste.png b/resources/images/edit-paste.png
new file mode 100644
index 0000000000..b790efec25
Binary files /dev/null and b/resources/images/edit-paste.png differ
diff --git a/resources/images/edit-redo.png b/resources/images/edit-redo.png
new file mode 100644
index 0000000000..8de333fe8c
Binary files /dev/null and b/resources/images/edit-redo.png differ
diff --git a/resources/images/edit-undo.png b/resources/images/edit-undo.png
new file mode 100644
index 0000000000..f6d7e8ba56
Binary files /dev/null and b/resources/images/edit-undo.png differ
diff --git a/resources/images/format-text-subscript.png b/resources/images/format-text-subscript.png
new file mode 100644
index 0000000000..7da8882aea
Binary files /dev/null and b/resources/images/format-text-subscript.png differ
diff --git a/resources/images/format-text-superscript.png b/resources/images/format-text-superscript.png
new file mode 100644
index 0000000000..9dc31ab783
Binary files /dev/null and b/resources/images/format-text-superscript.png differ
diff --git a/resources/images/swap.png b/resources/images/swap.png
index e5aeb60e22..7f8d40ca1d 100644
Binary files a/resources/images/swap.png and b/resources/images/swap.png differ
diff --git a/src/calibre/gui2/comments_editor.py b/src/calibre/gui2/comments_editor.py
index 8438fa3cfc..a73181164f 100644
--- a/src/calibre/gui2/comments_editor.py
+++ b/src/calibre/gui2/comments_editor.py
@@ -9,26 +9,65 @@ __docformat__ = 'restructuredtext en'
from lxml import html
from lxml.html import soupparser
-from PyQt4.Qt import QApplication, QFontInfo, QPalette, QSize, QWidget, \
- QToolBar, QVBoxLayout, QAction, QIcon
+from PyQt4.Qt import QApplication, QFontInfo, QSize, QWidget, \
+ QToolBar, QVBoxLayout, QAction, QIcon, QWebPage, Qt
from PyQt4.QtWebKit import QWebView
from calibre.ebooks.chardet import xml_to_unicode
from calibre import xml_replace_entities
+
+class PageAction(QAction):
+
+ def __init__(self, wac, icon, text, checkable, view):
+ QAction.__init__(self, QIcon(I(icon+'.png')), text, view)
+ self._page_action = getattr(QWebPage, wac)
+ self.setCheckable(checkable)
+ self.triggered.connect(self.trigger_page_action)
+ view.selectionChanged.connect(self.update_state,
+ type=Qt.QueuedConnection)
+ self.page_action.changed.connect(self.update_state,
+ type=Qt.QueuedConnection)
+
+ @property
+ def page_action(self):
+ return self.parent().pageAction(self._page_action)
+
+ def trigger_page_action(self, *args):
+ self.page_action.trigger()
+
+ def update_state(self, *args):
+ if self.isCheckable():
+ self.setChecked(self.page_action.isChecked())
+ self.setEnabled(self.page_action.isEnabled())
+
+
class EditorWidget(QWebView):
def __init__(self, parent=None):
QWebView.__init__(self, parent)
- for name, icon, text, checkable in [
- ('bold', 'format-text-bold', _('Bold'), True),
- ('italic', 'format-text-italic', _('Italic'), True),
- ('underline', 'format-text-underline', _('Underline'), True),
- ('strikethrough', 'format-text-underline', _('Underline'), True),
+ for wac, name, icon, text, checkable in [
+ ('ToggleBold', 'bold', 'format-text-bold', _('Bold'), True),
+ ('ToggleItalic', 'italic', 'format-text-italic', _('Italic'),
+ True),
+ ('ToggleUnderline', 'underline', 'format-text-underline',
+ _('Underline'), True),
+ ('ToggleStrikethrough', 'strikethrough', 'format-text-strikethrough',
+ _('Strikethrough'), True),
+ ('ToggleSuperscript', 'superscript', 'format-text-superscript',
+ _('Superscript'), True),
+ ('ToggleSubscript', 'subscript', 'format-text-subscript',
+ _('Subscript'), True),
+
+ ('Undo', 'undo', 'edit-undo', _('Undo'), False),
+ ('Redo', 'redo', 'edit-redo', _('Redo'), False),
+ ('Copy', 'copy', 'edit-copy', _('Copy'), False),
+ ('Paste', 'paste', 'edit-paste', _('Paste'), False),
+ ('Cut', 'cut', 'edit-cut', _('Cut'), False),
+
]:
- ac = QAction(QIcon(I(icon+'.png')), text, self)
- ac.setCheckable(checkable)
+ ac = PageAction(wac, icon, text, checkable, self)
setattr(self, 'action_'+name, ac)
def sizeHint(self):
@@ -67,12 +106,7 @@ class EditorWidget(QWebView):
def fset(self, val):
self.setHtml(val)
f = QFontInfo(QApplication.font(self)).pixelSize()
- b = unicode(QApplication.palette().color(QPalette.Normal,
- QPalette.Base).name())
- c = unicode(QApplication.palette().color(QPalette.Normal,
- QPalette.Text).name())
- style = 'font-size: %dpx; background-color: %s; color: %s' % (f, b,
- c)
+ style = 'font-size: %dpx;' % (f,)
for body in self.page().mainFrame().documentElement().findAll('body'):
body.setAttribute('style', style)
diff --git a/src/calibre/gui2/viewer/main.ui b/src/calibre/gui2/viewer/main.ui
index 4cfa1590da..d470a386c6 100644
--- a/src/calibre/gui2/viewer/main.ui
+++ b/src/calibre/gui2/viewer/main.ui
@@ -243,7 +243,7 @@
- :/images/edit_copy.png:/images/edit_copy.png
+ :/images/edit-copy.png:/images/edit-copy.png
Copy to clipboard