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
1e2563c4
Commit
1e2563c4
authored
Nov 14, 2021
by
Carl Schwan
🚴
Browse files
Trying to import multiple ical files won't open multiple instances anymore
parent
c8772969
Pipeline
#97571
passed with stage
in 5 minutes and 31 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
1e2563c4
...
...
@@ -43,7 +43,7 @@ ecm_setup_version(${PROJECT_VERSION}
################# Find dependencies #################
find_package
(
Qt5
${
QT_MIN_VERSION
}
REQUIRED COMPONENTS Core Gui Qml QuickControls2 Svg Location
)
find_package
(
KF5
${
KF5_MIN_VERSION
}
REQUIRED COMPONENTS Kirigami2 I18n CalendarCore ConfigWidgets WindowSystem CoreAddons People Contacts ItemModels XmlGui
)
find_package
(
KF5
${
KF5_MIN_VERSION
}
REQUIRED COMPONENTS Kirigami2
DBusAddons
I18n CalendarCore ConfigWidgets WindowSystem CoreAddons People Contacts ItemModels XmlGui
)
find_package
(
KF5Akonadi
${
AKONADI_VERSION
}
CONFIG REQUIRED
)
find_package
(
KF5AkonadiContact
${
AKONADI_CONTACT_VERSION
}
CONFIG REQUIRED
)
find_package
(
KF5CalendarSupport
${
CALENDARSUPPORT_LIB_VERSION
}
CONFIG REQUIRED
)
...
...
src/CMakeLists.txt
View file @
1e2563c4
...
...
@@ -14,6 +14,7 @@ target_link_libraries(kalendar
Qt5::Location
KF5::I18n
KF5::CoreAddons
KF5::DBusAddons
KF5::CalendarCore
KF5::AkonadiCore
KF5::AkonadiContact
...
...
src/contents/ui/main.qml
View file @
1e2563c4
...
...
@@ -68,6 +68,25 @@ Kirigami.ApplicationWindow {
readonly
property
var
openKCommandBarAction
:
KalendarApplication
.
action
(
"
open_kcommand_bar
"
)
readonly
property
var
tagManagerAction
:
KalendarApplication
.
action
(
"
open_tag_manager
"
)
property
var
calendarFilesToImport
:
[]
property
bool
calendarImportInProgress
:
false
onCalendarImportInProgressChanged
:
if
(
!
calendarImportInProgress
&&
calendarFilesToImport
.
length
>
0
)
{
importCalendarTimer
.
restart
()
}
// Timer is needed here since opening and closing a window at the same time can cause
// some kwin-x11 freeze
Timer
{
id
:
importCalendarTimer
interval
:
1000
running
:
false
onTriggered
:
{
// Start importing new calendar
KalendarApplication
.
importCalendarFromFile
(
calendarFilesToImport
.
shift
())
}
}
pageStack.globalToolBar.canContainHandles
:
true
pageStack.globalToolBar.style
:
Kirigami
.
ApplicationHeaderStyle
.
ToolBar
pageStack.initialPage
:
Kirigami
.
Settings
.
isMobile
?
scheduleViewComponent
:
monthViewComponent
...
...
@@ -224,7 +243,14 @@ Kirigami.ApplicationWindow {
}
function
onImportCalendarFromFile
(
file
)
{
if
(
root
.
calendarImportInProgress
)
{
// Save urls to import
root
.
calendarFilesToImport
.
push
(
file
)
return
;
}
importFileDialog
.
selectedUrl
=
file
// FIXME don't piggy-back on importFileDialog
root
.
calendarImportInProgress
=
true
;
const
openDialogWindow
=
pageStack
.
pushDialogLayer
(
importChoicePageComponent
,
{
width
:
root
.
width
...
...
@@ -662,7 +688,7 @@ Kirigami.ApplicationWindow {
property
string
selectedUrl
:
""
title
:
"
Import a calendar
"
title
:
i18n
(
"
Import a calendar
"
)
folder
:
shortcuts
.
home
nameFilters
:
[
"
Calendar files (*.ics *.vcs)
"
]
onAccepted
:
{
...
...
@@ -683,7 +709,9 @@ Kirigami.ApplicationWindow {
Component
{
id
:
importChoicePageComponent
Kirigami.Page
{
id
:
importChoicePage
title
:
i18n
(
"
Import Calendar
"
)
signal
closed
()
ColumnLayout
{
anchors.fill
:
parent
...
...
@@ -718,6 +746,7 @@ Kirigami.ApplicationWindow {
icon.name
:
"
document-new
"
text
:
i18n
(
"
Create new calendar
"
)
onClicked
:
{
root
.
calendarImportInProgress
=
false
;
KalendarApplication
.
importCalendarFromUrl
(
importFileDialog
.
selectedUrl
,
false
);
closeDialog
();
}
...
...
@@ -725,7 +754,10 @@ Kirigami.ApplicationWindow {
QQC2.Button
{
icon.name
:
"
gtk-cancel
"
text
:
i18n
(
"
Cancel
"
)
onClicked
:
closeDialog
();
onClicked
:
{
root
.
calendarImportInProgress
=
false
;
closeDialog
();
}
}
}
}
...
...
@@ -737,9 +769,13 @@ Kirigami.ApplicationWindow {
CollectionPickerPage
{
onCollectionPicked
:
{
KalendarApplication
.
importCalendarFromUrl
(
importFileDialog
.
selectedUrl
,
true
,
collectionId
);
root
.
calendarImportInProgress
=
false
;
closeDialog
();
}
onCancel
:
closeDialog
()
onCancel
:
{
root
.
calendarImportInProgress
=
false
;
closeDialog
()
}
}
}
...
...
src/main.cpp
View file @
1e2563c4
...
...
@@ -4,11 +4,13 @@
#include
<KAboutData>
#include
<KCalendarCore/MemoryCalendar>
#include
<KCalendarCore/VCalFormat>
#include
<KDBusService>
#include
<KLocalizedContext>
#include
<KLocalizedString>
#include
<KWindowConfig>
#include
<QApplication>
#include
<QCommandLineParser>
#include
<QDir>
#include
<QQmlApplicationEngine>
#include
<QQuickWindow>
#include
<QUrl>
...
...
@@ -73,6 +75,27 @@ int main(int argc, char *argv[])
KAboutData
::
setApplicationData
(
aboutData
);
QGuiApplication
::
setWindowIcon
(
QIcon
::
fromTheme
(
QStringLiteral
(
"org.kde.kalendar"
)));
auto
config
=
KalendarConfig
::
self
();
CalendarManager
manager
;
AgentConfiguration
agentConfiguration
;
auto
kalendarApplication
=
new
KalendarApplication
;
kalendarApplication
->
setCalendar
(
manager
.
calendar
());
KDBusService
service
(
KDBusService
::
Unique
);
service
.
connect
(
&
service
,
&
KDBusService
::
activateRequested
,
kalendarApplication
,
[
kalendarApplication
](
const
QStringList
&
arguments
,
const
QString
&
workingDirectory
)
{
if
(
arguments
.
isEmpty
())
{
return
;
}
auto
args
=
arguments
;
args
.
removeFirst
();
for
(
const
auto
&
arg
:
args
)
{
Q_EMIT
kalendarApplication
->
importCalendarFromFile
(
QUrl
::
fromUserInput
(
arg
,
workingDirectory
,
QUrl
::
AssumeLocalFile
));
}
});
QCommandLineParser
parser
;
aboutData
.
setupCommandLine
(
&
parser
);
parser
.
process
(
app
);
...
...
@@ -80,14 +103,8 @@ int main(int argc, char *argv[])
QQmlApplicationEngine
engine
;
auto
config
=
KalendarConfig
::
self
();
CalendarManager
manager
;
AgentConfiguration
agentConfiguration
;
auto
contactsManager
=
new
ContactsManager
(
&
engine
);
auto
tagManager
=
new
TagManager
(
&
engine
);
auto
kalendarApplication
=
new
KalendarApplication
;
kalendarApplication
->
setCalendar
(
manager
.
calendar
());
qmlRegisterSingletonInstance
(
"org.kde.kalendar"
,
1
,
0
,
"Config"
,
config
);
qmlRegisterSingletonInstance
(
"org.kde.kalendar"
,
1
,
0
,
"CalendarManager"
,
&
manager
);
qmlRegisterSingletonInstance
(
"org.kde.kalendar"
,
1
,
0
,
"AgentConfiguration"
,
&
agentConfiguration
);
...
...
@@ -131,7 +148,10 @@ int main(int argc, char *argv[])
}
if
(
!
parser
.
positionalArguments
().
empty
())
{
kalendarApplication
->
importCalendarFromFile
(
QUrl
::
fromUserInput
(
parser
.
positionalArguments
().
first
()));
const
auto
args
=
parser
.
positionalArguments
();
for
(
const
auto
&
arg
:
args
)
{
Q_EMIT
kalendarApplication
->
importCalendarFromFile
(
QUrl
::
fromUserInput
(
arg
,
QDir
::
currentPath
(),
QUrl
::
AssumeLocalFile
));
}
}
return
app
.
exec
();
...
...
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