From 258b80e7f0a6e66185676f4da56bccff94175955 Mon Sep 17 00:00:00 2001
From: peijiankang <peijiankang@kylinos.cn>
Date: Thu, 9 Jun 2022 09:27:39 +0800
Subject: [PATCH] Fix the problem of the help manual button

---
 src/kmenu.cpp      | 8 +++++++-
 src/mainwidget.cpp | 8 +++++++-
 src/topwindow.cpp  | 8 +++++++-
 3 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/src/kmenu.cpp b/src/kmenu.cpp
index 5240094..dd62c6a 100644
--- a/src/kmenu.cpp
+++ b/src/kmenu.cpp
@@ -11,6 +11,8 @@
 #include <QDesktopServices>
 #include <QFileSystemWatcher>
 #include <ukui-log4qt.h>
+#include <unistd.h>
+#include <sys/types.h>
 
 #include "global/global.h"
 #include "kaction.h"
@@ -1107,8 +1109,12 @@ void TitleMenu::createHelpMenu()
 
     act_f1 = new KAction(QKeySequence("F1"), nullptr, "manual");
     connect(act_f1, &KAction::triggered, [this](){
+        char service_name[30];
+        memset(service_name, 0, 30);
+        snprintf(service_name, 30, "com.kylinUserGuide.hotel_%d", getuid());
+        
         // 帮助手册
-        QDBusMessage m = QDBusMessage::createMethodCall("com.kylinUserGuide.hotel_1000",
+        QDBusMessage m = QDBusMessage::createMethodCall(QString(service_name),
                                                         "/",
                                                         "com.guide.hotel",
                                                         "showGuide");
diff --git a/src/mainwidget.cpp b/src/mainwidget.cpp
index 89856fc..c7ba972 100644
--- a/src/mainwidget.cpp
+++ b/src/mainwidget.cpp
@@ -25,6 +25,8 @@
 #include <QFileSystemWatcher>
 #include <QPropertyAnimation>
 #include <ukui-log4qt.h>
+#include <unistd.h>
+#include <sys/types.h>
 
 #include <KWindowSystem>
 
@@ -1449,8 +1451,12 @@ void MainWidget::keyPressEvent(QKeyEvent *event)
             g_user_signal->fullScreen();
     }
     else if(event->key() == Qt::Key_F1) {
+	char service_name[30];
+	memset(service_name, 0, 30);
+	snprintf(service_name, 30, "com.kylinUserGuide.hotel_%d", getuid());
+
         // 帮助手册 先就分开写吧，快捷键不生效不知道为啥
-        QDBusMessage m = QDBusMessage::createMethodCall("com.kylinUserGuide.hotel_1000",
+        QDBusMessage m = QDBusMessage::createMethodCall(QString(service_name),
                                                         "/",
                                                         "com.guide.hotel",
                                                         "showGuide");
diff --git a/src/topwindow.cpp b/src/topwindow.cpp
index 6b11f89..f55bdc2 100644
--- a/src/topwindow.cpp
+++ b/src/topwindow.cpp
@@ -14,6 +14,8 @@
 #include <QFileSystemWatcher>
 #include <KF5/KWindowSystem/kwindowsystem.h>
 #include <ukui-log4qt.h>
+#include <unistd.h>
+#include <sys/types.h>
 
 #include "global/xatom-helper.h"
 
@@ -229,8 +231,12 @@ void TopWindow::setHide()
 
 void TopWindow::openHelpDoc()
 {
+    char service_name[30];
+    memset(service_name, 0, 30);
+    snprintf(service_name, 30, "com.kylinUserGuide.hotel_%d", getuid());
+    
     // 帮助手册 先就分开写吧，快捷键不生效不知道为啥
-    QDBusMessage m = QDBusMessage::createMethodCall("com.kylinUserGuide.hotel_1000",
+    QDBusMessage m = QDBusMessage::createMethodCall(QString(service_name),
                                                     "/",
                                                     "com.guide.hotel",
                                                     "showGuide");
-- 
2.33.0

