From 8ae3e5c25d546351c99371bc9161005766e3da1b Mon Sep 17 00:00:00 2001 From: shun-iwasawa Date: Thu, 25 Mar 2021 18:27:45 +0900 Subject: [PATCH] wintab support option with customized qt --- .../doc/LICENSE/notice_about_modified_qt.txt | 74 +++++++++++++++++++ toonz/sources/CMakeLists.txt | 15 +--- toonz/sources/include/toonz/preferences.h | 5 +- .../include/toonz/preferencesitemids.h | 2 + toonz/sources/toonz/CMakeLists.txt | 4 + toonz/sources/toonz/main.cpp | 18 ++++- toonz/sources/toonz/preferencespopup.cpp | 9 ++- toonz/sources/toonzlib/preferences.cpp | 2 + 8 files changed, 112 insertions(+), 17 deletions(-) create mode 100644 stuff/doc/LICENSE/notice_about_modified_qt.txt diff --git a/stuff/doc/LICENSE/notice_about_modified_qt.txt b/stuff/doc/LICENSE/notice_about_modified_qt.txt new file mode 100644 index 00000000..d6902053 --- /dev/null +++ b/stuff/doc/LICENSE/notice_about_modified_qt.txt @@ -0,0 +1,74 @@ +## Notice about modified Qt + + If you are using Windows version of OpenToonz installed from the installer + provided from OpenToonz website (https://opentoonz.github.io/), Qt libraries + distributed with the software may be our customized version. + The other OS versions (macOS, Linux) are not the case. + + +### To check whether the Qt libraries are customized. + + - Launch OpenToonz. + - Open Preferences. + - Check if there is a checkbox "Use Qt's Native Windows Ink Support" in the + "Touch / Tablet Settings" category. + + If the option exists, Qt libraries are customized version (Qt 5.15.2 with WinTab support). + +---------- + +## About Qt 5.15.2 with WinTab support + + This version is made based on v5.15.2 with cherry-picking the following commit + to the qtbase module, in order to make it enable to use WinTab API in Qt 5.15.2: + + commit id: [4c4693cf964e9d7370c27a26e1d263a262aee568](https://github.com/shun-iwasawa/qtbase/commit/4c4693cf964e9d7370c27a26e1d263a262aee568) + commit title: Windows: Provide a way to switch between WinTab and Windows Ink at run-time + + +### Source Code + + You can find the source code tree to build this package and track the modification here: + https://github.com/shun-iwasawa/qt5/tree/v5.15.2_wintab + + +### Build Configurations + + The attached package is built by the following command lines: + ``` + > configure -debug-and-release -opensource -confirm-license -prefix ../build -make libs -no-pch -openssl OPENSSL_PREFIX="path\to\OpenSSL-Win64" -opengl dynamic + + > jom -j4 + + > jom module-qtscript -j4 + + > jom install + ``` + + +### Dependent Libraries + + The attached package is built by using the following libraries / softwares. + + - OpenSSL Toolkit 1.1.1j + [Binary package from Shining Light Productions](https://slproweb.com/products/Win32OpenSSL.html) + - Perl + [ActivePerl 5.28](https://www.activestate.com/products/perl/downloads/) + - [Python 2.7.18](https://www.python.org/downloads/release/python-2718/) + - [Ruby 2.7.2-1 (x64)](https://rubyinstaller.org/downloads/) + - ANGLE : already included in the repository. + - Microsoft Visual Studio Community 2019 + - [jom](https://wiki.qt.io/Jom) + - ICU : Not used. + + +#### Reference: + + - [Qt for Windows - Requirements](https://doc.qt.io/qt-5/windows-requirements.html) + - [Qt for Windows - Building from Source](https://doc.qt.io/qt-5/windows-building.html) + + +---------- +March 26, 2021 +Shun Iwasawa, OpenToonz team + diff --git a/toonz/sources/CMakeLists.txt b/toonz/sources/CMakeLists.txt index 7aaa5db1..c791fb37 100644 --- a/toonz/sources/CMakeLists.txt +++ b/toonz/sources/CMakeLists.txt @@ -104,6 +104,7 @@ option(WITH_SYSTEM_SUPERLU "Use the system SuperLU library instead of 'thirdpary option(WITH_CANON "Build with Canon DSLR support - Requires Canon SDK" OFF) option(WITH_TRANSLATION "Generate translation projects as well" ON) option(WITH_CRASHRPT "Build CrashRpt support - Requires CrashRpt Library" OFF) +option(WITH_WINTAB "(Windows only) Build with customized Qt with WinTab support. https://github.com/shun-iwasawa/qt5/releases/tag/v5.15.2_wintab" OFF) # avoid using again option_defaults_clear() @@ -128,19 +129,7 @@ endif() message(STATUS "Thirdpary Library Search path:" ${THIRDPARTY_LIBS_HINTS}) if(BUILD_ENV_MSVC) - if(MSVC_VERSION GREATER 1800) - if(CMAKE_SIZEOF_VOID_P EQUAL 4) - set(QT_PATH "C:/Qt/5.9.2/msvc2015" CACHE PATH "Qt installation directory") - else() - set(QT_PATH "C:/Qt/5.9.2/msvc2015_64" CACHE PATH "Qt installation directory") - endif() - else() - if(CMAKE_SIZEOF_VOID_P EQUAL 4) - set(QT_PATH "C:/Qt/5.9.2/msvc2013" CACHE PATH "Qt installation directory") - else() - set(QT_PATH "C:/Qt/5.9.2/msvc2013_64" CACHE PATH "Qt installation directory") - endif() - endif() + set(QT_PATH "C:/Qt/5.15.2/msvc2019${PLATFORM2}" CACHE PATH "Qt installation directory") if(NOT EXISTS ${QT_PATH}) message("Specify QT_PATH properly") return() diff --git a/toonz/sources/include/toonz/preferences.h b/toonz/sources/include/toonz/preferences.h index b61e0e63..3a730d0f 100644 --- a/toonz/sources/include/toonz/preferences.h +++ b/toonz/sources/include/toonz/preferences.h @@ -483,7 +483,10 @@ public: // Tablet tab bool isWinInkEnabled() const { return getBoolValue(winInkEnabled); } - + bool isQtNativeWinInkEnabled() const { + return getBoolValue(useQtNativeWinInk); + } + // Others (not appeared in the popup) // Shortcut popup settings QString getShortcutPreset() { return getStringValue(shortcutPreset); } diff --git a/toonz/sources/include/toonz/preferencesitemids.h b/toonz/sources/include/toonz/preferencesitemids.h index 65ea0c48..0525d25f 100644 --- a/toonz/sources/include/toonz/preferencesitemids.h +++ b/toonz/sources/include/toonz/preferencesitemids.h @@ -183,6 +183,8 @@ enum PreferencesItemId { // TounchGestureControl // Touch Gesture is a checkable command and not in // preferences.ini winInkEnabled, + // This option will be shown & available only when WITH_WINTAB is defined + useQtNativeWinInk, //---------- // Others (not appeared in the popup) diff --git a/toonz/sources/toonz/CMakeLists.txt b/toonz/sources/toonz/CMakeLists.txt index bbc9e20d..ad884b76 100644 --- a/toonz/sources/toonz/CMakeLists.txt +++ b/toonz/sources/toonz/CMakeLists.txt @@ -432,6 +432,10 @@ if (WITH_CRASHRPT) add_definitions(-DWITH_CRASHRPT) endif() +if (WITH_WINTAB AND BUILD_TARGET_WIN AND (PLATFORM EQUAL 64)) + add_definitions(-DWITH_WINTAB) +endif() + if(BUILD_ENV_APPLE) include_directories( ../../sources/mousedragfilter diff --git a/toonz/sources/toonz/main.cpp b/toonz/sources/toonz/main.cpp index 71318c79..7688ff9e 100644 --- a/toonz/sources/toonz/main.cpp +++ b/toonz/sources/toonz/main.cpp @@ -373,8 +373,9 @@ int main(int argc, char *argv[]) { #ifdef Q_OS_WIN // Since currently Tahoma does not work with OpenGL of software or - // angle, - // force Qt to use desktop OpenGL + // angle, force Qt to use desktop OpenGL + // FIXME: This options should be called before constructing the application. + // Thus, ANGLE seems to be enabled as of now. a.setAttribute(Qt::AA_UseDesktopOpenGL, true); #endif @@ -733,6 +734,19 @@ int main(int argc, char *argv[]) { QWindowsWindowFunctions::setHasBorderInFullScreen(w.windowHandle(), true); #endif + // Qt have started to support Windows Ink from 5.12. + // Unlike WinTab API used in Qt 5.9 the tablet behaviors are different and + // are (at least, for OT) problematic. The customized Qt5.15.2 are made with + // cherry-picking the WinTab feature to be officially introduced from 6.0. + // See https://github.com/shun-iwasawa/qt5/releases/tag/v5.15.2_wintab for + // details. The following feature can only be used with the customized Qt, + // with WITH_WINTAB build option, and in Windows-x64 build. + +#ifdef WITH_WINTAB + bool useQtNativeWinInk = Preferences::instance()->isQtNativeWinInkEnabled(); + QWindowsWindowFunctions::setWinTabEnabled(!useQtNativeWinInk); +#endif + splash.showMessage(offsetStr + "Loading style sheet...", Qt::AlignRight | Qt::AlignBottom, Qt::black); a.processEvents(); diff --git a/toonz/sources/toonz/preferencespopup.cpp b/toonz/sources/toonz/preferencespopup.cpp index ff7704d5..f6994892 100644 --- a/toonz/sources/toonz/preferencespopup.cpp +++ b/toonz/sources/toonz/preferencespopup.cpp @@ -1165,7 +1165,11 @@ QString PreferencesPopup::getUIString(PreferencesItemId id) { // Touch / Tablet Settings // TounchGestureControl // Touch Gesture is a checkable command and not in // preferences.ini - {winInkEnabled, tr("Enable Windows Ink Support* (EXPERIMENTAL)")}}; + {winInkEnabled, tr("Enable Windows Ink Support* (EXPERIMENTAL)")}, + {useQtNativeWinInk, + tr("Use Qt's Native Windows Ink Support*\n(CAUTION: This options is for " + "maintenance purpose. \n Do not activate this option or the tablet " + "won't work properly.)")}}; return uiStringTable.value(id, QString()); } @@ -1949,6 +1953,9 @@ QWidget* PreferencesPopup::createTouchTabletPage() { lay->addWidget(enableTouchGestures, 0, 0, 1, 2); if (winInkAvailable) insertUI(winInkEnabled, lay); +#ifdef WITH_WINTAB + insertUI(useQtNativeWinInk, lay); +#endif lay->setRowStretch(lay->rowCount(), 1); if (winInkAvailable) insertFootNote(lay); diff --git a/toonz/sources/toonzlib/preferences.cpp b/toonz/sources/toonzlib/preferences.cpp index d3d9768e..50594274 100644 --- a/toonz/sources/toonzlib/preferences.cpp +++ b/toonz/sources/toonzlib/preferences.cpp @@ -639,6 +639,8 @@ void Preferences::definePreferenceItems() { // TounchGestureControl // Touch Gesture is a checkable command and not in // preferences.ini define(winInkEnabled, "winInkEnabled", QMetaType::Bool, false); + // This option will be shown & available only when WITH_WINTAB is defined + define(useQtNativeWinInk, "useQtNativeWinInk", QMetaType::Bool, false); // Others (not appeared in the popup) // Shortcut popup settings