-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathkernelmanager.cpp
More file actions
2038 lines (1662 loc) · 88.9 KB
/
kernelmanager.cpp
File metadata and controls
2038 lines (1662 loc) · 88.9 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "kernelmanager.h"
#include "systemmanager.h"
#include <QMessageBox>
#include <QFileDialog>
#include <QProcess>
#include <QTimer>
#include <QDir>
#include <QFile>
#include <QTextStream>
#include <QSplitter>
#include <QDialog>
#include <QDialogButtonBox>
#include <QCheckBox>
#include <QProgressDialog>
#include <QRegularExpression>
#include <QRadioButton>
#include <QFileInfo>
#include <QDateTime>
KernelManager::KernelManager(SystemManager *systemManager, QWidget *parent)
: QWidget(parent)
, m_systemManager(systemManager)
{
// Initialize kernel directory to ~/tweaker/kernel
m_kernelDirectory = QDir::homePath() + "/tweaker/kernel";
setupUI();
// Initial refresh of kernel data
QTimer::singleShot(100, this, &KernelManager::onRefreshKernels);
QTimer::singleShot(200, this, &KernelManager::onRefreshModules);
}
void KernelManager::setupUI()
{
QVBoxLayout *mainLayout = new QVBoxLayout(this);
// Title
QLabel *title = new QLabel("Kernel Manager");
QFont titleFont = title->font();
titleFont.setPointSize(16);
titleFont.setBold(true);
title->setFont(titleFont);
title->setStyleSheet("color: #000000; margin: 10px;");
mainLayout->addWidget(title);
// Create tab widget for different kernel management functions
m_tabWidget = new QTabWidget();
m_tabWidget->setStyleSheet(
"QTabWidget::pane { border: 2px solid #000000; background-color: #DCDCDC; }"
"QTabBar::tab { background-color: #F0F0F0; color: #000000; border: 1px solid #000000; padding: 8px; }"
"QTabBar::tab:selected { background-color: #000000; color: #FFFFFF; }"
);
createKernelManagementTab();
createPatchingTab();
createLiveConfigTab();
createModuleManagementTab();
mainLayout->addWidget(m_tabWidget);
// Status label
m_statusLabel = new QLabel("Ready");
m_statusLabel->setStyleSheet("color: #000000; font-weight: bold; margin: 5px;");
mainLayout->addWidget(m_statusLabel);
}
void KernelManager::createKernelManagementTab()
{
QWidget *tab = new QWidget();
m_tabWidget->addTab(tab, "🐧 Kernel Management");
QHBoxLayout *layout = new QHBoxLayout(tab);
// Left side - Kernel list and details
QVBoxLayout *leftLayout = new QVBoxLayout();
m_kernelListGroup = new QGroupBox("Installed Kernels");
m_kernelListGroup->setStyleSheet(
"QGroupBox { font-weight: bold; color: #000000; border: 2px solid #000000; "
"border-radius: 5px; margin: 5px; padding-top: 10px; background-color: #DCDCDC; }"
"QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 5px 0 5px; }"
);
QVBoxLayout *kernelListLayout = new QVBoxLayout(m_kernelListGroup);
m_currentKernelLabel = new QLabel("Current: Detecting...");
m_currentKernelLabel->setStyleSheet("color: #000000; font-weight: bold;");
kernelListLayout->addWidget(m_currentKernelLabel);
m_defaultKernelLabel = new QLabel("Default: Detecting...");
m_defaultKernelLabel->setStyleSheet("color: #000000;");
kernelListLayout->addWidget(m_defaultKernelLabel);
// Add kernel directory controls
QLabel *kernelDirLabel = new QLabel("Kernel Directory:");
kernelDirLabel->setStyleSheet("color: #000000; margin-top: 10px;");
kernelListLayout->addWidget(kernelDirLabel);
QHBoxLayout *kernelDirLayout = new QHBoxLayout();
m_kernelDirectoryEdit = new QLineEdit(m_kernelDirectory);
m_kernelDirectoryEdit->setStyleSheet("background-color: #F0F0F0; color: #000000; border: 1px solid #000000;");
connect(m_kernelDirectoryEdit, &QLineEdit::returnPressed, this, &KernelManager::onRefreshKernels);
kernelDirLayout->addWidget(m_kernelDirectoryEdit);
m_browseKernelDirButton = new QPushButton("📁 Browse");
m_browseKernelDirButton->setStyleSheet("QPushButton { background-color: #F0F0F0; color: #000000; border: 2px solid #000000; padding: 4px; } QPushButton:hover { background-color: #E0E0E0; }");
connect(m_browseKernelDirButton, &QPushButton::clicked, this, &KernelManager::onBrowseKernelDirectory);
kernelDirLayout->addWidget(m_browseKernelDirButton);
kernelListLayout->addLayout(kernelDirLayout);
m_copyCurrentKernelButton = new QPushButton("📋 Copy Current Kernel");
m_copyCurrentKernelButton->setStyleSheet("QPushButton { background-color: #F0F0F0; color: #000000; border: 2px solid #000000; padding: 8px; margin-top: 5px; } QPushButton:hover { background-color: #E0E0E0; }");
connect(m_copyCurrentKernelButton, &QPushButton::clicked, this, &KernelManager::onCopyCurrentKernel);
kernelListLayout->addWidget(m_copyCurrentKernelButton);
m_backupKernelButton = new QPushButton("💾 Back Up Kernel");
m_backupKernelButton->setStyleSheet("QPushButton { background-color: #F0F0F0; color: #000000; border: 2px solid #000000; padding: 8px; margin-top: 5px; } QPushButton:hover { background-color: #E0E0E0; }");
m_backupKernelButton->setEnabled(false);
connect(m_backupKernelButton, &QPushButton::clicked, this, &KernelManager::onBackupKernel);
kernelListLayout->addWidget(m_backupKernelButton);
m_kernelList = new QListWidget();
m_kernelList->setStyleSheet(
"QListWidget { background-color: #F0F0F0; color: #000000; border: 1px solid #000000; }"
"QListWidget::item:selected { background-color: #000000; color: #FFFFFF; }"
);
connect(m_kernelList, &QListWidget::itemSelectionChanged,
this, &KernelManager::onKernelSelectionChanged);
kernelListLayout->addWidget(m_kernelList);
leftLayout->addWidget(m_kernelListGroup);
// Kernel details
m_kernelDetailsGroup = new QGroupBox("Kernel Details");
m_kernelDetailsGroup->setStyleSheet(
"QGroupBox { font-weight: bold; color: #000000; border: 2px solid #000000; "
"border-radius: 5px; margin: 5px; padding-top: 10px; background-color: #DCDCDC; }"
"QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 5px 0 5px; }"
);
QVBoxLayout *detailsLayout = new QVBoxLayout(m_kernelDetailsGroup);
m_kernelDetailsText = new QTextEdit();
m_kernelDetailsText->setReadOnly(true);
m_kernelDetailsText->setMaximumHeight(150);
m_kernelDetailsText->setStyleSheet("background-color: #F0F0F0; color: #000000; border: 1px solid #000000;");
detailsLayout->addWidget(m_kernelDetailsText);
leftLayout->addWidget(m_kernelDetailsGroup);
// Right side - Actions
QVBoxLayout *rightLayout = new QVBoxLayout();
m_kernelActionsGroup = new QGroupBox("Kernel Actions");
m_kernelActionsGroup->setStyleSheet(
"QGroupBox { font-weight: bold; color: #000000; border: 2px solid #000000; "
"border-radius: 5px; margin: 5px; padding-top: 10px; background-color: #DCDCDC; }"
"QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 5px 0 5px; }"
);
QVBoxLayout *actionsLayout = new QVBoxLayout(m_kernelActionsGroup);
m_refreshButton = new QPushButton("🔄 Refresh Kernels");
m_refreshButton->setStyleSheet("QPushButton { background-color: #F0F0F0; color: #000000; border: 2px solid #000000; padding: 8px; } QPushButton:hover { background-color: #E0E0E0; }");
connect(m_refreshButton, &QPushButton::clicked, this, &KernelManager::onRefreshKernels);
actionsLayout->addWidget(m_refreshButton);
m_setDefaultButton = new QPushButton("⭐ Set as Default");
m_setDefaultButton->setStyleSheet("QPushButton { background-color: #F0F0F0; color: #000000; border: 2px solid #000000; padding: 8px; } QPushButton:hover { background-color: #E0E0E0; }");
m_setDefaultButton->setEnabled(false);
connect(m_setDefaultButton, &QPushButton::clicked, this, &KernelManager::onSetDefaultKernel);
actionsLayout->addWidget(m_setDefaultButton);
m_removeButton = new QPushButton("🗑️ Remove Kernel");
m_removeButton->setStyleSheet("QPushButton { background-color: #F0F0F0; color: #000000; border: 2px solid #000000; padding: 8px; } QPushButton:hover { background-color: #E0E0E0; }");
m_removeButton->setEnabled(false);
connect(m_removeButton, &QPushButton::clicked, this, &KernelManager::onRemoveKernel);
actionsLayout->addWidget(m_removeButton);
m_updateInitramfsButton = new QPushButton("🔧 Update Initramfs");
m_updateInitramfsButton->setStyleSheet("QPushButton { background-color: #F0F0F0; color: #000000; border: 2px solid #000000; padding: 8px; } QPushButton:hover { background-color: #E0E0E0; }");
connect(m_updateInitramfsButton, &QPushButton::clicked, this, &KernelManager::onUpdateInitramfs);
actionsLayout->addWidget(m_updateInitramfsButton);
m_updateGrubButton = new QPushButton("🥾 Update GRUB");
m_updateGrubButton->setStyleSheet("QPushButton { background-color: #F0F0F0; color: #000000; border: 2px solid #000000; padding: 8px; } QPushButton:hover { background-color: #E0E0E0; }");
connect(m_updateGrubButton, &QPushButton::clicked, this, &KernelManager::onUpdateGrub);
actionsLayout->addWidget(m_updateGrubButton);
m_viewConfigButton = new QPushButton("📄 View Config");
m_viewConfigButton->setStyleSheet("QPushButton { background-color: #F0F0F0; color: #000000; border: 2px solid #000000; padding: 8px; } QPushButton:hover { background-color: #E0E0E0; }");
m_viewConfigButton->setEnabled(false);
connect(m_viewConfigButton, &QPushButton::clicked, this, &KernelManager::onViewKernelConfig);
actionsLayout->addWidget(m_viewConfigButton);
m_installToDeviceButton = new QPushButton("💾 Install to Other Device");
m_installToDeviceButton->setStyleSheet("QPushButton { background-color: #F0F0F0; color: #000000; border: 2px solid #000000; padding: 8px; } QPushButton:hover { background-color: #E0E0E0; }");
m_installToDeviceButton->setEnabled(false);
connect(m_installToDeviceButton, &QPushButton::clicked, this, &KernelManager::onInstallKernelToDevice);
actionsLayout->addWidget(m_installToDeviceButton);
m_updateGrubOnDeviceButton = new QPushButton("🥾 Update GRUB on Device");
m_updateGrubOnDeviceButton->setStyleSheet("QPushButton { background-color: #F0F0F0; color: #000000; border: 2px solid #000000; padding: 8px; } QPushButton:hover { background-color: #E0E0E0; }");
connect(m_updateGrubOnDeviceButton, &QPushButton::clicked, this, &KernelManager::onUpdateGrubOnDevice);
actionsLayout->addWidget(m_updateGrubOnDeviceButton);
// Install new kernel section
actionsLayout->addWidget(new QLabel("Install New Kernel:"));
m_availableKernelsCombo = new QComboBox();
m_availableKernelsCombo->setStyleSheet(
"QComboBox { background-color: #F0F0F0; color: #000000; border: 1px solid #000000; padding: 3px; }"
"QComboBox::drop-down { border: 0px; }"
"QComboBox QAbstractItemView { background-color: #F0F0F0; color: #000000; }"
);
actionsLayout->addWidget(m_availableKernelsCombo);
m_installKernelButton = new QPushButton("📦 Install Kernel");
m_installKernelButton->setStyleSheet("QPushButton { background-color: #F0F0F0; color: #000000; border: 2px solid #000000; padding: 8px; } QPushButton:hover { background-color: #E0E0E0; }");
connect(m_installKernelButton, &QPushButton::clicked, this, &KernelManager::onInstallKernel);
actionsLayout->addWidget(m_installKernelButton);
// Joshua's Fixes button
actionsLayout->addWidget(new QLabel("")); // Add spacing
m_joshuaFixesButton = new QPushButton("🔧 Joshua's Fixes");
m_joshuaFixesButton->setStyleSheet("QPushButton { background-color: #F0F0F0; color: #000000; border: 2px solid #000000; padding: 8px; } QPushButton:hover { background-color: #E0E0E0; }");
connect(m_joshuaFixesButton, &QPushButton::clicked, this, &KernelManager::onShowJoshuaFixes);
actionsLayout->addWidget(m_joshuaFixesButton);
actionsLayout->addStretch();
rightLayout->addWidget(m_kernelActionsGroup);
layout->addLayout(leftLayout, 2);
layout->addLayout(rightLayout, 1);
}
void KernelManager::createPatchingTab()
{
QWidget *tab = new QWidget();
m_tabWidget->addTab(tab, "🩹 Kernel Patching");
QHBoxLayout *layout = new QHBoxLayout(tab);
// Left side - Available patches
QVBoxLayout *leftLayout = new QVBoxLayout();
m_patchListGroup = new QGroupBox("Available Patches");
m_patchListGroup->setStyleSheet(
"QGroupBox { font-weight: bold; color: #000000; border: 2px solid #000000; "
"border-radius: 5px; margin: 5px; padding-top: 10px; background-color: #DCDCDC; }"
"QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 5px 0 5px; }"
);
QVBoxLayout *patchListLayout = new QVBoxLayout(m_patchListGroup);
m_patchList = new QListWidget();
m_patchList->setStyleSheet(
"QListWidget { background-color: #F0F0F0; color: #000000; border: 1px solid #000000; }"
"QListWidget::item:selected { background-color: #000000; color: #FFFFFF; }"
);
patchListLayout->addWidget(m_patchList);
leftLayout->addWidget(m_patchListGroup);
// Applied patches
QGroupBox *appliedGroup = new QGroupBox("Applied Patches");
appliedGroup->setStyleSheet(
"QGroupBox { font-weight: bold; color: #000000; border: 2px solid #000000; "
"border-radius: 5px; margin: 5px; padding-top: 10px; background-color: #DCDCDC; }"
"QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 5px 0 5px; }"
);
QVBoxLayout *appliedLayout = new QVBoxLayout(appliedGroup);
m_appliedPatchesList = new QListWidget();
m_appliedPatchesList->setStyleSheet(
"QListWidget { background-color: #F0F0F0; color: #000000; border: 1px solid #000000; }"
"QListWidget::item:selected { background-color: #00FF00; color: #000000; }"
);
appliedLayout->addWidget(m_appliedPatchesList);
leftLayout->addWidget(appliedGroup);
// Right side - Patch actions and preview
QVBoxLayout *rightLayout = new QVBoxLayout();
m_patchActionsGroup = new QGroupBox("Patch Actions");
m_patchActionsGroup->setStyleSheet(
"QGroupBox { font-weight: bold; color: #000000; border: 2px solid #000000; "
"border-radius: 5px; margin: 5px; padding-top: 10px; background-color: #DCDCDC; }"
"QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 5px 0 5px; }"
);
QVBoxLayout *patchActionsLayout = new QVBoxLayout(m_patchActionsGroup);
m_loadPatchButton = new QPushButton("📁 Load Patch File");
m_loadPatchButton->setStyleSheet("QPushButton { background-color: #F0F0F0; color: #000000; border: 2px solid #000000; padding: 8px; } QPushButton:hover { background-color: #E0E0E0; }");
connect(m_loadPatchButton, &QPushButton::clicked, this, &KernelManager::onLoadPatchFile);
patchActionsLayout->addWidget(m_loadPatchButton);
m_applyPatchButton = new QPushButton("✅ Apply Patch");
m_applyPatchButton->setStyleSheet("QPushButton { background-color: #F0F0F0; color: #000000; border: 2px solid #000000; padding: 8px; } QPushButton:hover { background-color: #E0E0E0; }");
connect(m_applyPatchButton, &QPushButton::clicked, this, &KernelManager::onApplyPatch);
patchActionsLayout->addWidget(m_applyPatchButton);
m_revertPatchButton = new QPushButton("❌ Revert Patch");
m_revertPatchButton->setStyleSheet("QPushButton { background-color: #F0F0F0; color: #FF0000; border: 2px solid #000000; padding: 8px; } QPushButton:hover { background-color: #E0E0E0; }");
connect(m_revertPatchButton, &QPushButton::clicked, this, &KernelManager::onRevertPatch);
patchActionsLayout->addWidget(m_revertPatchButton);
m_createPatchButton = new QPushButton("🔧 Create Patch");
m_createPatchButton->setStyleSheet("QPushButton { background-color: #F0F0F0; color: #00FFFF; border: 2px solid #000000; padding: 8px; } QPushButton:hover { background-color: #E0E0E0; }");
connect(m_createPatchButton, &QPushButton::clicked, this, &KernelManager::onCreatePatch);
patchActionsLayout->addWidget(m_createPatchButton);
rightLayout->addWidget(m_patchActionsGroup);
// Patch preview
QGroupBox *previewGroup = new QGroupBox("Patch Preview");
previewGroup->setStyleSheet(
"QGroupBox { font-weight: bold; color: #000000; border: 2px solid #000000; "
"border-radius: 5px; margin: 5px; padding-top: 10px; background-color: #DCDCDC; }"
"QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 5px 0 5px; }"
);
QVBoxLayout *previewLayout = new QVBoxLayout(previewGroup);
m_patchPreviewText = new QTextEdit();
m_patchPreviewText->setReadOnly(true);
m_patchPreviewText->setFont(QFont("monospace"));
m_patchPreviewText->setStyleSheet("background-color: #F0F0F0; color: #000000; border: 1px solid #000000;");
previewLayout->addWidget(m_patchPreviewText);
rightLayout->addWidget(previewGroup);
layout->addLayout(leftLayout, 1);
layout->addLayout(rightLayout, 1);
}
void KernelManager::createLiveConfigTab()
{
QWidget *tab = new QWidget();
m_tabWidget->addTab(tab, "⚡ Live Configuration");
QVBoxLayout *layout = new QVBoxLayout(tab);
// Kernel parameters section
m_kernelParamsGroup = new QGroupBox("Kernel Parameters");
m_kernelParamsGroup->setStyleSheet(
"QGroupBox { font-weight: bold; color: #000000; border: 2px solid #000000; "
"border-radius: 5px; margin: 5px; padding-top: 10px; background-color: #DCDCDC; }"
"QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 5px 0 5px; }"
);
QVBoxLayout *paramsLayout = new QVBoxLayout(m_kernelParamsGroup);
QHBoxLayout *paramInputLayout = new QHBoxLayout();
paramInputLayout->addWidget(new QLabel("Parameter:"));
m_paramNameEdit = new QLineEdit();
m_paramNameEdit->setStyleSheet("background-color: #F0F0F0; color: #000000; border: 1px solid #000000;");
paramInputLayout->addWidget(m_paramNameEdit);
paramInputLayout->addWidget(new QLabel("Value:"));
m_paramValueEdit = new QLineEdit();
m_paramValueEdit->setStyleSheet("background-color: #F0F0F0; color: #000000; border: 1px solid #000000;");
paramInputLayout->addWidget(m_paramValueEdit);
m_applyParamButton = new QPushButton("Apply");
m_applyParamButton->setStyleSheet("QPushButton { background-color: #000000; color: #39FF14; border: 2px solid #00FF00; padding: 5px; } QPushButton:hover { background-color: #001100; }");
connect(m_applyParamButton, &QPushButton::clicked, this, &KernelManager::onApplyKernelParameter);
paramInputLayout->addWidget(m_applyParamButton);
paramsLayout->addLayout(paramInputLayout);
m_kernelParamsList = new QListWidget();
m_kernelParamsList->setMaximumHeight(150);
m_kernelParamsList->setStyleSheet(
"QListWidget { background-color: #F0F0F0; color: #000000; border: 1px solid #000000; }"
"QListWidget::item:selected { background-color: #000000; color: #FFFFFF; }"
);
paramsLayout->addWidget(m_kernelParamsList);
layout->addWidget(m_kernelParamsGroup);
// Boot parameters section
m_bootParamsGroup = new QGroupBox("Boot Parameters");
m_bootParamsGroup->setStyleSheet(
"QGroupBox { font-weight: bold; color: #000000; border: 2px solid #000000; "
"border-radius: 5px; margin: 5px; padding-top: 10px; background-color: #DCDCDC; }"
"QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 5px 0 5px; }"
);
QVBoxLayout *bootLayout = new QVBoxLayout(m_bootParamsGroup);
m_bootParamsEdit = new QTextEdit();
m_bootParamsEdit->setMaximumHeight(100);
m_bootParamsEdit->setStyleSheet("background-color: #F0F0F0; color: #000000; border: 1px solid #000000;");
bootLayout->addWidget(m_bootParamsEdit);
m_updateBootParamsButton = new QPushButton("Update Boot Parameters");
m_updateBootParamsButton->setStyleSheet("QPushButton { background-color: #F0F0F0; color: #000000; border: 2px solid #000000; padding: 8px; } QPushButton:hover { background-color: #E0E0E0; }");
connect(m_updateBootParamsButton, &QPushButton::clicked, this, &KernelManager::onUpdateBootParameters);
bootLayout->addWidget(m_updateBootParamsButton);
layout->addWidget(m_bootParamsGroup);
// Kernel config editing
m_configOptionsGroup = new QGroupBox("Kernel Configuration");
m_configOptionsGroup->setStyleSheet(
"QGroupBox { font-weight: bold; color: #000000; border: 2px solid #000000; "
"border-radius: 5px; margin: 5px; padding-top: 10px; background-color: #DCDCDC; }"
"QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 5px 0 5px; }"
);
QVBoxLayout *configLayout = new QVBoxLayout(m_configOptionsGroup);
m_configOptionsList = new QListWidget();
m_configOptionsList->setMaximumHeight(150);
m_configOptionsList->setStyleSheet(
"QListWidget { background-color: #F0F0F0; color: #000000; border: 1px solid #000000; }"
"QListWidget::item:selected { background-color: #000000; color: #FFFFFF; }"
);
configLayout->addWidget(m_configOptionsList);
m_configEditor = new QTextEdit();
m_configEditor->setFont(QFont("monospace"));
m_configEditor->setStyleSheet("background-color: #F0F0F0; color: #000000; border: 1px solid #000000;");
configLayout->addWidget(m_configEditor);
m_saveConfigButton = new QPushButton("Save Configuration");
m_saveConfigButton->setStyleSheet("QPushButton { background-color: #F0F0F0; color: #000000; border: 2px solid #000000; padding: 8px; } QPushButton:hover { background-color: #E0E0E0; }");
connect(m_saveConfigButton, &QPushButton::clicked, this, &KernelManager::onSaveKernelConfig);
configLayout->addWidget(m_saveConfigButton);
layout->addWidget(m_configOptionsGroup);
}
void KernelManager::createModuleManagementTab()
{
QWidget *tab = new QWidget();
m_tabWidget->addTab(tab, "📦 Module Management");
QHBoxLayout *layout = new QHBoxLayout(tab);
// Left side - Loaded modules
QVBoxLayout *leftLayout = new QVBoxLayout();
m_loadedModulesGroup = new QGroupBox("Loaded Modules");
m_loadedModulesGroup->setStyleSheet(
"QGroupBox { font-weight: bold; color: #000000; border: 2px solid #000000; "
"border-radius: 5px; margin: 5px; padding-top: 10px; background-color: #DCDCDC; }"
"QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 5px 0 5px; }"
);
QVBoxLayout *loadedLayout = new QVBoxLayout(m_loadedModulesGroup);
m_loadedModulesList = new QListWidget();
m_loadedModulesList->setStyleSheet(
"QListWidget { background-color: #F0F0F0; color: #000000; border: 1px solid #000000; }"
"QListWidget::item:selected { background-color: #00FF00; color: #000000; }"
);
connect(m_loadedModulesList, &QListWidget::itemSelectionChanged,
this, &KernelManager::onModuleSelectionChanged);
loadedLayout->addWidget(m_loadedModulesList);
leftLayout->addWidget(m_loadedModulesGroup);
// Right side - Available modules and actions
QVBoxLayout *rightLayout = new QVBoxLayout();
m_availableModulesGroup = new QGroupBox("Available Modules");
m_availableModulesGroup->setStyleSheet(
"QGroupBox { font-weight: bold; color: #000000; border: 2px solid #000000; "
"border-radius: 5px; margin: 5px; padding-top: 10px; background-color: #DCDCDC; }"
"QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 5px 0 5px; }"
);
QVBoxLayout *availableLayout = new QVBoxLayout(m_availableModulesGroup);
// Search box
m_moduleSearchEdit = new QLineEdit();
m_moduleSearchEdit->setPlaceholderText("Search modules...");
m_moduleSearchEdit->setStyleSheet("background-color: #F0F0F0; color: #000000; border: 1px solid #000000;");
availableLayout->addWidget(m_moduleSearchEdit);
m_availableModulesList = new QListWidget();
m_availableModulesList->setStyleSheet(
"QListWidget { background-color: #F0F0F0; color: #000000; border: 1px solid #000000; }"
"QListWidget::item:selected { background-color: #000000; color: #FFFFFF; }"
);
availableLayout->addWidget(m_availableModulesList);
rightLayout->addWidget(m_availableModulesGroup);
// Module actions
m_moduleActionsGroup = new QGroupBox("Module Actions");
m_moduleActionsGroup->setStyleSheet(
"QGroupBox { font-weight: bold; color: #000000; border: 2px solid #000000; "
"border-radius: 5px; margin: 5px; padding-top: 10px; background-color: #DCDCDC; }"
"QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 5px 0 5px; }"
);
QVBoxLayout *actionsLayout = new QVBoxLayout(m_moduleActionsGroup);
m_loadModuleButton = new QPushButton("📥 Load Module");
m_loadModuleButton->setStyleSheet("QPushButton { background-color: #F0F0F0; color: #000000; border: 2px solid #000000; padding: 8px; } QPushButton:hover { background-color: #E0E0E0; }");
connect(m_loadModuleButton, &QPushButton::clicked, this, &KernelManager::onLoadModule);
actionsLayout->addWidget(m_loadModuleButton);
m_unloadModuleButton = new QPushButton("📤 Unload Module");
m_unloadModuleButton->setStyleSheet("QPushButton { background-color: #F0F0F0; color: #FF0000; border: 2px solid #000000; padding: 8px; } QPushButton:hover { background-color: #E0E0E0; }");
connect(m_unloadModuleButton, &QPushButton::clicked, this, &KernelManager::onUnloadModule);
actionsLayout->addWidget(m_unloadModuleButton);
m_blacklistModuleButton = new QPushButton("🚫 Blacklist Module");
m_blacklistModuleButton->setStyleSheet("QPushButton { background-color: #F0F0F0; color: #FF00FF; border: 2px solid #000000; padding: 8px; } QPushButton:hover { background-color: #E0E0E0; }");
connect(m_blacklistModuleButton, &QPushButton::clicked, this, &KernelManager::onBlacklistModule);
actionsLayout->addWidget(m_blacklistModuleButton);
m_refreshModulesButton = new QPushButton("🔄 Refresh");
m_refreshModulesButton->setStyleSheet("QPushButton { background-color: #F0F0F0; color: #00FFFF; border: 2px solid #000000; padding: 8px; } QPushButton:hover { background-color: #E0E0E0; }");
connect(m_refreshModulesButton, &QPushButton::clicked, this, &KernelManager::onRefreshModules);
actionsLayout->addWidget(m_refreshModulesButton);
rightLayout->addWidget(m_moduleActionsGroup);
// Module information
QGroupBox *infoGroup = new QGroupBox("Module Information");
infoGroup->setStyleSheet(
"QGroupBox { font-weight: bold; color: #000000; border: 2px solid #000000; "
"border-radius: 5px; margin: 5px; padding-top: 10px; background-color: #DCDCDC; }"
"QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 5px 0 5px; }"
);
QVBoxLayout *infoLayout = new QVBoxLayout(infoGroup);
m_moduleInfoText = new QTextEdit();
m_moduleInfoText->setReadOnly(true);
m_moduleInfoText->setMaximumHeight(150);
m_moduleInfoText->setFont(QFont("monospace"));
m_moduleInfoText->setStyleSheet("background-color: #F0F0F0; color: #000000; border: 1px solid #000000;");
infoLayout->addWidget(m_moduleInfoText);
rightLayout->addWidget(infoGroup);
layout->addLayout(leftLayout, 1);
layout->addLayout(rightLayout, 1);
}
// Implementation of slots would continue here with the actual functionality
// For brevity, I'll show a few key implementations:
void KernelManager::onRefreshKernels()
{
m_statusLabel->setText("Scanning for installed kernels...");
m_kernelList->clear();
m_installedKernels.clear();
// Get current kernel
QProcess *currentProcess = new QProcess(this);
connect(currentProcess, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
[this, currentProcess](int, QProcess::ExitStatus) {
m_currentKernel = currentProcess->readAllStandardOutput().trimmed();
m_currentKernelLabel->setText(QString("Current: %1").arg(m_currentKernel));
currentProcess->deleteLater();
});
currentProcess->start("uname", QStringList() << "-r");
// Scan for installed kernels in /boot
QDir bootDir("/boot");
QStringList installedKernelFiles = bootDir.entryList(QStringList() << "vmlinuz-*", QDir::Files);
QStringList installedVersions;
for (const QString &kernel : installedKernelFiles) {
QString version = kernel.mid(8); // Remove "vmlinuz-"
installedVersions.append(version);
m_installedKernels.append(version);
}
// Scan for kernels in the tweaker directory
QString kernelDir = m_kernelDirectoryEdit->text().trimmed();
if (kernelDir.isEmpty()) {
kernelDir = m_kernelDirectory;
}
QDir tweakerDir(kernelDir);
if (!tweakerDir.exists()) {
QDir().mkpath(kernelDir);
}
QStringList tweakerKernelFiles = tweakerDir.entryList(QStringList() << "vmlinuz-*", QDir::Files);
QStringList allVersions = installedVersions;
// Add tweaker kernels that aren't already installed
for (const QString &kernel : tweakerKernelFiles) {
QString version = kernel.mid(8); // Remove "vmlinuz-"
if (!allVersions.contains(version)) {
allVersions.append(version);
}
}
// Add all kernels to the list
for (const QString &version : allVersions) {
QString displayText = "🐧 " + version;
if (installedVersions.contains(version)) {
displayText += " (Installed)";
}
QListWidgetItem *item = new QListWidgetItem(displayText);
if (version == m_currentKernel) {
item->setBackground(QBrush(QColor(0, 0, 0, 50)));
}
m_kernelList->addItem(item);
}
m_statusLabel->setText(QString("Found %1 installed kernels").arg(m_installedKernels.size()));
}
void KernelManager::onRefreshModules()
{
m_statusLabel->setText("Scanning loaded modules...");
m_loadedModulesList->clear();
m_availableModulesList->clear();
// Get loaded modules
QProcess *lsmodProcess = new QProcess(this);
connect(lsmodProcess, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
[this, lsmodProcess](int, QProcess::ExitStatus) {
QString output = lsmodProcess->readAllStandardOutput();
QStringList lines = output.split('\n');
m_loadedModules.clear();
for (int i = 1; i < lines.size(); ++i) { // Skip header
QString line = lines[i].trimmed();
if (!line.isEmpty()) {
QString moduleName = line.split(' ').first();
m_loadedModules.append(moduleName);
m_loadedModulesList->addItem("✅ " + moduleName);
}
}
lsmodProcess->deleteLater();
m_statusLabel->setText(QString("Found %1 loaded modules").arg(m_loadedModules.size()));
});
lsmodProcess->start("lsmod", QStringList());
// Get available modules (this is simplified - real implementation would scan /lib/modules)
QDir modulesDir(QString("/lib/modules/%1").arg(m_currentKernel));
if (modulesDir.exists()) {
// Simplified: just show some common module directories
QStringList dirs = modulesDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
for (const QString &dir : dirs) {
m_availableModulesList->addItem("📦 " + dir);
}
}
}
void KernelManager::onKernelSelectionChanged()
{
QListWidgetItem *item = m_kernelList->currentItem();
if (!item) {
m_setDefaultButton->setEnabled(false);
m_removeButton->setEnabled(false);
m_viewConfigButton->setEnabled(false);
m_installToDeviceButton->setEnabled(false);
m_backupKernelButton->setEnabled(false);
return;
}
QString kernelVersion = cleanKernelVersion(item->text());
m_setDefaultButton->setEnabled(kernelVersion != m_currentKernel);
m_removeButton->setEnabled(kernelVersion != m_currentKernel);
m_viewConfigButton->setEnabled(true);
m_installToDeviceButton->setEnabled(true);
m_backupKernelButton->setEnabled(true);
// Show kernel details
QString details = QString("Kernel: %1\n").arg(kernelVersion);
// Check for config file
QString configPath = QString("/boot/config-%1").arg(kernelVersion);
if (QFile::exists(configPath)) {
details += "Configuration: Available\n";
}
// Check for initramfs
QString initramfsPath = QString("/boot/initrd.img-%1").arg(kernelVersion);
if (QFile::exists(initramfsPath)) {
QFileInfo initramfsInfo(initramfsPath);
details += QString("Initramfs: %1 MB\n").arg(initramfsInfo.size() / 1024 / 1024);
}
m_kernelDetailsText->setPlainText(details);
}
void KernelManager::onSetDefaultKernel()
{
QListWidgetItem *item = m_kernelList->currentItem();
if (!item) return;
QString kernelVersion = cleanKernelVersion(item->text());
QMessageBox::StandardButton reply = QMessageBox::question(this, "Set Default Kernel",
QString("Set %1 as the default kernel?\n\nThis will update GRUB configuration.").arg(kernelVersion),
QMessageBox::Yes | QMessageBox::No);
if (reply == QMessageBox::Yes) {
emit setDefaultKernelRequested(kernelVersion);
m_statusLabel->setText(QString("Setting %1 as default kernel...").arg(kernelVersion));
}
}
void KernelManager::onRemoveKernel()
{
QListWidgetItem *item = m_kernelList->currentItem();
if (!item) return;
QString kernelVersion = cleanKernelVersion(item->text());
QMessageBox::StandardButton reply = QMessageBox::question(this, "Remove Kernel",
QString("Remove kernel %1?\n\nThis will delete the kernel and its modules.").arg(kernelVersion),
QMessageBox::Yes | QMessageBox::No);
if (reply == QMessageBox::Yes) {
emit removeKernelRequested(kernelVersion);
m_statusLabel->setText(QString("Removing kernel %1...").arg(kernelVersion));
}
}
void KernelManager::onUpdateInitramfs()
{
emit updateInitramfsRequested("all");
m_statusLabel->setText("Updating initramfs for all kernels...");
}
void KernelManager::onUpdateGrub()
{
m_statusLabel->setText("Updating GRUB configuration...");
// This would trigger the SystemManager to update GRUB
}
void KernelManager::onViewKernelConfig()
{
QListWidgetItem *item = m_kernelList->currentItem();
if (!item) return;
QString kernelVersion = cleanKernelVersion(item->text());
QString configPath = QString("/boot/config-%1").arg(kernelVersion);
QFile configFile(configPath);
if (configFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
QString content = configFile.readAll();
m_configEditor->setPlainText(content);
m_tabWidget->setCurrentIndex(2); // Switch to Live Configuration tab
} else {
QMessageBox::warning(this, "Error", QString("Could not read kernel config: %1").arg(configPath));
}
}
// Add placeholder implementations for the other slots
void KernelManager::onInstallKernel() { /* Implementation */ }
void KernelManager::onInstallKernelToDevice()
{
QListWidgetItem *item = m_kernelList->currentItem();
if (!item) return;
QString originalText = item->text();
QString kernelVersion = cleanKernelVersion(originalText);
bool isInstalledKernel = originalText.contains("(Installed)");
// Create a dialog for device selection
QDialog dialog(this);
dialog.setWindowTitle("Install Kernel to Other Device");
dialog.setFixedSize(600, 500);
dialog.setStyleSheet("background-color: #DCDCDC;");
QVBoxLayout *dialogLayout = new QVBoxLayout(&dialog);
// Title
QLabel *titleLabel = new QLabel("Select Target Device for Kernel Installation");
QFont titleFont = titleLabel->font();
titleFont.setPointSize(14);
titleFont.setBold(true);
titleLabel->setFont(titleFont);
titleLabel->setAlignment(Qt::AlignCenter);
titleLabel->setStyleSheet("color: #000000; margin: 10px;");
dialogLayout->addWidget(titleLabel);
// Info label
QLabel *infoLabel = new QLabel(QString("Installing kernel %1 to another device.\n"
"This is useful for repairing systems from a live image.").arg(kernelVersion));
infoLabel->setWordWrap(true);
infoLabel->setStyleSheet("color: #000000; margin: 10px; padding: 10px; background-color: #F0F0F0; border: 1px solid #000000;");
dialogLayout->addWidget(infoLabel);
// Device list
QGroupBox *deviceGroup = new QGroupBox("Available Block Devices");
deviceGroup->setStyleSheet(
"QGroupBox { font-weight: bold; color: #000000; border: 2px solid #000000; "
"border-radius: 5px; margin: 5px; padding-top: 10px; background-color: #DCDCDC; }"
"QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 5px 0 5px; }"
);
QVBoxLayout *deviceLayout = new QVBoxLayout(deviceGroup);
QListWidget *deviceList = new QListWidget();
deviceList->setStyleSheet(
"QListWidget { background-color: #F0F0F0; color: #000000; border: 1px solid #000000; }"
"QListWidget::item:selected { background-color: #000000; color: #FFFFFF; }"
);
// Scan for block devices
m_statusLabel->setText("Scanning for block devices...");
QProcess *lsblkProcess = new QProcess(this);
lsblkProcess->start("lsblk", QStringList() << "-J" << "-o" << "NAME,SIZE,TYPE,MOUNTPOINT,MODEL");
lsblkProcess->waitForFinished();
QString lsblkOutput = lsblkProcess->readAllStandardOutput();
// Parse lsblk output (simplified for now - in real implementation would use JSON parser)
QDir devDir("/dev");
QStringList blockDevices = devDir.entryList(QStringList() << "sd*" << "nvme*" << "mmcblk*", QDir::System);
// Filter to only show main devices (not partitions)
QStringList mainDevices;
for (const QString &device : blockDevices) {
// Skip partition entries
if (!device.contains(QRegularExpression("[0-9]$")) || device.startsWith("mmcblk")) {
if (device.startsWith("mmcblk") && device.contains("p")) continue;
mainDevices.append(device);
}
}
// Add devices to list with details
for (const QString &device : mainDevices) {
QString devicePath = "/dev/" + device;
// Get device info
QProcess *deviceInfoProcess = new QProcess(this);
deviceInfoProcess->start("lsblk", QStringList() << "-n" << "-o" << "SIZE,MODEL" << devicePath);
deviceInfoProcess->waitForFinished();
QString deviceInfo = deviceInfoProcess->readAllStandardOutput().trimmed();
QString listEntry = QString("💾 %1 - %2").arg(devicePath).arg(deviceInfo);
// Check if device is mounted (safety check)
QProcess *mountProcess = new QProcess(this);
mountProcess->start("findmnt", QStringList() << "-n" << "-o" << "TARGET" << devicePath);
mountProcess->waitForFinished();
QString mountPoint = mountProcess->readAllStandardOutput().trimmed();
if (!mountPoint.isEmpty()) {
listEntry += QString(" [MOUNTED at %1]").arg(mountPoint);
}
QListWidgetItem *deviceItem = new QListWidgetItem(listEntry);
deviceItem->setData(Qt::UserRole, devicePath);
// Mark mounted devices with different color
if (!mountPoint.isEmpty()) {
deviceItem->setForeground(QBrush(QColor(255, 0, 0)));
}
deviceList->addItem(deviceItem);
}
deviceLayout->addWidget(deviceList);
dialogLayout->addWidget(deviceGroup);
// Options group
QGroupBox *optionsGroup = new QGroupBox("Installation Options");
optionsGroup->setStyleSheet(
"QGroupBox { font-weight: bold; color: #000000; border: 2px solid #000000; "
"border-radius: 5px; margin: 5px; padding-top: 10px; background-color: #DCDCDC; }"
"QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 5px 0 5px; }"
);
QVBoxLayout *optionsLayout = new QVBoxLayout(optionsGroup);
QCheckBox *mountRootCheckbox = new QCheckBox("Mount root partition automatically");
mountRootCheckbox->setChecked(true);
mountRootCheckbox->setStyleSheet("color: #000000;");
optionsLayout->addWidget(mountRootCheckbox);
// Add custom mount point option
QHBoxLayout *mountPointLayout = new QHBoxLayout();
QLabel *mountPointLabel = new QLabel("Custom mount point (if already mounted):");
mountPointLabel->setStyleSheet("color: #000000;");
mountPointLayout->addWidget(mountPointLabel);
QLineEdit *customMountPointEdit = new QLineEdit();
customMountPointEdit->setPlaceholderText("/mnt/target");
customMountPointEdit->setStyleSheet("background-color: #F0F0F0; color: #000000; border: 1px solid #000000;");
customMountPointEdit->setEnabled(!mountRootCheckbox->isChecked());
mountPointLayout->addWidget(customMountPointEdit);
optionsLayout->addLayout(mountPointLayout);
// Connect checkbox to enable/disable custom mount point
connect(mountRootCheckbox, &QCheckBox::toggled, [customMountPointEdit](bool checked) {
customMountPointEdit->setEnabled(!checked);
if (checked) {
customMountPointEdit->clear();
}
});
QCheckBox *updateGrubCheckbox = new QCheckBox("Update GRUB configuration");
updateGrubCheckbox->setChecked(true);
updateGrubCheckbox->setStyleSheet("color: #000000;");
optionsLayout->addWidget(updateGrubCheckbox);
QCheckBox *copyModulesCheckbox = new QCheckBox("Copy kernel modules");
copyModulesCheckbox->setChecked(true);
copyModulesCheckbox->setStyleSheet("color: #000000;");
optionsLayout->addWidget(copyModulesCheckbox);
dialogLayout->addWidget(optionsGroup);
// Warning label
QLabel *warningLabel = new QLabel("⚠️ WARNING: This operation will modify the target device.\n"
"Make sure you have selected the correct device!");
warningLabel->setStyleSheet("color: #FF0000; font-weight: bold; margin: 10px;");
warningLabel->setAlignment(Qt::AlignCenter);
dialogLayout->addWidget(warningLabel);
// Button box
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
buttonBox->button(QDialogButtonBox::Ok)->setText("Install Kernel");
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
buttonBox->setStyleSheet(
"QPushButton { background-color: #F0F0F0; color: #000000; border: 2px solid #000000; padding: 8px; }"
"QPushButton:hover { background-color: #E0E0E0; }"
);
// Enable OK button only when device is selected
connect(deviceList, &QListWidget::itemSelectionChanged, [buttonBox, deviceList]() {
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(deviceList->currentItem() != nullptr);
});
connect(buttonBox, &QDialogButtonBox::accepted, &dialog, &QDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, &dialog, &QDialog::reject);
dialogLayout->addWidget(buttonBox);
if (dialog.exec() == QDialog::Accepted) {
QListWidgetItem *selectedDevice = deviceList->currentItem();
if (selectedDevice) {
QString devicePath = selectedDevice->data(Qt::UserRole).toString();
// Build confirmation message based on selected options
QString confirmMessage = QString("Are you sure you want to install kernel %1 to device %2?\n\n"
"This operation will:\n").arg(kernelVersion).arg(devicePath);
if (mountRootCheckbox->isChecked()) {
confirmMessage += "• Mount the device's root partition\n";
} else if (!customMountPointEdit->text().trimmed().isEmpty()) {
confirmMessage += QString("• Use custom mount point: %1\n").arg(customMountPointEdit->text().trimmed());
}
confirmMessage += "• Copy kernel files to /boot\n";
confirmMessage += "• Update initramfs\n";
if (updateGrubCheckbox->isChecked()) {
confirmMessage += "• Update GRUB configuration\n";
}
if (copyModulesCheckbox->isChecked()) {
confirmMessage += "• Copy kernel modules\n";
}
confirmMessage += "\nThis may take several minutes.";
// Confirm with user
QMessageBox::StandardButton confirm = QMessageBox::question(this,
"Confirm Kernel Installation",
confirmMessage,
QMessageBox::Yes | QMessageBox::No);
if (confirm == QMessageBox::Yes) {
// Create progress dialog
QProgressDialog progress("Installing kernel to device...", "Cancel", 0, 100, this);
progress.setWindowModality(Qt::WindowModal);
progress.setWindowTitle("Kernel Installation Progress");
progress.setAutoClose(true);
progress.setValue(0);
// Perform the installation
QString customMountPoint = customMountPointEdit->text().trimmed();
performKernelInstallation(kernelVersion, devicePath,
mountRootCheckbox->isChecked(),
updateGrubCheckbox->isChecked(),
copyModulesCheckbox->isChecked(),
customMountPoint,
isInstalledKernel,
&progress);
}
}
}
m_statusLabel->setText("Ready");