eric6/QScintilla/EditorButtonsWidget.py

Wed, 30 Dec 2020 11:00:44 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 30 Dec 2020 11:00:44 +0100
branch
maintenance
changeset 7924
8a96736d465e
parent 7781
607a6098cb44
child 8143
2c730d5fd177
permissions
-rw-r--r--

Updated copyright for 2021.

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
7924
8a96736d465e Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
3 # Copyright (c) 2017 - 2021 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
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
11 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
12 from PyQt5.QtWidgets import (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
13 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
14 )
5394
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 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
17 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
18
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 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
20
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 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
23 """
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 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
25 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
26 """
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 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
28 """
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 Constructor
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 @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
32 @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
33 @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
34 @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
35 """
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 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
37
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
38 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
39 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
40
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 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
42
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 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
44 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
45 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
46
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 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
48
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 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
50 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
51 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
52 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
53 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
54 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
55
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 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
57
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 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
59
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 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
61 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
62 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
63 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
64
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 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
66 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
67 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
68 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
69 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
70
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 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
72 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
73 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
74 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
75 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
76 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
77 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
78 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
79
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 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
81 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
82 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
83 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
84 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
85
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 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
87 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
88 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
89
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 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
91 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
92
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
93 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
94 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
95
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 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
97
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 ## 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
100 #######################################################################
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 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
103 """
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 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
105 """
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 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
107 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
108
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 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
110 """
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 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
112
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 @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
114 """
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 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
116 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
117
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 ## 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
120 #######################################################################
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 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
123 """
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 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
125 """
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 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
127 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
128 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
129
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 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
131 """
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 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
133 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
134 """
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 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
136
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 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
138 """
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 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
140 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
141 """
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 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
143
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 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
145 """
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 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
147
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 @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
149 """
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 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
151 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
152 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
153 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
154 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
155 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
156 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 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
158 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 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
160 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
161
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 ## 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
164 #######################################################################
5394
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 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
167 """
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 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
169 """
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 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
171 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
172 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
173
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
174 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
175 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
176 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
177 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
178 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
179 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
180 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
181 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
182 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
183 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
184 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
185 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
186 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
187 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
188 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
189 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
190 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
191 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
192 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
193 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
194 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
195 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
196 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
197 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
198 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
199 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
200 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
201 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
202 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
203 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
204 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
205 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
206 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
207 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
208 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
209 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
210
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 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
212
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5416
diff changeset
213 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
214 """
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 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
216
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5416
diff changeset
217 @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
218 @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
219 @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
220 @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
221 @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
222 @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
223 @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
224 @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
225 """
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
226 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
227 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
228 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
229 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
230 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
231 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
232
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
233 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
234
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 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
236 """
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 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
238 """
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
239 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
240 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
241 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
242 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
243 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
244 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
245 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
246
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 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
248 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
249
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 @pyqtSlot()
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 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
252 """
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
253 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
254 """
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
255 provider = MarkupProviders.getMarkupProvider(self.__editor)
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
256 if (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
257 self.__provider is None or
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
258 provider.kind() != self.__provider.kind()
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
259 ):
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
260 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
261
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 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
263 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
264 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
265 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
266
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
267 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
268 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
269 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
270 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
271 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
272 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
273 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
274 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
275 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
276 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
277
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 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
279 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
280 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
281
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
282 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
283 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
284 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
285 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
286
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
287 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
288
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
289 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
290 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
291
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5416
diff changeset
292 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
293 """
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294 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
295
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5416
diff changeset
296 @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
297 @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
298 """
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5416
diff changeset
299 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
300 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
301 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
302 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
303 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
304 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
305 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
306 try:
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5416
diff changeset
307 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
308 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
309 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
310 pass
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5416
diff changeset
311 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
312 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
313 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
314 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
315 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
316 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
317 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
318 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
319 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
320 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
321 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
322 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
323 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
324 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
325 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
326 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
327
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 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
329 """
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 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
331
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 @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
333 @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
334 """
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5416
diff changeset
335 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
336 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
337
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 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
339 """
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 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
341 """
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 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
343 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
344 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
345 self.__provider.hasQuote() and (
5412
db5a520f69d3 Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5411
diff changeset
346 self.__provider.kind() == "html" or hasSelection
db5a520f69d3 Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5411
diff changeset
347 )
db5a520f69d3 Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5411
diff changeset
348 )
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
349 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
350 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
351 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
352 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
353 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
354 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
355
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 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
357 """
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 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
359 """
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 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
361 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
362 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
363 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
364 self.setVisible(True)

eric ide

mercurial