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
f957cabb
Commit
f957cabb
authored
Dec 12, 2021
by
Claudio Cambra
Browse files
Kalendar now gets raised to front when new instance is attempted to be opened
parent
96b1945d
Pipeline
#108878
passed with stage
in 6 minutes and 18 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/main.cpp
View file @
f957cabb
...
...
@@ -8,6 +8,7 @@
#include
<KLocalizedContext>
#include
<KLocalizedString>
#include
<KWindowConfig>
#include
<KWindowSystem>
#include
<QApplication>
#include
<QCommandLineParser>
#include
<QDBusConnection>
...
...
@@ -44,6 +45,16 @@
using
namespace
KCalendarCore
;
static
void
raiseWindow
(
QWindow
*
window
)
{
if
(
KWindowSystem
::
isPlatformWayland
())
{
KWindowSystem
::
setCurrentXdgActivationToken
(
qEnvironmentVariable
(
"XDG_ACTIVATION_TOKEN"
));
KWindowSystem
::
activateWindow
(
window
->
winId
());
}
else
{
window
->
raise
();
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
QGuiApplication
::
setAttribute
(
Qt
::
AA_EnableHighDpiScaling
);
...
...
@@ -149,12 +160,23 @@ int main(int argc, char *argv[])
return
-
1
;
}
QObject
::
connect
(
&
service
,
&
KDBusService
::
activateRequested
,
&
engine
,
[
&
engine
](
const
QStringList
&
/*arguments*/
,
const
QString
&
/*workingDirectory*/
)
{
const
auto
rootObjects
=
engine
.
rootObjects
();
for
(
auto
obj
:
rootObjects
)
{
auto
view
=
qobject_cast
<
QQuickWindow
*>
(
obj
);
if
(
view
)
{
view
->
show
();
raiseWindow
(
view
);
return
;
}
}
});
const
auto
rootObjects
=
engine
.
rootObjects
();
for
(
auto
obj
:
rootObjects
)
{
auto
view
=
qobject_cast
<
QQuickWindow
*>
(
obj
);
if
(
view
)
{
KConfig
dataResource
(
QStringLiteral
(
"data"
),
KConfig
::
SimpleConfig
,
QStandardPaths
::
AppDataLocation
);
KConfigGroup
windowGroup
(
&
dataResource
,
QStringLiteral
(
"Window"
)
)
;
KConfigGroup
windowGroup
(
&
dataResource
,
"Window"
);
KWindowConfig
::
restoreWindowSize
(
view
,
windowGroup
);
KWindowConfig
::
restoreWindowPosition
(
view
,
windowGroup
);
break
;
...
...
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