From a34c4413738f980bcd1296e0bd554d46685ddef7 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 12 Dec 2016 14:09:21 +0100 Subject: [PATCH] Qt4/Qt5 neutral changes: + replace Q_WS_WIN with Q_OS_WIN + replace Q_WS_X11 with Q_OS_LINUX + replace Q_WS_MACX with Q_OS_MACX + set explicit cast to HWND --- src/Gui/Application.cpp | 2 +- src/Gui/DlgExpressionInput.cpp | 6 +++--- src/Gui/DlgMaterialPropertiesImp.cpp | 2 +- src/Gui/GuiApplicationNativeEventAware.cpp | 14 +++++++------- src/Gui/GuiApplicationNativeEventAware.h | 16 ++++++++-------- src/Gui/MainWindow.cpp | 2 +- src/Gui/WinNativeGestureRecognizers.h | 4 ++-- src/Main/FreeCADGuiPy.cpp | 4 ++-- src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp | 2 +- src/Mod/Spreadsheet/Gui/qtcolorpicker.h | 2 +- 10 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index 3d84b346d3..acee4bb34d 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -1627,7 +1627,7 @@ void Application::runApplication(void) else if (version & QGLFormat::OpenGL_Version_None) Base::Console().Log("No OpenGL is present or no OpenGL context is current\n"); -#if !defined(Q_WS_X11) +#if !defined(Q_OS_LINUX) QIcon::setThemeSearchPaths(QIcon::themeSearchPaths() << QString::fromLatin1(":/icons/FreeCAD-default")); QIcon::setThemeName(QLatin1String("FreeCAD-default")); #endif diff --git a/src/Gui/DlgExpressionInput.cpp b/src/Gui/DlgExpressionInput.cpp index 1d9bc0bb3c..d6d2ab97e5 100644 --- a/src/Gui/DlgExpressionInput.cpp +++ b/src/Gui/DlgExpressionInput.cpp @@ -180,7 +180,7 @@ void DlgExpressionInput::setExpressionInputSize(int width, int height) void DlgExpressionInput::mouseReleaseEvent(QMouseEvent* ev) { -#if 0//defined(Q_WS_WIN) +#if 0//defined(Q_OS_WIN) if (QWidget::mouseGrabber() == this) { QList childs = this->findChildren(); for (QList::iterator it = childs.begin(); it != childs.end(); ++it) { @@ -203,7 +203,7 @@ void DlgExpressionInput::mouseReleaseEvent(QMouseEvent* ev) void DlgExpressionInput::mousePressEvent(QMouseEvent* ev) { -#if 0//defined(Q_WS_WIN) +#if 0//defined(Q_OS_WIN) bool handled = false; if (QWidget::mouseGrabber() == this) { QList childs = this->findChildren(); @@ -241,7 +241,7 @@ void DlgExpressionInput::showEvent(QShowEvent* ev) { QDialog::showEvent(ev); -#if 0//defined(Q_WS_WIN) +#if 0//defined(Q_OS_WIN) // This way we can fetch click events outside modal dialogs QWidget* widget = QApplication::activeModalWidget(); if (widget) { diff --git a/src/Gui/DlgMaterialPropertiesImp.cpp b/src/Gui/DlgMaterialPropertiesImp.cpp index 0703335e27..cf8c51f5a6 100644 --- a/src/Gui/DlgMaterialPropertiesImp.cpp +++ b/src/Gui/DlgMaterialPropertiesImp.cpp @@ -52,7 +52,7 @@ DlgMaterialPropertiesImp::DlgMaterialPropertiesImp(const std::string& mat, QWidg this->diffuseColor->hide(); } -//#if !defined(Q_WS_MAC) +//#if !defined(Q_OS_MAC) ambientColor->setAutoChangeColor(true); diffuseColor->setAutoChangeColor(true); emissiveColor->setAutoChangeColor(true); diff --git a/src/Gui/GuiApplicationNativeEventAware.cpp b/src/Gui/GuiApplicationNativeEventAware.cpp index fb934d593a..6168d59dff 100644 --- a/src/Gui/GuiApplicationNativeEventAware.cpp +++ b/src/Gui/GuiApplicationNativeEventAware.cpp @@ -43,7 +43,7 @@ #ifdef _USE_3DCONNEXION_SDK //windows -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN Gui::GUIApplicationNativeEventAware* Gui::GUIApplicationNativeEventAware::gMouseInput = 0; #endif #endif //_USE_3DCONNEXION_SDK @@ -66,14 +66,14 @@ Gui::GUIApplicationNativeEventAware::~GUIApplicationNativeEventAware() #endif #ifdef _USE_3DCONNEXION_SDK -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN if (gMouseInput == this) { gMouseInput = 0; Base::Console().Log("3Dconnexion device detached.\n"); } #endif //mac -#ifdef Q_WS_MACX +#ifdef Q_OS_MACX // if 3Dconnexion library was loaded at runtime if (InstallConnexionHandlers) { // Close our connection with the 3dx driver @@ -103,13 +103,13 @@ void Gui::GUIApplicationNativeEventAware::initSpaceball(QMainWindow *window) #endif #ifdef _USE_3DCONNEXION_SDK -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN spaceballPresent = Is3dmouseAttached(); if (spaceballPresent) { fLast3dmouseInputTime = 0; - if (InitializeRawInput(mainWindow->winId())){ + if (InitializeRawInput((HWND)mainWindow->winId())){ gMouseInput = this; qApp->setEventFilter(Gui::GUIApplicationNativeEventAware::RawInputEventFilter); Base::Console().Log("3Dconnexion device initialized.\n"); @@ -119,9 +119,9 @@ void Gui::GUIApplicationNativeEventAware::initSpaceball(QMainWindow *window) } else { Base::Console().Log("3Dconnexion device not attached.\n"); } -#endif // #ifdef Q_WS_WIN +#endif // #ifdef Q_OS_WIN //mac -#ifdef Q_WS_MACX +#ifdef Q_OS_MACX OSStatus err; /* make sure the framework is installed */ if (InstallConnexionHandlers == NULL) diff --git a/src/Gui/GuiApplicationNativeEventAware.h b/src/Gui/GuiApplicationNativeEventAware.h index b52cb0576b..d3a5f71080 100644 --- a/src/Gui/GuiApplicationNativeEventAware.h +++ b/src/Gui/GuiApplicationNativeEventAware.h @@ -32,7 +32,7 @@ class QMainWindow; #ifdef _USE_3DCONNEXION_SDK -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN #include "3Dconnexion/MouseParameters.h" #include @@ -41,9 +41,9 @@ class QMainWindow; //#define _WIN32_WINNT 0x0501 //target at least windows XP #include -#endif // Q_WS_WIN +#endif // Q_OS_WIN -#ifdef Q_WS_MACX +#ifdef Q_OS_MACX #include #include // Note that InstallConnexionHandlers will be replaced with @@ -56,7 +56,7 @@ extern UInt16 RegisterConnexionClient(UInt32 signature, UInt8 *name, UInt16 mode UInt32 mask) __attribute__((weak_import)); extern void UnregisterConnexionClient(UInt16 clientID) __attribute__((weak_import)); extern void CleanupConnexionHandlers(void) __attribute__((weak_import)); -#endif // Q_WS_MACX +#endif // Q_OS_MACX #endif // _USE_3DCONNEXION_SDK @@ -87,7 +87,7 @@ namespace Gui #ifdef _USE_3DCONNEXION_SDK // For Windows -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN public: static bool Is3dmouseAttached(); @@ -131,8 +131,8 @@ namespace Gui // use to calculate distance traveled since last event DWORD fLast3dmouseInputTime; static Gui::GUIApplicationNativeEventAware* gMouseInput; -#endif // Q_WS_WIN -#ifdef Q_WS_MACX +#endif // Q_OS_WIN +#ifdef Q_OS_MACX private: static UInt16 tdxClientID; /* ID assigned by the driver */ static uint32_t lastButtons; @@ -143,7 +143,7 @@ namespace Gui void Move3d(); void Button3d(bool buttonDown, int buttonNumber); -#endif// Q_WS_MACX +#endif// Q_OS_MACX #endif // _USE_3DCONNEXION_SDK }; } diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp index 31d6c8e773..8917d00a20 100644 --- a/src/Gui/MainWindow.cpp +++ b/src/Gui/MainWindow.cpp @@ -1019,7 +1019,7 @@ void MainWindow::showMainWindow() // starts a timer to check for the visibility of the main window and call // ShowWindow() if needed. // So far, this phenomena only appeared with Qt4.1.4 -#if defined(Q_WS_WIN) && (QT_VERSION == 0x040104) +#if defined(Q_OS_WIN) && (QT_VERSION == 0x040104) WId id = this->winId(); ShowWindow(id, SW_SHOW); std::cout << "Force to show main window" << std::endl; diff --git a/src/Gui/WinNativeGestureRecognizers.h b/src/Gui/WinNativeGestureRecognizers.h index 34eb3d8d76..b58faabbfe 100644 --- a/src/Gui/WinNativeGestureRecognizers.h +++ b/src/Gui/WinNativeGestureRecognizers.h @@ -33,13 +33,13 @@ #include #include -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN #if QT_VERSION < 0x050000 #if(WINVER >= 0x0601) // need Windows 7 #define GESTURE_MESS #endif #endif // QT_VERSION < 0x050000 -#endif // Q_WS_WIN +#endif // Q_OS_WIN #ifdef GESTURE_MESS diff --git a/src/Main/FreeCADGuiPy.cpp b/src/Main/FreeCADGuiPy.cpp index 37f7ae34c5..d0211c0147 100644 --- a/src/Main/FreeCADGuiPy.cpp +++ b/src/Main/FreeCADGuiPy.cpp @@ -198,14 +198,14 @@ FreeCADGui_embedToWindow(PyObject * /*self*/, PyObject *args) #if defined(Q_OS_WIN) void* window = 0; str >> window; - WId winid = (WId)window; + HWND winid = (HWND)window; LONG oldLong = GetWindowLong(winid, GWL_STYLE); SetWindowLong(winid, GWL_STYLE, oldLong | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); //SetWindowLong(widget->winId(), GWL_STYLE, // WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); - SetParent(widget->winId(), winid); + SetParent((HWND)widget->winId(), winid); QEvent embeddingEvent(QEvent::EmbeddingControl); QApplication::sendEvent(widget, &embeddingEvent); diff --git a/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp b/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp index c6b27aff3d..e8934d1f33 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp +++ b/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp @@ -393,7 +393,7 @@ void ConstraintView::contextMenuEvent (QContextMenuEvent* event) CONTEXT_ITEM("Sketcher_SelectElementsAssociatedWithConstraints","Select Elements","Sketcher_SelectElementsAssociatedWithConstraints",doSelectConstraints,true) QAction* rename = menu.addAction(tr("Rename"), this, SLOT(renameCurrentItem()) -#ifndef Q_WS_MAC // on Mac F2 doesn't seem to trigger an edit signal +#ifndef Q_OS_MAC // on Mac F2 doesn't seem to trigger an edit signal ,QKeySequence(Qt::Key_F2) #endif ); diff --git a/src/Mod/Spreadsheet/Gui/qtcolorpicker.h b/src/Mod/Spreadsheet/Gui/qtcolorpicker.h index 4f1a405ed9..c874297cda 100644 --- a/src/Mod/Spreadsheet/Gui/qtcolorpicker.h +++ b/src/Mod/Spreadsheet/Gui/qtcolorpicker.h @@ -54,7 +54,7 @@ #include #include -#if defined(Q_WS_WIN) +#if defined(Q_OS_WIN) # if !defined(QT_QTCOLORPICKER_EXPORT) && !defined(QT_QTCOLORPICKER_IMPORT) # define QT_QTCOLORPICKER_EXPORT # elif defined(QT_QTCOLORPICKER_IMPORT)