-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_pc_debug.cpp
More file actions
54 lines (43 loc) · 1.66 KB
/
main_pc_debug.cpp
File metadata and controls
54 lines (43 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "FileManagerWindow.h"
#include <QApplication>
#include <QCommandLineParser>
#include <QCommandLineOption>
#include <QDebug>
// PC 调试模式下直接运行的程序
int main(int argc, char *argv[])
{
// 创建 QApplication 实例
QApplication app(argc, argv);
// 设置应用程序信息
app.setApplicationName("FileManager");
app.setApplicationVersion("1.0");
// 命令行解析器
QCommandLineParser parser;
parser.setApplicationDescription("文件管理器 - PC 调试版本");
parser.addHelpOption();
parser.addVersionOption();
// 添加路径选项
QCommandLineOption pathOption(QStringList() << "p" << "path",
QCoreApplication::translate("main", "打开指定路径"),
QCoreApplication::translate("main", "路径"));
parser.addOption(pathOption);
// 解析命令行参数
parser.process(app);
// 创建并显示主窗口
FileManagerWindow mainWindow;
// 设置窗口属性
mainWindow.setAttribute(Qt::WA_QuitOnClose, true);
mainWindow.resize(800, 600); // PC 屏幕较大,使用更大的窗口尺寸
mainWindow.setWindowTitle("文件管理器 - PC 调试版本");
// 如果指定了路径参数,尝试打开该路径
if (parser.isSet(pathOption)) {
QString path = parser.value(pathOption);
qDebug() << "尝试打开路径:" << path;
// 这里可以添加设置路径的代码,需要在 FileManagerWindow 中添加相应方法
}
// 显示窗口
mainWindow.show();
// 运行 Qt 事件循环
qDebug() << "文件管理器启动成功";
return app.exec();
}