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