| 1 |
/* |
| 2 |
* SPDX-FileCopyrightText: 2020 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 QtQuick.Controls |
| 11 |
|
| 12 |
import org.kde.haruna |
| 13 |
import org.kde.haruna.settings |
| 14 |
|
| 15 |
Menu { |
| 16 |
id: root |
| 17 |
|
| 18 |
required property RecentFilesModel m_recentFilesModel |
| 19 |
|
| 20 |
title: i18nc("@title:menu", "&File") |
| 21 |
|
| 22 |
MenuItem { action: HarunaApp.actions.openFileAction } |
| 23 |
MenuItem { action: HarunaApp.actions.openUrlAction } |
| 24 |
MenuItem { |
| 25 |
action: HarunaApp.actions.loadLastPlayedFileAction |
| 26 |
enabled: GeneralSettings.lastPlayedFile !== "" |
| 27 |
} |
| 28 |
|
| 29 |
Menu { |
| 30 |
id: recentFilesMenu |
| 31 |
|
| 32 |
title: i18nc("@title:menu", "Recent Files") |
| 33 |
|
| 34 |
Instantiator { |
| 35 |
model: root.m_recentFilesModel |
| 36 |
delegate: MenuItem { |
| 37 |
id: delegate |
| 38 |
|
| 39 |
required property string url |
| 40 |
required property string toolTipText |
| 41 |
required property string filename |
| 42 |
required property int openedFrom |
| 43 |
|
| 44 |
text: openedFrom === RecentFilesModel.OpenedFrom.OpenAction |
| 45 |
|| openedFrom === RecentFilesModel.OpenedFrom.ExternalApp |
| 46 |
? `<strong>${delegate.filename}</strong>` |
| 47 |
: delegate.filename |
| 48 |
|
| 49 |
onClicked: { |
| 50 |
recentFilesMenu.dismiss() |
| 51 |
HarunaApp.openRecentFile(delegate.url) |
| 52 |
} |
| 53 |
|
| 54 |
ToolTip { |
| 55 |
text: delegate.toolTipText |
| 56 |
} |
| 57 |
} |
| 58 |
onObjectAdded: (index, object) => recentFilesMenu.insertItem(index, object) |
| 59 |
onObjectRemoved: (index, object) => recentFilesMenu.removeItem(object) |
| 60 |
} |
| 61 |
|
| 62 |
MenuSeparator {} |
| 63 |
MenuItem { |
| 64 |
text: i18nc("@action:inmenu", "Clear List") |
| 65 |
onClicked: root.m_recentFilesModel.deleteEntries() |
| 66 |
} |
| 67 |
} |
| 68 |
|
| 69 |
|
| 70 |
MenuSeparator {} |
| 71 |
|
| 72 |
MenuItem { action: HarunaApp.actions.quitApplicationAction } |
| 73 |
} |