diff --git a/launchers/qt/CMakeLists.txt b/launchers/qt/CMakeLists.txt index 57f900140c..50ea3362e1 100644 --- a/launchers/qt/CMakeLists.txt +++ b/launchers/qt/CMakeLists.txt @@ -165,7 +165,11 @@ set(TARGET_NAME ${PROJECT_NAME}) set_packaging_parameters() if (WIN32) - add_executable(${PROJECT_NAME} ${src_files} ${RES_SOURCES}) + set(CONFIGURE_ICON_PATH "${CMAKE_CURRENT_SOURCE_DIR}/resources/images/interface.ico") + message(${CONFIGURE_ICON_PATH}) + set(CONFIGURE_ICON_RC_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/Icon.rc") + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/Icon.rc.in" ${CONFIGURE_ICON_RC_OUTPUT}) + add_executable(${PROJECT_NAME} WIN32 ${src_files} ${RES_SOURCES} ${CONFIGURE_ICON_RC_OUTPUT}) elseif (APPLE) set_target_properties(${this_target} PROPERTIES MACOSX_BUNDLE_INFO_PLIST MacOSXBundleInfo.plist.in) diff --git a/launchers/qt/cmake/templates/Icon.rc.in b/launchers/qt/cmake/templates/Icon.rc.in new file mode 100644 index 0000000000..8cd04a60de --- /dev/null +++ b/launchers/qt/cmake/templates/Icon.rc.in @@ -0,0 +1 @@ +IDI_ICON1 ICON DISCARDABLE "@CONFIGURE_ICON_PATH@" \ No newline at end of file diff --git a/launchers/qt/deps/miniz/miniz.cpp b/launchers/qt/deps/miniz/miniz.cpp index 96d7cc106a..a7e3e3d520 100644 --- a/launchers/qt/deps/miniz/miniz.cpp +++ b/launchers/qt/deps/miniz/miniz.cpp @@ -3228,6 +3228,7 @@ struct mz_zip_internal_state_tag static MZ_FORCEINLINE mz_uint mz_zip_array_range_check(const mz_zip_array *pArray, mz_uint index) { MZ_ASSERT(index < pArray->m_size); + (void)(pArray); return index; } #define MZ_ZIP_ARRAY_ELEMENT(array_ptr, element_type, index) ((element_type *)((array_ptr)->m_p))[mz_zip_array_range_check(array_ptr, index)] diff --git a/launchers/qt/resources/images/Launcher.rc2 b/launchers/qt/resources/images/Launcher.rc2 new file mode 100644 index 0000000000..098b026372 --- /dev/null +++ b/launchers/qt/resources/images/Launcher.rc2 @@ -0,0 +1,13 @@ +// +// Launcher.rc2 - resources Microsoft Visual C++ does not edit directly +// + +#ifdef APSTUDIO_INVOKED +#error this file is not editable by Microsoft Visual C++ +#endif //APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// Add manually edited resources here... + +///////////////////////////////////////////////////////////////////////////// diff --git a/launchers/qt/resources/images/interface.ico b/launchers/qt/resources/images/interface.ico new file mode 100644 index 0000000000..09a97956a7 Binary files /dev/null and b/launchers/qt/resources/images/interface.ico differ diff --git a/launchers/qt/src/Helper.h b/launchers/qt/src/Helper.h index 65f68ec41d..a72b9a2d7a 100644 --- a/launchers/qt/src/Helper.h +++ b/launchers/qt/src/Helper.h @@ -21,4 +21,7 @@ bool isLauncherAlreadyRunning(); #ifdef Q_OS_WIN HRESULT createSymbolicLink(LPCSTR lpszPathObj, LPCSTR lpszPathLink, LPCSTR lpszDesc, LPCSTR lpszArgs = (LPCSTR)""); +bool insertRegistryKey(const std::string& regPath, const std::string& name, const std::string& value); +bool insertRegistryKey(const std::string& regPath, const std::string& name, DWORD value); +bool deleteRegistryKey(const std::string& regPath); #endif diff --git a/launchers/qt/src/Helper_windows.cpp b/launchers/qt/src/Helper_windows.cpp index 5295943a4e..a61db77f85 100644 --- a/launchers/qt/src/Helper_windows.cpp +++ b/launchers/qt/src/Helper_windows.cpp @@ -6,6 +6,8 @@ #include "objbase.h" #include "objidl.h" #include "shlguid.h" +#include +#include #include void launchClient(const QString& clientPath, const QString& homePath, const QString& defaultScriptsPath, @@ -113,3 +115,35 @@ HRESULT createSymbolicLink(LPCSTR lpszPathObj, LPCSTR lpszPathLink, LPCSTR lpszD CoUninitialize(); return SUCCEEDED(hres); } + +bool insertRegistryKey(const std::string& regPath, const std::string& name, const std::string& value) { + HKEY key; + auto status = RegCreateKeyExA(HKEY_CURRENT_USER, regPath.c_str(), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE | KEY_QUERY_VALUE, NULL, &key, NULL); + if (status == ERROR_SUCCESS) { + status = RegSetValueExA(key, name.c_str(), 0, REG_SZ, (const BYTE*)value.c_str(), (DWORD)(value.size() + 1)); + return (bool) (status == ERROR_SUCCESS); + } + RegCloseKey(key); + return false; +} + +bool insertRegistryKey(const std::string& regPath, const std::string& name, DWORD value) { + HKEY key; + auto status = RegCreateKeyExA(HKEY_CURRENT_USER, regPath.c_str(), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE | KEY_QUERY_VALUE, NULL, &key, NULL); + if (status == ERROR_SUCCESS) { + status = RegSetValueExA(key, name.c_str(), 0, REG_DWORD, (const BYTE*)&value, sizeof(value)); + return (bool) TRUE; + } + RegCloseKey(key); + return false; +} + +bool deleteRegistryKey(const std::string& regPath) { + TCHAR szDelKey[MAX_PATH * 2]; + StringCchCopy(szDelKey, MAX_PATH * 2, regPath.c_str()); + auto status = RegDeleteKey(HKEY_CURRENT_USER, szDelKey); + if (status == ERROR_SUCCESS) { + return (bool) TRUE; + } + return false; +} diff --git a/launchers/qt/src/Launcher.cpp b/launchers/qt/src/Launcher.cpp index 0b51328aef..af90507db6 100644 --- a/launchers/qt/src/Launcher.cpp +++ b/launchers/qt/src/Launcher.cpp @@ -13,7 +13,7 @@ Launcher::Launcher(int& argc, char**argv) : QGuiApplication(argc, argv) { _launcherWindow = std::make_unique(); _launcherWindow->rootContext()->setContextProperty("LauncherState", _launcherState.get()); _launcherWindow->rootContext()->setContextProperty("PathUtils", new PathUtils()); - _launcherWindow->setFlags(Qt::FramelessWindowHint); + _launcherWindow->setFlags(Qt::FramelessWindowHint | Qt::Window); LauncherState::declareQML(); _launcherWindow->setSource(QUrl(PathUtils::resourcePath("qml/root.qml"))); _launcherWindow->setResizeMode(QQuickView::SizeRootObjectToView); diff --git a/launchers/qt/src/LauncherInstaller_windows.cpp b/launchers/qt/src/LauncherInstaller_windows.cpp index ea35e86c64..1bbceb61e7 100644 --- a/launchers/qt/src/LauncherInstaller_windows.cpp +++ b/launchers/qt/src/LauncherInstaller_windows.cpp @@ -70,6 +70,8 @@ void LauncherInstaller::install() { createSymbolicLink((LPCSTR)oldLauncherPath.toStdString().c_str(), (LPCSTR)appStartLinkPath.toStdString().c_str(), (LPCSTR)("Click to Setup and Launch HQ")); + + createApplicationRegistryKeys(); } else { qDebug() << "FAILED!!!!!!!"; } @@ -100,3 +102,26 @@ void LauncherInstaller::uninstall() { QFile::remove(desktopAppLinkPath); } } + + +void LauncherInstaller::createApplicationRegistryKeys() { + const std::string REGISTRY_PATH = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\HQ"; + bool success = insertRegistryKey(REGISTRY_PATH, "DisplayName", "HQ"); + std::string installPath = _launcherInstallDir.absolutePath().toStdString(); + success = insertRegistryKey(REGISTRY_PATH, "InstallLocation", installPath); + std::string applicationExe = installPath + "/HQ Launcher.exe"; + std::string uninstallPath = '"' + applicationExe + '"' + " --uninstall"; + success = insertRegistryKey(REGISTRY_PATH, "UninstallString", uninstallPath); + success = insertRegistryKey(REGISTRY_PATH, "DisplayVersion", "DEV"); + success = insertRegistryKey(REGISTRY_PATH, "DisplayIcon", applicationExe); + success = insertRegistryKey(REGISTRY_PATH, "Publisher", "High Fidelity"); + //success = LauncherUtils::insertRegistryKey(REGISTRY_PATH, "InstallDate", LauncherUtils::cStringToStd(CTime::GetCurrentTime().Format("%Y%m%d"))); + //success = LauncherUtils::insertRegistryKey(REGISTRY_PATH, "EstimatedSize", (DWORD)size); + success = insertRegistryKey(REGISTRY_PATH, "NoModify", (DWORD)1); + success = insertRegistryKey(REGISTRY_PATH, "NoRepair", (DWORD)1); + + qDebug() << "--------: " << success; +} + +void LauncherInstaller::deleteApplicationRegistryKeys() { +} diff --git a/launchers/qt/src/LauncherInstaller_windows.h b/launchers/qt/src/LauncherInstaller_windows.h index 8791f9395f..6ddd74f53f 100644 --- a/launchers/qt/src/LauncherInstaller_windows.h +++ b/launchers/qt/src/LauncherInstaller_windows.h @@ -11,7 +11,9 @@ public: bool runningOutsideOfInstallDir(); private: void createShortcuts(); + void createApplicationRegistryKeys(); void deleteShortcuts(); + void deleteApplicationRegistryKeys(); QDir _launcherInstallDir; QDir _launcherApplicationsDir; diff --git a/launchers/qt/src/LauncherWindow.h b/launchers/qt/src/LauncherWindow.h index 02012dc342..79651e9e5e 100644 --- a/launchers/qt/src/LauncherWindow.h +++ b/launchers/qt/src/LauncherWindow.h @@ -5,6 +5,8 @@ class LauncherWindow : public QQuickView { public: + LauncherWindow() = default; + ~LauncherWindow() = default; void keyPressEvent(QKeyEvent* event) override; void mousePressEvent(QMouseEvent* event) override; void mouseReleaseEvent(QMouseEvent* event) override; diff --git a/launchers/qt/src/main.cpp b/launchers/qt/src/main.cpp index db69bfafe3..2f8e26d500 100644 --- a/launchers/qt/src/main.cpp +++ b/launchers/qt/src/main.cpp @@ -35,8 +35,6 @@ int main(int argc, char *argv[]) { return 0; } closeInterfaceIfRunning(); - // waitForInterfaceToClose(); - // auto updater if (argc == 3) { if (hasSuffix(argv[1], "app") && hasSuffix(argv[2], "app")) { swapLaunchers(argv[1], argv[2]);