46 QAction *action =
nullptr;
47 for (
const QString &path : savedEntries) {
48 if (!path.isEmpty()) {
49 action =
new QAction(path, m_menu);
50 action->setProperty(
"file_path", path);
51 m_menu->insertAction(m_sep, action);
52 connect(action, &QAction::triggered,
this, &RecentMenuManager::handleActionTriggered);
56 m_menu->actions().front()->setShortcut(QKeySequence(Qt::Key_F6));
57 m_menu->setEnabled(
true);
66 QStringList existingEntires;
67 QList<QAction *> entryActions = m_menu->actions();
68 existingEntires.reserve(entryActions.size());
69 for (
const QAction *action : entryActions) {
70 QVariant path = action->property(
"file_path");
72 existingEntires << path.toString();
75 return existingEntires;
84 QList<QAction *> existingEntries = m_menu->actions();
85 QAction *entry =
nullptr;
87 for (QAction *existingEntry : existingEntries) {
88 existingEntry->setShortcut(QKeySequence());
90 if (existingEntry->property(
"file_path").toString() == path) {
91 entry = existingEntry;
97 for (
auto i = existingEntries.size() - 1; i > 8; --i) {
98 delete existingEntries[i];
100 existingEntries = m_menu->actions();
102 entry =
new QAction(path,
this);
103 entry->setProperty(
"file_path", path);
104 connect(entry, &QAction::triggered,
this, &RecentMenuManager::handleActionTriggered);
107 m_menu->removeAction(entry);
110 entry->setShortcut(QKeySequence(Qt::Key_F6));
112 m_menu->setEnabled(
true);
114 m_menu->insertAction(m_menu->isEmpty() ?
nullptr : m_menu->actions().front(), entry);
149 QPushButton *deleteEntryButton = msg.addButton(tr(
"delete entry"), QMessageBox::YesRole);