QScintilla/EditorButtonsWidget.py

changeset 5407
f833f89571b8
parent 5404
6b19ad5470a3
child 5411
a163fbbf2bea
--- a/QScintilla/EditorButtonsWidget.py	Sun Jan 08 18:51:55 2017 +0100
+++ b/QScintilla/EditorButtonsWidget.py	Sun Jan 08 18:52:16 2017 +0100
@@ -35,9 +35,10 @@
         super(EditorButtonsWidget, self).__init__(parent)
         
         margin = 2
+        spacing = 3
         self.__layout = QVBoxLayout(self)
         self.__layout.setContentsMargins(margin, margin, margin, margin)
-        self.__layout.setSpacing(2)
+        self.__layout.setSpacing(spacing)
         
         self.__provider = None
         
@@ -63,26 +64,46 @@
         self.__separators = []
         self.__headerMenu = QMenu()
         
-        self.__addButton("bold", "formatTextBold.png")
-        self.__addButton("italic", "formatTextItalic.png")
-        self.__addButton("strikethrough", "formatTextStrikethrough.png")
+        self.__addButton("bold", "formatTextBold.png",
+                         self.tr("Bold"))
+        self.__addButton("italic", "formatTextItalic.png",
+                         self.tr("Italic"))
+        self.__addButton("strikethrough", "formatTextStrikethrough.png",
+                         self.tr("Strike Through"))
         self.__addSeparator()
-        self.__addButton("header1", "formatTextHeader1.png")
-        self.__addButton("header2", "formatTextHeader2.png")
-        self.__addButton("header3", "formatTextHeader3.png")
-        button = self.__addButton("header", "formatTextHeader.png")
+        self.__addButton("header1", "formatTextHeader1.png",
+                         self.tr("Header 1"))
+        self.__addButton("header2", "formatTextHeader2.png",
+                         self.tr("Header 2"))
+        self.__addButton("header3", "formatTextHeader3.png",
+                         self.tr("Header 3"))
+        button = self.__addButton("header", "formatTextHeader.png",
+                                  self.tr("Header"))
         button.setPopupMode(QToolButton.InstantPopup)
         button.setMenu(self.__headerMenu)
         self.__addSeparator()
-        self.__addButton("code", "formatTextInlineCode.png")
-        self.__addButton("codeBlock", "formatTextCodeBlock.png")
+        self.__addButton("code", "formatTextInlineCode.png",
+                         self.tr("Inline Code"))
+        self.__addButton("codeBlock", "formatTextCodeBlock.png",
+                         self.tr("Code Block"))
+        self.__addButton("quote", "formatTextQuote.png",
+                         self.tr("Quote"))
         self.__addSeparator()
-        self.__addButton("hyperlink", "formatTextHyperlink.png")
-        self.__addButton("line", "formatTextHorizontalLine.png")
+        self.__addButton("hyperlink", "formatTextHyperlink.png",
+                         self.tr("Add Hyperlink"))
+        self.__addButton("line", "formatTextHorizontalLine.png",
+                         self.tr("Add Horizontal Line"))
+        self.__addButton("image", "formatTextImage.png",
+                         self.tr("Add Image"))
+        self.__addSeparator()
+        self.__addButton("bulletedList", "formatTextBulletedList.png",
+                         self.tr("Add Bulleted List"))
+        self.__addButton("numberedList", "formatTextNumberedList.png",
+                         self.tr("Add Numbered List"))
         
         self.__headerMenu.triggered.connect(self.__headerMenuTriggered)
     
-    def __addButton(self, format, iconName):
+    def __addButton(self, format, iconName, toolTip):
         """
         Private method to add a format button.
         
@@ -90,11 +111,14 @@
         @type str
         @param iconName name of the icon for the button
         @type str
+        @param toolTip text for the tool tip
+        @type str
         @return generated button
         @rtype QToolButton
         """
         button = QToolButton(self)
         button.setIcon(UI.PixmapCache.getIcon(iconName))
+        button.setToolTip(toolTip)
         button.clicked.connect(lambda: self.__formatClicked(format))
         self.__layout.addWidget(button)
         self.__buttons[format] = button
@@ -174,10 +198,14 @@
             self.__provider.code(self.__editor)
         elif format == "codeBlock":
             self.__provider.codeBlock(self.__editor)
+        elif format == "quote":
+            self.__provider.quote(self.__editor)
         elif format == "hyperlink":
             self.__provider.hyperlink(self.__editor)
         elif format == "line":
             self.__provider.line(self.__editor)
+        elif format == "image":
+            self.__provider.image(self.__editor)
     
     def __headerMenuTriggered(self, act):
         """
@@ -195,7 +223,12 @@
         """
         hasSelection = self.__editor.hasSelectedText()
         if self.__provider:
+            self.__buttons["quote"].setEnabled(
+                self.__provider.hasQuote() and (
+                self.__provider.kind() == "html" or hasSelection))
             self.__buttons["hyperlink"].setEnabled(
                 self.__provider.hasHyperlink() and not hasSelection)
             self.__buttons["line"].setEnabled(
                 self.__provider.hasLine() and not hasSelection)
+            self.__buttons["image"].setEnabled(
+                self.__provider.hasImage() and not hasSelection)

eric ide

mercurial