KTextEditor
6#include "documentation_tip.h"
24 layout->setContentsMargins({});
25 layout->setSpacing(0);
26 setContentsMargins({});
27 layout->addWidget(&m_stack);
28 m_stack.addWidget(m_textView);
33 return m_stack.currentWidget();
36void DocTip::clearWidgets()
38 for (
auto *widget : m_widgets) {
39 widget->deleteLater();
44void DocTip::setText(
const QString &s)
46 m_textView->setPlainText(s);
47 if (m_stack.currentWidget() != m_textView) {
48 m_stack.removeWidget(m_stack.currentWidget());
49 m_stack.addWidget(m_textView);
51 Q_ASSERT(m_stack.count() == 1);
54void DocTip::setWidget(
QWidget *widget)
56 if (
auto w = m_stack.currentWidget()) {
57 if (w != m_textView) {
58 m_widgets.push_back(w);
60 m_stack.removeWidget(w);
67 m_stack.addWidget(widget);
69 Q_ASSERT(m_stack.count() == 1);
72void DocTip::updatePosition(
QWidget *completionWidget)
76 qWarning() << Q_FUNC_INFO <<
"Unexpected null parent!";
80 const auto parentRight =
parent->geometry().right();
81 auto completionWidgetRight = completionWidget->
geometry().right();
82 constexpr int Margin = 8;
86 if ((completionWidgetRight + this->
width()) > parentRight) {
88 x = (completionWidget->
x() - this->
width()) - Margin;
91 x = completionWidget->
x() + completionWidget->
width() + Margin;
93 move(
x, completionWidget->
y());
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Feb 21 2025 11:52:51 by
doxygen 1.13.2 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.