forked from qt-creator/qt-creator
Prepare for QDesktopWidget removal
Change-Id: I9aa2eadea16b5795ee2c4e7b21a24f356cfd3b03 Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
This commit is contained in:
@@ -29,25 +29,21 @@
|
|||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QRect>
|
#include <QApplication>
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
|
#include <QFontMetrics>
|
||||||
|
#include <QPaintEvent>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QPen>
|
#include <QPen>
|
||||||
#include <QPixmap>
|
|
||||||
#include <QStyle>
|
|
||||||
#include <QFontMetrics>
|
|
||||||
#include <QTextDocument>
|
|
||||||
#include <QStylePainter>
|
|
||||||
#include <QStyleOptionFrame>
|
|
||||||
#include <QResizeEvent>
|
|
||||||
#include <QPaintEvent>
|
|
||||||
#include <QVBoxLayout>
|
|
||||||
|
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
#include <QRect>
|
#include <QRect>
|
||||||
|
#include <QResizeEvent>
|
||||||
|
#include <QStyle>
|
||||||
|
#include <QStylePainter>
|
||||||
|
#include <QStyleOptionFrame>
|
||||||
|
#include <QTextDocument>
|
||||||
|
#include <QScreen>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QApplication>
|
|
||||||
#include <QDesktopWidget>
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@@ -127,10 +123,9 @@ void ColorTip::setContent(const QVariant &content)
|
|||||||
tilePainter.fillRect(size, size, size, size, col);
|
tilePainter.fillRect(size, size, size, size, col);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorTip::configure(const QPoint &pos, QWidget *w)
|
void ColorTip::configure(const QPoint &pos)
|
||||||
{
|
{
|
||||||
Q_UNUSED(pos)
|
Q_UNUSED(pos)
|
||||||
Q_UNUSED(w)
|
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
@@ -197,7 +192,7 @@ bool TextTip::isInteractive() const
|
|||||||
return likelyContainsLink(m_text);
|
return likelyContainsLink(m_text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextTip::configure(const QPoint &pos, QWidget *w)
|
void TextTip::configure(const QPoint &pos)
|
||||||
{
|
{
|
||||||
setTextFormat(m_format);
|
setTextFormat(m_format);
|
||||||
setText(m_text);
|
setText(m_text);
|
||||||
@@ -211,7 +206,7 @@ void TextTip::configure(const QPoint &pos, QWidget *w)
|
|||||||
// Try to find a nice width without unnecessary wrapping.
|
// Try to find a nice width without unnecessary wrapping.
|
||||||
setWordWrap(false);
|
setWordWrap(false);
|
||||||
int tipWidth = sizeHint().width();
|
int tipWidth = sizeHint().width();
|
||||||
const int screenWidth = screenGeometry(pos, w).width();
|
const int screenWidth = QGuiApplication::screenAt(pos)->availableGeometry().width();
|
||||||
const int maxDesiredWidth = int(screenWidth * .5);
|
const int maxDesiredWidth = int(screenWidth * .5);
|
||||||
if (tipWidth > maxDesiredWidth) {
|
if (tipWidth > maxDesiredWidth) {
|
||||||
setWordWrap(true);
|
setWordWrap(true);
|
||||||
@@ -273,7 +268,7 @@ void WidgetTip::setContent(const QVariant &content)
|
|||||||
m_widget = content.value<QWidget *>();
|
m_widget = content.value<QWidget *>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WidgetTip::configure(const QPoint &pos, QWidget *)
|
void WidgetTip::configure(const QPoint &pos)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_widget && m_layout->count() == 0, return);
|
QTC_ASSERT(m_widget && m_layout->count() == 0, return);
|
||||||
|
|
||||||
@@ -319,21 +314,5 @@ bool WidgetTip::equals(int typeId, const QVariant &other, const QVariant &otherC
|
|||||||
&& other.value<QWidget *>() == m_widget;
|
&& other.value<QWidget *>() == m_widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int screenNumber(const QPoint &pos, QWidget *w)
|
|
||||||
{
|
|
||||||
if (QApplication::desktop()->isVirtualDesktop())
|
|
||||||
return QApplication::desktop()->screenNumber(pos);
|
|
||||||
else
|
|
||||||
return QApplication::desktop()->screenNumber(w);
|
|
||||||
}
|
|
||||||
|
|
||||||
QRect screenGeometry(const QPoint &pos, QWidget *w)
|
|
||||||
{
|
|
||||||
if (HostOsInfo::isMacHost())
|
|
||||||
return QApplication::desktop()->availableGeometry(screenNumber(pos, w));
|
|
||||||
return QApplication::desktop()->screenGeometry(screenNumber(pos, w));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Utils
|
} // namespace Utils
|
||||||
|
@@ -36,9 +36,6 @@
|
|||||||
namespace Utils {
|
namespace Utils {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
int screenNumber(const QPoint &pos, QWidget *w);
|
|
||||||
QRect screenGeometry(const QPoint &pos, QWidget *w);
|
|
||||||
|
|
||||||
class TipLabel : public QLabel
|
class TipLabel : public QLabel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -47,7 +44,7 @@ public:
|
|||||||
virtual void setContent(const QVariant &content) = 0;
|
virtual void setContent(const QVariant &content) = 0;
|
||||||
virtual bool isInteractive() const { return false; }
|
virtual bool isInteractive() const { return false; }
|
||||||
virtual int showTime() const = 0;
|
virtual int showTime() const = 0;
|
||||||
virtual void configure(const QPoint &pos, QWidget *w) = 0;
|
virtual void configure(const QPoint &pos) = 0;
|
||||||
virtual bool canHandleContentReplacement(int typeId) const = 0;
|
virtual bool canHandleContentReplacement(int typeId) const = 0;
|
||||||
virtual bool equals(int typeId, const QVariant &other, const QVariant &contextHelp) const = 0;
|
virtual bool equals(int typeId, const QVariant &other, const QVariant &contextHelp) const = 0;
|
||||||
virtual void setContextHelp(const QVariant &help);
|
virtual void setContextHelp(const QVariant &help);
|
||||||
@@ -69,7 +66,7 @@ public:
|
|||||||
|
|
||||||
void setContent(const QVariant &content) override;
|
void setContent(const QVariant &content) override;
|
||||||
bool isInteractive() const override;
|
bool isInteractive() const override;
|
||||||
void configure(const QPoint &pos, QWidget *w) override;
|
void configure(const QPoint &pos) override;
|
||||||
bool canHandleContentReplacement(int typeId) const override;
|
bool canHandleContentReplacement(int typeId) const override;
|
||||||
int showTime() const override;
|
int showTime() const override;
|
||||||
bool equals(int typeId, const QVariant &other, const QVariant &otherContextHelp) const override;
|
bool equals(int typeId, const QVariant &other, const QVariant &otherContextHelp) const override;
|
||||||
@@ -87,7 +84,7 @@ public:
|
|||||||
ColorTip(QWidget *parent);
|
ColorTip(QWidget *parent);
|
||||||
|
|
||||||
void setContent(const QVariant &content) override;
|
void setContent(const QVariant &content) override;
|
||||||
void configure(const QPoint &pos, QWidget *w) override;
|
void configure(const QPoint &pos) override;
|
||||||
bool canHandleContentReplacement(int typeId) const override;
|
bool canHandleContentReplacement(int typeId) const override;
|
||||||
int showTime() const override { return 4000; }
|
int showTime() const override { return 4000; }
|
||||||
bool equals(int typeId, const QVariant &other, const QVariant &otherContextHelp) const override;
|
bool equals(int typeId, const QVariant &other, const QVariant &otherContextHelp) const override;
|
||||||
@@ -107,7 +104,7 @@ public:
|
|||||||
void pinToolTipWidget(QWidget *parent);
|
void pinToolTipWidget(QWidget *parent);
|
||||||
|
|
||||||
void setContent(const QVariant &content) override;
|
void setContent(const QVariant &content) override;
|
||||||
void configure(const QPoint &pos, QWidget *w) override;
|
void configure(const QPoint &pos) override;
|
||||||
bool canHandleContentReplacement(int typeId) const override;
|
bool canHandleContentReplacement(int typeId) const override;
|
||||||
int showTime() const override { return 30000; }
|
int showTime() const override { return 30000; }
|
||||||
bool equals(int typeId, const QVariant &other, const QVariant &otherContextHelp) const override;
|
bool equals(int typeId, const QVariant &other, const QVariant &otherContextHelp) const override;
|
||||||
|
@@ -33,12 +33,11 @@
|
|||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QDebug>
|
|
||||||
#include <QDesktopWidget>
|
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
#include <QScreen>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
@@ -171,10 +170,10 @@ void ToolTip::show(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolTip::move(const QPoint &pos, QWidget *w)
|
void ToolTip::move(const QPoint &pos)
|
||||||
{
|
{
|
||||||
if (isVisible())
|
if (isVisible())
|
||||||
instance()->placeTip(pos, w);
|
instance()->placeTip(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ToolTip::pinToolTip(QWidget *w, QWidget *parent)
|
bool ToolTip::pinToolTip(QWidget *w, QWidget *parent)
|
||||||
@@ -232,9 +231,9 @@ bool ToolTip::acceptShow(const QVariant &content,
|
|||||||
|
|
||||||
void ToolTip::setUp(const QPoint &pos, QWidget *w, const QRect &rect)
|
void ToolTip::setUp(const QPoint &pos, QWidget *w, const QRect &rect)
|
||||||
{
|
{
|
||||||
m_tip->configure(pos, w);
|
m_tip->configure(pos);
|
||||||
|
|
||||||
placeTip(pos, w);
|
placeTip(pos);
|
||||||
setTipRect(w, rect);
|
setTipRect(w, rect);
|
||||||
|
|
||||||
if (m_hideDelayTimer.isActive())
|
if (m_hideDelayTimer.isActive())
|
||||||
@@ -320,21 +319,15 @@ void ToolTip::showInternal(const QPoint &pos, const QVariant &content,
|
|||||||
int typeId, QWidget *w, const QVariant &contextHelp, const QRect &rect)
|
int typeId, QWidget *w, const QVariant &contextHelp, const QRect &rect)
|
||||||
{
|
{
|
||||||
if (acceptShow(content, typeId, pos, w, contextHelp, rect)) {
|
if (acceptShow(content, typeId, pos, w, contextHelp, rect)) {
|
||||||
QWidget *target = nullptr;
|
|
||||||
if (HostOsInfo::isWindowsHost())
|
|
||||||
target = QApplication::desktop()->screen(Internal::screenNumber(pos, w));
|
|
||||||
else
|
|
||||||
target = w;
|
|
||||||
|
|
||||||
switch (typeId) {
|
switch (typeId) {
|
||||||
case ColorContent:
|
case ColorContent:
|
||||||
m_tip = new ColorTip(target);
|
m_tip = new ColorTip(w);
|
||||||
break;
|
break;
|
||||||
case TextContent:
|
case TextContent:
|
||||||
m_tip = new TextTip(target);
|
m_tip = new TextTip(w);
|
||||||
break;
|
break;
|
||||||
case WidgetContent:
|
case WidgetContent:
|
||||||
m_tip = new WidgetTip(target);
|
m_tip = new WidgetTip(w);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
m_tip->setObjectName("qcToolTip");
|
m_tip->setObjectName("qcToolTip");
|
||||||
@@ -347,9 +340,9 @@ void ToolTip::showInternal(const QPoint &pos, const QVariant &content,
|
|||||||
emit shown();
|
emit shown();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolTip::placeTip(const QPoint &pos, QWidget *w)
|
void ToolTip::placeTip(const QPoint &pos)
|
||||||
{
|
{
|
||||||
QRect screen = Internal::screenGeometry(pos, w);
|
QRect screen = QGuiApplication::screenAt(pos)->availableGeometry();
|
||||||
QPoint p = pos;
|
QPoint p = pos;
|
||||||
p += offsetFromPosition();
|
p += offsetFromPosition();
|
||||||
if (p.x() + m_tip->width() > screen.x() + screen.width())
|
if (p.x() + m_tip->width() > screen.x() + screen.width())
|
||||||
|
@@ -89,7 +89,7 @@ public:
|
|||||||
const QVariant &contextHelp = {}, const QRect &rect = QRect());
|
const QVariant &contextHelp = {}, const QRect &rect = QRect());
|
||||||
static void show(const QPoint &pos, QLayout *content, QWidget *w = nullptr,
|
static void show(const QPoint &pos, QLayout *content, QWidget *w = nullptr,
|
||||||
const QVariant &contextHelp = {}, const QRect &rect = QRect());
|
const QVariant &contextHelp = {}, const QRect &rect = QRect());
|
||||||
static void move(const QPoint &pos, QWidget *w);
|
static void move(const QPoint &pos);
|
||||||
static void hide();
|
static void hide();
|
||||||
static void hideImmediately();
|
static void hideImmediately();
|
||||||
static bool isVisible();
|
static bool isVisible();
|
||||||
@@ -116,7 +116,7 @@ private:
|
|||||||
bool tipChanged(const QPoint &pos, const QVariant &content, int typeId, QWidget *w,
|
bool tipChanged(const QPoint &pos, const QVariant &content, int typeId, QWidget *w,
|
||||||
const QVariant &contextHelp) const;
|
const QVariant &contextHelp) const;
|
||||||
void setTipRect(QWidget *w, const QRect &rect);
|
void setTipRect(QWidget *w, const QRect &rect);
|
||||||
void placeTip(const QPoint &pos, QWidget *w);
|
void placeTip(const QPoint &pos);
|
||||||
void showTip();
|
void showTip();
|
||||||
void hideTipWithDelay();
|
void hideTipWithDelay();
|
||||||
|
|
||||||
|
@@ -37,7 +37,6 @@
|
|||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDesktopWidget>
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QMenuBar>
|
#include <QMenuBar>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
@@ -457,9 +456,7 @@ void ActionManagerPrivate::showShortcutPopup(const QString &shortcut)
|
|||||||
if (!QApplication::topLevelWidgets().isEmpty()) {
|
if (!QApplication::topLevelWidgets().isEmpty()) {
|
||||||
window = QApplication::topLevelWidgets().first();
|
window = QApplication::topLevelWidgets().first();
|
||||||
} else {
|
} else {
|
||||||
QTC_ASSERT(QApplication::desktop(), return);
|
window = ICore::mainWindow();
|
||||||
window = QApplication::desktop()->screen();
|
|
||||||
QTC_ASSERT(window, return);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1235,7 +1235,7 @@ void DebuggerToolTipManagerPrivate::slotTooltipOverrideRequested
|
|||||||
if (tooltip) {
|
if (tooltip) {
|
||||||
DEBUG("REUSING LOCALS TOOLTIP");
|
DEBUG("REUSING LOCALS TOOLTIP");
|
||||||
tooltip->context.mousePosition = point;
|
tooltip->context.mousePosition = point;
|
||||||
ToolTip::move(point, DebuggerMainWindow::instance());
|
ToolTip::move(point);
|
||||||
} else {
|
} else {
|
||||||
DEBUG("CREATING LOCALS, WAITING...");
|
DEBUG("CREATING LOCALS, WAITING...");
|
||||||
tooltip = new DebuggerToolTipHolder(context);
|
tooltip = new DebuggerToolTipHolder(context);
|
||||||
@@ -1257,7 +1257,7 @@ void DebuggerToolTipManagerPrivate::slotTooltipOverrideRequested
|
|||||||
if (tooltip) {
|
if (tooltip) {
|
||||||
//tooltip->destroy();
|
//tooltip->destroy();
|
||||||
tooltip->context.mousePosition = point;
|
tooltip->context.mousePosition = point;
|
||||||
ToolTip::move(point, DebuggerMainWindow::instance());
|
ToolTip::move(point);
|
||||||
DEBUG("UPDATING DELAYED.");
|
DEBUG("UPDATING DELAYED.");
|
||||||
} else {
|
} else {
|
||||||
DEBUG("CREATING DELAYED.");
|
DEBUG("CREATING DELAYED.");
|
||||||
|
@@ -37,7 +37,6 @@
|
|||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QDesktopWidget>
|
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
@@ -366,9 +365,7 @@ void FunctionHintProposalWidget::updateContent()
|
|||||||
|
|
||||||
void FunctionHintProposalWidget::updatePosition()
|
void FunctionHintProposalWidget::updatePosition()
|
||||||
{
|
{
|
||||||
const QDesktopWidget *desktop = QApplication::desktop();
|
auto widgetScreen = d->m_underlyingWidget->screen();
|
||||||
const int screenNumber = desktop->screenNumber(d->m_underlyingWidget);
|
|
||||||
auto widgetScreen = QGuiApplication::screens().value(screenNumber, QGuiApplication::primaryScreen());
|
|
||||||
const QRect &screen = Utils::HostOsInfo::isMacHost()
|
const QRect &screen = Utils::HostOsInfo::isMacHost()
|
||||||
? widgetScreen->availableGeometry() : widgetScreen->geometry();
|
? widgetScreen->availableGeometry() : widgetScreen->geometry();
|
||||||
|
|
||||||
|
@@ -47,9 +47,9 @@
|
|||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QListView>
|
#include <QListView>
|
||||||
#include <QAbstractItemView>
|
#include <QAbstractItemView>
|
||||||
|
#include <QScreen>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QDesktopWidget>
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QStyledItemDelegate>
|
#include <QStyledItemDelegate>
|
||||||
|
|
||||||
@@ -143,10 +143,7 @@ public:
|
|||||||
// Workaround QTCREATORBUG-11653
|
// Workaround QTCREATORBUG-11653
|
||||||
void calculateMaximumWidth()
|
void calculateMaximumWidth()
|
||||||
{
|
{
|
||||||
const QDesktopWidget *desktopWidget = QApplication::desktop();
|
const int desktopWidth = screen()->availableGeometry().width();
|
||||||
const int desktopWidth = desktopWidget->isVirtualDesktop()
|
|
||||||
? desktopWidget->width()
|
|
||||||
: desktopWidget->availableGeometry(desktopWidget->primaryScreen()).width();
|
|
||||||
const QMargins widgetMargins = contentsMargins();
|
const QMargins widgetMargins = contentsMargins();
|
||||||
const QMargins layoutMargins = layout()->contentsMargins();
|
const QMargins layoutMargins = layout()->contentsMargins();
|
||||||
const int margins = widgetMargins.left() + widgetMargins.right()
|
const int margins = widgetMargins.left() + widgetMargins.right()
|
||||||
@@ -531,10 +528,7 @@ void GenericProposalWidget::updatePositionAndSize()
|
|||||||
const int height = shint.height() + fw * 2;
|
const int height = shint.height() + fw * 2;
|
||||||
|
|
||||||
// Determine the position, keeping the popup on the screen
|
// Determine the position, keeping the popup on the screen
|
||||||
const QDesktopWidget *desktop = QApplication::desktop();
|
const QRect screen = d->m_underlyingWidget->screen()->availableGeometry();
|
||||||
const QRect screen = HostOsInfo::isMacHost()
|
|
||||||
? desktop->availableGeometry(desktop->screenNumber(d->m_underlyingWidget))
|
|
||||||
: desktop->screenGeometry(desktop->screenNumber(d->m_underlyingWidget));
|
|
||||||
|
|
||||||
QPoint pos = d->m_displayRect.bottomLeft();
|
QPoint pos = d->m_displayRect.bottomLeft();
|
||||||
pos.rx() -= 16 + fw; // Space for the icons
|
pos.rx() -= 16 + fw; // Space for the icons
|
||||||
|
Reference in New Issue
Block a user