Skip to content

Commit

Permalink
Fix to updater
Browse files Browse the repository at this point in the history
Addressing #152 and #151
  • Loading branch information
Lymphatus committed Sep 16, 2022
1 parent d597165 commit 84ac0db
Show file tree
Hide file tree
Showing 18 changed files with 54 additions and 69 deletions.
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand Down Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
<key>NSSupportsAutomaticGraphicsSwitching</key>
<true/>
<key>CFBundleShortVersionString</key>
<string>2.2.0</string>
<string>2.2.1</string>
<key>CFBundleVersion</key>
<string>2.2.0</string>
<string>2.2.1</string>
<key>SUFeedURL</key>
<string>https://saerasoft.com/repository/com.saerasoft.caesium/osx/appcast.xml</string>
<key>SUEnableAutomaticChecks</key>
Expand Down
6 changes: 3 additions & 3 deletions resources/i18n/caesium_ar_EG.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ Do you really want to continue?</source>
<translation>لا</translation>
</message>
<message>
<location filename="../../src/MainWindow.cpp" line="1121"/>
<location filename="../../src/MainWindow.cpp" line="1103"/>
<source>Finishing...</source>
<translation>جاري الإنهاء...</translation>
</message>
<message>
<location filename="../../src/MainWindow.cpp" line="560"/>
<location filename="../../src/MainWindow.cpp" line="1188"/>
<location filename="../../src/MainWindow.cpp" line="1170"/>
<source>Compressing...</source>
<translation>جاري الضغط...</translation>
</message>
Expand Down Expand Up @@ -341,7 +341,7 @@ Saved: %4 (%5%)</source>
</message>
<message>
<location filename="../../views/MainWindow.ui" line="1440"/>
<location filename="../../src/MainWindow.cpp" line="1107"/>
<location filename="../../src/MainWindow.cpp" line="1089"/>
<source>Preview</source>
<translation type="unfinished"></translation>
</message>
Expand Down
6 changes: 3 additions & 3 deletions resources/i18n/caesium_de_DE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ Wollen Sie trotzdem fortfahren</translation>
<translation>Nein</translation>
</message>
<message>
<location filename="../../src/MainWindow.cpp" line="1121"/>
<location filename="../../src/MainWindow.cpp" line="1103"/>
<source>Finishing...</source>
<translation>Beende...</translation>
</message>
<message>
<location filename="../../src/MainWindow.cpp" line="560"/>
<location filename="../../src/MainWindow.cpp" line="1188"/>
<location filename="../../src/MainWindow.cpp" line="1170"/>
<source>Compressing...</source>
<translation>Komprimiere...</translation>
</message>
Expand Down Expand Up @@ -473,7 +473,7 @@ Ersparnis: %4 (%5%)</translation>
</message>
<message>
<location filename="../../views/MainWindow.ui" line="1440"/>
<location filename="../../src/MainWindow.cpp" line="1107"/>
<location filename="../../src/MainWindow.cpp" line="1089"/>
<source>Preview</source>
<translation type="unfinished"></translation>
</message>
Expand Down
6 changes: 3 additions & 3 deletions resources/i18n/caesium_en_US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ Do you really want to continue?</translation>
<translation>No</translation>
</message>
<message>
<location filename="../../src/MainWindow.cpp" line="1121"/>
<location filename="../../src/MainWindow.cpp" line="1103"/>
<source>Finishing...</source>
<translation>Finishing...</translation>
</message>
<message>
<location filename="../../src/MainWindow.cpp" line="560"/>
<location filename="../../src/MainWindow.cpp" line="1188"/>
<location filename="../../src/MainWindow.cpp" line="1170"/>
<source>Compressing...</source>
<translation>Compressing...</translation>
</message>
Expand Down Expand Up @@ -341,7 +341,7 @@ Saved: %4 (%5%)</translation>
</message>
<message>
<location filename="../../views/MainWindow.ui" line="1440"/>
<location filename="../../src/MainWindow.cpp" line="1107"/>
<location filename="../../src/MainWindow.cpp" line="1089"/>
<source>Preview</source>
<translation>Preview</translation>
</message>
Expand Down
6 changes: 3 additions & 3 deletions resources/i18n/caesium_es_ES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ Desea continuar?</translation>
<translation>No</translation>
</message>
<message>
<location filename="../../src/MainWindow.cpp" line="1121"/>
<location filename="../../src/MainWindow.cpp" line="1103"/>
<source>Finishing...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/MainWindow.cpp" line="560"/>
<location filename="../../src/MainWindow.cpp" line="1188"/>
<location filename="../../src/MainWindow.cpp" line="1170"/>
<source>Compressing...</source>
<translation>Comprimiendo...</translation>
</message>
Expand Down Expand Up @@ -341,7 +341,7 @@ Ahorrado: %4 (%5%)</translation>
</message>
<message>
<location filename="../../views/MainWindow.ui" line="1440"/>
<location filename="../../src/MainWindow.cpp" line="1107"/>
<location filename="../../src/MainWindow.cpp" line="1089"/>
<source>Preview</source>
<translation type="unfinished"></translation>
</message>
Expand Down
6 changes: 3 additions & 3 deletions resources/i18n/caesium_fr_FR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ Voulez vous vraiment continuer?</translation>
<translation>Non</translation>
</message>
<message>
<location filename="../../src/MainWindow.cpp" line="1121"/>
<location filename="../../src/MainWindow.cpp" line="1103"/>
<source>Finishing...</source>
<translation>Finalisation...</translation>
</message>
<message>
<location filename="../../src/MainWindow.cpp" line="560"/>
<location filename="../../src/MainWindow.cpp" line="1188"/>
<location filename="../../src/MainWindow.cpp" line="1170"/>
<source>Compressing...</source>
<translation>Compression...</translation>
</message>
Expand Down Expand Up @@ -341,7 +341,7 @@ Saved: %4 (%5%)</translation>
</message>
<message>
<location filename="../../views/MainWindow.ui" line="1440"/>
<location filename="../../src/MainWindow.cpp" line="1107"/>
<location filename="../../src/MainWindow.cpp" line="1089"/>
<source>Preview</source>
<translation type="unfinished"></translation>
</message>
Expand Down
6 changes: 3 additions & 3 deletions resources/i18n/caesium_it_IT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@ Vuoi veramente continuare?</translation>
<translation>No</translation>
</message>
<message>
<location filename="../../src/MainWindow.cpp" line="1121"/>
<location filename="../../src/MainWindow.cpp" line="1103"/>
<source>Finishing...</source>
<translation>Completamento...</translation>
</message>
<message>
<location filename="../../src/MainWindow.cpp" line="560"/>
<location filename="../../src/MainWindow.cpp" line="1188"/>
<location filename="../../src/MainWindow.cpp" line="1170"/>
<source>Compressing...</source>
<translation>Compressione...</translation>
</message>
Expand Down Expand Up @@ -353,7 +353,7 @@ Risparmiato: %4 (%5%)</translation>
</message>
<message>
<location filename="../../views/MainWindow.ui" line="1440"/>
<location filename="../../src/MainWindow.cpp" line="1107"/>
<location filename="../../src/MainWindow.cpp" line="1089"/>
<source>Preview</source>
<translation>Anteprima</translation>
</message>
Expand Down
6 changes: 3 additions & 3 deletions resources/i18n/caesium_ja_JP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ Do you really want to continue?</source>
<translation>いいえ</translation>
</message>
<message>
<location filename="../../src/MainWindow.cpp" line="1121"/>
<location filename="../../src/MainWindow.cpp" line="1103"/>
<source>Finishing...</source>
<translation>終了中...</translation>
</message>
<message>
<location filename="../../src/MainWindow.cpp" line="560"/>
<location filename="../../src/MainWindow.cpp" line="1188"/>
<location filename="../../src/MainWindow.cpp" line="1170"/>
<source>Compressing...</source>
<translation>圧縮中...</translation>
</message>
Expand Down Expand Up @@ -341,7 +341,7 @@ Saved: %4 (%5%)</source>
</message>
<message>
<location filename="../../views/MainWindow.ui" line="1440"/>
<location filename="../../src/MainWindow.cpp" line="1107"/>
<location filename="../../src/MainWindow.cpp" line="1089"/>
<source>Preview</source>
<translation type="unfinished"></translation>
</message>
Expand Down
6 changes: 3 additions & 3 deletions resources/i18n/caesium_ru_RU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ Do you really want to continue?</source>
<translation>Нет</translation>
</message>
<message>
<location filename="../../src/MainWindow.cpp" line="1121"/>
<location filename="../../src/MainWindow.cpp" line="1103"/>
<source>Finishing...</source>
<translation>Завершение...</translation>
</message>
<message>
<location filename="../../src/MainWindow.cpp" line="560"/>
<location filename="../../src/MainWindow.cpp" line="1188"/>
<location filename="../../src/MainWindow.cpp" line="1170"/>
<source>Compressing...</source>
<translation>Сжатие...</translation>
</message>
Expand Down Expand Up @@ -341,7 +341,7 @@ Saved: %4 (%5%)</source>
</message>
<message>
<location filename="../../views/MainWindow.ui" line="1440"/>
<location filename="../../src/MainWindow.cpp" line="1107"/>
<location filename="../../src/MainWindow.cpp" line="1089"/>
<source>Preview</source>
<translation>Предварительный просмотр</translation>
</message>
Expand Down
6 changes: 3 additions & 3 deletions resources/i18n/caesium_tr_TR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ All rights reserved.</translation>
</message>
<message>
<location filename="../../views/MainWindow.ui" line="1440"/>
<location filename="../../src/MainWindow.cpp" line="1107"/>
<location filename="../../src/MainWindow.cpp" line="1089"/>
<source>Preview</source>
<translation>Ön izleme</translation>
</message>
Expand Down Expand Up @@ -425,7 +425,7 @@ Do you really want to continue?</source>
</message>
<message>
<location filename="../../src/MainWindow.cpp" line="560"/>
<location filename="../../src/MainWindow.cpp" line="1188"/>
<location filename="../../src/MainWindow.cpp" line="1170"/>
<source>Compressing...</source>
<translation>Sıkıştırılıyor...</translation>
</message>
Expand Down Expand Up @@ -472,7 +472,7 @@ Kaydedildi: %4 (%5%)</translation>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/MainWindow.cpp" line="1121"/>
<location filename="../../src/MainWindow.cpp" line="1103"/>
<source>Finishing...</source>
<translation type="unfinished"></translation>
</message>
Expand Down
6 changes: 3 additions & 3 deletions resources/i18n/caesium_zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ Do you really want to continue?</source>
<translation>取消</translation>
</message>
<message>
<location filename="../../src/MainWindow.cpp" line="1121"/>
<location filename="../../src/MainWindow.cpp" line="1103"/>
<source>Finishing...</source>
<translation>正在取消...</translation>
</message>
<message>
<location filename="../../src/MainWindow.cpp" line="560"/>
<location filename="../../src/MainWindow.cpp" line="1188"/>
<location filename="../../src/MainWindow.cpp" line="1170"/>
<source>Compressing...</source>
<translation>正在压缩...</translation>
</message>
Expand Down Expand Up @@ -341,7 +341,7 @@ Saved: %4 (%5%)</source>
</message>
<message>
<location filename="../../views/MainWindow.ui" line="1440"/>
<location filename="../../src/MainWindow.cpp" line="1107"/>
<location filename="../../src/MainWindow.cpp" line="1089"/>
<source>Preview</source>
<translation type="unfinished"></translation>
</message>
Expand Down
4 changes: 2 additions & 2 deletions resources/icons.rc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions setup.iss
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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]
Expand Down
34 changes: 8 additions & 26 deletions src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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();
Expand Down
4 changes: 4 additions & 0 deletions src/dialogs/AboutDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ AboutDialog::AboutDialog(QWidget* parent)
ui->version_Label->setText("v" + QCoreApplication::applicationVersion());
ui->uuid_Label->setText("<small>UUID: " + settings.value("uuid", "").toString() + "</small>");

#ifdef IS_PORTABLE
ui->checkForUpdates_Button->hide();
#endif

this->setAttribute(Qt::WA_DeleteOnClose, true);
this->setWindowFlags(Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
this->setWindowModality(Qt::ApplicationModal);
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading

0 comments on commit 84ac0db

Please sign in to comment.