| 1 |
/* |
| 2 |
* SPDX-FileCopyrightText: 2022 George Florea Bănuș <[email protected]> |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: GPL-3.0-or-later |
| 5 |
*/ |
| 6 |
|
| 7 |
pragma ComponentBehavior: Bound |
| 8 |
|
| 9 |
import QtQuick |
| 10 |
import Qt.labs.platform as Labs |
| 11 |
|
| 12 |
import org.kde.haruna |
| 13 |
|
| 14 |
Labs.Menu { |
| 15 |
id: root |
| 16 |
|
| 17 |
required property RecentFilesModel m_recentFilesModel |
| 18 |
|
| 19 |
title: i18nc("@title:menu", "&File") |
| 20 |
|
| 21 |
Labs.MenuItem { |
| 22 |
icon.name: HarunaApp.actions.openFileAction.icon.name |
| 23 |
text: HarunaApp.actions.openFileAction.text |
| 24 |
onTriggered: HarunaApp.actions.openFileAction.trigger() |
| 25 |
} |
| 26 |
|
| 27 |
Labs.MenuItem { |
| 28 |
icon.name: HarunaApp.actions.openUrlAction.icon.name |
| 29 |
text: HarunaApp.actions.openUrlAction.text |
| 30 |
onTriggered: HarunaApp.actions.openUrlAction.trigger() |
| 31 |
} |
| 32 |
|
| 33 |
Labs.MenuItem { |
| 34 |
icon.name: HarunaApp.actions.loadLastPlayedFileAction.icon.name |
| 35 |
text: HarunaApp.actions.loadLastPlayedFileAction.text |
| 36 |
onTriggered: HarunaApp.actions.loadLastPlayedFileAction.trigger() |
| 37 |
} |
| 38 |
|
| 39 |
Labs.Menu { |
| 40 |
id: recentFilesMenu |
| 41 |
|
| 42 |
title: i18nc("@title:menu", "Recent Files") |
| 43 |
onAboutToShow: recentFilesInstantiator.model = root.m_recentFilesModel |
| 44 |
|
| 45 |
Instantiator { |
| 46 |
id: recentFilesInstantiator |
| 47 |
|
| 48 |
model: 0 |
| 49 |
onObjectAdded: (index, object) => recentFilesMenu.insertItem( index, object ) |
| 50 |
onObjectRemoved: (index, object) => recentFilesMenu.removeItem( object ) |
| 51 |
delegate: Labs.MenuItem { |
| 52 |
id: delegate |
| 53 |
|
| 54 |
required property string url |
| 55 |
required property string filename |
| 56 |
required property int openedFrom |
| 57 |
|
| 58 |
text: openedFrom === RecentFilesModel.OpenedFrom.OpenAction |
| 59 |
|| openedFrom === RecentFilesModel.OpenedFrom.ExternalApp |
| 60 |
? `<strong>${delegate.filename}</strong>` |
| 61 |
: delegate.filename |
| 62 |
onTriggered: { |
| 63 |
recentFilesMenu.close() |
| 64 |
const mainWindow = Window.window as Main |
| 65 |
mainWindow.openFile(delegate.url, RecentFilesModel.OpenedFrom.Other) |
| 66 |
} |
| 67 |
} |
| 68 |
} |
| 69 |
Labs.MenuSeparator {} |
| 70 |
Labs.MenuItem { |
| 71 |
text: i18nc("@action:inmenu", "Clear List") |
| 72 |
onTriggered: root.m_recentFilesModel.deleteEntries() |
| 73 |
} |
| 74 |
} |
| 75 |
|
| 76 |
|
| 77 |
Labs.MenuSeparator {} |
| 78 |
|
| 79 |
Labs.MenuItem { |
| 80 |
icon.name: HarunaApp.actions.quitApplicationAction.icon.name |
| 81 |
text: HarunaApp.actions.quitApplicationAction.text |
| 82 |
onTriggered: HarunaApp.actions.quitApplicationAction.trigger() |
| 83 |
} |
| 84 |
} |