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
Plasma
Plasma Desktop
Commits
3ae6d0bb
Commit
3ae6d0bb
authored
Dec 03, 2019
by
Aleix Pol Gonzalez
🐧
Browse files
emojier: save and restore the window size between runs
parent
0e82fc26
Changes
1
Hide whitespace changes
Inline
Side-by-side
applets/kimpanel/backend/ibus/emojier/emojier.cpp
View file @
3ae6d0bb
...
...
@@ -38,6 +38,7 @@
#include
<KQuickAddons/QtQuickSettings>
#include
<KCrash>
#include
<KDBusService>
#include
<KWindowConfig>
#include
<QDebug>
#include
<QDBusConnection>
#include
<QDBusMessage>
...
...
@@ -271,6 +272,38 @@ class CopyHelperPrivate : public QObject
}
};
class
EngineWatcher
:
public
QObject
{
public:
EngineWatcher
(
QQmlApplicationEngine
*
engine
)
:
QObject
(
engine
)
{
connect
(
engine
,
&
QQmlApplicationEngine
::
objectCreated
,
this
,
&
EngineWatcher
::
integrateObject
);
}
void
integrateObject
(
QObject
*
object
)
{
QWindow
*
window
=
qobject_cast
<
QWindow
*>
(
object
);
auto
conf
=
KSharedConfig
::
openConfig
();
KWindowConfig
::
restoreWindowSize
(
window
,
conf
->
group
(
"Window"
));
object
->
installEventFilter
(
this
);
}
bool
eventFilter
(
QObject
*
object
,
QEvent
*
event
)
{
if
(
event
->
type
()
==
QEvent
::
Close
)
{
QWindow
*
window
=
qobject_cast
<
QWindow
*>
(
object
);
auto
conf
=
KSharedConfig
::
openConfig
();
auto
group
=
conf
->
group
(
"Window"
);
KWindowConfig
::
saveWindowSize
(
window
,
group
);
group
.
sync
();
}
return
false
;
}
};
int
main
(
int
argc
,
char
**
argv
)
{
QApplication
app
(
argc
,
argv
);
...
...
@@ -313,8 +346,10 @@ int main(int argc, char** argv)
qmlRegisterType
<
RecentEmojiModel
>
(
"org.kde.plasma.emoji"
,
1
,
0
,
"RecentEmojiModel"
);
qmlRegisterSingletonType
<
CopyHelperPrivate
>
(
"org.kde.plasma.emoji"
,
1
,
0
,
"CopyHelper"
,
[]
(
QQmlEngine
*
,
QJSEngine
*
)
->
QObject
*
{
return
new
CopyHelperPrivate
;
});
QQmlApplicationEngine
engine
(
QUrl
(
QStringLiteral
(
"qrc:/ui/emojier.qml"
)));
QQmlApplicationEngine
engine
;
new
EngineWatcher
(
&
engine
);
engine
.
addImageProvider
(
QLatin1String
(
"text"
),
new
TextImageProvider
);
engine
.
load
(
QUrl
(
QStringLiteral
(
"qrc:/ui/emojier.qml"
)));
QObject
::
connect
(
service
,
&
KDBusService
::
activateRequested
,
&
engine
,
[
&
engine
](
const
QStringList
&
/*arguments*/
,
const
QString
&
/*workingDirectory*/
)
{
for
(
QObject
*
object
:
engine
.
rootObjects
())
{
...
...
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