Skip to content

Commit a58aceb

Browse files
committed
Update choruskit
1 parent 678e846 commit a58aceb

File tree

8 files changed

+120
-85
lines changed

8 files changed

+120
-85
lines changed

src/plugins/coreplugin/internal/CorePlugin.cpp

Lines changed: 19 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
#include "CorePlugin.h"
22

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-
113
#include <algorithm>
124

135
#include <QApplication>
@@ -37,6 +29,7 @@
3729
#include <QAKCore/actionregistry.h>
3830

3931
#include <SVSCraftQuick/Theme.h>
32+
#include <SVSCraftQuick/MessageBox.h>
4033

4134
#include <loadapi/initroutine.h>
4235

@@ -67,6 +60,7 @@
6760
#include <coreplugin/internal/WorkspaceAddOn.h>
6861
#include <coreplugin/ProjectWindowInterface.h>
6962
#include <coreplugin/internal/CloseSaveCheckAddOn.h>
63+
#include <coreplugin/internal/PlatformJumpListHelper.h>
7064

7165
static auto getCoreActionExtension() {
7266
return QAK_STATIC_ACTION_EXTENSION(coreplugin);
@@ -198,11 +192,25 @@ namespace Core::Internal {
198192
}
199193

200194
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..."));
203196
for (auto plugin : ExtensionSystem::PluginManager::plugins()) {
204197
qCInfo(lcCorePlugin) << "Plugin" << plugin->name() << "enabled =" << plugin->isEffectivelyEnabled();
205198
}
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+
});
206214
}
207215

208216
bool CorePlugin::delayedInitialize() {
@@ -241,71 +249,6 @@ namespace Core::Internal {
241249
return QObject::eventFilter(obj, event);
242250
}
243251

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-
309252
void CorePlugin::initializeSingletons() {
310253
new CoreInterface(this);
311254
new BehaviorPreference(this);
@@ -407,11 +350,7 @@ namespace Core::Internal {
407350
}
408351

409352
void CorePlugin::initializeJumpList() {
410-
#ifdef Q_OS_WIN
411-
initializeWindowsJumpList();
412-
#elif defined(Q_OS_MACOS)
413-
initializeMacOSJumpList();
414-
#endif
353+
PlatformJumpListHelper::initializePlatformJumpList();
415354
}
416355

417356
void CorePlugin::initializeHelpContents() {
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#include "PlatformJumpListHelper.h"
2+
3+
#include <QApplication>
4+
5+
#ifdef Q_OS_WIN
6+
# include <ShObjIdl.h>
7+
# include <ShlObj.h>
8+
# include <atlbase.h>
9+
# include <propkey.h>
10+
# include <propvarutil.h>
11+
#elif defined(Q_OS_MACOS)
12+
// TODO: Add macOS jump list (dock menu) implementation when available
13+
#endif
14+
15+
namespace Core::Internal {
16+
17+
void PlatformJumpListHelper::initializePlatformJumpList() {
18+
#ifdef Q_OS_WIN
19+
CoInitialize(nullptr);
20+
21+
CComPtr<ICustomDestinationList> pcdl;
22+
HRESULT hr = pcdl.CoCreateInstance(CLSID_DestinationList, nullptr, CLSCTX_INPROC_SERVER);
23+
if (FAILED(hr)) {
24+
CoUninitialize();
25+
return;
26+
}
27+
28+
UINT cMinSlots;
29+
CComPtr<IObjectArray> poaRemoved;
30+
hr = pcdl->BeginList(&cMinSlots, IID_PPV_ARGS(&poaRemoved));
31+
if (FAILED(hr)) {
32+
CoUninitialize();
33+
return;
34+
}
35+
36+
CComPtr<IObjectCollection> poc;
37+
hr = poc.CoCreateInstance(CLSID_EnumerableObjectCollection, nullptr, CLSCTX_INPROC_SERVER);
38+
if (FAILED(hr)) {
39+
CoUninitialize();
40+
return;
41+
}
42+
43+
CComPtr<IShellLink> psl;
44+
hr = psl.CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER);
45+
if (FAILED(hr)) {
46+
CoUninitialize();
47+
return;
48+
}
49+
50+
auto appPath = QApplication::applicationFilePath().toStdWString();
51+
psl->SetPath(appPath.c_str());
52+
psl->SetArguments(L"--new");
53+
54+
CComPtr<IPropertyStore> pps;
55+
hr = psl->QueryInterface(IID_PPV_ARGS(&pps));
56+
if (SUCCEEDED(hr)) {
57+
PROPVARIANT propvar;
58+
InitPropVariantFromString(L"New Project", &propvar);
59+
pps->SetValue(PKEY_Title, propvar);
60+
PropVariantClear(&propvar);
61+
pps->Commit();
62+
}
63+
64+
poc->AddObject(psl);
65+
66+
CComPtr<IObjectArray> poa;
67+
hr = poc->QueryInterface(IID_PPV_ARGS(&poa));
68+
if (SUCCEEDED(hr)) {
69+
pcdl->AddUserTasks(poa);
70+
}
71+
72+
pcdl->CommitList();
73+
CoUninitialize();
74+
#elif defined(Q_OS_MACOS)
75+
// TODO: Add macOS jump list (dock menu) implementation when available
76+
#endif
77+
}
78+
79+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#ifndef DIFFSCOPE_COREPLUGIN_PLATFORMJUMPLISTHELPER_H
2+
#define DIFFSCOPE_COREPLUGIN_PLATFORMJUMPLISTHELPER_H
3+
4+
namespace Core::Internal {
5+
6+
class PlatformJumpListHelper {
7+
public:
8+
static void initializePlatformJumpList();
9+
};
10+
11+
}
12+
13+
#endif // DIFFSCOPE_COREPLUGIN_PLATFORMJUMPLISTHELPER_H

src/plugins/coreplugin/internal/settings/GeneralPage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ namespace Core::Internal {
121121
title.arg(QApplication::applicationDisplayName()),
122122
text.arg(QApplication::applicationDisplayName())
123123
) == SVS::SVSCraft::Yes) {
124-
CoreInterface::restartApplication();
124+
RuntimeInterface::restartApplication();
125125
}
126126
}
127127
return ISettingPage::accept();

src/plugins/coreplugin/qml/actions/GlobalActions.qml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import QtQuick.Controls
55
import SVSCraft.UIComponents
66
import SVSCraft.UIComponents.impl
77

8+
import ChorusKit.AppCore
9+
810
import QActionKit
911

1012
import DiffScope.UIShell
@@ -84,7 +86,7 @@ ActionCollection {
8486
actionId: "org.diffscope.core.exit"
8587
Action {
8688
onTriggered: () => {
87-
CoreInterface.exitApplicationGracefully()
89+
RuntimeInterface.exitApplicationGracefully()
8890
}
8991
}
9092
}

src/plugins/coreplugin/qml/dialogs/PluginDialog.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Window {
2020
onClosing: finished()
2121
PluginView {
2222
anchors.fill: parent
23-
onRestartRequested: CoreInterface.restartApplication()
23+
onRestartRequested: RuntimeInterface.restartApplication()
2424
}
2525
// TODO: load/save window and splitter size
2626
}

src/plugins/coreplugin/qml/panels/PluginsPanel.qml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import QtQuick
33
import QtQuick.Controls
44
import QtQuick.Layouts
55

6+
import ChorusKit.AppCore
7+
68
import SVSCraft
79
import SVSCraft.UIComponents
810

@@ -12,6 +14,6 @@ ActionDockingPane {
1214
PluginView {
1315
anchors.fill: parent
1416
useSplitView: false
15-
onRestartRequested: CoreInterface.restartApplication()
17+
onRestartRequested: RuntimeInterface.restartApplication()
1618
}
1719
}

0 commit comments

Comments
 (0)