Windows QPA: Fix some clang-tidy-warnings
- Replace index-based loops by range-based for - Change else if to if after return/break/continue or simplify - Fix indentation - Do not check for non-null before invoking delete on pointer - Use isEmpty() instead size() to check for empty containers - Remove C-style casts - Use raw string literal - Do not repeat type in return, use {} instead - Reference local variables by const ref where applicable Change-Id: I5cc4b4026a10bddb561ba1ba8ec137e0d4119f94 Reviewed-by: Miguel Costa <miguel.costa@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
parent
67b296e249
commit
43af54c228
@ -524,10 +524,11 @@ HCURSOR QWindowsCursor::createCursorFromShape(Qt::CursorShape cursorShape, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load available standard cursors from resources
|
// Load available standard cursors from resources
|
||||||
const QWindowsStandardCursorMapping *sEnd = standardCursors + sizeof(standardCursors) / sizeof(standardCursors[0]);
|
for (const QWindowsStandardCursorMapping &s : standardCursors) {
|
||||||
for (const QWindowsStandardCursorMapping *s = standardCursors; s < sEnd; ++s) {
|
if (s.shape == cursorShape) {
|
||||||
if (s->shape == cursorShape)
|
return static_cast<HCURSOR>(LoadImage(nullptr, s.resource, IMAGE_CURSOR,
|
||||||
return static_cast<HCURSOR>(LoadImage(0, s->resource, IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE | LR_SHARED));
|
0, 0, LR_DEFAULTSIZE | LR_SHARED));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qWarning("%s: Invalid cursor shape %d", __FUNCTION__, cursorShape);
|
qWarning("%s: Invalid cursor shape %d", __FUNCTION__, cursorShape);
|
||||||
|
@ -364,7 +364,7 @@ static BOOL QT_WIN_CALLBACK findDialogEnumWindowsProc(HWND hwnd, LPARAM lParam)
|
|||||||
wchar_t buf[256];
|
wchar_t buf[256];
|
||||||
if (!RealGetWindowClass(hwnd, buf, sizeof(buf)/sizeof(wchar_t)) || buf[0] != L'#')
|
if (!RealGetWindowClass(hwnd, buf, sizeof(buf)/sizeof(wchar_t)) || buf[0] != L'#')
|
||||||
return TRUE;
|
return TRUE;
|
||||||
if (!GetWindowTextW(hwnd, buf, sizeof(buf)/sizeof(wchar_t)) || wcscmp(buf, context->title.data()))
|
if (!GetWindowTextW(hwnd, buf, sizeof(buf)/sizeof(wchar_t)) || wcscmp(buf, context->title.data()) != 0)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
context->hwnd = hwnd;
|
context->hwnd = hwnd;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -1545,8 +1545,8 @@ QWindowsNativeDialogBase *QWindowsFileDialogHelper::createNativeDialog()
|
|||||||
result->updateDirectory();
|
result->updateDirectory();
|
||||||
result->updateSelectedNameFilter();
|
result->updateSelectedNameFilter();
|
||||||
const QList<QUrl> initialSelection = opts->initiallySelectedFiles();
|
const QList<QUrl> initialSelection = opts->initiallySelectedFiles();
|
||||||
if (initialSelection.size() > 0) {
|
if (!initialSelection.empty()) {
|
||||||
const QUrl url = initialSelection.front();
|
const QUrl &url = initialSelection.constFirst();
|
||||||
if (url.isLocalFile()) {
|
if (url.isLocalFile()) {
|
||||||
QFileInfo info(url.toLocalFile());
|
QFileInfo info(url.toLocalFile());
|
||||||
if (!info.isDir())
|
if (!info.isDir())
|
||||||
@ -1698,7 +1698,7 @@ void QWindowsXpNativeFileDialog::doExec(HWND owner)
|
|||||||
const QStringList nameFilters = m_options->nameFilters();
|
const QStringList nameFilters = m_options->nameFilters();
|
||||||
if (selectedFilterIndex >= 0 && selectedFilterIndex < nameFilters.size())
|
if (selectedFilterIndex >= 0 && selectedFilterIndex < nameFilters.size())
|
||||||
m_data.setSelectedNameFilter(nameFilters.at(selectedFilterIndex));
|
m_data.setSelectedNameFilter(nameFilters.at(selectedFilterIndex));
|
||||||
QUrl firstFile = selectedFiles.front();
|
const QUrl &firstFile = selectedFiles.constFirst();
|
||||||
m_data.setDirectory(firstFile.adjusted(QUrl::RemoveFilename));
|
m_data.setDirectory(firstFile.adjusted(QUrl::RemoveFilename));
|
||||||
m_result = QPlatformDialogHelper::Accepted;
|
m_result = QPlatformDialogHelper::Accepted;
|
||||||
emit accepted();
|
emit accepted();
|
||||||
@ -1727,7 +1727,7 @@ int QWindowsXpNativeFileDialog::existingDirCallback(HWND hwnd, UINT uMsg, LPARAM
|
|||||||
switch (uMsg) {
|
switch (uMsg) {
|
||||||
case BFFM_INITIALIZED: {
|
case BFFM_INITIALIZED: {
|
||||||
if (!m_title.isEmpty())
|
if (!m_title.isEmpty())
|
||||||
SetWindowText(hwnd, (wchar_t *)m_title.utf16());
|
SetWindowText(hwnd, reinterpret_cast<const wchar_t *>(m_title.utf16()));
|
||||||
const QString initialFile = QDir::toNativeSeparators(m_data.directory().toLocalFile());
|
const QString initialFile = QDir::toNativeSeparators(m_data.directory().toLocalFile());
|
||||||
if (!initialFile.isEmpty())
|
if (!initialFile.isEmpty())
|
||||||
SendMessage(hwnd, BFFM_SETSELECTION, TRUE, LPARAM(initialFile.utf16()));
|
SendMessage(hwnd, BFFM_SETSELECTION, TRUE, LPARAM(initialFile.utf16()));
|
||||||
|
@ -889,19 +889,19 @@ EGLConfig QWindowsEGLContext::chooseConfig(const QSurfaceFormat &format)
|
|||||||
EGLint green = 0;
|
EGLint green = 0;
|
||||||
EGLint blue = 0;
|
EGLint blue = 0;
|
||||||
EGLint alpha = 0;
|
EGLint alpha = 0;
|
||||||
for (int i = 0; i < configs.size(); ++i) {
|
for (const EGLConfig &config : configs) {
|
||||||
if (confAttrRed)
|
if (confAttrRed)
|
||||||
QWindowsEGLStaticContext::libEGL.eglGetConfigAttrib(display, configs[i], EGL_RED_SIZE, &red);
|
QWindowsEGLStaticContext::libEGL.eglGetConfigAttrib(display, config, EGL_RED_SIZE, &red);
|
||||||
if (confAttrGreen)
|
if (confAttrGreen)
|
||||||
QWindowsEGLStaticContext::libEGL.eglGetConfigAttrib(display, configs[i], EGL_GREEN_SIZE, &green);
|
QWindowsEGLStaticContext::libEGL.eglGetConfigAttrib(display, config, EGL_GREEN_SIZE, &green);
|
||||||
if (confAttrBlue)
|
if (confAttrBlue)
|
||||||
QWindowsEGLStaticContext::libEGL.eglGetConfigAttrib(display, configs[i], EGL_BLUE_SIZE, &blue);
|
QWindowsEGLStaticContext::libEGL.eglGetConfigAttrib(display, config, EGL_BLUE_SIZE, &blue);
|
||||||
if (confAttrAlpha)
|
if (confAttrAlpha)
|
||||||
QWindowsEGLStaticContext::libEGL.eglGetConfigAttrib(display, configs[i], EGL_ALPHA_SIZE, &alpha);
|
QWindowsEGLStaticContext::libEGL.eglGetConfigAttrib(display, config, EGL_ALPHA_SIZE, &alpha);
|
||||||
|
|
||||||
if (red == confAttrRed && green == confAttrGreen
|
if (red == confAttrRed && green == confAttrGreen
|
||||||
&& blue == confAttrBlue && alpha == confAttrAlpha)
|
&& blue == confAttrBlue && alpha == confAttrAlpha)
|
||||||
return configs[i];
|
return config;
|
||||||
}
|
}
|
||||||
} while (reduceConfigAttributes(&configureAttributes));
|
} while (reduceConfigAttributes(&configureAttributes));
|
||||||
|
|
||||||
|
@ -206,18 +206,12 @@ bool QWindowsOpengl32DLL::init(bool softwareRendering)
|
|||||||
|
|
||||||
BOOL QWindowsOpengl32DLL::swapBuffers(HDC dc)
|
BOOL QWindowsOpengl32DLL::swapBuffers(HDC dc)
|
||||||
{
|
{
|
||||||
if (moduleIsNotOpengl32())
|
return moduleIsNotOpengl32() ? wglSwapBuffers(dc) : SwapBuffers(dc);
|
||||||
return wglSwapBuffers(dc);
|
|
||||||
else
|
|
||||||
return SwapBuffers(dc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL QWindowsOpengl32DLL::setPixelFormat(HDC dc, int pf, const PIXELFORMATDESCRIPTOR *pfd)
|
BOOL QWindowsOpengl32DLL::setPixelFormat(HDC dc, int pf, const PIXELFORMATDESCRIPTOR *pfd)
|
||||||
{
|
{
|
||||||
if (moduleIsNotOpengl32())
|
return moduleIsNotOpengl32() ? wglSetPixelFormat(dc, pf, pfd) : SetPixelFormat(dc, pf, pfd);
|
||||||
return wglSetPixelFormat(dc, pf, pfd);
|
|
||||||
else
|
|
||||||
return SetPixelFormat(dc, pf, pfd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QWindowsOpenGLContext *QOpenGLStaticContext::createContext(QOpenGLContext *context)
|
QWindowsOpenGLContext *QOpenGLStaticContext::createContext(QOpenGLContext *context)
|
||||||
|
@ -255,7 +255,6 @@ QWindowsIntegrationPrivate::QWindowsIntegrationPrivate(const QStringList ¶mL
|
|||||||
|
|
||||||
QWindowsIntegrationPrivate::~QWindowsIntegrationPrivate()
|
QWindowsIntegrationPrivate::~QWindowsIntegrationPrivate()
|
||||||
{
|
{
|
||||||
if (m_fontDatabase)
|
|
||||||
delete m_fontDatabase;
|
delete m_fontDatabase;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -653,8 +653,8 @@ static inline int asciiToKeycode(char a, int state)
|
|||||||
|
|
||||||
void QWindowsKeyMapper::deleteLayouts()
|
void QWindowsKeyMapper::deleteLayouts()
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < NumKeyboardLayoutItems; ++i)
|
for (KeyboardLayoutItem &k : keyLayout)
|
||||||
keyLayout[i].exists = false;
|
k.exists = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWindowsKeyMapper::changeKeyboard()
|
void QWindowsKeyMapper::changeKeyboard()
|
||||||
@ -1111,7 +1111,8 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms
|
|||||||
if (uch.isHighSurrogate()) {
|
if (uch.isHighSurrogate()) {
|
||||||
m_lastHighSurrogate = uch;
|
m_lastHighSurrogate = uch;
|
||||||
return true;
|
return true;
|
||||||
} else if (uch.isLowSurrogate() && !m_lastHighSurrogate.isNull()) {
|
}
|
||||||
|
if (uch.isLowSurrogate() && !m_lastHighSurrogate.isNull()) {
|
||||||
if (QObject *focusObject = QGuiApplication::focusObject()) {
|
if (QObject *focusObject = QGuiApplication::focusObject()) {
|
||||||
const QChar chars[2] = {m_lastHighSurrogate, uch};
|
const QChar chars[2] = {m_lastHighSurrogate, uch};
|
||||||
QInputMethodEvent event;
|
QInputMethodEvent event;
|
||||||
|
@ -628,7 +628,8 @@ bool QWindowsMimeText::convertFromMime(const FORMATETC &formatetc, const QMimeDa
|
|||||||
}
|
}
|
||||||
o[j]=0;
|
o[j]=0;
|
||||||
return setData(r, pmedium);
|
return setData(r, pmedium);
|
||||||
} else if (cf == CF_UNICODETEXT) {
|
}
|
||||||
|
if (cf == CF_UNICODETEXT) {
|
||||||
QString str = mimeData->text();
|
QString str = mimeData->text();
|
||||||
const QChar *u = str.unicode();
|
const QChar *u = str.unicode();
|
||||||
QString res;
|
QString res;
|
||||||
@ -750,9 +751,9 @@ QWindowsMimeURI::QWindowsMimeURI()
|
|||||||
bool QWindowsMimeURI::canConvertFromMime(const FORMATETC &formatetc, const QMimeData *mimeData) const
|
bool QWindowsMimeURI::canConvertFromMime(const FORMATETC &formatetc, const QMimeData *mimeData) const
|
||||||
{
|
{
|
||||||
if (mimeData->hasUrls() && getCf(formatetc) == CF_HDROP) {
|
if (mimeData->hasUrls() && getCf(formatetc) == CF_HDROP) {
|
||||||
QList<QUrl> urls = mimeData->urls();
|
const QList<QUrl> urls = mimeData->urls();
|
||||||
for (int i=0; i<urls.size(); i++) {
|
for (const QUrl &url : urls) {
|
||||||
if (!urls.at(i).toLocalFile().isEmpty())
|
if (url.isLocalFile())
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -763,11 +764,11 @@ bool QWindowsMimeURI::convertFromMime(const FORMATETC &formatetc, const QMimeDat
|
|||||||
{
|
{
|
||||||
if (canConvertFromMime(formatetc, mimeData)) {
|
if (canConvertFromMime(formatetc, mimeData)) {
|
||||||
if (getCf(formatetc) == CF_HDROP) {
|
if (getCf(formatetc) == CF_HDROP) {
|
||||||
QList<QUrl> urls = mimeData->urls();
|
const QList<QUrl> &urls = mimeData->urls();
|
||||||
QStringList fileNames;
|
QStringList fileNames;
|
||||||
int size = sizeof(DROPFILES)+2;
|
int size = sizeof(DROPFILES)+2;
|
||||||
for (int i=0; i<urls.size(); i++) {
|
for (const QUrl &url : urls) {
|
||||||
QString fn = QDir::toNativeSeparators(urls.at(i).toLocalFile());
|
const QString fn = QDir::toNativeSeparators(url.toLocalFile());
|
||||||
if (!fn.isEmpty()) {
|
if (!fn.isEmpty()) {
|
||||||
size += sizeof(ushort) * size_t(fn.length() + 1);
|
size += sizeof(ushort) * size_t(fn.length() + 1);
|
||||||
fileNames.append(fn);
|
fileNames.append(fn);
|
||||||
@ -792,7 +793,8 @@ bool QWindowsMimeURI::convertFromMime(const FORMATETC &formatetc, const QMimeDat
|
|||||||
*f = 0;
|
*f = 0;
|
||||||
|
|
||||||
return setData(result, pmedium);
|
return setData(result, pmedium);
|
||||||
} else if (getCf(formatetc) == CF_INETURL_W) {
|
}
|
||||||
|
if (getCf(formatetc) == CF_INETURL_W) {
|
||||||
QList<QUrl> urls = mimeData->urls();
|
QList<QUrl> urls = mimeData->urls();
|
||||||
QByteArray result;
|
QByteArray result;
|
||||||
if (!urls.isEmpty()) {
|
if (!urls.isEmpty()) {
|
||||||
@ -803,7 +805,8 @@ bool QWindowsMimeURI::convertFromMime(const FORMATETC &formatetc, const QMimeDat
|
|||||||
result.append('\0');
|
result.append('\0');
|
||||||
result.append('\0');
|
result.append('\0');
|
||||||
return setData(result, pmedium);
|
return setData(result, pmedium);
|
||||||
} else if (getCf(formatetc) == CF_INETURL) {
|
}
|
||||||
|
if (getCf(formatetc) == CF_INETURL) {
|
||||||
QList<QUrl> urls = mimeData->urls();
|
QList<QUrl> urls = mimeData->urls();
|
||||||
QByteArray result;
|
QByteArray result;
|
||||||
if (!urls.isEmpty())
|
if (!urls.isEmpty())
|
||||||
@ -873,7 +876,7 @@ QVariant QWindowsMimeURI::convertToMime(const QString &mimeType, LPDATAOBJECT pD
|
|||||||
|
|
||||||
if (preferredType == QVariant::Url && urls.size() == 1)
|
if (preferredType == QVariant::Url && urls.size() == 1)
|
||||||
return urls.at(0);
|
return urls.at(0);
|
||||||
else if (!urls.isEmpty())
|
if (!urls.isEmpty())
|
||||||
return urls;
|
return urls;
|
||||||
} else if (canGetData(CF_INETURL_W, pDataObj)) {
|
} else if (canGetData(CF_INETURL_W, pDataObj)) {
|
||||||
QByteArray data = getData(CF_INETURL_W, pDataObj);
|
QByteArray data = getData(CF_INETURL_W, pDataObj);
|
||||||
@ -1076,10 +1079,8 @@ QString QWindowsMimeImage::mimeForFormat(const FORMATETC &formatetc) const
|
|||||||
|
|
||||||
bool QWindowsMimeImage::canConvertToMime(const QString &mimeType, IDataObject *pDataObj) const
|
bool QWindowsMimeImage::canConvertToMime(const QString &mimeType, IDataObject *pDataObj) const
|
||||||
{
|
{
|
||||||
if (mimeType == QLatin1String("application/x-qt-image") &&
|
return mimeType == QLatin1String("application/x-qt-image")
|
||||||
(canGetData(CF_DIB, pDataObj) || canGetData(CF_PNG, pDataObj)))
|
&& (canGetData(CF_DIB, pDataObj) || canGetData(CF_PNG, pDataObj));
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QWindowsMimeImage::canConvertFromMime(const FORMATETC &formatetc, const QMimeData *mimeData) const
|
bool QWindowsMimeImage::canConvertFromMime(const FORMATETC &formatetc, const QMimeData *mimeData) const
|
||||||
@ -1135,7 +1136,7 @@ bool QWindowsMimeImage::hasOriginalDIBV5(IDataObject *pDataObj) const
|
|||||||
CoTaskMemFree(fc.ptd);
|
CoTaskMemFree(fc.ptd);
|
||||||
if (fc.cfFormat == CF_DIB)
|
if (fc.cfFormat == CF_DIB)
|
||||||
break;
|
break;
|
||||||
else if (fc.cfFormat == CF_DIBV5) {
|
if (fc.cfFormat == CF_DIBV5) {
|
||||||
isSynthesized = false;
|
isSynthesized = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1329,7 +1330,7 @@ QStringList QLastResortMimes::excludeList;
|
|||||||
QLastResortMimes::QLastResortMimes()
|
QLastResortMimes::QLastResortMimes()
|
||||||
{
|
{
|
||||||
//MIME Media-Types
|
//MIME Media-Types
|
||||||
if (!ianaTypes.size()) {
|
if (ianaTypes.isEmpty()) {
|
||||||
ianaTypes.append(QStringLiteral("application/"));
|
ianaTypes.append(QStringLiteral("application/"));
|
||||||
ianaTypes.append(QStringLiteral("audio/"));
|
ianaTypes.append(QStringLiteral("audio/"));
|
||||||
ianaTypes.append(QStringLiteral("example/"));
|
ianaTypes.append(QStringLiteral("example/"));
|
||||||
@ -1341,7 +1342,7 @@ QLastResortMimes::QLastResortMimes()
|
|||||||
ianaTypes.append(QStringLiteral("video/"));
|
ianaTypes.append(QStringLiteral("video/"));
|
||||||
}
|
}
|
||||||
//Types handled by other classes
|
//Types handled by other classes
|
||||||
if (!excludeList.size()) {
|
if (excludeList.isEmpty()) {
|
||||||
excludeList.append(QStringLiteral("HTML Format"));
|
excludeList.append(QStringLiteral("HTML Format"));
|
||||||
excludeList.append(QStringLiteral("UniformResourceLocator"));
|
excludeList.append(QStringLiteral("UniformResourceLocator"));
|
||||||
excludeList.append(QStringLiteral("text/html"));
|
excludeList.append(QStringLiteral("text/html"));
|
||||||
|
@ -363,9 +363,9 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd,
|
|||||||
}
|
}
|
||||||
m_previousCaptureWindow = window;
|
m_previousCaptureWindow = window;
|
||||||
return true;
|
return true;
|
||||||
} else if (m_leftButtonDown && !actualLeftDown) {
|
|
||||||
m_leftButtonDown = false;
|
|
||||||
}
|
}
|
||||||
|
if (m_leftButtonDown && !actualLeftDown)
|
||||||
|
m_leftButtonDown = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// In this context, neither an invisible nor a transparent window (transparent regarding mouse
|
// In this context, neither an invisible nor a transparent window (transparent regarding mouse
|
||||||
|
@ -275,11 +275,11 @@ QFunctionPointer QWindowsNativeInterface::platformFunction(const QByteArray &fun
|
|||||||
{
|
{
|
||||||
if (function == QWindowsWindowFunctions::setTouchWindowTouchTypeIdentifier())
|
if (function == QWindowsWindowFunctions::setTouchWindowTouchTypeIdentifier())
|
||||||
return QFunctionPointer(QWindowsWindow::setTouchWindowTouchTypeStatic);
|
return QFunctionPointer(QWindowsWindow::setTouchWindowTouchTypeStatic);
|
||||||
else if (function == QWindowsWindowFunctions::setHasBorderInFullScreenIdentifier())
|
if (function == QWindowsWindowFunctions::setHasBorderInFullScreenIdentifier())
|
||||||
return QFunctionPointer(QWindowsWindow::setHasBorderInFullScreenStatic);
|
return QFunctionPointer(QWindowsWindow::setHasBorderInFullScreenStatic);
|
||||||
else if (function == QWindowsWindowFunctions::setWindowActivationBehaviorIdentifier())
|
if (function == QWindowsWindowFunctions::setWindowActivationBehaviorIdentifier())
|
||||||
return QFunctionPointer(QWindowsNativeInterface::setWindowActivationBehavior);
|
return QFunctionPointer(QWindowsNativeInterface::setWindowActivationBehavior);
|
||||||
else if (function == QWindowsWindowFunctions::isTabletModeIdentifier())
|
if (function == QWindowsWindowFunctions::isTabletModeIdentifier())
|
||||||
return QFunctionPointer(QWindowsNativeInterface::isTabletMode);
|
return QFunctionPointer(QWindowsNativeInterface::isTabletMode);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -365,10 +365,9 @@ QWindowsOleEnumFmtEtc::Clone(LPENUMFORMATETC FAR* newEnum)
|
|||||||
if (result->isNull()) {
|
if (result->isNull()) {
|
||||||
delete result;
|
delete result;
|
||||||
return ResultFromScode(E_OUTOFMEMORY);
|
return ResultFromScode(E_OUTOFMEMORY);
|
||||||
} else {
|
|
||||||
*newEnum = result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*newEnum = result;
|
||||||
return NOERROR;
|
return NOERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ static inline QDpi monitorDPI(HMONITOR hMonitor)
|
|||||||
if (SUCCEEDED(QWindowsContext::shcoredll.getDpiForMonitor(hMonitor, 0, &dpiX, &dpiY)))
|
if (SUCCEEDED(QWindowsContext::shcoredll.getDpiForMonitor(hMonitor, 0, &dpiX, &dpiY)))
|
||||||
return QDpi(dpiX, dpiY);
|
return QDpi(dpiX, dpiY);
|
||||||
}
|
}
|
||||||
return QDpi(0, 0);
|
return {0, 0};
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef QList<QWindowsScreenData> WindowsScreenDataList;
|
typedef QList<QWindowsScreenData> WindowsScreenDataList;
|
||||||
@ -401,7 +401,8 @@ QPlatformScreen::SubpixelAntialiasingType QWindowsScreen::subpixelAntialiasingTy
|
|||||||
{
|
{
|
||||||
QPlatformScreen::SubpixelAntialiasingType type = QPlatformScreen::subpixelAntialiasingTypeHint();
|
QPlatformScreen::SubpixelAntialiasingType type = QPlatformScreen::subpixelAntialiasingTypeHint();
|
||||||
if (type == QPlatformScreen::Subpixel_None) {
|
if (type == QPlatformScreen::Subpixel_None) {
|
||||||
QSettings settings(QLatin1String("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Avalon.Graphics\\DISPLAY1"), QSettings::NativeFormat);
|
QSettings settings(QLatin1String(R"(HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Avalon.Graphics\DISPLAY1)"),
|
||||||
|
QSettings::NativeFormat);
|
||||||
int registryValue = settings.value(QLatin1String("PixelStructure"), -1).toInt();
|
int registryValue = settings.value(QLatin1String("PixelStructure"), -1).toInt();
|
||||||
switch (registryValue) {
|
switch (registryValue) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -108,7 +108,7 @@ inline QPointF QWindowsTabletDeviceData::scaleCoordinates(int coordX, int coordY
|
|||||||
((coordY - minY) * qAbs(targetHeight) / qAbs(qreal(maxY - minY))) + targetY :
|
((coordY - minY) * qAbs(targetHeight) / qAbs(qreal(maxY - minY))) + targetY :
|
||||||
((qAbs(maxY) - (coordY - minY)) * qAbs(targetHeight) / qAbs(qreal(maxY - minY))) + targetY;
|
((qAbs(maxY) - (coordY - minY)) * qAbs(targetHeight) / qAbs(qreal(maxY - minY))) + targetY;
|
||||||
|
|
||||||
return QPointF(x, y);
|
return {x, y};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Stream>
|
template <class Stream>
|
||||||
|
@ -107,7 +107,7 @@ static inline bool booleanSystemParametersInfo(UINT what, bool defaultValue)
|
|||||||
{
|
{
|
||||||
BOOL result;
|
BOOL result;
|
||||||
if (SystemParametersInfo(what, 0, &result, 0))
|
if (SystemParametersInfo(what, 0, &result, 0))
|
||||||
return result ? true : false;
|
return result != FALSE;
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,9 +121,9 @@ static inline DWORD dWordSystemParametersInfo(UINT what, DWORD defaultValue)
|
|||||||
|
|
||||||
static inline QColor mixColors(const QColor &c1, const QColor &c2)
|
static inline QColor mixColors(const QColor &c1, const QColor &c2)
|
||||||
{
|
{
|
||||||
return QColor ((c1.red() + c2.red()) / 2,
|
return {(c1.red() + c2.red()) / 2,
|
||||||
(c1.green() + c2.green()) / 2,
|
(c1.green() + c2.green()) / 2,
|
||||||
(c1.blue() + c2.blue()) / 2);
|
(c1.blue() + c2.blue()) / 2};
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline QColor getSysColor(int index)
|
static inline QColor getSysColor(int index)
|
||||||
|
@ -660,7 +660,7 @@ QWindowsWindowData
|
|||||||
WindowData result;
|
WindowData result;
|
||||||
result.flags = flags;
|
result.flags = flags;
|
||||||
|
|
||||||
const HINSTANCE appinst = (HINSTANCE)GetModuleHandle(0);
|
const auto appinst = reinterpret_cast<HINSTANCE>(GetModuleHandle(nullptr));
|
||||||
|
|
||||||
const QString windowClassName = QWindowsContext::instance()->registerWindowClass(w);
|
const QString windowClassName = QWindowsContext::instance()->registerWindowClass(w);
|
||||||
|
|
||||||
@ -1374,18 +1374,12 @@ bool QWindowsWindow::isEmbedded() const
|
|||||||
|
|
||||||
QPoint QWindowsWindow::mapToGlobal(const QPoint &pos) const
|
QPoint QWindowsWindow::mapToGlobal(const QPoint &pos) const
|
||||||
{
|
{
|
||||||
if (m_data.hwnd)
|
return m_data.hwnd ? QWindowsGeometryHint::mapToGlobal(m_data.hwnd, pos) : pos;
|
||||||
return QWindowsGeometryHint::mapToGlobal(m_data.hwnd, pos);
|
|
||||||
else
|
|
||||||
return pos;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QPoint QWindowsWindow::mapFromGlobal(const QPoint &pos) const
|
QPoint QWindowsWindow::mapFromGlobal(const QPoint &pos) const
|
||||||
{
|
{
|
||||||
if (m_data.hwnd)
|
return m_data.hwnd ? QWindowsGeometryHint::mapFromGlobal(m_data.hwnd, pos) : pos;
|
||||||
return QWindowsGeometryHint::mapFromGlobal(m_data.hwnd, pos);
|
|
||||||
else
|
|
||||||
return pos;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline HWND transientParentHwnd(HWND hwnd)
|
static inline HWND transientParentHwnd(HWND hwnd)
|
||||||
|
@ -430,7 +430,7 @@ inline QWindowsWindow *QWindowsWindow::windowsWindowOf(const QWindow *w)
|
|||||||
|
|
||||||
void *QWindowsWindow::userDataOf(HWND hwnd)
|
void *QWindowsWindow::userDataOf(HWND hwnd)
|
||||||
{
|
{
|
||||||
return (void *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
return reinterpret_cast<void *>(GetWindowLongPtr(hwnd, GWLP_USERDATA));
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWindowsWindow::setUserDataOf(HWND hwnd, void *ud)
|
void QWindowsWindow::setUserDataOf(HWND hwnd, void *ud)
|
||||||
|
Loading…
Reference in New Issue
Block a user