Skip to content

Commit 86098ee

Browse files
committed
Show app screen by re-launch in nativeqt app
:Release Notes: Show app screen by re-launch in nativeqt app :Detailed Notes: - When receiving re-launch, the app is not shown full screen. - Call showFullScreen() to make the app is shown.
1 parent b6f105f commit 86098ee

3 files changed

Lines changed: 13 additions & 5 deletions

File tree

native-apps/built-in/com.example.app.nativeqt/ServiceRequest.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ static std::string convertJsonToString(const pbnjson::JValue json)
3333
return pbnjson::JGenerator::serialize(json, pbnjson::JSchemaFragment("{}"));
3434
}
3535

36-
ServiceRequest::ServiceRequest(std::string appId)
36+
ServiceRequest::ServiceRequest(std::string appId, QWindow &window)
3737
: m_mainLoop(g_main_loop_new(nullptr, false))
3838
, m_serviceHandle(nullptr)
3939
{
4040
m_appId = appId;
41+
m_window = &window;
4142
m_serviceHandle = acquireHandle();
4243
}
4344

@@ -83,7 +84,7 @@ void ServiceRequest::clearHandle()
8384
}
8485
}
8586

86-
static bool registerAppCallback(LSHandle* sh, LSMessage* msg, void* ctx)
87+
static bool registerAppCallback(LSHandle* sh, LSMessage* msg, void* context)
8788
{
8889
PmLogInfo(getPmLogContext(), "REGISTER_CALLBACK", 1, PMLOGJSON("payload", LSMessageGetPayload(msg)), " ");
8990

@@ -100,6 +101,11 @@ static bool registerAppCallback(LSHandle* sh, LSMessage* msg, void* ctx)
100101
}
101102
else if (event == "relaunch")
102103
{
104+
//relaunch screen
105+
if (context != nullptr)
106+
{
107+
((ServiceRequest*)context)->m_window->showFullScreen();
108+
}
103109
//handle "relaunch" event
104110
if (response.hasKey("parameters"))
105111
{
@@ -136,7 +142,7 @@ void ServiceRequest::registerApp()
136142
"luna://com.webos.service.applicationmanager/registerApp",
137143
"{}",
138144
registerAppCallback,
139-
NULL,
145+
this,
140146
NULL,
141147
&lserror))
142148
{

native-apps/built-in/com.example.app.nativeqt/ServiceRequest.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <luna-service2/lunaservice.h>
2323
#include <pbnjson.hpp>
2424
#include <PmLog.h>
25+
#include <QtGui/QWindow>
2526

2627
static PmLogContext getPmLogContext()
2728
{
@@ -36,10 +37,11 @@ static PmLogContext getPmLogContext()
3637
class ServiceRequest
3738
{
3839
public:
39-
ServiceRequest(std::string appId);
40+
ServiceRequest(std::string appId, QWindow &window);
4041
virtual ~ServiceRequest();
4142
LSHandle* getHandle() const { return m_serviceHandle; }
4243
void registerApp();
44+
QWindow* m_window;
4345

4446
protected:
4547
LSHandle* acquireHandle();

native-apps/built-in/com.example.app.nativeqt/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ int main(int argc, char **argv)
3535
window.resize(screenGeometry.width(), screenGeometry.height());
3636
window.show();
3737

38-
ServiceRequest s_request("com.example.app.nativeqt");
38+
ServiceRequest s_request("com.example.app.nativeqt", window);
3939
s_request.registerApp();
4040

4141
QGuiApplication::platformNativeInterface()->setWindowProperty(window.handle(), "appId", "com.example.app.nativeqt");

0 commit comments

Comments
 (0)