-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsimple_gui_test.cpp
More file actions
143 lines (106 loc) · 4.6 KB
/
simple_gui_test.cpp
File metadata and controls
143 lines (106 loc) · 4.6 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#include <QtWidgets/QApplication>
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QVBoxLayout>
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QLabel>
#include <QtWidgets/QComboBox>
#include <QtWidgets/QProgressBar>
#include <QtWidgets/QTextEdit>
#include <QtWidgets/QGroupBox>
#include <QtWidgets/QListWidget>
#include <QtWidgets/QStatusBar>
class SimpleMainWindow : public QMainWindow {
Q_OBJECT
public:
SimpleMainWindow(QWidget *parent = nullptr) : QMainWindow(parent) {
setWindowTitle("SamFlash Alternative v1.0 - Qt6 GUI");
setMinimumSize(1200, 800);
setupUI();
}
private slots:
void onRefreshClicked() {
device_list_->addItem("Samsung Galaxy (COM3)");
device_list_->addItem("Test Device (COM4)");
log_console_->append("[INFO] Found 2 device(s)");
}
void onConnectClicked() {
log_console_->append("[INFO] Connecting to selected device...");
progress_bar_->setValue(25);
}
void onFlashClicked() {
log_console_->append("[INFO] Starting firmware flash...");
progress_bar_->setValue(75);
}
private:
void setupUI() {
// Main widget and layout
auto central_widget = new QWidget(this);
setCentralWidget(central_widget);
auto main_layout = new QHBoxLayout(central_widget);
// Left panel - Device list
auto device_group = new QGroupBox("Devices", this);
auto device_layout = new QVBoxLayout(device_group);
device_list_ = new QListWidget(this);
device_layout->addWidget(device_list_);
auto refresh_btn = new QPushButton("Refresh Devices", this);
connect(refresh_btn, &QPushButton::clicked, this, &SimpleMainWindow::onRefreshClicked);
device_layout->addWidget(refresh_btn);
auto connect_btn = new QPushButton("Connect", this);
connect(connect_btn, &QPushButton::clicked, this, &SimpleMainWindow::onConnectClicked);
device_layout->addWidget(connect_btn);
main_layout->addWidget(device_group);
// Right panel - Controls and log
auto right_layout = new QVBoxLayout();
// Firmware section
auto firmware_group = new QGroupBox("Firmware", this);
auto firmware_layout = new QHBoxLayout(firmware_group);
firmware_file_label_ = new QLabel("No file selected", this);
firmware_layout->addWidget(firmware_file_label_);
auto browse_btn = new QPushButton("Browse...", this);
firmware_layout->addWidget(browse_btn);
right_layout->addWidget(firmware_group);
// Control buttons
auto control_group = new QGroupBox("Flash Operations", this);
auto control_layout = new QHBoxLayout(control_group);
auto flash_btn = new QPushButton("Flash Firmware", this);
connect(flash_btn, &QPushButton::clicked, this, &SimpleMainWindow::onFlashClicked);
control_layout->addWidget(flash_btn);
auto verify_btn = new QPushButton("Verify", this);
control_layout->addWidget(verify_btn);
auto erase_btn = new QPushButton("Erase", this);
control_layout->addWidget(erase_btn);
right_layout->addWidget(control_group);
// Progress bar
auto progress_group = new QGroupBox("Progress", this);
auto progress_layout = new QVBoxLayout(progress_group);
progress_bar_ = new QProgressBar(this);
progress_layout->addWidget(progress_bar_);
auto progress_label = new QLabel("Ready", this);
progress_layout->addWidget(progress_label);
right_layout->addWidget(progress_group);
// Log console
auto log_group = new QGroupBox("Console Log", this);
auto log_layout = new QVBoxLayout(log_group);
log_console_ = new QTextEdit(this);
log_console_->setReadOnly(true);
log_console_->append("[INFO] SamFlash Alternative started");
log_layout->addWidget(log_console_);
right_layout->addWidget(log_group);
main_layout->addLayout(right_layout);
// Status bar
statusBar()->showMessage("Ready");
}
private:
QListWidget* device_list_;
QLabel* firmware_file_label_;
QProgressBar* progress_bar_;
QTextEdit* log_console_;
};
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
SimpleMainWindow window;
window.show();
return app.exec();
}
#include "simple_gui_test.moc"