Commit f417db34 authored by Carl Schwan's avatar Carl Schwan 🚴
Browse files

Adapt menu for the new contact integration

parent 8c6a9d20
Pipeline #174987 passed with stage
in 3 minutes and 15 seconds
......@@ -5,6 +5,7 @@
#include "contactmanager.h"
#include <Akonadi/AgentManager>
#include <Akonadi/Collection>
#include <Akonadi/ContactsTreeModel>
#include <Akonadi/ETMViewStateSaver>
......@@ -241,3 +242,11 @@ QUrl ContactManager::decorationToUrl(QVariant decoration)
const QString base64 = QString::fromUtf8(byteArray.toBase64());
return QUrl(QLatin1String("data:image/png;base64,") + base64);
}
void ContactManager::updateAllCollections()
{
for (int i = 0; i < contactCollections()->rowCount(); i++) {
auto collection = contactCollections()->data(contactCollections()->index(i, 0), Akonadi::EntityTreeModel::CollectionRole).value<Akonadi::Collection>();
Akonadi::AgentManager::self()->synchronizeCollection(collection, true);
}
}
......@@ -45,6 +45,7 @@ public:
QSortFilterProxyModel *contactsModel();
Q_INVOKABLE void contactEmails(qint64 itemId);
Q_INVOKABLE void updateAllCollections();
Q_INVOKABLE QUrl decorationToUrl(QVariant decoration);
Q_INVOKABLE Akonadi::Item getItem(qint64 itemId);
......
......@@ -8,6 +8,7 @@ import QtQuick.Controls 2.12 as QQC2
import QtQuick.Layouts 1.10
import org.kde.kirigami 2.15 as Kirigami
import QtQuick.Window 2.15
import org.kde.kalendar 1.0
Labs.MenuBar {
id: bar
......@@ -68,6 +69,10 @@ Labs.MenuBar {
kalendarAction: 'open_todo_view'
}
NativeMenuItemFromAction {
kalendarAction: 'open_contact_view'
}
NativeMenuItemFromAction {
kalendarAction: 'open_kcommand_bar'
}
......@@ -77,6 +82,7 @@ Labs.MenuBar {
Labs.Menu {
title: i18nc("@action:menu", "Sort Tasks")
enabled: mode === KalendarApplication.Todo
NativeMenuItemFromAction {
kalendarAction: 'todoview_sort_by_due_date'
......@@ -104,13 +110,20 @@ Labs.MenuBar {
NativeMenuItemFromAction {
kalendarAction: 'todoview_show_completed'
enabled: mode === KalendarApplication.Todo
}
Labs.MenuSeparator {
}
NativeMenuItemFromAction {
kalendarAction: "refresh_all_calendars"
text: switch(mode) {
case KalendarApplication.Contact:
return i18n('Refresh All Address Books')
default:
return i18n('Refresh All Calendars')
}
kalendarAction: "refresh_all"
}
}
......@@ -119,18 +132,22 @@ Labs.MenuBar {
NativeMenuItemFromAction {
kalendarAction: "move_view_backwards"
enabled: mode === KalendarApplication.Event
}
NativeMenuItemFromAction {
kalendarAction: "move_view_forwards"
enabled: mode === KalendarApplication.Event
}
Labs.MenuSeparator {}
NativeMenuItemFromAction {
kalendarAction: "move_view_to_today"
enabled: mode === KalendarApplication.Event
}
NativeMenuItemFromAction {
kalendarAction: "open_date_changer"
enabled: mode === KalendarApplication.Event
}
}
......
......@@ -144,6 +144,9 @@ QQC2.MenuBar {
KActionFromAction {
kalendarAction: "open_todo_view"
}
KActionFromAction {
kalendarAction: "open_contact_view"
}
KActionFromAction {
kalendarAction: 'open_kcommand_bar'
}
......@@ -153,6 +156,7 @@ QQC2.MenuBar {
QQC2.Menu {
title: i18n("Sort Tasks")
enabled: mode === KalendarApplication.Todo
KActionFromAction {
kalendarAction: "todoview_sort_by_due_date"
......@@ -177,15 +181,21 @@ QQC2.MenuBar {
KActionFromAction {
kalendarAction: "todoview_show_completed"
enabled: mode === KalendarApplication.Todo
}
QQC2.MenuSeparator {
}
KActionFromAction {
kalendarAction: "refresh_all_calendars"
text: switch(mode) {
case KalendarApplication.Contact:
return i18n('Refresh All Address Books')
default:
return i18n('Refresh All Calendars')
}
kalendarAction: "refresh_all"
}
}
QQC2.Menu {
......@@ -193,18 +203,22 @@ QQC2.MenuBar {
KActionFromAction {
kalendarAction: "move_view_backwards"
enabled: mode === KalendarApplication.Event
}
KActionFromAction {
kalendarAction: "move_view_forwards"
enabled: mode === KalendarApplication.Event
}
QQC2.MenuSeparator {}
KActionFromAction {
kalendarAction: "move_view_to_today"
enabled: mode === KalendarApplication.Event
}
KActionFromAction {
kalendarAction: "open_date_changer"
enabled: mode === KalendarApplication.Event
}
}
......
......@@ -38,7 +38,10 @@ Kirigami.ApplicationWindow {
"tags": [],
"name": ""
}
onFilterChanged: if(pageStack.currentItem.objectName === "todoView") pageStack.currentItem.filter = filter
onFilterChanged: if(pageStack.currentItem.mode === KalendarApplication.Todo) {
pageStack.currentItem.filter = filter
}
readonly property bool isDark: LabelUtils.isDarkColor(Kirigami.Theme.backgroundColor)
readonly property var monthViewAction: KalendarApplication.action("open_month_view")
......@@ -61,7 +64,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 refreshAllAction: KalendarApplication.action("refresh_all")
readonly property var todoViewSortAlphabeticallyAction: KalendarApplication.action("todoview_sort_alphabetically")
readonly property var todoViewSortByDueDateAction: KalendarApplication.action("todoview_sort_by_due_date")
......@@ -382,12 +385,16 @@ Kirigami.ApplicationWindow {
kcommandbarLoader.active = true;
}
function onRefreshAllCalendars() {
CalendarManager.updateAllCollections();
function onRefreshAll() {
if (pageStack.currentItem.mode === KalendarApplication.Contact) {
ContactManager.updateAllCollections();
} else {
CalendarManager.updateAllCollections();
}
}
function onOpenIncidence(incidenceData, occurrenceDate) {
if(pageStack.currentItem.objectName === "todoView" && incidenceData.incidenceType !== IncidenceWrapper.TypeTodo) {
if(pageStack.currentItem.mode === KalendarApplication.Todo && incidenceData.incidenceType !== IncidenceWrapper.TypeTodo) {
Kirigami.Settings.isMobile ? dayViewAction.trigger() : weekViewAction.trigger();
}
......@@ -475,7 +482,8 @@ Kirigami.ApplicationWindow {
sourceComponent: WindowMenu {
parentWindow: root
mode: pageStack.currentItem ? pageStack.currentItem.mode : KalendarApplication.Event
mode: applicationWindow().pageStack.currentItem ? applicationWindow().pageStack.currentItem.mode : KalendarApplication.Event
Component.onCompleted: console.log(mode, KalendarApplication.Event, KalendarApplication.Todo)
Kirigami.Theme.colorSet: Kirigami.Theme.Header
}
}
......
......@@ -426,10 +426,10 @@ void KalendarApplication::setupActions()
mCollection.setDefaultShortcut(openKCommandBarAction, QKeySequence(Qt::CTRL | Qt::ALT | Qt::Key_I));
}
actionName = QLatin1String("refresh_all_calendars");
actionName = QLatin1String("refresh_all");
if (KAuthorized::authorizeAction(actionName)) {
auto refreshAllAction = mCollection.addAction(actionName, this, &KalendarApplication::refreshAllCalendars);
refreshAllAction->setText(i18n("Refresh All Calendars"));
auto refreshAllAction = mCollection.addAction(actionName, this, &KalendarApplication::refreshAll);
refreshAllAction->setText(i18n("Refresh All"));
refreshAllAction->setIcon(QIcon::fromTheme(QStringLiteral("view-refresh")));
mCollection.addAction(refreshAllAction->objectName(), refreshAllAction);
......
......@@ -99,7 +99,7 @@ Q_SIGNALS:
void importIntoExistingFinished(bool success, int total);
void importIntoNewFinished(bool success);
void importErrorMessageChanged();
void refreshAllCalendars();
void refreshAll();
void openIncidence(const QVariantMap incidenceData, const QDateTime occurrence);
private:
......
Supports Markdown
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