|
1 | 1 | #include "CorePlugin.h" |
2 | 2 |
|
3 | | -#ifdef Q_OS_WIN |
4 | | -# include <ShObjIdl.h> |
5 | | -# include <ShlObj.h> |
6 | | -# include <atlbase.h> |
7 | | -# include <propkey.h> |
8 | | -# include <propvarutil.h> |
9 | | -#endif |
10 | | - |
11 | 3 | #include <algorithm> |
12 | 4 |
|
13 | 5 | #include <QApplication> |
|
37 | 29 | #include <QAKCore/actionregistry.h> |
38 | 30 |
|
39 | 31 | #include <SVSCraftQuick/Theme.h> |
| 32 | +#include <SVSCraftQuick/MessageBox.h> |
40 | 33 |
|
41 | 34 | #include <loadapi/initroutine.h> |
42 | 35 |
|
|
67 | 60 | #include <coreplugin/internal/WorkspaceAddOn.h> |
68 | 61 | #include <coreplugin/ProjectWindowInterface.h> |
69 | 62 | #include <coreplugin/internal/CloseSaveCheckAddOn.h> |
| 63 | +#include <coreplugin/internal/PlatformJumpListHelper.h> |
70 | 64 |
|
71 | 65 | static auto getCoreActionExtension() { |
72 | 66 | return QAK_STATIC_ACTION_EXTENSION(coreplugin); |
@@ -198,11 +192,25 @@ namespace Core::Internal { |
198 | 192 | } |
199 | 193 |
|
200 | 194 | void CorePlugin::extensionsInitialized() { |
201 | | - auto settings = RuntimeInterface::settings(); |
202 | | - settings->setValue("lastInitializationAbortedFlag", false); |
| 195 | + RuntimeInterface::splash()->showMessage(tr("Plugins loading complete, preparing for subsequent initialization...")); |
203 | 196 | for (auto plugin : ExtensionSystem::PluginManager::plugins()) { |
204 | 197 | qCInfo(lcCorePlugin) << "Plugin" << plugin->name() << "enabled =" << plugin->isEffectivelyEnabled(); |
205 | 198 | } |
| 199 | + auto settings = RuntimeInterface::settings(); |
| 200 | + settings->setValue("lastInitializationAbortedFlag", false); |
| 201 | + if (settings->value("lastRunTerminatedAbnormally").toBool()) { |
| 202 | + qCWarning(lcCorePlugin) << "Last run terminated abnormally"; |
| 203 | + SVS::MessageBox::warning(RuntimeInterface::qmlEngine(), nullptr, |
| 204 | + tr("Last run terminated abnormally"), |
| 205 | + tr("%1 did not exit normally during its last run.\n\nTo check for unsaved files, please go to Recovery Files.").arg(QApplication::applicationDisplayName()) |
| 206 | + ); |
| 207 | + } |
| 208 | + settings->setValue("lastRunTerminatedAbnormally", true); |
| 209 | + RuntimeInterface::addExitCallback([](int exitCode) { |
| 210 | + if (exitCode == 0) { |
| 211 | + RuntimeInterface::settings()->setValue("lastRunTerminatedAbnormally", false); |
| 212 | + } |
| 213 | + }); |
206 | 214 | } |
207 | 215 |
|
208 | 216 | bool CorePlugin::delayedInitialize() { |
@@ -241,71 +249,6 @@ namespace Core::Internal { |
241 | 249 | return QObject::eventFilter(obj, event); |
242 | 250 | } |
243 | 251 |
|
244 | | -#ifdef Q_OS_WIN |
245 | | - static void initializeWindowsJumpList() { |
246 | | - CoInitialize(nullptr); |
247 | | - |
248 | | - CComPtr<ICustomDestinationList> pcdl; |
249 | | - HRESULT hr = pcdl.CoCreateInstance(CLSID_DestinationList, nullptr, CLSCTX_INPROC_SERVER); |
250 | | - if (FAILED(hr)) { |
251 | | - CoUninitialize(); |
252 | | - return; |
253 | | - } |
254 | | - |
255 | | - UINT cMinSlots; |
256 | | - CComPtr<IObjectArray> poaRemoved; |
257 | | - hr = pcdl->BeginList(&cMinSlots, IID_PPV_ARGS(&poaRemoved)); |
258 | | - if (FAILED(hr)) { |
259 | | - CoUninitialize(); |
260 | | - return; |
261 | | - } |
262 | | - |
263 | | - CComPtr<IObjectCollection> poc; |
264 | | - hr = poc.CoCreateInstance(CLSID_EnumerableObjectCollection, nullptr, CLSCTX_INPROC_SERVER); |
265 | | - if (FAILED(hr)) { |
266 | | - CoUninitialize(); |
267 | | - return; |
268 | | - } |
269 | | - |
270 | | - CComPtr<IShellLink> psl; |
271 | | - hr = psl.CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER); |
272 | | - if (FAILED(hr)) { |
273 | | - CoUninitialize(); |
274 | | - return; |
275 | | - } |
276 | | - |
277 | | - auto appPath = QApplication::applicationFilePath().toStdWString(); |
278 | | - psl->SetPath(appPath.c_str()); |
279 | | - psl->SetArguments(L"--new"); |
280 | | - |
281 | | - CComPtr<IPropertyStore> pps; |
282 | | - hr = psl->QueryInterface(IID_PPV_ARGS(&pps)); |
283 | | - if (SUCCEEDED(hr)) { |
284 | | - PROPVARIANT propvar; |
285 | | - InitPropVariantFromString(L"New Project", &propvar); |
286 | | - pps->SetValue(PKEY_Title, propvar); |
287 | | - PropVariantClear(&propvar); |
288 | | - pps->Commit(); |
289 | | - } |
290 | | - |
291 | | - poc->AddObject(psl); |
292 | | - |
293 | | - CComPtr<IObjectArray> poa; |
294 | | - hr = poc->QueryInterface(IID_PPV_ARGS(&poa)); |
295 | | - if (SUCCEEDED(hr)) { |
296 | | - pcdl->AddUserTasks(poa); |
297 | | - } |
298 | | - |
299 | | - pcdl->CommitList(); |
300 | | - CoUninitialize(); |
301 | | - } |
302 | | -#endif |
303 | | - |
304 | | -#ifdef Q_OS_MACOS |
305 | | - static void initializeMacOSJumpList() { |
306 | | - } |
307 | | -#endif |
308 | | - |
309 | 252 | void CorePlugin::initializeSingletons() { |
310 | 253 | new CoreInterface(this); |
311 | 254 | new BehaviorPreference(this); |
@@ -407,11 +350,7 @@ namespace Core::Internal { |
407 | 350 | } |
408 | 351 |
|
409 | 352 | void CorePlugin::initializeJumpList() { |
410 | | -#ifdef Q_OS_WIN |
411 | | - initializeWindowsJumpList(); |
412 | | -#elif defined(Q_OS_MACOS) |
413 | | - initializeMacOSJumpList(); |
414 | | -#endif |
| 353 | + PlatformJumpListHelper::initializePlatformJumpList(); |
415 | 354 | } |
416 | 355 |
|
417 | 356 | void CorePlugin::initializeHelpContents() { |
|
0 commit comments