Working text bold shortcut and toolbar
This commit is contained in:
+18
-1
@@ -230,6 +230,22 @@ class GuiDocEditor(QWidget):
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
##
|
||||||
|
# Key Shortcut Handlers
|
||||||
|
##
|
||||||
|
|
||||||
|
def _doBold(self):
|
||||||
|
theCursor = self.guiEditor.textCursor()
|
||||||
|
if theCursor.hasSelection():
|
||||||
|
selBeg = theCursor.selectionStart()
|
||||||
|
selEnd = theCursor.selectionEnd()
|
||||||
|
selText = theCursor.selectedText()
|
||||||
|
theText = "**%s**" % theCursor.selectedText()
|
||||||
|
theCursor.removeSelectedText()
|
||||||
|
theCursor.setPosition(selBeg)
|
||||||
|
self.guiEditor.textCursor().insertText(theText)
|
||||||
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
# GUI Builder
|
# GUI Builder
|
||||||
##
|
##
|
||||||
@@ -241,8 +257,9 @@ class GuiDocEditor(QWidget):
|
|||||||
|
|
||||||
# Text > Bold
|
# Text > Bold
|
||||||
tbTextBold = QAction(QIcon.fromTheme("format-text-bold"), "Bold (Ctrl+B)", toolBar)
|
tbTextBold = QAction(QIcon.fromTheme("format-text-bold"), "Bold (Ctrl+B)", toolBar)
|
||||||
tbTextBold.setShortcut("Ctrl+B")
|
|
||||||
tbTextBold.setStatusTip("Toggle Selected Text Bold")
|
tbTextBold.setStatusTip("Toggle Selected Text Bold")
|
||||||
|
tbTextBold.setShortcut("Ctrl+B")
|
||||||
|
tbTextBold.triggered.connect(self._doBold)
|
||||||
toolBar.addAction(tbTextBold)
|
toolBar.addAction(tbTextBold)
|
||||||
|
|
||||||
# Text > Italics
|
# Text > Italics
|
||||||
|
|||||||
+34
-34
@@ -377,48 +377,48 @@ class GuiMain(QMainWindow):
|
|||||||
|
|
||||||
############################################################################################
|
############################################################################################
|
||||||
|
|
||||||
# Format
|
# # Format
|
||||||
formatMenu = menuBar.addMenu("&Format")
|
# formatMenu = menuBar.addMenu("&Format")
|
||||||
|
|
||||||
# Format > Font Style
|
# # Format > Font Style
|
||||||
menuFont = QAction(QIcon.fromTheme("preferences-desktop-font"), "Font Family", menuBar)
|
# menuFont = QAction(QIcon.fromTheme("preferences-desktop-font"), "Font Family", menuBar)
|
||||||
menuFont.setStatusTip("Set Font for Selected text")
|
# menuFont.setStatusTip("Set Font for Selected text")
|
||||||
formatMenu.addAction(menuFont)
|
# formatMenu.addAction(menuFont)
|
||||||
|
|
||||||
# Format > Separator
|
# # Format > Separator
|
||||||
formatMenu.addSeparator()
|
# formatMenu.addSeparator()
|
||||||
|
|
||||||
# Format > Bold
|
# # Format > Bold
|
||||||
menuBold = QAction(QIcon.fromTheme("format-text-bold"), "Bold Text", menuBar)
|
# menuBold = QAction(QIcon.fromTheme("format-text-bold"), "Bold Text", menuBar)
|
||||||
menuBold.setShortcut("Ctrl+B")
|
# menuBold.setShortcut("Ctrl+B")
|
||||||
menuBold.setStatusTip("Toggle Bold for Selected Text")
|
# menuBold.setStatusTip("Toggle Bold for Selected Text")
|
||||||
formatMenu.addAction(menuBold)
|
# formatMenu.addAction(menuBold)
|
||||||
|
|
||||||
# Format > Italic
|
# # Format > Italic
|
||||||
menuItalic = QAction(QIcon.fromTheme("format-text-italic"), "Italic Text", menuBar)
|
# menuItalic = QAction(QIcon.fromTheme("format-text-italic"), "Italic Text", menuBar)
|
||||||
menuItalic.setShortcut("Ctrl+I")
|
# menuItalic.setShortcut("Ctrl+I")
|
||||||
menuItalic.setStatusTip("Toggle Italic for Selected Text")
|
# menuItalic.setStatusTip("Toggle Italic for Selected Text")
|
||||||
formatMenu.addAction(menuItalic)
|
# formatMenu.addAction(menuItalic)
|
||||||
|
|
||||||
# Format > Underline
|
# # Format > Underline
|
||||||
menuUnderline = QAction(QIcon.fromTheme("format-text-underline"), "Underline Text", menuBar)
|
# menuUnderline = QAction(QIcon.fromTheme("format-text-underline"), "Underline Text", menuBar)
|
||||||
menuUnderline.setShortcut("Ctrl+U")
|
# menuUnderline.setShortcut("Ctrl+U")
|
||||||
menuUnderline.setStatusTip("Toggle Underline for Selected Text")
|
# menuUnderline.setStatusTip("Toggle Underline for Selected Text")
|
||||||
formatMenu.addAction(menuUnderline)
|
# formatMenu.addAction(menuUnderline)
|
||||||
|
|
||||||
# Format > Strikethrough
|
# # Format > Strikethrough
|
||||||
menuStrikethrough = QAction(QIcon.fromTheme("format-text-strikethrough"), "Strikethrough Text", menuBar)
|
# menuStrikethrough = QAction(QIcon.fromTheme("format-text-strikethrough"), "Strikethrough Text", menuBar)
|
||||||
menuStrikethrough.setShortcut("Ctrl+D")
|
# menuStrikethrough.setShortcut("Ctrl+D")
|
||||||
menuStrikethrough.setStatusTip("Toggle Strikethrough for Selected Text")
|
# menuStrikethrough.setStatusTip("Toggle Strikethrough for Selected Text")
|
||||||
formatMenu.addAction(menuStrikethrough)
|
# formatMenu.addAction(menuStrikethrough)
|
||||||
|
|
||||||
# Format > Separator
|
# # Format > Separator
|
||||||
formatMenu.addSeparator()
|
# formatMenu.addSeparator()
|
||||||
|
|
||||||
# Format > Clear
|
# # Format > Clear
|
||||||
menuClear = QAction(QIcon.fromTheme("edit-clear"), "Clear Formatting", menuBar)
|
# menuClear = QAction(QIcon.fromTheme("edit-clear"), "Clear Formatting", menuBar)
|
||||||
menuClear.setStatusTip("Clear Formatting for Selected Text")
|
# menuClear.setStatusTip("Clear Formatting for Selected Text")
|
||||||
formatMenu.addAction(menuClear)
|
# formatMenu.addAction(menuClear)
|
||||||
|
|
||||||
############################################################################################
|
############################################################################################
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user