Krita Source Code Documentation
Loading...
Searching...
No Matches
krita.sceditor.assist.PopupWidget Class Reference
+ Inheritance diagram for krita.sceditor.assist.PopupWidget:

Public Member Functions

 __init__ (self, textedit)
 
 hide (self)
 
 show (self, timeout=0, above=False)
 

Public Attributes

 active
 
 cursor_start_col
 
 hide
 
 textedit
 
 vlayout
 

Detailed Description

Definition at line 15 of file assist.py.

Constructor & Destructor Documentation

◆ __init__()

krita.sceditor.assist.PopupWidget.__init__ ( self,
textedit )

Definition at line 17 of file assist.py.

17 def __init__(self, textedit):
18 flags = Qt.WindowType.ToolTip
19 flags = Qt.WindowType.Window | Qt.WindowType.FramelessWindowHint | \
20 Qt.WindowType.CustomizeWindowHint | Qt.WindowType.X11BypassWindowManagerHint
21 QWidget.__init__(self, None, flags)
22 self.textedit = textedit
23 self.vlayout = QVBoxLayout(self)
24 self.vlayout.setContentsMargins(0, 0, 0, 0)
25 self.init_popup()
26 self.show()
27 self.hide()
28 self.active = False
29

Member Function Documentation

◆ hide()

◆ show()

krita.sceditor.assist.PopupWidget.show ( self,
timeout = 0,
above = False )

Definition at line 30 of file assist.py.

30 def show(self, timeout=0, above=False):
31 self.cursor_start_col = self.textedit.textCursor().columnNumber()
32 desktop = QApplication.instance().desktop()
33 screen = desktop.screen(desktop.screenNumber(self))
34 screen_width = screen.width()
35 screen_height = screen.height()
36 win_width = self.width()
37 win_height = self.height()
38 cursorRect = self.textedit.cursorRect()
39 if above:
40 pos = self.textedit.mapToGlobal(cursorRect.topLeft())
41 pos.setY(pos.y() - win_height)
42 else:
43 pos = self.textedit.mapToGlobal(cursorRect.bottomLeft())
44 if pos.y() < 0:
45 pos = self.textedit.mapToGlobal(cursorRect.bottomLeft())
46 if pos.y() + win_height > screen_height:
47 pos = self.textedit.mapToGlobal(cursorRect.topLeft())
48 pos.setY(pos.y() - win_height)
49 if pos.x() + win_width > screen_width:
50 pos.setX(screen_width - win_width)
51
52 self.move(pos)
53 QWidget.show(self)
54 self.active = True
55 if timeout:
56 QTimer.singleShot(timeout * 1000, self.hide)
57

Member Data Documentation

◆ active

krita.sceditor.assist.PopupWidget.active

Definition at line 28 of file assist.py.

◆ cursor_start_col

krita.sceditor.assist.PopupWidget.cursor_start_col

Definition at line 31 of file assist.py.

◆ hide

krita.sceditor.assist.PopupWidget.hide

Definition at line 56 of file assist.py.

◆ textedit

krita.sceditor.assist.PopupWidget.textedit

Definition at line 22 of file assist.py.

◆ vlayout

krita.sceditor.assist.PopupWidget.vlayout

Definition at line 23 of file assist.py.


The documentation for this class was generated from the following file: