MCPcopy Create free account
hub / github.com/Palm1r/QodeAssist / calculateWidgetPosition

Method calculateWidgetPosition

widgets/RefactorWidgetHandler.cpp:106–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104}
105
106QPoint RefactorWidgetHandler::calculateWidgetPosition()
107{
108 if (m_editor.isNull()) {
109 return QPoint(0, 0);
110 }
111
112 QTextCursor cursor = m_editor->textCursor();
113 QRect cursorRect = m_editor->cursorRect(cursor);
114 QPoint globalPos = m_editor->mapToGlobal(cursorRect.bottomLeft());
115 globalPos.setY(globalPos.y() + 10);
116
117 if (m_refactorWidget) {
118 QRect widgetRect(globalPos, m_refactorWidget->size());
119 QRect screenRect = m_editor->screen()->availableGeometry();
120
121 if (widgetRect.right() > screenRect.right()) {
122 globalPos.setX(screenRect.right() - m_refactorWidget->width() - 10);
123 }
124
125 if (widgetRect.bottom() > screenRect.bottom()) {
126 globalPos.setY(m_editor->mapToGlobal(cursorRect.topLeft()).y()
127 - m_refactorWidget->height() - 10);
128 }
129
130 if (globalPos.x() < screenRect.left()) {
131 globalPos.setX(screenRect.left() + 10);
132 }
133
134 if (globalPos.y() < screenRect.top()) {
135 globalPos.setY(screenRect.top() + 10);
136 }
137 }
138
139 return globalPos;
140}
141
142int RefactorWidgetHandler::getEditorWidth() const
143{

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.80

Tested by

no test coverage detected