forked from qt-creator/qt-creator
WelcomePage: Workaround broken QFrame in HighDPI cases
This change introduces Core::WelcomeFrame which draws proper rectangles. The need for this workaround is unfortunate, but the very visible regression with the new welcome mode would be worse. Task-number: QTBUG-59116 Change-Id: I158b8309cf396a247136d7017406ca1f7bce2407 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -33,6 +33,7 @@
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QMetaEnum>
|
||||
#include <QPainter>
|
||||
#include <QPixmap>
|
||||
#include <QUrl>
|
||||
|
||||
@@ -90,6 +91,25 @@ static QPalette buttonPalette(bool isActive, bool isCursorInside, bool forText)
|
||||
return pal;
|
||||
}
|
||||
|
||||
WelcomePageFrame::WelcomePageFrame(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
setContentsMargins(1, 1, 1, 1);
|
||||
}
|
||||
|
||||
void WelcomePageFrame::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QWidget::paintEvent(event);
|
||||
|
||||
const QRectF adjustedRect(QRectF(rect()).adjusted(0.5, 0.5, -0.5, -0.5));
|
||||
QPen pen(palette().color(QPalette::WindowText));
|
||||
pen.setJoinStyle(Qt::MiterJoin);
|
||||
|
||||
QPainter p(this);
|
||||
p.setPen(pen);
|
||||
p.drawRect(adjustedRect);
|
||||
}
|
||||
|
||||
class WelcomePageButtonPrivate
|
||||
{
|
||||
public:
|
||||
@@ -107,11 +127,9 @@ public:
|
||||
};
|
||||
|
||||
WelcomePageButton::WelcomePageButton(QWidget *parent)
|
||||
: QFrame(parent), d(new WelcomePageButtonPrivate(this))
|
||||
: WelcomePageFrame(parent), d(new WelcomePageButtonPrivate(this))
|
||||
{
|
||||
setAutoFillBackground(true);
|
||||
setFrameShape(QFrame::Box);
|
||||
setFrameShadow(QFrame::Plain);
|
||||
setPalette(buttonPalette(false, false, false));
|
||||
|
||||
QFont f = font();
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
#include "id.h"
|
||||
|
||||
#include <QFrame>
|
||||
#include <QWidget>
|
||||
#include <QObject>
|
||||
|
||||
#include <functional>
|
||||
@@ -61,7 +61,15 @@ public:
|
||||
|
||||
class WelcomePageButtonPrivate;
|
||||
|
||||
class CORE_EXPORT WelcomePageButton : public QFrame
|
||||
class CORE_EXPORT WelcomePageFrame : public QWidget
|
||||
{
|
||||
public:
|
||||
WelcomePageFrame(QWidget *parent);
|
||||
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
};
|
||||
|
||||
class CORE_EXPORT WelcomePageButton : public WelcomePageFrame
|
||||
{
|
||||
public:
|
||||
WelcomePageButton(QWidget *parent);
|
||||
|
||||
@@ -244,15 +244,12 @@ static QString resourcePath()
|
||||
return FileUtils::normalizePathName(ICore::resourcePath());
|
||||
}
|
||||
|
||||
class SearchBox : public QFrame
|
||||
class SearchBox : public WelcomePageFrame
|
||||
{
|
||||
public:
|
||||
SearchBox(QWidget *parent)
|
||||
: QFrame(parent)
|
||||
: WelcomePageFrame(parent)
|
||||
{
|
||||
setFrameShape(QFrame::Box);
|
||||
setFrameShadow(QFrame::Plain);
|
||||
|
||||
QPalette pal;
|
||||
pal.setColor(QPalette::Base, themeColor(Theme::Welcome_BackgroundColor));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user