mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
Hi_DPI support
Change-Id: If063f16f246b65f4c2ce4eef3e57df5cc0347427
This commit is contained in:
parent
dceb21dbcf
commit
58d3b69ce7
Notes:
Deepin Code Review
2017-08-30 17:46:24 +08:00
Verified+1: Anonymous Coward #1000004 Code-Review+2: 石博文 <sbw@sbw.so> Submitted-by: 石博文 <sbw@sbw.so> Submitted-at: Wed, 30 Aug 2017 17:46:24 +0800 Reviewed-on: https://cr.deepin.io/25874 Project: dde/dde-dock Branch: refs/heads/master
@ -19,6 +19,7 @@
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtDBus/QtDBus>
|
||||
#include <QtGui/QGuiApplication>
|
||||
|
||||
typedef QMap<QString, double> BrightnessMap;
|
||||
|
||||
@ -108,15 +109,24 @@ public:
|
||||
|
||||
Q_PROPERTY(DisplayRect PrimaryRect READ primaryRect NOTIFY PrimaryRectChanged)
|
||||
inline DisplayRect primaryRect() const
|
||||
{ return qvariant_cast< DisplayRect >(property("PrimaryRect")); }
|
||||
{
|
||||
const qreal scale = qApp->devicePixelRatio();
|
||||
DisplayRect dr = qvariant_cast< DisplayRect >(property("PrimaryRect"));
|
||||
dr.x = qreal(dr.x) / scale;
|
||||
dr.y = qreal(dr.y) / scale;
|
||||
dr.width = qreal(dr.width) / scale;
|
||||
dr.height = qreal(dr.height) / scale;
|
||||
|
||||
return dr;
|
||||
}
|
||||
|
||||
Q_PROPERTY(ushort ScreenHeight READ screenHeight NOTIFY ScreenHeightChanged)
|
||||
inline ushort screenHeight() const
|
||||
{ return qvariant_cast< ushort >(property("ScreenHeight")); }
|
||||
{ return qreal(qvariant_cast< ushort >(property("ScreenHeight"))) / qApp->devicePixelRatio(); }
|
||||
|
||||
Q_PROPERTY(ushort ScreenWidth READ screenWidth NOTIFY ScreenWidthChanged)
|
||||
inline ushort screenWidth() const
|
||||
{ return qvariant_cast< ushort >(property("ScreenWidth")); }
|
||||
{ return qreal(qvariant_cast< ushort >(property("ScreenWidth"))) / qApp->devicePixelRatio(); }
|
||||
|
||||
public Q_SLOTS: // METHODS
|
||||
inline QDBusPendingReply<> Apply()
|
||||
|
@ -35,7 +35,6 @@ void RegisterDdeSession()
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
DApplication::loadDXcbPlugin();
|
||||
|
||||
DApplication app(argc, argv);
|
||||
if (!app.setSingleInstance(QString("dde-dock_%1").arg(getuid()))) {
|
||||
qDebug() << "set single instance failed!";
|
||||
@ -47,6 +46,7 @@ int main(int argc, char *argv[])
|
||||
app.setApplicationDisplayName("DDE Dock");
|
||||
app.setApplicationVersion("2.0");
|
||||
app.loadTranslator();
|
||||
app.setAttribute(Qt::AA_EnableHighDpiScaling, true);
|
||||
|
||||
DLogManager::registerConsoleAppender();
|
||||
DLogManager::registerFileAppender();
|
||||
|
@ -42,7 +42,7 @@ DockSettings::DockSettings(QWidget *parent)
|
||||
m_hideMode = Dock::HideMode(m_dockInter->hideMode());
|
||||
m_hideState = Dock::HideState(m_dockInter->hideState());
|
||||
m_iconSize = m_dockInter->iconSize();
|
||||
AppItem::setIconBaseSize(m_iconSize);
|
||||
AppItem::setIconBaseSize(m_iconSize * qApp->devicePixelRatio());
|
||||
DockItem::setDockPosition(m_position);
|
||||
qApp->setProperty(PROP_POSITION, QVariant::fromValue(m_position));
|
||||
DockItem::setDockDisplayMode(m_displayMode);
|
||||
@ -304,7 +304,7 @@ void DockSettings::iconSizeChanged()
|
||||
{
|
||||
// qDebug() << Q_FUNC_INFO;
|
||||
m_iconSize = m_dockInter->iconSize();
|
||||
AppItem::setIconBaseSize(m_iconSize);
|
||||
AppItem::setIconBaseSize(m_iconSize * qApp->devicePixelRatio());
|
||||
|
||||
calculateWindowConfig();
|
||||
|
||||
|
@ -430,7 +430,7 @@ void MainWindow::setStrutPartial()
|
||||
if (count > 0)
|
||||
return;
|
||||
|
||||
m_xcbMisc->set_strut_partial(winId(), orientation, strut, strutStart, strutEnd);
|
||||
m_xcbMisc->set_strut_partial(winId(), orientation, strut * qApp->devicePixelRatio(), strutStart, strutEnd);
|
||||
}
|
||||
|
||||
void MainWindow::expand()
|
||||
@ -567,7 +567,8 @@ void MainWindow::adjustShadowMask()
|
||||
return;
|
||||
}
|
||||
|
||||
const QRect r = rect();
|
||||
const qreal scale = qApp->devicePixelRatio();
|
||||
const QRect r = QRect(QPoint(), rect().size() * scale);
|
||||
const int radius = 5;
|
||||
|
||||
QPainterPath path;
|
||||
@ -589,7 +590,7 @@ void MainWindow::adjustShadowMask()
|
||||
default:;
|
||||
}
|
||||
} else {
|
||||
path.addRect(rect());
|
||||
path.addRect(r);
|
||||
}
|
||||
|
||||
m_platformWindowHandle.setShadowRadius(60);
|
||||
|
Loading…
x
Reference in New Issue
Block a user