@@ -57,7 +57,10 @@ void showWatermark(const QString &sJson, MainWindow *w)
5757 if (mapdata.contains (" wndWatermark" )) {
5858 mapwaterMark = mapdata.value (" wndWatermark" ).toMap ();
5959 }
60- if (mapwaterMark.isEmpty ()) return ;
60+ if (mapwaterMark.isEmpty ()) {
61+ qDebug () << " no watermark data" ;
62+ return ;
63+ }
6164
6265#ifdef DTKWIDGET_CLASS_DWaterMarkHelper
6366 auto ins = DWaterMarkHelper::instance ();
@@ -117,8 +120,11 @@ void showWatermark(const QString &sJson, MainWindow *w)
117120
118121int main (int argc, char *argv[])
119122{
123+ qDebug () << " Application starting with arguments:" << QCoreApplication::arguments ();
124+
120125 // for qt5platform-plugins load DPlatformIntegration or DPlatformIntegrationParent
121126 if (!QString (qgetenv (" XDG_CURRENT_DESKTOP" )).toLower ().startsWith (" deepin" )) {
127+ qDebug () << " Setting XDG_CURRENT_DESKTOP to Deepin" ;
122128 setenv (" XDG_CURRENT_DESKTOP" , " Deepin" , 1 );
123129 }
124130 bool orderObject = false ;
@@ -127,10 +133,11 @@ int main(int argc, char *argv[])
127133
128134 QGuiApplication::setAttribute (Qt::AA_UseHighDpiPixmaps); // 使用高分屏
129135
130- // 初始化DTK应用程序属性
136+ qDebug () << " Initializing DTK application properties " ;
131137 CompressorApplication app (argc, argv);
132138 app.setOrganizationName (" deepin" );
133139 app.setApplicationName (" deepin-compressor" );
140+ qDebug () << " Loading application translations" ;
134141 app.loadTranslator ();
135142 app.setApplicationVersion (DApplication::buildVersion (QDate::currentDate ().toString (" yyyyMMdd" )));
136143 app.setApplicationAcknowledgementPage (" https://www.deepin.org/original/deepin-compressor/" );
@@ -140,8 +147,10 @@ int main(int argc, char *argv[])
140147 app.setApplicationDisplayName (DApplication::translate (" Main" , " Archive Manager" ));
141148 app.setApplicationDescription (DApplication::translate (" Main" , " Archive Manager is a fast and lightweight application for creating and extracting archives." ));
142149#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
150+ qDebug () << " Initializing application settings for Qt5" ;
143151 DApplicationSettings settings (&app);
144152#endif
153+ qDebug () << " Setting up logging system" ;
145154 DLogManager::registerConsoleAppender ();
146155 DLogManager::registerFileAppender ();
147156
@@ -155,7 +164,7 @@ int main(int argc, char *argv[])
155164 app.setProductIcon (appIcon);
156165 app.setWindowIcon (appIcon);
157166
158- // 命令行参数的解析
167+ qDebug () << " Initializing command line parser " ;
159168 QCommandLineParser parser;
160169 parser.setApplicationDescription (" Deepin Compressor." );
161170 parser.addHelpOption (); // 添加帮助信息(-h,--help),这个方法由QCommandLineParser自动处理
@@ -170,67 +179,83 @@ int main(int argc, char *argv[])
170179 QStringList newfilelist;
171180 if (argc == 3 && QString (argv[2 ]).startsWith (" --param=" ))
172181 {
182+ qDebug () << " Processing WPS order parameters" ;
173183 orderObject = true ;
174184 QString slast = QString (argv[2 ]).remove (0 ,strlen (" --param=" ));
175185 // 接收时需要转换为可用数据
176- qInfo () << " last :" << slast;
186+ qInfo () << " Base64 encoded parameter :" << slast;
177187 sJsonStr = QByteArray::fromBase64 (slast.toLatin1 ().data ()).data ();
178- // sJsonStr = sList.last();
179- qInfo () << " json:" << sJsonStr ;
188+ qInfo () << " Decoded JSON parameter:" << sJsonStr ;
180189 QString file = argv[1 ];
181190 if (file.contains (" file://" )) {
191+ qDebug () << " Removing file:// prefix" ;
182192 file.remove (" file://" );
183193 }
184194 newfilelist.append (file);
185195 newfilelist.append (QString (argv[2 ]));
186196 } else {
197+ qDebug () << " Processing standard command line arguments" ;
187198 parser.process (app);
188199 foreach (QString file, parser.positionalArguments ()) {
189200 if (file.contains (" file://" )) {
201+ qDebug () << " Removing file:// prefix from:" << file;
190202 file.remove (" file://" );
191203 }
192204 newfilelist.append (file);
193205 }
194206 }
195207
196- qInfo () << " 传入参数: " << newfilelist;
208+ qInfo () << " Final file list to process: " << newfilelist;
197209 if (orderObject) {
198- // 启动由wps控制,本地不做控制
210+ qDebug () << " Removing WPS parameter from file list " ;
199211 newfilelist.removeLast ();
212+ qDebug () << " WPS order object flag:" << orderObject;
200213 }
201214
202215 // 创建主界面
203216 MainWindow w;
204217 showWatermark (sJsonStr , &w);
205218
206- // 默认居中显示(使用dbus判断是否为第一个进程,第一个进程居中显示)
219+ qDebug () << " Creating DBus adaptor and connecting to session bus " ;
207220 ApplicationAdaptor adaptor (&app);
208221 QDBusConnection dbus = QDBusConnection::sessionBus ();
222+
209223 if (!orderObject){
224+ qDebug () << " Registering standard DBus service" ;
210225 if (dbus.registerService (" com.deepin.compressor" )) {
226+ qDebug () << " DBus service registered successfully, moving window to center" ;
211227 Dtk::Widget::moveToCenter (&w);
228+ } else {
229+ qWarning () << " Failed to register standard DBus service" ;
212230 }
213231 } else {
214- if (dbus.registerService (" com.deepin.compressor" +QString::number (QGuiApplication::applicationPid ()))) {
215- dbus.registerObject (" /" +QString::number (QGuiApplication::applicationPid ()), &app);
216- adaptor.setCompressFile (newfilelist.first ());
217- Dtk::Widget::moveToCenter (&w);
218- w.setProperty (ORDER_JSON, sJsonStr );
232+ qDebug () << " Registering WPS-specific DBus service" ;
233+ QString serviceName = " com.deepin.compressor" +QString::number (QGuiApplication::applicationPid ());
234+ if (dbus.registerService (serviceName)) {
235+ qDebug () << " WPS DBus service registered successfully" ;
236+ QString objectPath = " /" +QString::number (QGuiApplication::applicationPid ());
237+ dbus.registerObject (objectPath, &app);
238+ adaptor.setCompressFile (newfilelist.first ());
239+ Dtk::Widget::moveToCenter (&w);
240+ w.setProperty (ORDER_JSON, sJsonStr );
241+ qDebug () << " Window properties set for WPS mode" ;
242+ } else {
243+ qWarning () << " Failed to register WPS DBus service" ;
219244 }
220- QDBusConnection dbusConnection = QDBusConnection::sessionBus ();
221245
222- if (dbusConnection.connect (" com.wps.cryptfs"
223- , " /com/wps/cryptfs"
224- , " cryptfs.method.Type"
225- , " activateProcess"
226- , &adaptor
227- , SLOT (onActiveWindow (qint64))
228- ))
246+ qDebug () << " Connecting to WPS cryptfs DBus interface" ;
247+ QDBusConnection dbusConnection = QDBusConnection::sessionBus ();
248+ if (dbusConnection.connect (" com.wps.cryptfs" ,
249+ " /com/wps/cryptfs" ,
250+ " cryptfs.method.Type" ,
251+ " activateProcess" ,
252+ &adaptor,
253+ SLOT (onActiveWindow (qint64))))
229254 {
230- qInfo () << " DBus connect success! " ;
255+ qInfo () << " DBus connection to WPS cryptfs established successfully " ;
231256 } else {
232- qInfo () << " DBus connect failed! " ;
233- };
257+ qCritical () << " Failed to connect to WPS cryptfs DBus interface " ;
258+ }
234259 }
235260
236261
0 commit comments