eric6/QScintilla/EditorButtonsWidget.py

Sun, 12 Apr 2020 19:07:49 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 12 Apr 2020 19:07:49 +0200
changeset 7533
88261c96484b
parent 7360
9190402e4505
child 7781
607a6098cb44
permissions
-rw-r--r--

Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.

5394
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7360
9190402e4505 Updated copyright for 2020.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7267
diff changeset
3 # Copyright (c) 2017 - 2020 Detlev Offenbach <detlev@die-offenbachs.de>
5394
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a widget containing various buttons for accessing
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 editor actions.
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9 """
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
5411
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
12 from PyQt5.QtCore import pyqtSlot, Qt
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
13 from PyQt5.QtWidgets import (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
14 QWidget, QVBoxLayout, QToolButton, QFrame, QMenu, QSizePolicy, QScrollArea
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
15 )
5394
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 import UI.PixmapCache
5416
16366120b523 Added an option to hide the format buttons bar, if formatting is not supported for the editor text type (only supported for HTML, Markdown and reStructured Text).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5412
diff changeset
18 import Preferences
5394
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 from . import MarkupProviders
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 class EditorButtonsWidget(QWidget):
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 """
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 Class implementing a widget containing various buttons for accessing
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 editor actions.
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 """
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 def __init__(self, editor, parent=None):
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 """
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 Constructor
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 @param editor reference to the editor
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 @type Editor
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 @param parent reference to the parent widget
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 @type QWidget
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 """
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 super(EditorButtonsWidget, self).__init__(parent)
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38
5398
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
39 margin = 2
5407
f833f89571b8 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5404
diff changeset
40 spacing = 3
5411
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
41
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
42 self.__buttonsWidget = QWidget(self)
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
43
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
44 self.__layout = QVBoxLayout(self.__buttonsWidget)
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
45 self.__layout.setContentsMargins(0, 0, 0, 0)
5407
f833f89571b8 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5404
diff changeset
46 self.__layout.setSpacing(spacing)
5394
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 self.__provider = None
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 self.__editor = editor
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 self.__editor.languageChanged.connect(self.__updateButtonStates)
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 self.__editor.editorSaved.connect(self.__updateButtonStates)
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 self.__editor.editorRenamed.connect(self.__updateButtonStates)
5404
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5402
diff changeset
54 self.__editor.selectionChanged.connect(self.__editorSelectionChanged)
5416
16366120b523 Added an option to hide the format buttons bar, if formatting is not supported for the editor text type (only supported for HTML, Markdown and reStructured Text).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5412
diff changeset
55 self.__editor.settingsRead.connect(self.__editorSettingsRead)
5394
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 self.__createButtons()
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 self.__layout.addStretch()
5411
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
60
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
61 self.__outerLayout = QVBoxLayout(self)
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
62 self.__outerLayout.setContentsMargins(margin, margin, margin, margin)
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
63 self.__outerLayout.setSpacing(spacing)
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
64 self.__outerLayout.setAlignment(Qt.AlignHCenter)
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
65
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
66 self.__upButton = QToolButton(self)
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
67 self.__upButton.setArrowType(Qt.UpArrow)
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
68 self.__upButton.setSizePolicy(
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
69 QSizePolicy.MinimumExpanding, QSizePolicy.Minimum)
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
70 self.__upButton.setAutoRepeat(True)
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
71
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
72 self.__scroller = QScrollArea(self)
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
73 self.__scroller.setWidget(self.__buttonsWidget)
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
74 self.__scroller.setSizePolicy(
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
75 QSizePolicy.Minimum, QSizePolicy.Expanding)
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
76 self.__scroller.setFrameShape(QFrame.NoFrame)
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
77 self.__scroller.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
78 self.__scroller.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
79 self.__scroller.setWidgetResizable(False)
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
80
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
81 self.__downButton = QToolButton(self)
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
82 self.__downButton.setArrowType(Qt.DownArrow)
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
83 self.__downButton.setSizePolicy(
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
84 QSizePolicy.MinimumExpanding, QSizePolicy.Minimum)
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
85 self.__downButton.setAutoRepeat(True)
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
86
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
87 self.__outerLayout.addWidget(self.__upButton)
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
88 self.__outerLayout.addWidget(self.__scroller)
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
89 self.__outerLayout.addWidget(self.__downButton)
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
90
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
91 self.__upButton.clicked.connect(self.__slideUp)
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
92 self.__downButton.clicked.connect(self.__slideDown)
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
93
5398
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
94 self.setMaximumWidth(
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
95 self.__buttons["bold"].sizeHint().width() + 2 * margin)
5394
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 self.__updateButtonStates()
5411
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
98
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
99 #######################################################################
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
100 ## Methods below implement some event handlers
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
101 #######################################################################
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
102
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
103 def show(self):
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
104 """
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
105 Public slot to show the widget.
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
106 """
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
107 super(EditorButtonsWidget, self).show()
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
108 self.__enableScrollerButtons()
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
109
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
110 def resizeEvent(self, evt):
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
111 """
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
112 Protected method to handle resize events.
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
113
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
114 @param evt reference to the resize event (QResizeEvent)
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
115 """
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
116 self.__enableScrollerButtons()
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
117 super(EditorButtonsWidget, self).resizeEvent(evt)
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
118
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
119 #######################################################################
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
120 ## Methods below implement scroller related functions
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
121 #######################################################################
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
122
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
123 def __enableScrollerButtons(self):
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
124 """
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
125 Private method to set the enabled state of the scroll buttons.
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
126 """
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
127 scrollBar = self.__scroller.verticalScrollBar()
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
128 self.__upButton.setEnabled(scrollBar.value() > 0)
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
129 self.__downButton.setEnabled(scrollBar.value() < scrollBar.maximum())
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
130
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
131 def __slideUp(self):
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
132 """
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
133 Private slot to move the widget upwards, i.e. show contents to the
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
134 bottom.
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
135 """
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
136 self.__slide(True)
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
137
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
138 def __slideDown(self):
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
139 """
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
140 Private slot to move the widget downwards, i.e. show contents to
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
141 the top.
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
142 """
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
143 self.__slide(False)
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
144
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
145 def __slide(self, up):
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
146 """
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
147 Private method to move the sliding widget.
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
148
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
149 @param up flag indicating to move upwards (boolean)
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
150 """
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
151 scrollBar = self.__scroller.verticalScrollBar()
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
152 stepSize = scrollBar.singleStep()
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
153 if up:
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
154 stepSize = -stepSize
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
155 newValue = scrollBar.value() + stepSize
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
156 if newValue < 0:
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
157 newValue = 0
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
158 elif newValue > scrollBar.maximum():
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
159 newValue = scrollBar.maximum()
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
160 scrollBar.setValue(newValue)
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
161 self.__enableScrollerButtons()
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
162
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
163 #######################################################################
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
164 ## Methods below implement the format button functions
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
165 #######################################################################
5394
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 def __createButtons(self):
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 """
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 Private slot to create the various tool buttons.
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 """
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 self.__buttons = {}
5398
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
172 self.__separators = []
5402
ce21a78a5fcf Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5398
diff changeset
173 self.__headerMenu = QMenu()
5394
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
175 self.__addButton("bold", "formatTextBold",
5407
f833f89571b8 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5404
diff changeset
176 self.tr("Bold"))
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
177 self.__addButton("italic", "formatTextItalic",
5407
f833f89571b8 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5404
diff changeset
178 self.tr("Italic"))
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
179 self.__addButton("strikethrough", "formatTextStrikethrough",
5407
f833f89571b8 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5404
diff changeset
180 self.tr("Strike Through"))
5398
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
181 self.__addSeparator()
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
182 self.__addButton("header1", "formatTextHeader1",
5407
f833f89571b8 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5404
diff changeset
183 self.tr("Header 1"))
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
184 self.__addButton("header2", "formatTextHeader2",
5407
f833f89571b8 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5404
diff changeset
185 self.tr("Header 2"))
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
186 self.__addButton("header3", "formatTextHeader3",
5407
f833f89571b8 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5404
diff changeset
187 self.tr("Header 3"))
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
188 button = self.__addButton("header", "formatTextHeader",
5407
f833f89571b8 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5404
diff changeset
189 self.tr("Header"))
5398
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
190 button.setPopupMode(QToolButton.InstantPopup)
5402
ce21a78a5fcf Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5398
diff changeset
191 button.setMenu(self.__headerMenu)
ce21a78a5fcf Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5398
diff changeset
192 self.__addSeparator()
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
193 self.__addButton("code", "formatTextInlineCode",
5407
f833f89571b8 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5404
diff changeset
194 self.tr("Inline Code"))
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
195 self.__addButton("codeBlock", "formatTextCodeBlock",
5407
f833f89571b8 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5404
diff changeset
196 self.tr("Code Block"))
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
197 self.__addButton("quote", "formatTextQuote",
5407
f833f89571b8 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5404
diff changeset
198 self.tr("Quote"))
5404
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5402
diff changeset
199 self.__addSeparator()
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
200 self.__addButton("hyperlink", "formatTextHyperlink",
5407
f833f89571b8 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5404
diff changeset
201 self.tr("Add Hyperlink"))
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
202 self.__addButton("line", "formatTextHorizontalLine",
5407
f833f89571b8 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5404
diff changeset
203 self.tr("Add Horizontal Line"))
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
204 self.__addButton("image", "formatTextImage",
5407
f833f89571b8 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5404
diff changeset
205 self.tr("Add Image"))
f833f89571b8 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5404
diff changeset
206 self.__addSeparator()
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
207 self.__addButton("bulletedList", "formatTextBulletedList",
5407
f833f89571b8 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5404
diff changeset
208 self.tr("Add Bulleted List"))
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
209 self.__addButton("numberedList", "formatTextNumberedList",
5407
f833f89571b8 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5404
diff changeset
210 self.tr("Add Numbered List"))
5402
ce21a78a5fcf Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5398
diff changeset
211
ce21a78a5fcf Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5398
diff changeset
212 self.__headerMenu.triggered.connect(self.__headerMenuTriggered)
5398
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
213
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5416
diff changeset
214 def __addButton(self, formatName, iconName, toolTip):
5398
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
215 """
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
216 Private method to add a format button.
5394
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5416
diff changeset
218 @param formatName unique name of the format
5398
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
219 @type str
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
220 @param iconName name of the icon for the button
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
221 @type str
5407
f833f89571b8 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5404
diff changeset
222 @param toolTip text for the tool tip
f833f89571b8 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5404
diff changeset
223 @type str
5398
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
224 @return generated button
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
225 @rtype QToolButton
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
226 """
5411
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
227 button = QToolButton(self.__buttonsWidget)
5398
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
228 button.setIcon(UI.PixmapCache.getIcon(iconName))
5407
f833f89571b8 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5404
diff changeset
229 button.setToolTip(toolTip)
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5416
diff changeset
230 button.clicked.connect(lambda: self.__formatClicked(formatName))
5394
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 self.__layout.addWidget(button)
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5416
diff changeset
232 self.__buttons[formatName] = button
5394
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233
5398
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
234 return button
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
235
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
236 def __addSeparator(self):
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
237 """
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
238 Private method to add a separator line.
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
239 """
5411
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
240 line = QFrame(self.__buttonsWidget)
5398
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
241 line.setLineWidth(2)
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
242 if isinstance(self.__layout, QVBoxLayout):
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
243 line.setFrameShape(QFrame.HLine)
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
244 else:
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
245 line.setFrameShape(QFrame.VLine)
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
246 line.setFrameShadow(QFrame.Sunken)
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
247
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
248 self.__layout.addWidget(line)
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
249 self.__separators.append(line)
5394
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 @pyqtSlot()
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 def __updateButtonStates(self):
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 """
5398
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
254 Private slot to change the button states.
5394
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 """
5398
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
256 provider = MarkupProviders.getMarkupProvider(self.__editor)
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
257 if (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
258 self.__provider is None or
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
259 provider.kind() != self.__provider.kind()
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
260 ):
5398
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
261 self.__provider = provider
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
262
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
263 self.__buttons["bold"].setEnabled(self.__provider.hasBold())
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
264 self.__buttons["italic"].setEnabled(self.__provider.hasItalic())
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
265 self.__buttons["strikethrough"].setEnabled(
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
266 self.__provider.hasStrikethrough())
5402
ce21a78a5fcf Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5398
diff changeset
267
5398
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
268 headerLevels = self.__provider.headerLevels()
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
269 self.__buttons["header1"].setEnabled(headerLevels >= 1)
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
270 self.__buttons["header2"].setEnabled(headerLevels >= 2)
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
271 self.__buttons["header3"].setEnabled(headerLevels >= 3)
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
272 self.__buttons["header"].setEnabled(headerLevels > 3)
5402
ce21a78a5fcf Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5398
diff changeset
273 self.__headerMenu.clear()
ce21a78a5fcf Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5398
diff changeset
274 for level in range(1, headerLevels + 1):
ce21a78a5fcf Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5398
diff changeset
275 act = self.__headerMenu.addAction(
ce21a78a5fcf Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5398
diff changeset
276 self.tr("Level {0}").format(level))
ce21a78a5fcf Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5398
diff changeset
277 act.setData("header{0}".format(level))
ce21a78a5fcf Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5398
diff changeset
278
ce21a78a5fcf Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5398
diff changeset
279 self.__buttons["code"].setEnabled(self.__provider.hasCode())
5404
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5402
diff changeset
280 self.__buttons["codeBlock"].setEnabled(
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5402
diff changeset
281 self.__provider.hasCodeBlock())
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5402
diff changeset
282
5411
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
283 self.__buttons["bulletedList"].setEnabled(
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
284 self.__provider.hasBulletedList())
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
285 self.__buttons["numberedList"].setEnabled(
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
286 self.__provider.hasNumberedList())
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
287
5404
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5402
diff changeset
288 self.__editorSelectionChanged()
5402
ce21a78a5fcf Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5398
diff changeset
289
5416
16366120b523 Added an option to hide the format buttons bar, if formatting is not supported for the editor text type (only supported for HTML, Markdown and reStructured Text).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5412
diff changeset
290 if Preferences.getEditor("HideFormatButtons"):
16366120b523 Added an option to hide the format buttons bar, if formatting is not supported for the editor text type (only supported for HTML, Markdown and reStructured Text).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5412
diff changeset
291 self.setVisible(self.__provider.kind() != "none")
5394
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5416
diff changeset
293 def __formatClicked(self, formatName):
5394
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294 """
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295 Private slot to handle a format button being clicked.
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5416
diff changeset
297 @param formatName format type of the button
5394
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298 @type str
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299 """
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5416
diff changeset
300 if formatName == "bold":
5394
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301 self.__provider.bold(self.__editor)
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5416
diff changeset
302 elif formatName == "italic":
5394
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303 self.__provider.italic(self.__editor)
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5416
diff changeset
304 elif formatName == "strikethrough":
5394
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305 self.__provider.strikethrough(self.__editor)
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5416
diff changeset
306 elif formatName.startswith("header"):
5398
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
307 try:
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5416
diff changeset
308 level = int(formatName[-1])
5398
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
309 self.__provider.header(self.__editor, level)
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
310 except ValueError:
1f4509cf8f35 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
311 pass
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5416
diff changeset
312 elif formatName == "code":
5402
ce21a78a5fcf Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5398
diff changeset
313 self.__provider.code(self.__editor)
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5416
diff changeset
314 elif formatName == "codeBlock":
5404
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5402
diff changeset
315 self.__provider.codeBlock(self.__editor)
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5416
diff changeset
316 elif formatName == "quote":
5407
f833f89571b8 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5404
diff changeset
317 self.__provider.quote(self.__editor)
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5416
diff changeset
318 elif formatName == "hyperlink":
5404
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5402
diff changeset
319 self.__provider.hyperlink(self.__editor)
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5416
diff changeset
320 elif formatName == "line":
5404
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5402
diff changeset
321 self.__provider.line(self.__editor)
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5416
diff changeset
322 elif formatName == "image":
5407
f833f89571b8 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5404
diff changeset
323 self.__provider.image(self.__editor)
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5416
diff changeset
324 elif formatName == "bulletedList":
5411
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
325 self.__provider.bulletedList(self.__editor)
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5416
diff changeset
326 elif formatName == "numberedList":
5411
a163fbbf2bea Finished implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5407
diff changeset
327 self.__provider.numberedList(self.__editor)
5402
ce21a78a5fcf Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5398
diff changeset
328
ce21a78a5fcf Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5398
diff changeset
329 def __headerMenuTriggered(self, act):
ce21a78a5fcf Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5398
diff changeset
330 """
ce21a78a5fcf Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5398
diff changeset
331 Private method handling the selection of a header menu entry.
ce21a78a5fcf Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5398
diff changeset
332
ce21a78a5fcf Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5398
diff changeset
333 @param act action of the headers menu that was triggered
ce21a78a5fcf Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5398
diff changeset
334 @type QAction
ce21a78a5fcf Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5398
diff changeset
335 """
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5416
diff changeset
336 formatName = act.data()
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5416
diff changeset
337 self.__formatClicked(formatName)
5404
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5402
diff changeset
338
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5402
diff changeset
339 def __editorSelectionChanged(self):
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5402
diff changeset
340 """
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5402
diff changeset
341 Private slot to handle a change of the editor's selection.
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5402
diff changeset
342 """
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5402
diff changeset
343 hasSelection = self.__editor.hasSelectedText()
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5402
diff changeset
344 if self.__provider:
5407
f833f89571b8 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5404
diff changeset
345 self.__buttons["quote"].setEnabled(
f833f89571b8 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5404
diff changeset
346 self.__provider.hasQuote() and (
5412
db5a520f69d3 Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5411
diff changeset
347 self.__provider.kind() == "html" or hasSelection
db5a520f69d3 Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5411
diff changeset
348 )
db5a520f69d3 Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5411
diff changeset
349 )
5404
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5402
diff changeset
350 self.__buttons["hyperlink"].setEnabled(
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5402
diff changeset
351 self.__provider.hasHyperlink() and not hasSelection)
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5402
diff changeset
352 self.__buttons["line"].setEnabled(
6b19ad5470a3 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5402
diff changeset
353 self.__provider.hasLine() and not hasSelection)
5407
f833f89571b8 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5404
diff changeset
354 self.__buttons["image"].setEnabled(
f833f89571b8 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5404
diff changeset
355 self.__provider.hasImage() and not hasSelection)
5416
16366120b523 Added an option to hide the format buttons bar, if formatting is not supported for the editor text type (only supported for HTML, Markdown and reStructured Text).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5412
diff changeset
356
16366120b523 Added an option to hide the format buttons bar, if formatting is not supported for the editor text type (only supported for HTML, Markdown and reStructured Text).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5412
diff changeset
357 def __editorSettingsRead(self):
16366120b523 Added an option to hide the format buttons bar, if formatting is not supported for the editor text type (only supported for HTML, Markdown and reStructured Text).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5412
diff changeset
358 """
16366120b523 Added an option to hide the format buttons bar, if formatting is not supported for the editor text type (only supported for HTML, Markdown and reStructured Text).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5412
diff changeset
359 Private slot to handle a change of the editor related settings.
16366120b523 Added an option to hide the format buttons bar, if formatting is not supported for the editor text type (only supported for HTML, Markdown and reStructured Text).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5412
diff changeset
360 """
16366120b523 Added an option to hide the format buttons bar, if formatting is not supported for the editor text type (only supported for HTML, Markdown and reStructured Text).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5412
diff changeset
361 if Preferences.getEditor("HideFormatButtons"):
16366120b523 Added an option to hide the format buttons bar, if formatting is not supported for the editor text type (only supported for HTML, Markdown and reStructured Text).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5412
diff changeset
362 if self.__provider is not None:
16366120b523 Added an option to hide the format buttons bar, if formatting is not supported for the editor text type (only supported for HTML, Markdown and reStructured Text).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5412
diff changeset
363 self.setVisible(self.__provider.kind() != "none")
16366120b523 Added an option to hide the format buttons bar, if formatting is not supported for the editor text type (only supported for HTML, Markdown and reStructured Text).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5412
diff changeset
364 else:
16366120b523 Added an option to hide the format buttons bar, if formatting is not supported for the editor text type (only supported for HTML, Markdown and reStructured Text).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5412
diff changeset
365 self.setVisible(True)

eric ide

mercurial