Commit 1101e556 authored by hjk's avatar hjk
Browse files

Debugger: Make pinned tooltips a frameless Tool window



This avoids the "StayOnTop" situation described in QTCREATORBUG-13397
for the case of pinned tooltips.

Task-number: QTCREATORBUG-13397
Change-Id: I3801368c07895b652e10fe1d173b21cef7869ed0
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent 045905fb
......@@ -178,14 +178,14 @@ bool WidgetContent::equals(const TipContent &tipContent) const
return false;
}
bool WidgetContent::pinToolTip(QWidget *w)
bool WidgetContent::pinToolTip(QWidget *w, QWidget *parent)
{
QTC_ASSERT(w, return false);
// Find the parent WidgetTip, tell it to pin/release the
// widget and close.
for (QWidget *p = w->parentWidget(); p ; p = p->parentWidget()) {
if (Internal::WidgetTip *wt = qobject_cast<Internal::WidgetTip *>(p)) {
wt->pinToolTipWidget();
wt->pinToolTipWidget(parent);
ToolTip::hide();
return true;
}
......
......@@ -114,7 +114,7 @@ public:
// Helper to 'pin' (show as real window) a tooltip shown
// using WidgetContent
static bool pinToolTip(QWidget *w);
static bool pinToolTip(QWidget *w, QWidget *parent);
static const int WIDGET_CONTENT_ID = 42;
......
......@@ -217,20 +217,6 @@ WidgetTip::WidgetTip(QWidget *parent) :
setLayout(m_layout);
}
QWidget *WidgetTip::takeWidget(Qt::WindowFlags wf)
{
// Remove widget from layout
if (!m_layout->count())
return 0;
QLayoutItem *item = m_layout->takeAt(0);
QWidget *widget = item->widget();
delete item;
if (!widget)
return 0;
widget->setParent(0, wf);
return widget;
}
void WidgetTip::configure(const QPoint &pos, QWidget *)
{
const WidgetContent &anyContent = static_cast<const WidgetContent &>(content());
......@@ -244,16 +230,24 @@ void WidgetTip::configure(const QPoint &pos, QWidget *)
adjustSize();
}
void WidgetTip::pinToolTipWidget()
void WidgetTip::pinToolTipWidget(QWidget *parent)
{
QTC_ASSERT(m_layout->count(), return);
// Pin the content widget: Rip the widget out of the layout
// and re-show as a tooltip, with delete on close.
const QPoint screenPos = mapToGlobal(QPoint(0, 0));
QWidget *widget = takeWidget(Qt::ToolTip);
QTC_ASSERT(widget, return);
// Remove widget from layout
if (!m_layout->count())
return;
QLayoutItem *item = m_layout->takeAt(0);
QWidget *widget = item->widget();
delete item;
if (!widget)
return;
widget->setParent(parent, Qt::Tool|Qt::FramelessWindowHint);
widget->move(screenPos);
widget->show();
widget->setAttribute(Qt::WA_DeleteOnClose);
......
......@@ -107,11 +107,9 @@ public:
virtual bool canHandleContentReplacement(const TipContent &content) const;
public slots:
void pinToolTipWidget();
void pinToolTipWidget(QWidget *parent);
private:
QWidget *takeWidget(Qt::WindowFlags wf = 0);
QVBoxLayout *m_layout;
};
......
......@@ -688,7 +688,7 @@ public:
if (parentWidget()) {
// We are currently within a text editor tooltip:
// Rip out of parent widget and re-show as a tooltip
Utils::WidgetContent::pinToolTip(this);
Utils::WidgetContent::pinToolTip(this, ICore::mainWindow());
} else {
// We have just be restored from session data.
setWindowFlags(Qt::ToolTip);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment