From 84ac0db80032a0d85c7d2934aba46963038b9e88 Mon Sep 17 00:00:00 2001 From: Matteo Paonessa Date: Fri, 16 Sep 2022 18:35:59 +0200 Subject: [PATCH] Fix to updater Addressing #152 and #151 --- CMakeLists.txt | 7 +++++-- Info.plist | 4 ++-- resources/i18n/caesium_ar_EG.ts | 6 +++--- resources/i18n/caesium_de_DE.ts | 6 +++--- resources/i18n/caesium_en_US.ts | 6 +++--- resources/i18n/caesium_es_ES.ts | 6 +++--- resources/i18n/caesium_fr_FR.ts | 6 +++--- resources/i18n/caesium_it_IT.ts | 6 +++--- resources/i18n/caesium_ja_JP.ts | 6 +++--- resources/i18n/caesium_ru_RU.ts | 6 +++--- resources/i18n/caesium_tr_TR.ts | 6 +++--- resources/i18n/caesium_zh_CN.ts | 6 +++--- resources/icons.rc | 4 ++-- setup.iss | 4 ++-- src/MainWindow.cpp | 34 ++++++++------------------------- src/dialogs/AboutDialog.cpp | 4 ++++ src/main.cpp | 2 +- src/utils/Utils.h | 4 ---- 18 files changed, 54 insertions(+), 69 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d956e82..aa324e4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,10 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) set(TARGET caesium_image_compressor) if (WIN32) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + if (DEFINED PORTABLE AND PORTABLE) + message("-- Configuring for portable") + add_compile_definitions(IS_PORTABLE) + endif () else () set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations -Wno-deprecated-register -Wno-deprecated") endif () @@ -61,10 +65,9 @@ string(TOLOWER ${CMAKE_BUILD_TYPE} LIBCAESIUM_BUILD_TYPE) if (WIN32) #link_directories(${LIBCAESIUM_SOURCE_DIR}\\target\\x86_64-pc-windows-msvc\\${LIBCAESIUM_BUILD_TYPE}) else () - + link_directories(${LIBCAESIUM_SOURCE_DIR}/target/${LIBCAESIUM_BUILD_TYPE}) endif () - find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets Core Gui Concurrent Svg Network Sql LinguistTools REQUIRED) find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets Core Gui Concurrent Svg Network Sql LinguistTools REQUIRED) diff --git a/Info.plist b/Info.plist index d84d0e2..ba440bd 100644 --- a/Info.plist +++ b/Info.plist @@ -19,9 +19,9 @@ NSSupportsAutomaticGraphicsSwitching CFBundleShortVersionString - 2.2.0 + 2.2.1 CFBundleVersion - 2.2.0 + 2.2.1 SUFeedURL https://saerasoft.com/repository/com.saerasoft.caesium/osx/appcast.xml SUEnableAutomaticChecks diff --git a/resources/i18n/caesium_ar_EG.ts b/resources/i18n/caesium_ar_EG.ts index f0d2173..81c966f 100644 --- a/resources/i18n/caesium_ar_EG.ts +++ b/resources/i18n/caesium_ar_EG.ts @@ -99,13 +99,13 @@ Do you really want to continue? لا - + Finishing... جاري الإنهاء... - + Compressing... جاري الضغط... @@ -341,7 +341,7 @@ Saved: %4 (%5%) - + Preview diff --git a/resources/i18n/caesium_de_DE.ts b/resources/i18n/caesium_de_DE.ts index b5f4f47..5c39d3f 100644 --- a/resources/i18n/caesium_de_DE.ts +++ b/resources/i18n/caesium_de_DE.ts @@ -99,13 +99,13 @@ Wollen Sie trotzdem fortfahren Nein - + Finishing... Beende... - + Compressing... Komprimiere... @@ -473,7 +473,7 @@ Ersparnis: %4 (%5%) - + Preview diff --git a/resources/i18n/caesium_en_US.ts b/resources/i18n/caesium_en_US.ts index 41bdc97..1ae6ff4 100644 --- a/resources/i18n/caesium_en_US.ts +++ b/resources/i18n/caesium_en_US.ts @@ -99,13 +99,13 @@ Do you really want to continue? No - + Finishing... Finishing... - + Compressing... Compressing... @@ -341,7 +341,7 @@ Saved: %4 (%5%) - + Preview Preview diff --git a/resources/i18n/caesium_es_ES.ts b/resources/i18n/caesium_es_ES.ts index 1172826..7fec380 100644 --- a/resources/i18n/caesium_es_ES.ts +++ b/resources/i18n/caesium_es_ES.ts @@ -99,13 +99,13 @@ Desea continuar? No - + Finishing... - + Compressing... Comprimiendo... @@ -341,7 +341,7 @@ Ahorrado: %4 (%5%) - + Preview diff --git a/resources/i18n/caesium_fr_FR.ts b/resources/i18n/caesium_fr_FR.ts index 38ea1ed..9a601ce 100644 --- a/resources/i18n/caesium_fr_FR.ts +++ b/resources/i18n/caesium_fr_FR.ts @@ -99,13 +99,13 @@ Voulez vous vraiment continuer? Non - + Finishing... Finalisation... - + Compressing... Compression... @@ -341,7 +341,7 @@ Saved: %4 (%5%) - + Preview diff --git a/resources/i18n/caesium_it_IT.ts b/resources/i18n/caesium_it_IT.ts index d7a05e8..a6f8ae6 100644 --- a/resources/i18n/caesium_it_IT.ts +++ b/resources/i18n/caesium_it_IT.ts @@ -107,13 +107,13 @@ Vuoi veramente continuare? No - + Finishing... Completamento... - + Compressing... Compressione... @@ -353,7 +353,7 @@ Risparmiato: %4 (%5%) - + Preview Anteprima diff --git a/resources/i18n/caesium_ja_JP.ts b/resources/i18n/caesium_ja_JP.ts index 1f45cc5..313480f 100644 --- a/resources/i18n/caesium_ja_JP.ts +++ b/resources/i18n/caesium_ja_JP.ts @@ -99,13 +99,13 @@ Do you really want to continue? いいえ - + Finishing... 終了中... - + Compressing... 圧縮中... @@ -341,7 +341,7 @@ Saved: %4 (%5%) - + Preview diff --git a/resources/i18n/caesium_ru_RU.ts b/resources/i18n/caesium_ru_RU.ts index 74f40f6..9401f7b 100644 --- a/resources/i18n/caesium_ru_RU.ts +++ b/resources/i18n/caesium_ru_RU.ts @@ -99,13 +99,13 @@ Do you really want to continue? Нет - + Finishing... Завершение... - + Compressing... Сжатие... @@ -341,7 +341,7 @@ Saved: %4 (%5%) - + Preview Предварительный просмотр diff --git a/resources/i18n/caesium_tr_TR.ts b/resources/i18n/caesium_tr_TR.ts index 9632830..9859d6e 100644 --- a/resources/i18n/caesium_tr_TR.ts +++ b/resources/i18n/caesium_tr_TR.ts @@ -386,7 +386,7 @@ All rights reserved. - + Preview Ön izleme @@ -425,7 +425,7 @@ Do you really want to continue? - + Compressing... Sıkıştırılıyor... @@ -472,7 +472,7 @@ Kaydedildi: %4 (%5%) - + Finishing... diff --git a/resources/i18n/caesium_zh_CN.ts b/resources/i18n/caesium_zh_CN.ts index f1bcdd4..aa86577 100644 --- a/resources/i18n/caesium_zh_CN.ts +++ b/resources/i18n/caesium_zh_CN.ts @@ -99,13 +99,13 @@ Do you really want to continue? 取消 - + Finishing... 正在取消... - + Compressing... 正在压缩... @@ -341,7 +341,7 @@ Saved: %4 (%5%) - + Preview diff --git a/resources/icons.rc b/resources/icons.rc index a9c53da..623aecc 100644 --- a/resources/icons.rc +++ b/resources/icons.rc @@ -4,7 +4,7 @@ IDI_ICON1 ICON "icons/icon.ico" 1 VERSIONINFO FILEVERSION 1,0,0,0 - PRODUCTVERSION 2,2,0,0 + PRODUCTVERSION 2,2,1,0 BEGIN BLOCK "StringFileInfo" BEGIN @@ -15,7 +15,7 @@ BEGIN VALUE "FileVersion", "1.0.0\0" VALUE "InternalName", "Cs-133\0" VALUE "ProductName", "Caesium Image Compressor\0" - VALUE "ProductVersion", "2.2.0\0" + VALUE "ProductVersion", "2.2.1\0" END END diff --git a/setup.iss b/setup.iss index c9f17fa..8474b78 100644 --- a/setup.iss +++ b/setup.iss @@ -2,7 +2,7 @@ ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! #define MyAppName "Caesium Image Compressor" -#define MyAppVersion "2.2.0" +#define MyAppVersion "2.2.1" #define MyAppPublisher "SaeraSoft" #define MyAppURL "https://saerasoft.com/caesium" #define MyAppExeName "Caesium Image Compressor.exe" @@ -47,7 +47,7 @@ Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{ [Files] Source: "package\{#MyAppVersion}\caesium-image-compressor-{#MyAppVersion}-win\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion -Source: "package\{#MyAppVersion}\caesium-image-compressor-{#MyAppVersion}-win\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs +Source: "package\{#MyAppVersion}\caesium-image-compressor-{#MyAppVersion}-win-setup\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs ; NOTE: Don't use "Flags: ignoreversion" on any shared system files [Icons] diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 7384066..bda57a7 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -912,6 +912,10 @@ void MainWindow::cModelItemsChanged() void MainWindow::initUpdater() { QSettings settings; + bool isPortable = false; +#ifdef IS_PORTABLE + isPortable = true; +#endif #ifdef Q_OS_MAC CocoaInitializer initializer; auto updater = new SparkleAutoUpdater("https://saerasoft.com/repository/com.saerasoft.caesium/osx/appcast.xml"); @@ -922,39 +926,17 @@ void MainWindow::initUpdater() #endif #ifdef Q_OS_WIN - QStringList possibleKeys = { - R"(HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall)", - R"(HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall)", - R"(HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall)", - R"(HKEY_CURRENT_USER\\SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall)", - }; - QStringListIterator keysIterator(possibleKeys); - QString uninstallExecutable = ""; - while (keysIterator.hasNext()) { - QSettings winRegistryUninstall(keysIterator.next(), QSettings::Registry64Format); - uninstallExecutable = winRegistryUninstall.value("{C457F5B2-65EB-48E9-9744-A3719FEABA4C}_is1/UninstallString", "").toString(); - if (!uninstallExecutable.isEmpty()) { - break; - } - } - - // Means nothing is installed - if (uninstallExecutable.isEmpty()) { - qInfo() << "Updater not initialized: no installed Caesium found."; - return; - } - QFileInfo uninstallExecutableInfo(uninstallExecutable); - // Something is installed, but we check if we are running from the same path as the uninstallation executable - if (!uninstallExecutableInfo.exists() || uninstallExecutableInfo.absolutePath().compare(QCoreApplication::applicationDirPath()) != 0) { - qInfo() << "Updater not initialized: probably running on a portable version."; + if (isPortable) { return; } + int localeIndex = settings.value("preferences/language/locale", 0).toInt(); if (localeIndex < 0 || localeIndex > LANGUAGES_COUNT - 1) { localeIndex = 0; } if (localeIndex != 0) { - win_sparkle_set_langid(WIN32_LANGUAGES[localeIndex]); + QString locale = LANGUAGES[localeIndex].locale; + win_sparkle_set_lang(locale.replace('_', '-').toUtf8().constData()); } win_sparkle_set_appcast_url("https://saerasoft.com/repository/com.saerasoft.caesium/win/appcast.xml"); win_sparkle_init(); diff --git a/src/dialogs/AboutDialog.cpp b/src/dialogs/AboutDialog.cpp index 2adce8a..7ec1f0a 100644 --- a/src/dialogs/AboutDialog.cpp +++ b/src/dialogs/AboutDialog.cpp @@ -22,6 +22,10 @@ AboutDialog::AboutDialog(QWidget* parent) ui->version_Label->setText("v" + QCoreApplication::applicationVersion()); ui->uuid_Label->setText("UUID: " + settings.value("uuid", "").toString() + ""); +#ifdef IS_PORTABLE + ui->checkForUpdates_Button->hide(); +#endif + this->setAttribute(Qt::WA_DeleteOnClose, true); this->setWindowFlags(Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint); this->setWindowModality(Qt::ApplicationModal); diff --git a/src/main.cpp b/src/main.cpp index bcadbf6..5858334 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -132,7 +132,7 @@ int main(int argc, char* argv[]) QCoreApplication::setOrganizationName("SaeraSoft"); QCoreApplication::setOrganizationDomain("saerasoft.com"); QCoreApplication::setApplicationName("Caesium Image Compressor"); - QCoreApplication::setApplicationVersion("2.2.0"); + QCoreApplication::setApplicationVersion("2.2.1"); qInstallMessageHandler(messageHandler); QApplication a(argc, argv); diff --git a/src/utils/Utils.h b/src/utils/Utils.h index 3275dac..d03361c 100644 --- a/src/utils/Utils.h +++ b/src/utils/Utils.h @@ -113,10 +113,6 @@ const CsLocale LANGUAGES[LANGUAGES_COUNT] = { { QString("tr_TR"), QString("Türkçe") }, }; -const unsigned short WIN32_LANGUAGES[LANGUAGES_COUNT] = { - 0x0, 0x0409, 0x0410, 0x040C, 0x0411, 0x0804, 0x0c0A, 0x0C01, 0x0407, 0x0419, 0x041F -}; - const int THEMES_COUNT = 3; const CsTheme THEMES[THEMES_COUNT] = { { QString("Native"), QString("Native") },