[pim/korganizer/release/26.08] src/kontactplugin/korganizer: apptsummarywidget.cpp,todosummarywidget.cpp - improve menu for read-only
Allen Winter <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit e4473348c984f4b8da4a1cfa360b8e2374786a66 by Allen Winter.
Committed on 25/07/2026 at 15:16.
Pushed by winterz into branch 'release/26.08'.
apptsummarywidget.cpp,todosummarywidget.cpp - improve menu for read-only
For read-only calendars the context menus say:
- Show Appointment or Show To-do
- disable Delete
For writeable calendars the context menus say:
- Edit Appointment or Edit To-do
- enable Delete
(cherry picked from commit 89be2657c4b542b9d1ca3affc38517f4763051c3)
M +17 -8 src/kontactplugin/korganizer/apptsummarywidget.cpp
M +19 -10 src/kontactplugin/korganizer/todosummarywidget.cpp
https://invent.kde.org/pim/korganizer/-/commit/e4473348c984f4b8da4a1cfa360b8e2374786a66
diff --git a/src/kontactplugin/korganizer/apptsummarywidget.cpp b/src/kontactplugin/korganizer/apptsummarywidget.cpp
index 2e4654f45..bc92b1913 100644
--- a/src/kontactplugin/korganizer/apptsummarywidget.cpp
+++ b/src/kontactplugin/korganizer/apptsummarywidget.cpp
@@ -232,17 +232,26 @@ void ApptSummaryWidget::removeEvent(const Akonadi::Item &item)
void ApptSummaryWidget::popupMenu(const QString &uid)
{
+ const Akonadi::Item item = mCalendar->item(uid);
+ if (!item.isValid()) {
+ return;
+ }
+
QMenu popup(this);
- // FIXME: Should say "Show Appointment" if we don't have rights to edit
- // Doesn't make sense to edit events from birthday resource for example
- QAction *editIt = popup.addAction(i18n("&Edit Appointment…"));
- editIt->setIcon(QIcon::fromTheme(QStringLiteral("document-edit")));
- QAction *delIt = popup.addAction(i18n("&Delete Appointment"));
- delIt->setIcon(QIcon::fromTheme(QStringLiteral("edit-delete")));
+ QAction *editIt;
+ const bool writeable = mCalendar->hasRight(item, Akonadi::Collection::CanDeleteItem);
+ if (writeable) {
+ editIt = popup.addAction(i18nc("@action:inmenu", "&Edit Appointment…"));
+ editIt->setIcon(QIcon::fromTheme(QStringLiteral("document-edit")));
+ } else {
+ editIt = popup.addAction(i18nc("@action:inmenu", "&Show Appointment…"));
+ editIt->setIcon(QIcon::fromTheme(QStringLiteral("document-preview")));
+ }
- const Akonadi::Item item = mCalendar->item(uid);
- delIt->setEnabled(mCalendar->hasRight(item, Akonadi::Collection::CanDeleteItem));
+ QAction *delIt = popup.addAction(i18nc("@action:inmenu", "&Delete Appointment"));
+ delIt->setIcon(QIcon::fromTheme(QStringLiteral("edit-delete")));
+ delIt->setEnabled(writeable);
const QAction *selectedAction = popup.exec(QCursor::pos());
if (selectedAction == editIt) {
diff --git a/src/kontactplugin/korganizer/todosummarywidget.cpp b/src/kontactplugin/korganizer/todosummarywidget.cpp
index fd8e67672..169543c1a 100644
--- a/src/kontactplugin/korganizer/todosummarywidget.cpp
+++ b/src/kontactplugin/korganizer/todosummarywidget.cpp
@@ -372,23 +372,32 @@ void TodoSummaryWidget::completeTodo(Akonadi::Item::Id id)
void TodoSummaryWidget::popupMenu(const QString &uid)
{
- KCalendarCore::Todo::Ptr const todo = mCalendar->todo(uid);
- if (!todo) {
+ const Akonadi::Item item = mCalendar->item(uid);
+ if (!item.isValid()) {
return;
}
- Akonadi::Item const item = mCalendar->item(uid);
+
QMenu popup(this);
- QAction *editIt = popup.addAction(i18n("&Edit To-do…"));
- editIt->setIcon(QIcon::fromTheme(QStringLiteral("document-edit")));
- QAction *delIt = popup.addAction(i18n("&Delete To-do"));
+
+ QAction *editIt;
+ const bool writeable = mCalendar->hasRight(item, Akonadi::Collection::CanDeleteItem);
+ if (writeable) {
+ editIt = popup.addAction(i18nc("@action:inmenu", "&Edit To-do…"));
+ editIt->setIcon(QIcon::fromTheme(QStringLiteral("document-edit")));
+ } else {
+ editIt = popup.addAction(i18nc("@action:inmenu", "&Show To-do…"));
+ editIt->setIcon(QIcon::fromTheme(QStringLiteral("document-preview")));
+ }
+
+ QAction *delIt = popup.addAction(i18nc("@action:inmenu", "&Delete To-do"));
delIt->setIcon(QIcon::fromTheme(QStringLiteral("edit-delete")));
- delIt->setEnabled(mCalendar->hasRight(item, Akonadi::Collection::CanDeleteItem));
+ delIt->setEnabled(writeable);
QAction *doneIt = nullptr;
- if (!todo->isCompleted()) {
- doneIt = popup.addAction(i18n("&Mark To-do Completed"));
+ if (!mCalendar->todo(uid)->isCompleted()) {
+ doneIt = popup.addAction(i18nc("@action:inmenu", "&Mark To-do Completed"));
doneIt->setIcon(QIcon::fromTheme(QStringLiteral("task-complete")));
- doneIt->setEnabled(mCalendar->hasRight(item, Akonadi::Collection::CanChangeItem));
+ doneIt->setEnabled(writeable);
}
const QAction *selectedAction = popup.exec(QCursor::pos());