]>
glassweightruler.freedombox.rocks Git - Ventoy.git/blob - LinuxGUI/Ventoy2Disk/QT/main.cpp
1 #include "ventoy2diskwindow.h"
3 #include <QApplication>
8 #include <QDesktopWidget>
11 #include <sys/types.h>
14 #include "ventoy_define.h"
15 #include "ventoy_util.h"
16 #include "ventoy_qt.h"
21 char g_log_file
[4096];
22 char g_ini_file
[4096];
24 int main(int argc
, char *argv
[])
28 QApplication
a(argc
, argv
);
34 QMessageBox::critical(NULL
, "Error", "Permission denied!\nPlease run with root privileges.");
39 if (!QFileInfo::exists("./boot/boot.img"))
41 QString curdir
= a
.applicationDirPath();
42 int index
= curdir
.indexOf("/tool/");
46 QDir::setCurrent(curdir
.left(index
));
50 QDir::setCurrent(curdir
);
54 if (!QFileInfo::exists("./boot/boot.img"))
56 QMessageBox::critical(NULL
, "Error", "Please run under the correct directory.");
62 snprintf(g_log_file
, sizeof(g_log_file
), "./log.txt");
63 snprintf(g_ini_file
, sizeof(g_ini_file
), "./Ventoy2Disk.ini");
64 for (int i
= 0; i
< argc
; i
++)
66 if (argv
[i
] && argv
[i
+ 1] && strcmp(argv
[i
], "-l") == 0)
68 snprintf(g_log_file
, sizeof(g_log_file
), "%s", argv
[i
+ 1]);
70 else if (argv
[i
] && argv
[i
+ 1] && strcmp(argv
[i
], "-i") == 0)
72 snprintf(g_ini_file
, sizeof(g_ini_file
), "%s", argv
[i
+ 1]);
76 QFileInfo
Info(g_log_file
);
77 size
= (long long)Info
.size();
78 if (size
>= 4 * SIZE_1MB
)
80 QFile::remove(g_log_file
);
83 vlog("===================================================\n");
84 vlog("===== Ventoy2Disk %s powered by QT %s =====\n", ventoy_get_local_version(), qVersion());
85 vlog("===================================================\n");
86 vlog("log file is <%s> lastsize:%lld\n", g_log_file
, (long long)size
);
87 vlog("ini file is <%s>\n", g_ini_file
);
92 w
.setGeometry(QStyle::alignedRect(Qt::LeftToRight
,
95 a
.desktop()->availableGeometry()));
102 data
= (const uchar
*)get_window_icon_raw_data(&len
);
103 pix
.loadFromData(data
, len
);
105 w
.setWindowIcon(icon
);
108 w
.setFixedSize(w
.size());
115 vlog("######## Ventoy2Disk QT %s exit ########\n", ventoy_get_local_version());
117 /* log exit must at the end */