Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
Kalendar
Commits
9afb6601
Commit
9afb6601
authored
Feb 11, 2022
by
Claudio Cambra
Browse files
Add ability to customise and edit calendars that are also resources with context menu
parent
02f4f326
Pipeline
#135932
passed with stage
in 1 minute and 29 seconds
Changes
8
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/agentconfiguration.cpp
View file @
9afb6601
...
...
@@ -69,6 +69,17 @@ void AgentConfiguration::edit(int index)
Q_ASSERT
(
m_runningAgents
!=
nullptr
);
auto
instance
=
m_runningAgents
->
data
(
m_runningAgents
->
index
(
index
,
0
),
AgentInstanceModel
::
InstanceRole
).
value
<
AgentInstance
>
();
setupEdit
(
instance
);
}
void
AgentConfiguration
::
editIdentifier
(
QString
resourceIdentifier
)
{
auto
instance
=
Akonadi
::
AgentManager
::
self
()
->
instance
(
resourceIdentifier
);
setupEdit
(
instance
);
}
void
AgentConfiguration
::
setupEdit
(
Akonadi
::
AgentInstance
instance
)
{
if
(
instance
.
isValid
())
{
KWindowSystem
::
allowExternalProcessWindowActivation
();
QPointer
<
AgentConfigurationDialog
>
dlg
(
new
AgentConfigurationDialog
(
instance
,
nullptr
));
...
...
@@ -82,6 +93,17 @@ void AgentConfiguration::restart(int index)
Q_ASSERT
(
m_runningAgents
!=
nullptr
);
auto
instance
=
m_runningAgents
->
data
(
m_runningAgents
->
index
(
index
,
0
),
AgentInstanceModel
::
InstanceRole
).
value
<
AgentInstance
>
();
setupRestart
(
instance
);
}
void
AgentConfiguration
::
restartIdentifier
(
QString
resourceIdentifier
)
{
auto
instance
=
Akonadi
::
AgentManager
::
self
()
->
instance
(
resourceIdentifier
);
setupRestart
(
instance
);
}
void
AgentConfiguration
::
setupRestart
(
Akonadi
::
AgentInstance
instance
)
{
if
(
instance
.
isValid
())
{
instance
.
restart
();
}
...
...
@@ -92,6 +114,17 @@ void AgentConfiguration::remove(int index)
Q_ASSERT
(
m_runningAgents
!=
nullptr
);
auto
instance
=
m_runningAgents
->
data
(
m_runningAgents
->
index
(
index
,
0
),
AgentInstanceModel
::
InstanceRole
).
value
<
AgentInstance
>
();
setupRemove
(
instance
);
}
void
AgentConfiguration
::
removeIdentifier
(
QString
resourceIdentifier
)
{
auto
instance
=
Akonadi
::
AgentManager
::
self
()
->
instance
(
resourceIdentifier
);
setupRemove
(
instance
);
}
void
AgentConfiguration
::
setupRemove
(
Akonadi
::
AgentInstance
instance
)
{
if
(
instance
.
isValid
())
{
Akonadi
::
AgentManager
::
self
()
->
removeInstance
(
instance
);
}
...
...
src/agentconfiguration.h
View file @
9afb6601
...
...
@@ -3,9 +3,10 @@
#pragma once
#include
<Akonadi/AgentFilterProxyModel>
#include
<Akonadi/AgentInstance>
#include
<QObject>
#include
<akonadi_version.h>
#include
<Akonadi/AgentFilterProxyModel>
class
AgentConfiguration
:
public
QObject
{
...
...
@@ -21,10 +22,17 @@ public:
Q_INVOKABLE
void
createNew
(
int
index
);
Q_INVOKABLE
void
edit
(
int
index
);
Q_INVOKABLE
void
editIdentifier
(
QString
resourceIdentifier
);
Q_INVOKABLE
void
remove
(
int
index
);
Q_INVOKABLE
void
removeIdentifier
(
QString
resourceIdentifier
);
Q_INVOKABLE
void
restart
(
int
index
);
Q_INVOKABLE
void
restartIdentifier
(
QString
resourceIdentifier
);
private:
void
setupEdit
(
Akonadi
::
AgentInstance
instance
);
void
setupRemove
(
Akonadi
::
AgentInstance
instance
);
void
setupRestart
(
Akonadi
::
AgentInstance
instance
);
Akonadi
::
AgentFilterProxyModel
*
m_runningAgents
;
Akonadi
::
AgentFilterProxyModel
*
m_availableAgents
;
};
src/calendarmanager.cpp
View file @
9afb6601
...
...
@@ -889,10 +889,12 @@ QVariantMap CalendarManager::getCollectionDetails(QVariant collectionId)
collectionDetails
[
QLatin1String
(
"color"
)]
=
m_baseModel
->
colorCache
[
QString
::
number
(
collection
.
id
())];
collectionDetails
[
QLatin1String
(
"count"
)]
=
collection
.
statistics
().
count
();
collectionDetails
[
QLatin1String
(
"isResource"
)]
=
Akonadi
::
CollectionUtils
::
isResource
(
collection
);
collectionDetails
[
QLatin1String
(
"resource"
)]
=
collection
.
resource
();
collectionDetails
[
QLatin1String
(
"readOnly"
)]
=
collection
.
rights
().
testFlag
(
Collection
::
ReadOnly
);
collectionDetails
[
QLatin1String
(
"canChange"
)]
=
collection
.
rights
().
testFlag
(
Collection
::
CanChangeCollection
);
collectionDetails
[
QLatin1String
(
"canCreate"
)]
=
collection
.
rights
().
testFlag
(
Collection
::
CanCreateCollection
);
collectionDetails
[
QLatin1String
(
"canDelete"
)]
=
collection
.
rights
().
testFlag
(
Collection
::
CanDeleteCollection
);
collectionDetails
[
QLatin1String
(
"canDelete"
)]
=
collection
.
rights
().
testFlag
(
Collection
::
CanDeleteCollection
)
&&
!
Akonadi
::
CollectionUtils
::
isResource
(
collection
);
collectionDetails
[
QLatin1String
(
"isFiltered"
)]
=
isFiltered
;
collectionDetails
[
QLatin1String
(
"allCalendarsRow"
)]
=
allCalendarsRow
;
...
...
src/contents/ui/CalendarItemMenu.qml
0 → 100644
View file @
9afb6601
// SPDX-FileCopyrightText: 2022 Claudio Cambra <claudio.cambra@gmail.com>
// SPDX-License-Identifier: GPL-2.0-or-later
import
QtQuick
2.4
import
QtQuick
.
Layouts
1.15
import
QtQuick
.
Dialogs
1.0
import
QtQuick
.
Controls
2.15
as
QQC2
import
org
.
kde
.
kirigami
2.14
as
Kirigami
import
org
.
kde
.
kalendar
1.0
as
Kalendar
QQC2.Menu
{
id
:
actionsPopup
z
:
1000
property
var
collectionId
property
var
collectionDetails
QQC2.MenuItem
{
icon.name
:
"
edit-entry
"
text
:
i18nc
(
"
@action:inmenu
"
,
"
Edit calendar…
"
)
onClicked
:
Kalendar
.
CalendarManager
.
editCollection
(
actionsPopup
.
collectionId
);
}
QQC2.MenuItem
{
icon.name
:
"
view-refresh
"
text
:
i18nc
(
"
@action:inmenu
"
,
"
Update calendar
"
)
onClicked
:
Kalendar
.
CalendarManager
.
updateCollection
(
actionsPopup
.
collectionId
);
}
QQC2.MenuItem
{
icon.name
:
"
edit-delete
"
text
:
i18nc
(
"
@action:inmenu
"
,
"
Delete calendar
"
)
enabled
:
actionsPopup
.
collectionDetails
[
"
canDelete
"
]
onClicked
:
deleteCalendar
(
actionsPopup
.
collectionId
,
actionsPopup
.
collectionDetails
)
}
QQC2.MenuSeparator
{
}
QQC2.MenuItem
{
icon.name
:
"
color-picker
"
text
:
i18nc
(
"
@action:inmenu
"
,
"
Set calendar colour…
"
)
onClicked
:
{
colorDialogLoader
.
active
=
true
;
colorDialogLoader
.
item
.
open
();
}
}
QQC2.MenuSeparator
{
visible
:
collectionDetails
.
isResource
}
QQC2.MenuItem
{
icon.name
:
"
settings-configure
"
text
:
i18nc
(
"
@action:inmenu
"
,
"
Calendar source settings…
"
)
onClicked
:
Kalendar
.
AgentConfiguration
.
editIdentifier
(
collectionDetails
.
resource
)
visible
:
collectionDetails
.
isResource
}
QQC2.MenuItem
{
icon.name
:
"
view-refresh
"
text
:
i18nc
(
"
@action:inmenu
"
,
"
Update calendar source
"
)
onClicked
:
Kalendar
.
AgentConfiguration
.
restartIdentifier
(
collectionDetails
.
resource
)
visible
:
collectionDetails
.
isResource
}
QQC2.MenuItem
{
icon.name
:
"
edit-delete
"
text
:
i18nc
(
"
@action:inmenu
"
,
"
Delete calendar source
"
)
onClicked
:
Kalendar
.
AgentConfiguration
.
removeIdentifier
(
collectionDetails
.
resource
)
visible
:
collectionDetails
.
isResource
}
}
src/contents/ui/CalendarItemMouseArea.qml
View file @
9afb6601
...
...
@@ -52,39 +52,12 @@ MouseArea {
Component
{
id
:
calendarActions
QQC2.Menu
{
id
:
actionsPopup
CalendarItemMenu
{
y
:
calendarMouseArea
.
clickY
x
:
calendarMouseArea
.
clickX
z
:
1000
collectionId
:
calendarMouseArea
.
collectionId
collectionDetails
:
calendarMouseArea
.
collectionDetails
Component.onCompleted
:
if
(
calendarMouseArea
.
collectionId
&&
!
calendarMouseArea
.
collectionDetails
)
calendarMouseArea
.
collectionDetails
=
Kalendar
.
CalendarManager
.
getCollectionDetails
(
calendarMouseArea
.
collectionId
)
QQC2.MenuItem
{
icon.name
:
"
edit-entry
"
text
:
i18nc
(
"
@action:inmenu
"
,
"
Edit calendar…
"
)
onClicked
:
Kalendar
.
CalendarManager
.
editCollection
(
calendarMouseArea
.
collectionId
);
}
QQC2.MenuItem
{
icon.name
:
"
view-refresh
"
text
:
i18nc
(
"
@action:inmenu
"
,
"
Update calendar
"
)
onClicked
:
Kalendar
.
CalendarManager
.
updateCollection
(
calendarMouseArea
.
collectionId
);
}
QQC2.MenuItem
{
icon.name
:
"
edit-delete
"
text
:
i18nc
(
"
@action:inmenu
"
,
"
Delete calendar
"
)
enabled
:
calendarMouseArea
.
collectionDetails
[
"
canDelete
"
]
onClicked
:
deleteCalendar
(
calendarMouseArea
.
collectionId
,
calendarMouseArea
.
collectionDetails
)
}
QQC2.MenuSeparator
{
}
QQC2.MenuItem
{
icon.name
:
"
color-picker
"
text
:
i18nc
(
"
@action:inmenu
"
,
"
Set calendar colour…
"
)
onClicked
:
{
colorDialogLoader
.
active
=
true
;
colorDialogLoader
.
item
.
open
();
}
}
}
}
}
src/contents/ui/Settings/CalendarSettingsPage.qml
View file @
9afb6601
...
...
@@ -31,7 +31,7 @@ Kirigami.Page {
roleValue
:
true
Kirigami.BasicListItem
{
id
:
calendarSource
Heading
id
:
calendarSource
Item
label
:
display
labelItem.color
:
Kirigami
.
Theme
.
disabledTextColor
labelItem.font.weight
:
Font
.
DemiBold
...
...
@@ -47,7 +47,7 @@ Kirigami.Page {
leading
:
Kirigami.Icon
{
implicitWidth
:
Kirigami
.
Units
.
iconSizes
.
smallMedium
implicitHeight
:
Kirigami
.
Units
.
iconSizes
.
smallMedium
color
:
calendarSource
Heading
.
labelItem
.
color
color
:
calendarSource
Item
.
labelItem
.
color
isMask
:
true
source
:
model
.
decoration
}
...
...
@@ -58,7 +58,7 @@ Kirigami.Page {
implicitWidth
:
Kirigami
.
Units
.
iconSizes
.
small
implicitHeight
:
Kirigami
.
Units
.
iconSizes
.
small
source
:
model
.
kDescendantExpanded
?
'
arrow-up
'
:
'
arrow-down
'
color
:
calendarSource
Heading
.
labelItem
.
color
color
:
calendarSource
Item
.
labelItem
.
color
isMask
:
true
}
ColoredCheckbox
{
...
...
@@ -71,6 +71,13 @@ Kirigami.Page {
}
onClicked
:
collectionsList
.
model
.
toggleChildren
(
index
)
CalendarItemMouseArea
{
id
:
calendarItemMouseArea
parent
:
calendarSourceItem
.
contentItem
// Otherwise label elide breaks
collectionId
:
model
.
collectionId
anchors.fill
:
parent
}
}
}
...
...
src/contents/ui/Sidebar.qml
View file @
9afb6601
...
...
@@ -438,6 +438,7 @@ Kirigami.OverlayDrawer {
model
:
sidebar
.
todoMode
?
CalendarManager
.
todoCollections
:
CalendarManager
.
viewCollections
}
model
:
calendarHeadingItem
.
expanded
?
calendarModel
:
[]
delegate
:
DelegateChooser
{
...
...
@@ -446,9 +447,9 @@ Kirigami.OverlayDrawer {
roleValue
:
true
Kirigami.BasicListItem
{
id
:
calendarSource
Heading
id
:
calendarSource
Item
label
:
display
highlighted
:
visualFocus
highlighted
:
visualFocus
||
incidenceDropArea
.
containsDrag
labelItem.color
:
visualFocus
?
Kirigami
.
Theme
.
textColor
:
Kirigami
.
Theme
.
disabledTextColor
labelItem.font.weight
:
Font
.
DemiBold
Layout.topMargin
:
2
*
Kirigami
.
Units
.
largeSpacing
...
...
@@ -463,7 +464,7 @@ Kirigami.OverlayDrawer {
leading
:
Kirigami.Icon
{
implicitWidth
:
Kirigami
.
Units
.
iconSizes
.
smallMedium
implicitHeight
:
Kirigami
.
Units
.
iconSizes
.
smallMedium
color
:
calendarSource
Heading
.
labelItem
.
color
color
:
calendarSource
Item
.
labelItem
.
color
isMask
:
true
source
:
model
.
decoration
}
...
...
@@ -474,7 +475,7 @@ Kirigami.OverlayDrawer {
implicitWidth
:
Kirigami
.
Units
.
iconSizes
.
small
implicitHeight
:
Kirigami
.
Units
.
iconSizes
.
small
source
:
model
.
kDescendantExpanded
?
'
arrow-up
'
:
'
arrow-down
'
color
:
calendarSource
Heading
.
labelItem
.
color
color
:
calendarSource
Item
.
labelItem
.
color
isMask
:
true
}
ColoredCheckbox
{
...
...
@@ -493,6 +494,29 @@ Kirigami.OverlayDrawer {
}
onClicked
:
calendarList
.
model
.
toggleChildren
(
index
)
CalendarItemMouseArea
{
id
:
calendarSourceItemMouseArea
parent
:
calendarSourceItem
.
contentItem
// Otherwise label elide breaks
collectionId
:
model
.
collectionId
collectionDetails
:
CalendarManager
.
getCollectionDetails
(
collectionId
)
anchors.fill
:
parent
DropArea
{
id
:
incidenceDropArea
anchors.fill
:
parent
z
:
9999
enabled
:
calendarSourceItemMouseArea
.
collectionDetails
.
canCreate
onDropped
:
if
(
drop
.
source
.
objectName
===
"
taskDelegate
"
)
{
CalendarManager
.
changeIncidenceCollection
(
drop
.
source
.
incidencePtr
,
calendarSourceItemMouseArea
.
collectionId
);
const
pos
=
mapToItem
(
applicationWindow
().
contentItem
,
x
,
y
);
drop
.
source
.
caughtX
=
pos
.
x
;
drop
.
source
.
caughtY
=
pos
.
y
;
drop
.
source
.
caught
=
true
;
}
}
}
}
}
...
...
@@ -507,7 +531,7 @@ Kirigami.OverlayDrawer {
(
Kirigami
.
Units
.
largeSpacing
*
model
.
kDescendantLevel
)
+
(
Kirigami
.
Units
.
iconSizes
.
smallMedium
*
(
model
.
kDescendantLevel
-
1
))
separatorVisible
:
false
enabled
:
!
sidebar
.
collapsed
highlighted
:
incidenceDropArea
.
containsDrag
highlighted
:
visualFocus
||
incidenceDropArea
.
containsDrag
leading
:
Kirigami.Icon
{
implicitWidth
:
Kirigami
.
Units
.
iconSizes
.
smallMedium
...
...
@@ -538,6 +562,7 @@ Kirigami.OverlayDrawer {
id
:
calendarItemMouseArea
parent
:
calendarItem
.
contentItem
// Otherwise label elide breaks
collectionId
:
model
.
collectionId
collectionDetails
:
CalendarManager
.
getCollectionDetails
(
collectionId
)
anchors.fill
:
parent
onDeleteCalendar
:
sidebar
.
deleteCalendar
(
collectionId
,
collectionDetails
)
...
...
@@ -546,6 +571,7 @@ Kirigami.OverlayDrawer {
id
:
incidenceDropArea
anchors.fill
:
parent
z
:
9999
enabled
:
calendarItemMouseArea
.
collectionDetails
.
canCreate
onDropped
:
if
(
drop
.
source
.
objectName
===
"
taskDelegate
"
)
{
CalendarManager
.
changeIncidenceCollection
(
drop
.
source
.
incidencePtr
,
calendarItemMouseArea
.
collectionId
);
...
...
src/resources.qrc
View file @
9afb6601
...
...
@@ -58,6 +58,7 @@ SPDX-License-Identifier: CC0-1.0
<file alias="TreeViewDecoration.qml">contents/ui/TreeView/TreeViewDecoration.qml</file>
<file alias="CollectionPickerPage.qml">contents/ui/CollectionPickerPage.qml</file>
<file alias="CalendarItemMouseArea.qml">contents/ui/CalendarItemMouseArea.qml</file>
<file alias="CalendarItemMenu.qml">contents/ui/CalendarItemMenu.qml</file>
<file alias="RecurringIncidenceChangeSheet.qml">contents/ui/RecurringIncidenceChangeSheet.qml</file>
</qresource>
</RCC>
Claudio Cambra
@clau-cambra
mentioned in issue
#135 (closed)
·
Feb 11, 2022
mentioned in issue
#135 (closed)
mentioned in issue #135
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment