Skip to content

Commit b061e47

Browse files
committed
Update actions
1 parent 4387b99 commit b061e47

File tree

7 files changed

+68
-78
lines changed

7 files changed

+68
-78
lines changed

src/libs/application/uishell/src/qml/HomeWindow.qml

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Window {
2323
property var recoveryFilesModel: null
2424
property var navigationActionsModel: null
2525
property var toolActionsModel: null
26-
property var macosMenusModel: null
26+
property var menusModel: null
2727

2828
readonly property bool isMacOS: Qt.platform.os === "osx" || Qt.platform.os === "macos"
2929

@@ -58,6 +58,7 @@ Window {
5858
windowAgent.setSystemButton(WindowAgent.Minimize, minimizeSystemButton)
5959
windowAgent.setSystemButton(WindowAgent.Maximize, maximizeSystemButton)
6060
windowAgent.setSystemButton(WindowAgent.Close, closeSystemButton)
61+
windowAgent.setHitTestVisible(menuBar)
6162
windowAgent.setHitTestVisible(Overlay.overlay)
6263
}
6364
}
@@ -322,35 +323,56 @@ Window {
322323
property bool framelessSetup: false
323324
}
324325

325-
MenuBar {
326-
id: menuBar
327-
visible: window.isMacOS
328-
Instantiator {
329-
model: window.macosMenusModel
330-
onObjectAdded: (index, object) => {
331-
if (object instanceof Menu) {
332-
menuBar.insertMenu(index, object)
333-
} else {
334-
throw new TypeError("Unsupported menu type")
335-
}
336-
}
337-
onObjectRemoved: (index, object) => {
338-
if (object instanceof Menu) {
339-
menuBar.removeMenu(object)
340-
} else {
341-
throw new TypeError("Unsupported menu type")
342-
}
343-
}
344-
}
345-
}
346-
347326
Item {
348327
id: titleBarArea
349328
width: window.width
350329
height: !window.isMacOS ? 36 : 28
351330
visible: windowAgent.framelessSetup && (!window.isMacOS || window.visibility !== Window.FullScreen)
352331
z: 1
353332
Accessible.role: Accessible.TitleBar
333+
Rectangle {
334+
id: menuBarBackground
335+
width: parent.width
336+
height: menuBar.height
337+
visible: menuBar.height !== 0
338+
anchors.top: parent.top
339+
anchors.topMargin: menuBar.anchors.topMargin
340+
color: Theme.backgroundQuaternaryColor
341+
}
342+
MenuBar {
343+
id: menuBar
344+
anchors.left: parent.left
345+
anchors.top: parent.top
346+
anchors.topMargin: activeFocus || menus.some(menu => menu.visible) || children.some(item => item.activeFocus) ? 0 : -height
347+
ThemedItem.backgroundLevel: SVS.BL_Quaternary
348+
Behavior on anchors.topMargin {
349+
id: topMarginBehavior
350+
enabled: false
351+
NumberAnimation {
352+
duration: Theme.visualEffectAnimationDuration
353+
easing.type: Easing.OutCubic
354+
}
355+
}
356+
Component.onCompleted: Qt.callLater(() => topMarginBehavior.enabled = true)
357+
Instantiator {
358+
model: window.menusModel
359+
onObjectAdded: (index, object) => {
360+
if (object instanceof Menu) {
361+
console.log(object)
362+
menuBar.insertMenu(index, object)
363+
} else {
364+
throw new TypeError("Unsupported menu type")
365+
}
366+
}
367+
onObjectRemoved: (index, object) => {
368+
if (object instanceof Menu) {
369+
menuBar.removeMenu(object)
370+
} else {
371+
throw new TypeError("Unsupported menu type")
372+
}
373+
}
374+
}
375+
}
354376
RowLayout {
355377
anchors.right: parent.right
356378
visible: !window.isMacOS

src/plugins/coreplugin/CMakeLists.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,6 @@ qak_add_action_extension(
2727
res/core_actions.xml
2828
)
2929
list(APPEND _src ${_core_actions_src})
30-
if(APPLE)
31-
qak_add_action_extension(
32-
_core_macos_actions_src
33-
res/core_macos_actions.xml
34-
)
35-
list(APPEND _src ${_core_macos_actions_src})
36-
endif()
3730

3831
qm_configure_target(${PROJECT_NAME}
3932
SOURCES ${_src}

src/plugins/coreplugin/internal/coreplugin.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,6 @@ static auto getCoreActionExtension() {
7070
return QAK_STATIC_ACTION_EXTENSION(core_actions);
7171
}
7272

73-
#ifdef Q_OS_MAC
74-
static auto getCoreMacOSActionExtension() {
75-
return QAK_STATIC_ACTION_EXTENSION(core_macos_actions);
76-
}
77-
#endif
78-
7973
namespace Core::Internal {
8074

8175
Q_STATIC_LOGGING_CATEGORY(lcCorePlugin, "diffscope.core.coreplugin")
@@ -319,9 +313,6 @@ namespace Core::Internal {
319313

320314
void CorePlugin::initializeActions() {
321315
CoreInterface::actionRegistry()->addExtension(::getCoreActionExtension());
322-
#ifdef Q_OS_MAC
323-
CoreInterface::actionRegistry()->addExtension(::getCoreMacOSActionExtension());
324-
#endif
325316

326317
// TODO: move to icon manifest later
327318
const auto addIcon = [&](const QString &id, const QString &iconName) {

src/plugins/coreplugin/qml/actions/ProjectWindowNavigatorAddOnActions.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ ActionCollection {
4646
checked: d.addOn.windowHandle === modelData
4747
onTriggered: () => {
4848
d.addOn.raiseWindow(modelData)
49+
checked = d.addOn.windowHandle === modelData
4950
}
5051
}
5152
}

src/plugins/coreplugin/qml/windows/HomeWindow.qml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ HomeWindow {
5858
}
5959
}
6060
}
61-
macosMenusModel: ObjectModel {
61+
menusModel: ObjectModel {
6262
property ActionInstantiator instantiator: ActionInstantiator {
63-
actionId: homeWindow.isMacOS ? "core.homeMenu" : ""
63+
actionId: "core.homeMenu"
6464
context: homeWindow.windowHandle.actionContext
6565
onObjectAdded: (index, object) => {
66-
homeWindow.macosMenusModel.insert(index, object)
66+
homeWindow.menusModel.insert(index, object)
6767
}
6868
onObjectRemoved: (index, object) => {
69-
homeWindow.macosMenusModel.remove(index)
69+
homeWindow.menusModel.remove(index)
7070
}
7171
}
7272
}

src/plugins/coreplugin/res/core_actions.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,24 @@
372372
</menu>
373373
<menu id="core.help" />
374374
</menu>
375+
376+
377+
<menu id="core.homeMenu">
378+
<menu id="core.homeFile" text="&amp;File">
379+
<group id="core.fileOpenActions" />
380+
<group id="core.preferenceActions" />
381+
<action id="core.exit" />
382+
</menu>
383+
<menu id="core.homeView" text="&amp;View">
384+
<action id="core.home.recentFiles" />
385+
<action id="core.home.recoveryFiles" />
386+
<separator />
387+
<action id="core.home.gridView" />
388+
<action id="core.home.listView" />
389+
</menu>
390+
<menu id="core.window" />
391+
<menu id="core.help" />
392+
</menu>
375393
</layouts>
376394

377395
</actionExtension>

src/plugins/coreplugin/res/core_macos_actions.xml

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)