From fef992a12c81ad728b44617e02c3f5180c4a3cc0 Mon Sep 17 00:00:00 2001 From: Victor Tran Date: Mon, 3 Aug 2020 23:25:55 +1000 Subject: Add Windows Class ID information --- installer/backgrounds/theBeat.svg | 42 ++++++++++++++++------ installer/installer.pro | 8 +++-- installer/main.cpp | 2 +- installer/mainwindow.cpp | 4 +++ installer/metadata.txt | 2 +- installer/process/installworker.cpp | 67 ++++++++++++++++++++++++++++++++++-- installer/process/removeworker.cpp | 14 ++++++++ installer/resources.qrc | 5 +++ installer/translations/de_DE.qm | Bin 5325 -> 6380 bytes installer/translations/de_DE.ts | 18 +++++----- installer/translations/en_AU.ts | 18 +++++----- installer/translations/en_GB.ts | 18 +++++----- installer/translations/en_NZ.ts | 18 +++++----- installer/translations/en_US.ts | 18 +++++----- installer/translations/nl_NL.ts | 18 +++++----- installer/translations/pt_BR.ts | 18 +++++----- installer/translations/vi_VN.ts | 18 +++++----- 17 files changed, 198 insertions(+), 90 deletions(-) (limited to 'installer') diff --git a/installer/backgrounds/theBeat.svg b/installer/backgrounds/theBeat.svg index a19b2b1..efa7497 100644 --- a/installer/backgrounds/theBeat.svg +++ b/installer/backgrounds/theBeat.svg @@ -95,7 +95,7 @@ inkscape:window-width="2560" units="px" showgrid="true" - inkscape:current-layer="layer1" + inkscape:current-layer="layer1-8" inkscape:document-units="mm" inkscape:cy="225.7971" inkscape:cx="225.15375" @@ -153,17 +153,39 @@ height="148.16666" x="4.4408921e-16" y="148.83331" /> - + + + + + + + theBeat + d="m 128.62332,185.86393 q 0,0.15522 0.127,0.26811 0.14111,0.0988 0.29633,0.0988 h 0.52211 q 0.15523,0 0.26812,-0.11289 0.11288,-0.11289 0.11288,-0.26811 l -0.0423,-5.74322 h 1.48167 q 0.15522,0 0.26811,-0.11289 0.11289,-0.11289 0.11289,-0.26811 v -0.45155 q 0,-0.15522 -0.11289,-0.26811 -0.11289,-0.11289 -0.26811,-0.11289 h -1.48167 v -2.30011 q 0,-0.15522 -0.11289,-0.26811 -0.11289,-0.11289 -0.26811,-0.11289 h -0.52211 q -0.15522,0 -0.26811,0.11289 -0.11289,0.11289 -0.11289,0.26811 v 2.30011 h -1.35466 q -0.15523,0 -0.26812,0.11289 -0.11288,0.11289 -0.11288,0.26811 v 0.45155 q 0,0.15522 0.11288,0.26811 0.11289,0.11289 0.26812,0.11289 h 1.35466 z" /> + installPathLineEdit->text(); if (destdir.endsWith("\\")) { destdir.append("\\"); diff --git a/installer/metadata.txt b/installer/metadata.txt index e7b27c7..5f3fde9 100644 --- a/installer/metadata.txt +++ b/installer/metadata.txt @@ -1 +1 @@ -https://vicr123.com/thebeat/theinstaller/installer.json \ No newline at end of file +file:///C:/Users/victo/Documents/Website/MainSite/thebeat/theinstaller/installer.json \ No newline at end of file diff --git a/installer/process/installworker.cpp b/installer/process/installworker.cpp index d4f5c5b..e1c0dbc 100644 --- a/installer/process/installworker.cpp +++ b/installer/process/installworker.cpp @@ -1,5 +1,15 @@ #include "installworker.h" +#include +#include +#include +#include +#include +#include +#include +#include + + extern QString calculateSize(quint64 size); InstallWorker::InstallWorker(QObject *parent) : QObject(parent) @@ -8,7 +18,7 @@ InstallWorker::InstallWorker(QObject *parent) : QObject(parent) bool InstallWorker::startWork() { QLocalSocket* sock = new QLocalSocket(); - QString vendor, name, url, destPath, executable; + QString vendor, name, url, destPath, executable, clsid; bool isStableStream = true, isGlobalInstall = true; QString previousToken; @@ -26,10 +36,12 @@ bool InstallWorker::startWork() { destPath = arg; } else if (previousToken == "--executable") { executable = arg; + } else if (previousToken == "--clsid") { + clsid = arg; } previousToken = ""; } else { - if (arg == "--socket" || arg == "--vendor" || arg == "--name" || arg == "--url" || arg == "--destdir" || arg == "--executable") { + if (arg == "--socket" || arg == "--vendor" || arg == "--name" || arg == "--url" || arg == "--destdir" || arg == "--executable" || arg == "--clsid") { previousToken = arg; } else if (arg == "--blueprint") { isStableStream = false; @@ -135,9 +147,54 @@ bool InstallWorker::startWork() { if (QFile::exists(linkFile)) { QFile::remove(linkFile); } - QFile::link(executableFile.absoluteFilePath(), linkFile); QFile::copy(QApplication::applicationFilePath(), dest.absoluteFilePath("uninstall.exe")); + bool shouldUseQFileLink = false; + if (!clsid.isEmpty()) { + QString appUMID = QStringLiteral("%1.%2").arg(vendor.toLower()).arg(name.toLower()); + QSettings* comServer; + if (isGlobalInstall) { + comServer = new QSettings(QStringLiteral("HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\CLSID\\%1\\LocalServer32").arg(clsid), QSettings::NativeFormat); + } else { + comServer = new QSettings(QStringLiteral("HKEY_CURRENT_USER\\SOFTWARE\\Classes\\CLSID\\%1\\LocalServer32").arg(clsid), QSettings::NativeFormat); + } + + comServer->setValue(".", "\"" + executableFile.absoluteFilePath() + "\" -ToastActivated"); + + comServer->deleteLater(); + + try { + auto link{ winrt::create_instance(CLSID_ShellLink) }; + winrt::check_hresult(link->SetPath(executableFile.absoluteFilePath().toStdWString().c_str())); + + auto store = link.as(); + PROPVARIANT value; + winrt::check_hresult(::InitPropVariantFromString(appUMID.toStdWString().c_str(), &value)); + winrt::check_hresult(store->SetValue(PKEY_AppUserModel_ID, value)); + ::PropVariantClear(&value); + + CLSID clsidVar; + winrt::check_hresult(::CLSIDFromString(clsid.toStdWString().c_str(), &clsidVar)); + winrt::check_hresult(::InitPropVariantFromCLSID(clsidVar, &value)); + winrt::check_hresult(store->SetValue(PKEY_AppUserModel_ToastActivatorCLSID, value)); + + auto file{ store.as() }; + winrt::check_hresult(file->Save(linkFile.toStdWString().c_str(), TRUE)); + + ::PropVariantClear(&value); + } catch (...) { + sock->write(QString("DEBUG Error while creating link; falling back to QFile::link\n").toUtf8()); + + shouldUseQFileLink = true; + } + } else { + shouldUseQFileLink = true; + } + + if (shouldUseQFileLink) { + QFile::link(executableFile.absoluteFilePath(), linkFile); + } + QJsonObject dataRoot; dataRoot.insert("vendor", vendor); dataRoot.insert("name", name); @@ -147,6 +204,10 @@ bool InstallWorker::startWork() { dataRoot.insert("stream", isStableStream); dataRoot.insert("registryUuid", name); + if (!clsid.isEmpty()) { + dataRoot.insert("clsid", clsid); + } + QSettings* settings; if (isGlobalInstall) { settings = new QSettings("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + name, QSettings::NativeFormat); diff --git a/installer/process/removeworker.cpp b/installer/process/removeworker.cpp index 5356f26..39a890b 100644 --- a/installer/process/removeworker.cpp +++ b/installer/process/removeworker.cpp @@ -74,6 +74,20 @@ bool RemoveWorker::startWork() { QDir dest(metadata.value("installPath").toString()); dest.removeRecursively(); + if (metadata.contains("clsid")) { + QSettings* comServer; + if (metadata.value("global").toBool()) { + comServer = new QSettings(QStringLiteral("HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\CLSID"), QSettings::NativeFormat); + } else { + comServer = new QSettings(QStringLiteral("HKEY_CURRENT_USER\\SOFTWARE\\Classes\\CLSID"), QSettings::NativeFormat); + } + + comServer->remove(metadata.value("clsid").toString()); + comServer->sync(); + + comServer->deleteLater(); + } + //Remove registry entry QSettings* settings; if (metadata.value("global").toBool()) { diff --git a/installer/resources.qrc b/installer/resources.qrc index e300594..6f99058 100644 --- a/installer/resources.qrc +++ b/installer/resources.qrc @@ -11,5 +11,10 @@ translations/en_US.qm licenses/gpl3.html icons/go-previous.svg + translations/de_DE.qm + translations/nl_NL.qm + translations/it_IT.qm + translations/pl_PL.qm + translations/sv_SE.qm diff --git a/installer/translations/de_DE.qm b/installer/translations/de_DE.qm index 2ee4e76..f0a87c6 100644 Binary files a/installer/translations/de_DE.qm and b/installer/translations/de_DE.qm differ diff --git a/installer/translations/de_DE.ts b/installer/translations/de_DE.ts index 1610aee..8ca7ec8 100644 --- a/installer/translations/de_DE.ts +++ b/installer/translations/de_DE.ts @@ -4,28 +4,28 @@ InstallWorker - - + + Downloading %1... Downloade %1... - + Unpacking %1... Entpacke %1... - + Configuring %1... Konfiguriere %1... - + %1 of %2 %1 von %2 - + %n days remaining %n Tag übrig @@ -33,7 +33,7 @@ - + %n hours remaining %n Stunde übrig @@ -41,7 +41,7 @@ - + %n minutes remaining %n Minute übrig @@ -49,7 +49,7 @@ - + %n seconds remaining %n Sekunde übrig diff --git a/installer/translations/en_AU.ts b/installer/translations/en_AU.ts index 916981e..4f069fe 100644 --- a/installer/translations/en_AU.ts +++ b/installer/translations/en_AU.ts @@ -4,28 +4,28 @@ InstallWorker - - + + Downloading %1... - + Unpacking %1... - + Configuring %1... - + %1 of %2 - + %n days remaining %n day remaining @@ -33,7 +33,7 @@ - + %n hours remaining %n hour remaining @@ -41,7 +41,7 @@ - + %n minutes remaining %n minute remaining @@ -49,7 +49,7 @@ - + %n seconds remaining %n second remaining diff --git a/installer/translations/en_GB.ts b/installer/translations/en_GB.ts index 674b68b..f5a21be 100644 --- a/installer/translations/en_GB.ts +++ b/installer/translations/en_GB.ts @@ -4,28 +4,28 @@ InstallWorker - - + + Downloading %1... - + Unpacking %1... - + Configuring %1... - + %1 of %2 - + %n days remaining %n day remaining @@ -33,7 +33,7 @@ - + %n hours remaining %n hour remaining @@ -41,7 +41,7 @@ - + %n minutes remaining %n minute remaining @@ -49,7 +49,7 @@ - + %n seconds remaining %n second remaining diff --git a/installer/translations/en_NZ.ts b/installer/translations/en_NZ.ts index 9604900..2a359c9 100644 --- a/installer/translations/en_NZ.ts +++ b/installer/translations/en_NZ.ts @@ -4,28 +4,28 @@ InstallWorker - - + + Downloading %1... - + Unpacking %1... - + Configuring %1... - + %1 of %2 - + %n days remaining %n day remaining @@ -33,7 +33,7 @@ - + %n hours remaining %n hour remaining @@ -41,7 +41,7 @@ - + %n minutes remaining %n minute remaining @@ -49,7 +49,7 @@ - + %n seconds remaining %n second remaining diff --git a/installer/translations/en_US.ts b/installer/translations/en_US.ts index 3671b3b..2ecdc2c 100644 --- a/installer/translations/en_US.ts +++ b/installer/translations/en_US.ts @@ -4,28 +4,28 @@ InstallWorker - - + + Downloading %1... - + Unpacking %1... - + Configuring %1... - + %1 of %2 - + %n days remaining %n day remaining @@ -33,7 +33,7 @@ - + %n hours remaining %n hour remaining @@ -41,7 +41,7 @@ - + %n minutes remaining %n minute remaining @@ -49,7 +49,7 @@ - + %n seconds remaining %n second remaining diff --git a/installer/translations/nl_NL.ts b/installer/translations/nl_NL.ts index d8387de..ccfad6f 100644 --- a/installer/translations/nl_NL.ts +++ b/installer/translations/nl_NL.ts @@ -4,28 +4,28 @@ InstallWorker - - + + Downloading %1... %1 Downloaden... - + Unpacking %1... %1 Uitpakken... - + Configuring %1... %1 Instellen... - + %1 of %2 %1 van %2 - + %n days remaining %n dag resterend @@ -33,7 +33,7 @@ - + %n hours remaining %n uur resterend @@ -41,7 +41,7 @@ - + %n minutes remaining %n minuut resterend @@ -49,7 +49,7 @@ - + %n seconds remaining %n seconde resterend diff --git a/installer/translations/pt_BR.ts b/installer/translations/pt_BR.ts index 45399a9..5311a74 100644 --- a/installer/translations/pt_BR.ts +++ b/installer/translations/pt_BR.ts @@ -4,28 +4,28 @@ InstallWorker - - + + Downloading %1... Baixando %1… - + Unpacking %1... Descompactando %1… - + Configuring %1... Configurando %1… - + %1 of %2 %1 de %2 - + %n days remaining %n dia restante @@ -33,7 +33,7 @@ - + %n hours remaining %n hora restante @@ -41,7 +41,7 @@ - + %n minutes remaining %n minuto restante @@ -49,7 +49,7 @@ - + %n seconds remaining %n segundo restante diff --git a/installer/translations/vi_VN.ts b/installer/translations/vi_VN.ts index 2b7c5d8..8b75ab9 100644 --- a/installer/translations/vi_VN.ts +++ b/installer/translations/vi_VN.ts @@ -4,49 +4,49 @@ InstallWorker - - + + Downloading %1... Đang tải xuống %1... - + Unpacking %1... Đang giải nén %1... - + Configuring %1... Đang cấu hình %1... - + %1 of %2 %1 trén %2 - + %n days remaining Còn %n ngày - + %n hours remaining Còn %n tiếng - + %n minutes remaining Còn %n phút - + %n seconds remaining Còn %n giay -- cgit v1.2.3