Commit afd4fff5 authored by Claudio Cambra's avatar Claudio Cambra
Browse files

Added menu entries to refresh all calendars, including an F5 shortcut. Fixes #83

parent 16e03ba2
Pipeline #99406 failed with stage
in 2 minutes and 22 seconds
......@@ -816,6 +816,14 @@ void CalendarManager::redoAction()
m_changer->history()->redo();
}
void CalendarManager::updateAllCollections()
{
for (int i = 0; i < collections()->rowCount(); i++) {
auto collection = collections()->data(collections()->index(i, 0), Akonadi::EntityTreeModel::CollectionRole).value<Akonadi::Collection>();
Akonadi::AgentManager::self()->synchronizeCollection(collection, true);
}
}
void CalendarManager::updateCollection(qint64 collectionId)
{
auto collection = m_calendar->collection(collectionId);
......
......@@ -87,6 +87,7 @@ public:
Q_INVOKABLE void undoAction();
Q_INVOKABLE void redoAction();
Q_INVOKABLE void updateAllCollections();
Q_INVOKABLE void updateCollection(qint64 collectionId);
Q_INVOKABLE void deleteCollection(qint64 collectionId);
Q_INVOKABLE void editCollection(qint64 collectionId);
......
......@@ -97,6 +97,13 @@ Labs.MenuBar {
NativeMenuItemFromAction {
kalendarAction: 'todoview_show_completed'
}
Labs.MenuSeparator {
}
NativeMenuItemFromAction {
kalendarAction: "refresh_all_calendars"
}
}
Labs.Menu {
......
......@@ -162,6 +162,9 @@ Kirigami.OverlayDrawer {
KActionFromAction {
kalendarAction: "import_calendar"
},
KActionFromAction {
kalendarAction: "refresh_all_calendars"
},
Kirigami.Action {
icon.name: KalendarApplication.iconName(quitAction.icon)
text: quitAction.text
......
......@@ -172,6 +172,13 @@ QQC2.MenuBar {
kalendarAction: "todoview_show_completed"
}
QQC2.MenuSeparator {
}
KActionFromAction {
kalendarAction: "refresh_all_calendars"
}
}
QQC2.Menu {
......
......@@ -58,6 +58,7 @@ Kirigami.ApplicationWindow {
readonly property var quitAction: KalendarApplication.action("file_quit")
readonly property var undoAction: KalendarApplication.action("edit_undo")
readonly property var redoAction: KalendarApplication.action("edit_redo")
readonly property var refreshAllAction: KalendarApplication.action("refresh_all_calendars")
readonly property var todoViewSortAlphabeticallyAction: KalendarApplication.action("todoview_sort_alphabetically")
readonly property var todoViewSortByDueDateAction: KalendarApplication.action("todoview_sort_by_due_date")
......@@ -324,6 +325,10 @@ Kirigami.ApplicationWindow {
function onOpenKCommandBarAction() {
kcommandbarLoader.active = true;
}
function onRefreshAllCalendars() {
CalendarManager.updateAllCollections();
}
}
Loader {
......
......@@ -367,6 +367,17 @@ void KalendarApplication::setupActions()
mCollection.addAction(openKCommandBarAction->objectName(), openKCommandBarAction);
mCollection.setDefaultShortcut(openKCommandBarAction, QKeySequence(Qt::CTRL | Qt::ALT | Qt::Key_I));
}
actionName = QLatin1String("refresh_all_calendars");
if (KAuthorized::authorizeAction(actionName)) {
auto refreshAllAction = mCollection.addAction(actionName, this, &KalendarApplication::refreshAllCalendars);
refreshAllAction->setText(i18n("Refresh All Calendars"));
refreshAllAction->setIcon(QIcon::fromTheme(QStringLiteral("view-refresh")));
mCollection.addAction(refreshAllAction->objectName(), refreshAllAction);
mCollection.setDefaultShortcut(refreshAllAction, QKeySequence(QKeySequence::Refresh));
}
mSortCollection.readSettings();
mCollection.readSettings();
}
......
......@@ -77,6 +77,7 @@ Q_SIGNALS:
void importIntoExistingFinished(bool success, int total);
void importIntoNewFinished(bool success);
void importErrorMessageChanged();
void refreshAllCalendars();
private:
KActionCollection mCollection;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment