Skip to content

Commit 55eaaa7

Browse files
committed
chore: More logs for application
Add more logs for application. 86.21% Log: More logs for application.
1 parent 24b9a2a commit 55eaaa7

47 files changed

Lines changed: 2213 additions & 85 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

application/common.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88

99
QIcon Common::getIcon(const QString &iconName)
1010
{
11+
// qDebug() << "Common::getIcon called with iconName:" << iconName;
1112
return QIcon::fromTheme("dm_" + iconName);
1213
}
1314

1415
int Common::getLabelAdjustHeight(const int &width, const QString &text, const QFont &font)
1516
{
16-
qDebug() << "Calculating label height for text:" << text.left(20) << "...";
17+
// qDebug() << "Calculating label height for text:" << text.left(20) << "...";
1718
DLabel label;
1819
label.setFont(font);
1920
label.setWordWrap(true);
@@ -22,6 +23,6 @@ int Common::getLabelAdjustHeight(const int &width, const QString &text, const QF
2223
label.adjustSize();
2324

2425
int height = label.height();
25-
qDebug() << "Calculated label height:" << height;
26+
// qDebug() << "Calculated label height:" << height;
2627
return height;
2728
}

application/main.cpp

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,27 @@ DWIDGET_USE_NAMESPACE
4040
// 接口工厂
4141
QAccessibleInterface *accessibleFactory(const QString &classname, QObject *object)
4242
{
43+
qDebug() << "accessibleFactory called for classname:" << classname;
4344
QAccessibleInterface *interface = nullptr;
4445

4546
if (object && object->isWidgetType()) {
46-
if (classname == "QLabel")
47+
qDebug() << "Object is a widget type, classname:" << classname;
48+
if (classname == "QLabel") {
49+
qDebug() << "Creating AccessibleLabel for QLabel";
4750
interface = new AccessibleLabel(qobject_cast<QLabel *>(object));
51+
}
4852

49-
if (classname == "QPushButton")
53+
if (classname == "QPushButton") {
54+
qDebug() << "Creating AccessibleButton for QPushButton";
5055
interface = new AccessibleButton(qobject_cast<QPushButton *>(object));
56+
}
5157

52-
if (classname == "QComboBox")
58+
if (classname == "QComboBox") {
59+
qDebug() << "Creating AccessibleComboBox for QComboBox";
5360
interface = new AccessibleComboBox(qobject_cast<QComboBox *>(object));
61+
}
62+
} else {
63+
qDebug() << "Object is not a widget type or is null.";
5464
}
5565

5666
return interface;
@@ -65,20 +75,23 @@ QAccessibleInterface *accessibleFactory(const QString &classname, QObject *objec
6575
*/
6676
int executCmd(const QString &strCmd, QString &outPut, QString &error)
6777
{
78+
qDebug() << "executCmd called with command:" << strCmd;
6879
QProcess proc;
6980
#if QT_VERSION_MAJOR > 5
81+
qDebug() << "QT_VERSION_MAJOR > 5, using split command start.";
7082
QStringList list = strCmd.split(" ");
7183
proc.start(list.at(0), QStringList() << list.at(1));
7284
#else
85+
qDebug() << "QT_VERSION_MAJOR <= 5, using direct command start.";
7386
proc.start(strCmd);
7487
#endif
7588
proc.waitForFinished(-1);
7689
outPut = proc.readAllStandardOutput();
7790
error = proc.readAllStandardError();
7891
error = proc.errorString();
7992
int exitcode = proc.exitCode();
93+
qDebug() << "executCmd finished. Exit code:" << exitcode << ", Output size:" << outPut.size() << ", Error size:" << error.size();
8094
return exitcode;
81-
8295
}
8396

8497
int main(int argc, char *argv[])
@@ -87,13 +100,15 @@ int main(int argc, char *argv[])
87100
// signal(SIGKILL, SIG_IGN);
88101

89102
if (qEnvironmentVariableIsEmpty("XDG_CURRENT_DESKTOP")){
103+
qDebug() << "XDG_CURRENT_DESKTOP is empty, setting to Deepin.";
90104
qputenv("XDG_CURRENT_DESKTOP", "Deepin");
91105
}
92106

93107
auto e = QProcessEnvironment::systemEnvironment();
94108
#if QT_VERSION_MAJOR <= 5
95109
QString XDG_SESSION_TYPE = e.value(QStringLiteral("XDG_SESSION_TYPE"));
96110
if (XDG_SESSION_TYPE == QLatin1String("x11")) {
111+
qDebug() << "XDG_SESSION_TYPE is x11, loading DXcbPlugin.";
97112
CusApplication::loadDXcbPlugin();
98113
}
99114
#endif
@@ -115,52 +130,58 @@ int main(int argc, char *argv[])
115130
a.setApplicationDescription(QObject::tr("Disk Utility is a disk management tool for creating, reorganizing and formatting partitions."));
116131
#if QT_VERSION_MAJOR <= 5
117132
DApplicationSettings savetheme;
133+
qDebug() << "DApplicationSettings initialized for QT_VERSION_MAJOR <= 5.";
118134
#endif
119135
Dtk::Core::DLogManager::registerConsoleAppender();
120136
Dtk::Core::DLogManager::registerFileAppender();
137+
qDebug() << "Console and file appenders registered.";
121138

122139
// 安装工厂
123140
QAccessible::installFactory(accessibleFactory);
141+
qDebug() << "Accessible factory installed.";
124142

125-
// MainWindow w;
126-
// if (a.setSingleInstance(appName)) {
127-
// QObject::connect(&a, &DApplication::newInstanceStarted, &w, [&] {qDebug() << "======"; w.activateWindow(); });
128-
// } else {
129-
// exit(0);
130-
// }
131143
if (a.setSingleInstance(appName)) {
144+
qDebug() << "Application is single instance, proceeding with service check.";
132145
QProcess proc;
133146
QString cmd, oldPid, newPid, error;
134147
//先判断后台服务进程是否存在,如果存在可能是强制退出导致,应先退出后台程序再重新启动磁盘管理器
135148
cmd = QString("pidof deepin-diskmanager-service");
149+
qDebug() << "Checking for deepin-diskmanager-service PID with command:" << cmd;
136150

137151
if (!executCmd(cmd, oldPid, error)) {
152+
qDebug() << "deepin-diskmanager-service found, sending Quit signal.";
138153
proc.startDetached("/usr/bin/dbus-send --system --type=method_call --dest=com.deepin.diskmanager /com/deepin/diskmanager com.deepin.diskmanager.Quit");
139154
}
140155

141156
QStringList argList;
142157
argList << QString::number(QCoreApplication::applicationPid()) << QDBusConnection::systemBus().baseService();
158+
qDebug() << "Starting deepin-diskmanager-authenticateProxy with args:" << argList;
143159
proc.startDetached("/usr/bin/deepin-diskmanager-authenticateProxy", argList);
144160

145161
//正常启动程序后,循环查询后台服务是否已经启动,如果后台服务启动说明鉴权成功,启动前端界面
146162
while (1) {
147163
cmd = QString("pidof deepin-diskmanager-service");
148164

149165
if (!executCmd(cmd, newPid, error) && oldPid != newPid) {
166+
qDebug() << "New deepin-diskmanager-service PID found, breaking loop.";
150167
break;
151168
}
152169
QThread::msleep(300);
153170
}
154171

155172
proc.close();
173+
qDebug() << "Process closed after service check.";
156174

157175
} else {
176+
qDebug() << "Application is another instance which is already running, sending message to it and exiting.";
177+
// The message is sent automatically by DApplication framework.
158178
exit(0);
159179
}
160180

161181
MainWindow w;
162182
QObject::connect(&a, &DApplication::newInstanceStarted, &w, [&] {qDebug() << "======"; w.activateWindow(); });
163183
QObject::connect(&a, &CusApplication::handleQuitActionChanged, &w, &MainWindow::onHandleQuitAction);
184+
qDebug() << "MainWindow signals connected.";
164185

165186
// DMDbusHandler::instance()->startService(static_cast<qint64>(getpid()));
166187
// QObject::connect(DMDbusHandler::instance(), &DMDbusHandler::rootLogin, &w, [&] {
@@ -175,6 +196,7 @@ int main(int argc, char *argv[])
175196

176197
Dtk::Widget::moveToCenter(&w);
177198
w.show();
199+
qDebug() << "MainWindow shown.";
178200

179201
return a.exec();
180202
}

0 commit comments

Comments
 (0)