summaryrefslogtreecommitdiffstats
path: root/src/ui.py
blob: 2c92800eb1b4fda1e7ffe1039622ca6a8588c887 (plain)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
import sys
import os
import pwd
from PyQt6.QtWidgets import (
    QApplication,
    QCheckBox,
    QMainWindow,
    QWidget,
    QStackedWidget,
    QVBoxLayout,
    QHBoxLayout,
    QGridLayout,
    QPushButton,
    QLabel,
    QScrollArea,
    QMessageBox,
    QStyledItemDelegate,
    QListView,
)
from PyQt6.QtCore import (
    Qt,
    QPropertyAnimation,
    QEasingCurve,
    QPoint,
    QTimer,
    QSize,
    QObject,
    pyqtSlot,
    pyqtSignal,
)
from PyQt6.QtGui import (
    QColor,
    QPalette,
    QFont,
    QPixmap,
    QImage,
    QPainter,
    QLinearGradient,
    QColorConstants,
)
import webbrowser
import subprocess
from functools import partial
from helpers import (
    get_desktop_name,
    get_desktop_name2,
    is_installed,
    NetworkState,
    ConfList,
    Autostart,
)
from AppList import AppList

DEFAULT_WIDTH = 900
_ = QApplication.translate


class Commands():
    def weblink(self, url):
        webbrowser.open_new_tab(url)

    def command(self, app):
        print(f"Lancement de {app}")
        if type(app) == list:
            cmd = app
            try:
                subprocess.Popen(cmd)
            except FileNotFoundError as e:
                print(f"Exception running {cmd}")
                print(e)
                message = QMessageBox(
                    QMessageBox.Icon.Warning,
                    _("mw-ui", "Launching command"),
                    _("mw-ui", "This command is not installed"),
                )
                message.exec()

    def install(self, app):
        if type(app) == list:
            cmd = app
            repo = cmd[1]
            # Check if repositories are enabled
            core = False
            updates = False
            tainted = False
            t_updates = False
            nonfree = False
            nf_updates = False
            core32 = False
            core32_updates = False
            try:
                active = subprocess.run(
                    ["urpmq", "--list-media", "active"], capture_output=True, text=True
                )
                active.check_returncode()
            except subprocess.CalledProcessError:
                print("Error with urpmq")
                return
            for line in active.stdout.splitlines():
                if line.startswith("Core Release"):
                    core = True
                if line.startswith("Core Updates"):
                    updates = True
                if line.startswith("Tainted Release"):
                    tainted = True
                if line.startswith("Tainted Updates"):
                    t_updates = True
                if line.startswith("Nonfree Release"):
                    nonfree = True
                if line.startswith("Nonfree Updates"):
                    nf_updates = True
                if line.startswith("Core 32bit Release"):
                    core32 = True
                if line.startswith("Core 32bit Updates"):
                    core32_updates = True
            if repo == "tainted" and not (tainted and t_updates):
                #   repo tainted not enabled
                message = QMessageBox(
                    QMessageBox.Icon.Warning,
                    _("mw-ui", "Application installation"),
                    #: {} will be replaced with the 'Media sources' translation
                    _("mw-ui", "Tainted repositories are not enabled. See the '{}' tab.").format(_("Sources",_("Media sources"))),
                )
                message.exec()
                return
            if repo == "non-free" and not (nonfree and nf_updates):
                #   repo nonfree not enabled
                message = QMessageBox(
                    QMessageBox.Icon.Warning,
                    _("mw-ui", "Application installation"),
                    #: {} will be replaced with the 'Media sources' translation
                    _("mw-ui", "Nonfree repositories are not enabled. See the '{}' tab.").format(_("Sources",_("Media sources"))),
                )
                message.exec()
                return
            if repo == "steam" and not (
                core32 and core32_updates and nonfree and nf_updates
            ):
                #   repo not enabled . See the '%1' tab
                message = QMessageBox(
                    QMessageBox.Icon.Warning,
                    _("mw-ui", "Application installation"),
                    #: {} will be replaced with the 'Media sources' translation
                    _("mw-ui", "Steam needs that Nonfree and Core 32bit repositories are enabled. See the '{}' tab.").format(_("Sources",_("Media sources"))),
                )
                message.exec()
                return
            if repo == "" and not (core and updates):
                #   repo not enabled
                message = QMessageBox(
                    QMessageBox.Icon.Warning,
                    _("mw-ui", "Application installation"),
                    #: {} will be replaced with the 'Media sources' translation
                    _("mw-ui", "Core repositories are not enabled. See the '{}' tab.").format(_("Sources",_("Media sources"))),
                )
                message.exec()
                return
            proc = subprocess.Popen(["/usr/bin/gurpmi", cmd[0]])
            proc.wait()

    def install_and_launch(self, app):
        """
        app should be an array with the package name to install and then the command to launch
        """
        if type(app) == list:
            cmd = app
            # app should contain package, repository
            is_app_installed, inst_repo = is_installed(cmd[0])
            if not is_app_installed:
                proc = subprocess.Popen(["/usr/bin/gurpmi", cmd[0]])
                proc.wait()
            self.command([cmd[1]])


class SlidePage(QWidget, Commands):
    """Widget pour une page individuelle du diaporama"""

    def __init__(self, title):
        super().__init__()

        # Stocker le titre pour référence
        self.title = title

    def paintEvent(self, event):
        painter = QPainter(self)
        gradient = QLinearGradient(0, 0, 0, self.height())
        gradient.setColorAt(0.0, QColor("#262F45"))
        gradient.setColorAt(1.0, QColor("#2397D4"))
        painter.setBrush(gradient)
        painter.setPen(Qt.PenStyle.NoPen)
        painter.drawRect(self.rect())

    def resizeEvent(self, event):
        self.paintEvent(event)


class Links(SlidePage):
    """Widget pour une page individuelle du diaporama"""

    def __init__(self):
        super().__init__(_("Links", "More information"))

        data = [
            {
                "name": _("Links", "Release notes"),
                "url":
                #: Translate only if the link is to a specific page for your language
                _("Links", "https://wiki.mageia.org/en/Mageia_9_Release_Notes"),
            },
            {
                "name": _("Links", "Forums"),
                "url":
                #: Translate only if the link is to a specific page for your language
                _("Links", "https://forums.mageia.org/en/"),
            },
            {
                "name": _("Links", "Community Center"),
                "url": "https://www.mageia.org/community/",
            },
            {
                "name": _("Links", "Errata"),
                "url":
                #: Translate only if the link is to a specific page for your language
                _("Links", "https://wiki.mageia.org/en/Mageia_9_Errata"),
            },
            {
                "name": _("Links", "Wiki"),
                "url":
                #: Translate only if the link is to a specific page for your language
                _("Links", "https://wiki.mageia.org/en/Documentation"),
            },
            {
                "name": _("Links", "Contribute"),
                "url": "https://www.mageia.org/contribute/",
            },
            {
                "name": _("Links", "Newcomers Howto"),
                "url":
                #: Translate only if the link is to a specific page for your language
                _("Links", "https://wiki.mageia.org/en/Newcomers_start_here"),
            },
            {
                "name": _("Links", "Chat Room"),
                #: Translate only if the link is to a specific page for your language
                "url": _("Links", "ircs://irc.libera.chat:6697/#mageia"),
            },
            {"name": _("Links", "Donations"), "url": "https://www.mageia.org/donate/"},
            {"name": _("Links", "Documentation"), "url": "https://www.mageia.org/doc/"},
            {"name": _("Links", "Bugs tracker"), "url": "https://bugs.mageia.org/"},
            {"name": _("Links", "Join us!"), "url": "https://identity.mageia.org/"},
        ]
        layout = QGridLayout()

        layout.setSpacing(30)
        col = 1
        for title in (_("Links","Documentation"), _("Links", "Support"), _("Links", "Community")):
            button = QLabel(title)
            button.setAlignment(Qt.AlignmentFlag.AlignCenter)
            button.setWordWrap(True)
            button.setStyleSheet(
                "color: white; font-size: 18px; padding: 2px 8px; font-weight: bold;"
            )
            layout.addWidget(button, 0, col)
            col += 1

        iter_data = iter(data)
        for row in range(2, 6):
            for col in range(1, 4):
                item = next(iter_data)
                button = MyPushButton(item["name"])
                button.clicked.connect(partial(self.weblink, item["url"]))
                layout.addWidget(button, row, col)
        # Dummy widgets at corner to center the buttons
        layout.addWidget(QWidget(), 6, 4)
        layout.addWidget(QWidget(), 0, 0)

        self.setLayout(layout)


class Welcome(SlidePage):
    def __init__(self, user):
        super().__init__(_("Welcome", "Welcome"))

        #  vertical layout
        layout = QVBoxLayout()

        # Add title
        if user == "live":
            title = _("Welcome", "Welcome to Mageia")
        else:
            title = _("Welcome", "Welcome to Mageia, {}".format(user))
        title_label = QLabel(title)
        title_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
        title_label.setStyleSheet("font-size: 28px; color: white; font-weight: bold;")
        layout.addWidget(title_label)

        # Add the content
        if user == "live":
            content = _(
                "Welcome",
                "We are going to guide you through a few important pieces of information and<BR />help you to go further with Mageia.<BR /><BR />Now, click on <i> {} </i> to go to the first step.",
            ).format(_("Welcome", "Live mode"))
        else:
            content = _(
                "Welcome",
                "We are going to guide you through some important steps and help<BR />you with the configuration of your newly installed system.<BR /><BR />Now, click on <i>{}</i> to go to the first step.",
            ).format(_("Sources", "Media sources"))
        content_label = QLabel(content)
        content_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
        content_label.setStyleSheet("font-size: 22px; color: white;")
        layout.addWidget(content_label)

        self.setLayout(layout)


class Sources(SlidePage):
    def __init__(self):
        super().__init__(_("Sources", "Media sources"))

        #  vertical layout
        layout = QVBoxLayout()
        layout.addStretch(0)
        grid = QGridLayout()

        title_label = QLabel(_("Sources", "Configure software repositories"))
        title_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
        title_label.setStyleSheet("font-size: 28px; color: white; font-weight: bold;")
        layout.addWidget(title_label)

        explain_label = QLabel(_("Sources", "Mageia official repositories contain:"))
        explain_label.setStyleSheet("font-size: 14px; color: white;")
        layout.addWidget(explain_label)

        core_legend = GradientLegend(
            _("Sources", "core"), QColor("lightgreen"), QColor("green")
        )
        grid.addWidget(core_legend, 2, 0)
        core_label = QLabel(_("Sources", "- the free-open-source packages"))
        core_label.setStyleSheet("font-size: 14px; color: white;")
        core_label.setWordWrap(True)
        grid.addWidget(core_label, 2, 1)

        nonfree_legend = GradientLegend(
            _("Sources", "nonfree"), QColor("red"), QColor("darkred")
        )
        grid.addWidget(nonfree_legend, 3, 0)
        nonfree_label = QLabel(
            _(
                "Sources",
                "- closed-source programs, e.g. Nvidia proprietary drivers, non-free drivers for some Wi-Fi cards, etc",
            )
        )
        nonfree_label.setWordWrap(True)
        nonfree_label.setStyleSheet("font-size: 14px; color: white;")
        grid.addWidget(nonfree_label, 3, 1)

        tainted_legend = GradientLegend(
            _("Sources", "tainted"), QColor("red"), QColor("darkred")
        )
        grid.addWidget(tainted_legend, 4, 0)
        tainted_label = QLabel(
            _(
                "Sources",
                "- these packages (eg audio and video codecs needed for certain multimedia files or commercial DVDs) may infringe on patents or copyright laws in certain countries. ",
            )
        )
        tainted_label.setWordWrap(True)
        tainted_label.setStyleSheet("font-size: 14px; color: white;")
        grid.addWidget(tainted_label, 4, 1)

        backports_legend = GradientLegend(
            _("Sources", "backports"), QColor("lightgrey"), QColor("darkgrey")
        )
        grid.addWidget(backports_legend, 5, 0)
        backports_label = QLabel(
            _(
                "Sources",
                "- include new versions of packages, and new packages, that do not meet the updates policy.",
            )
        )
        backports_label.setWordWrap(True)
        backports_label.setStyleSheet("font-size: 14px; color: white;")
        grid.addWidget(backports_label, 5, 1)

        note_legend = GradientLegend(
            _("Sources", "Note! "), QColor("#e6c200"), QColor("#e6c200")
        )
        grid.addWidget(note_legend, 6, 0)
        note_label = QLabel(
            _(
                "Sources",
                """If you enabled the online repositories during installation, some media sources should be installed already. Otherwise, we will now configure these online repositories. If this computer will have access to the Internet, you can delete the <i>Local</i> entry from the list of repositories.""",
            )
        )
        note_label.setWordWrap(True)
        note_label.setStyleSheet("font-size: 14px; color: white;")
        grid.addWidget(note_label, 6, 1)
        note_legend = GradientLegend(
            _("Sources", "Note! "), QColor("#e6c200"), QColor("#e6c200")
        )
        layout.addLayout(grid)
        content_label = QLabel(
            _(
                "Sources",
                "Now, please enable or disable the online repositories of your choice: click on the <i>Edit software repositories</i> button. Select at least the <i>release</i> and <i>updates</i> pair. <i>Debug</i> and <i>Testing</i> are for special cases.",
            )
            + "<BR />"
            + _(
                "Sources",
                "After you have checked and enabled the repositories you need, you can go to the next slide.",
            )
        )
        content_label.setWordWrap(True)
        content_label.setStyleSheet("font-size: 14px; color: white;")
        layout.addWidget(content_label)
        ns = NetworkState()
        if not ns.isOffLine:
            net_layout = QHBoxLayout()
            net_layout.addStretch(1)
            network_button = MyPushButton(_("Sources", "Configure network"))
            net_layout.addWidget(network_button)
            net_layout.addStretch(1)
            network_button.clicked.connect(
                partial(
                    self.command,
                    [
                        "/usr/bin/draknetcenter",
                    ],
                )
            )
            layout.addLayout(net_layout)
        button_layout = QHBoxLayout()
        button_layout.addStretch(1)
        configure_button = MyPushButton(_("Sources", "Edit software sources") + " *")
        configure_button.clicked.connect(
            partial(
                self.command,
                [
                    "/usr/bin/drakrpm-edit-media",
                ],
            )
        )
        button_layout.addWidget(configure_button)
        button_layout.addStretch(1)
        layout.addLayout(button_layout)
        layout.addStretch(0)

        self.setLayout(layout)


class Updates(SlidePage):
    def __init__(self):
        #  The button in the buttons bar
        super().__init__(_("Updates", "Update"))

        #  vertical layout
        layout = QVBoxLayout()
        layout.addStretch(0)

        title_label = QLabel(_("Updates", "How Mageia manages updates"))
        title_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
        title_label.setStyleSheet("font-size: 28px; color: white; font-weight: bold;")
        layout.addWidget(title_label)

        content_label = QLabel(
            _(
                "Updates",
                "Mageia provides software which may be updated in order to fix bugs or security issues. It is highly recommended that you update your system regularly. \
An Update icon will appear in your task bar when new updates are available. To run the updates, just click on the icon below and give your user password - or use the Software Manager (root password). \
This is a background process and you will be able to use your computer normally during the updates.",
            )
        )
        content_label.setWordWrap(True)
        content_label.setStyleSheet("font-size: 16px; color: white; padding: 0px 60px")
        layout.addWidget(content_label)

        button_layout = QHBoxLayout()
        button_layout.addStretch(1)
        check_button = MyPushButton(_("Updates", "Check system updates") + " *")
        check_button.clicked.connect(
            partial(
                self.command,
                [
                    "/usr/bin/drakrpm-update",
                ],
            )
        )
        button_layout.addWidget(check_button)
        button_layout.addStretch(1)
        layout.addLayout(button_layout)
        button2_layout = QHBoxLayout()
        button2_layout.addStretch(1)
        advisories_button = MyPushButton(_("Updates", "Advisories of updates (en)"))
        advisories_button.clicked.connect(
            partial(self.weblink, "https://advisories.mageia.org/")
        )
        button2_layout.addWidget(advisories_button)
        button2_layout.addStretch(1)
        layout.addLayout(button2_layout)
        layout.addStretch(0)

        self.setLayout(layout)


class Mcc(SlidePage):
    def __init__(self):
        #  The button in the buttons bar, shortcut for Mageia Control Center
        super().__init__(_("Mcc", "MCC"))

        #  vertical layout
        layout = QVBoxLayout()
        layout.addStretch(0)

        title_label = QLabel(_("Mcc", "Mageia Control Center"))
        title_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
        title_label.setStyleSheet("font-size: 28px; color: white; font-weight: bold;")
        layout.addWidget(title_label)

        entries_list = [
            _("Mcc", "Software Management"),
            _("Mcc", "Hardware"),
            _("Mcc", "Network and Internet"),
            _("Mcc", "System"),
            _("Mcc", "Network Sharing"),
            _("Mcc", "Local Disks"),
            _("Mcc","Security"),
            _("Mcc", "Boot"),
        ]

        content_label = QLabel(
            _(
                "Mcc",
                "<b>Mageia Control Center</b> (aka drakconf) is a set of tools to help you configure your system.",
            )
            + "<BR>• "
            + "<BR>• ".join(entries_list)
        )
        content_label.setWordWrap(True)
        content_label.setStyleSheet("font-size: 14px; color: white; padding: 0px 60px")
        layout.addWidget(content_label)

        button_layout = QHBoxLayout()
        button_layout.addStretch(1)
        mcc_button = MyPushButton(_("Mcc", "Mageia Control Center") + " *")
        mcc_button.clicked.connect(
            partial(
                self.command,
                [
                    "/usr/bin/drakconf",
                ],
            )
        )
        button_layout.addWidget(mcc_button)
        button_layout.addStretch(1)
        layout.addLayout(button_layout)
        button2_layout = QHBoxLayout()
        button2_layout.addStretch(1)
        doc_button = MyPushButton(_("Mcc", "MCC documentation"))
        doc_button.clicked.connect(partial(self.weblink, "https://www.mageia.org/doc"))
        button2_layout.addWidget(doc_button)
        button2_layout.addStretch(1)
        layout.addLayout(button2_layout)
        layout.addStretch(0)

        self.setLayout(layout)


class InstallSoftware(SlidePage):
    def __init__(self, user):
        #:  The button in the buttons bar
        super().__init__(_("InstallSoftware", "Install software"))

        #  vertical layout
        layout = QVBoxLayout()
        layout.addStretch(0)

        title_label = QLabel(_("InstallSoftware", "Install and remove software"))
        title_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
        title_label.setStyleSheet("font-size: 28px; color: white; font-weight: bold;")
        layout.addWidget(title_label)

        content_label = QLabel(
            _(
                "InstallSoftware",
                "With Mageia, you will find the software in the media repositories. Mageia users simply access these media via one of the Software Managers.",
            )
        )
        content_label.setWordWrap(True)
        content_label.setStyleSheet("font-size: 14px; color: white; padding: 0px 60px")
        layout.addWidget(content_label)

        button_layout = QHBoxLayout()
        button_layout.addStretch(1)
        #: Normally, this is not to translate
        button = MyPushButton(_("InstallSoftware", "RPMdrake") + " *")
        button.clicked.connect(
            partial(
                self.command,
                [
                    "/usr/bin/drakconf",
                ],
            )
        )
        button_layout.addWidget(button)
        button_layout.addStretch(1)
        layout.addLayout(button_layout)
        button2_layout = QHBoxLayout()
        button2_layout.addStretch(1)
        #: Normally, this is not to translate
        doc_button = MyPushButton(_("InstallSoftware", "Dnfdragora"))
        doc_button.clicked.connect(
            partial(self.install_and_launch, ["dnfdragora", "/usr/bin/dnfdragora"])
        )
        button2_layout.addWidget(doc_button)
        button2_layout.addStretch(1)
        layout.addLayout(button2_layout)

        if user != "live":
            text = _(
                "InstallSoftware",
                "The next slide shows a small selection of popular applications - any of which may be installed at this point.<BR/>",
            )
            text += _("InstallSoftware", "You can find a more detailed list here:")
        else:
            text = _("InstallSoftware", "You can find a more detailed list here:")
        content_label2 = QLabel(text)
        content_label2.setWordWrap(True)
        content_label2.setStyleSheet("font-size: 14px; color: white; padding: 0px 60px")
        layout.addWidget(content_label2)

        button3_layout = QHBoxLayout()
        button3_layout.addStretch(1)
        app_button = MyPushButton(_("InstallSoftware", "List of applications (wiki)"))
        app_button.clicked.connect(
            partial(
                self.weblink,
                _("InstallSoftware", "https://wiki.mageia.org/en/List_of_applications"),
            )
        )
        button3_layout.addWidget(app_button)
        button3_layout.addStretch(1)
        layout.addLayout(button3_layout)
        layout.addStretch(0)

        self.setLayout(layout)


class Applications(SlidePage):
    def __init__(self):
        #:  The button in the buttons bar
        super().__init__(_("mw-ui", "Applications"))

        self.items = []
        layout = QVBoxLayout()
        content_layout = QHBoxLayout()
        nav_layout = QVBoxLayout()
        content_label = QLabel(
            "<b>"
            + _(
                "mw-ui",
                "Here is a small selection of popular applications - any of which may be installed or launched at this point.",
            )
            + "<BR />"
            + _("mw-ui", "Ensure that you have enabled the <i>Media sources</i>.")
            + "</b>"
        )
        content_label.setWordWrap(True)
        content_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
        content_label.setStyleSheet(
            "font-size: 12px; color: black; background-color: gold;"
        )
        layout.addWidget(content_label)

        self.nav = Breadcrumb(lateral=True)
        entries = [
            #: category entries in Applications tab
            {"name": _("mw-ui", "Featured"), "group": "featured"},
            {"name": _("mw-ui", "Games"), "group": "games"},
            {"name": _("mw-ui", "Internet"), "group": "internet"},
            {"name": _("mw-ui", "Video"), "group": "video"},
            {"name": _("mw-ui", "Audio"), "group": "audio"},
            {"name": _("mw-ui", "Office"), "group": "office"},
            {"name": _("mw-ui", "Graphics"), "group": "graphics"},
            {"name": _("mw-ui", "System"), "group": "system"},
            {"name": _("mw-ui", "Programming"), "group": "programming"},
        ]
        i = 0
        for entry in entries:
            self.nav.add_item(entry["name"], i)
            i += 1
        self.nav.setFixedWidth(int(content_label.width() / 4))
        nav_layout.addWidget(self.nav)
        nav_layout.addStretch(0)

        content_layout.addLayout(nav_layout)
        layout.addLayout(content_layout)
        self.stack = AppListStack(entries, self.nav)
        self.nav.set_slideshow(self.stack)
        content_layout.addWidget(self.stack)
        self.setLayout(layout)

    def showEvent(self, event):
        self.stack.goto_slide(0)


class AppListStack(QStackedWidget):
    """Collection of stacked pages of applications lists"""

    def __init__(self, entries, nav):
        super().__init__()
        self.applist = []
        self.nav = nav
        self.current_index = 0
        for entry in entries:
            self.addWidget(AppListPage(entry["group"]))

    def goto_slide(self, index):
        self.current_index = index
        self.setCurrentIndex(index)
        self.nav.set_active_item(index)


class AppListPage(QWidget):
    """Page of applications lists for a group"""

    def __init__(self, group):
        super().__init__()
        self.list_layout = QVBoxLayout()
        index = 0
        for item in AppList:
            if group in item["group"]:
                self.list_layout.addWidget(
                    ApplistItem(
                        item["group"],
                        item["icon"],
                        item["name"],
                        item["title"],
                        item["description"],
                        item["repo"],
                        item["command"],
                        index,
                        self,
                    )
                )
            index += 1
        self.list_layout.addStretch(0)
        self.setLayout(self.list_layout)

    def update_item(self, widget, applist_index):
        index = self.list_layout.indexOf(widget)
        widget.deleteLater()
        item = AppList[applist_index]
        self.list_layout.insertWidget(
                index,
                ApplistItem(
                    item["group"],
                    item["icon"],
                    item["name"],
                    item["title"],
                    item["description"],
                    item["repo"],
                    item["command"],
                    index,
                    self,
                )
            )
        self.update()
        
        

class Configuration(SlidePage):
    def __init__(self):
        #:  The button in the buttons bar
        super().__init__(_("Configuration", "Your configuration"))

        #  vertical layout
        layout = QVBoxLayout()
        layout.addStretch(0)
        ns = NetworkState()
        cf = ConfList(ns)
        for config in cf.configuration:
            content_label = QLabel(config)
            content_label.setWordWrap(True)
            content_label.setStyleSheet("font-size: 14px; color: white; padding: 0px 60px")
            layout.addWidget(content_label)

        # About button
        button_layout = QHBoxLayout()
        button_layout.addStretch(1)
        about_button = MyPushButton(_("Configuration", "About"))
        about_button.clicked.connect(self.about)
        button_layout.addWidget(about_button)
        button_layout.addStretch(1)
        layout.addLayout(button_layout)
        layout.addStretch(0)

        self.setLayout(layout)

    def about(self):
        message = QMessageBox(
            QMessageBox.Icon.Warning,
            _("Configuration", "About Mageiawelcome"),
            #: %1 will be replaced with the release number, %2 with author's names
            _("Configuration", "Release %1<br />Authors : %2")
            % (version.version, "Daniel Napora, Papoteur, Antony Baker<br />"),
        )
        #: Replace with the list of translator's names
        messaget.setDetailedText(
            _("Configuration", "Translators: English is the source language")
        )
        message.exec()


class Live(SlidePage):
    def __init__(self):
        #:  The button in the buttons bar
        super().__init__(_("Live", "Live mode"))

        #  vertical layout
        layout = QVBoxLayout()
        content_label = QLabel(
            _(
                "Live",
                "This mode allows you to try out Mageia without having to actually install it, or make any changes to your computer. However, the Live media also includes an Installer, which can be started when booting the media, or after booting into Live mode, like now.",
            )
        )
        content_label.setWordWrap(True)
        content_label.setStyleSheet("font-size: 14px; color: white; padding: 0px 60px")
        layout.addWidget(content_label)

        content_label2 = QLabel(
            _(
                "Live",
                "Any customization, including installation of additional software, will only survive until you reboot the system, unless you have added a persistence partition.",
            )
        )
        content_label2.setWordWrap(True)
        content_label2.setStyleSheet("font-size: 14px; color: white; padding: 0px 60px")
        layout.addWidget(content_label2)

        
        button_layout = QHBoxLayout()
        button_layout.addStretch(1)
        doc_button = MyPushButton(_("Live", "Installer documentation"))
        doc_button.clicked.connect(
            partial(
                self.weblink,
                #: the link to the local file can be adapted to your language if the documentation is translated
                _("Live", "file:///usr/share/doc/mageia/en/draklive/index.html"),
            )
        )
        button_layout.addWidget(doc_button)
        button_layout.addStretch(1)
        layout.addLayout(button_layout)

        self.setLayout(layout)


class Install(SlidePage):
    def __init__(self):
        #:  The button in the buttons bar
        super().__init__(_("Install", "Install"))

        #  vertical layout
        layout = QVBoxLayout()
        content_label = QLabel(
            _(
                "Install",
                "Here you can choose to permanently install this Mageia system on your computer. Any customizations you have made before launching the installer will be included.",
            )
        )
        content_label.setWordWrap(True)
        content_label.setStyleSheet("font-size: 14px; color: white; padding: 0px 60px")
        layout.addWidget(content_label)

        image = QPixmap("file:/usr/share/icons/draklive-install.png")
        content_image = QLabel()
        content_image.setPixmap(image)
        layout.addWidget(content_image)

        button_layout = QHBoxLayout()
        button_layout.addStretch(1)
        install_button = MyPushButton(_("Install", "Launch installation"))
        install_button.clicked.connect(
            partial(self.command, ["/usr/bin/draklive-install"])
        )
        button_layout.addWidget(install_button)
        button_layout.addStretch(1)
        layout.addLayout(button_layout)

        self.setLayout(layout)


class GradientLegend(QWidget):
    def __init__(self, label, top_color, bottom_color):
        super().__init__()
        self.top_color = top_color
        self.bottom_color = bottom_color
        layout = QHBoxLayout()
        label_widget = QLabel(label)
        label_widget.setStyleSheet("font-size: 14px; color: white; font-weight: bold;")
        label_widget.setAlignment(Qt.AlignmentFlag.AlignCenter)
        layout.addWidget(label_widget)
        self.setLayout(layout)
        self.setAutoFillBackground(True)
        self.setFixedWidth(100)
        self.setFixedHeight(40)

    def paintEvent(self, event):
        painter = QPainter(self)
        gradient = QLinearGradient(0, 0, 0, 20)
        gradient.setColorAt(0.0, self.top_color)
        gradient.setColorAt(1.0, self.bottom_color)
        painter.setBrush(gradient)
        painter.setPen(Qt.PenStyle.NoPen)
        painter.drawRect(self.rect())


class ApplistItem(QWidget, Commands):
    """An element in application list"""

    def __init__(self, group, icon, name, title, description, repo, command, index, parent):
        super().__init__()

        self.index = index
        self.parent = parent
        layout = QHBoxLayout()
        layout.setContentsMargins(2, 2, 2, 2)
        image = QPixmap(icon)
        icon_widget = QLabel()
        icon_widget.setPixmap(image.scaled(32, 32))
        icon_widget.setFixedWidth(32)
        icon_widget.setFixedHeight(32)
        layout.addWidget(icon_widget)

        desc_layout = QVBoxLayout()
        name_label = QLabel(f"<b>{title}</b><br /><i>{description}</i>")
        name_label.setStyleSheet(
                """
                    QLabel {
                        color: white;
                        font-size: 14px;
                    }
                """
        )
        desc_layout.addWidget(name_label)
        layout.addLayout(desc_layout)
        release, inst_repo = is_installed(name)
        if (not release) or (repo != inst_repo and inst_repo == ""):
            # the application is not yet installed, we display an Install button
            button = MyPushButton(_("mw-ui", "Install"))
            button.clicked.connect(partial(self.installation, [name, repo]))
        else:
            if command == "":
                # there is no command associated, we display it is installed
                button = QLabel(_("mw-ui", "Installed"))
                button.setAlignment(Qt.AlignmentFlag.AlignCenter)
                button.setStyleSheet(
                    """
                    QLabel {
                        color: white;
                        font-size: 12px;
                        padding: 0px 0px;
                    }
                    """
                )
            else:
                # display a button for launching command associated
                button = MyPushButton(_("mw-ui", "Launch"))
                button.clicked.connect(partial(self.command, [command]))
        button.setFixedWidth(QApplication.font().pointSize() * 10)
        layout.addWidget(button)
        # label for repository
        repo_label = QLabel(repo)
        repo_label.setFixedWidth(QApplication.font().pointSize() * 8)
        repo_label.setFixedHeight(int(QApplication.font().pointSize() * 2))
        repo_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
        if repo != "":
            repo_label.setStyleSheet(
                """
                    QWidget {
                        background-color: "#FF4C4C";
                        radius: 3
                    }
                    QLabel {
                        color: white;
                        font-size: 14px;
                    }
                """
            )
        layout.addWidget(repo_label)
        self.setLayout(layout)
    
    def installation(self, args):
        self.install(args)
        # Give the signal to reload the app widget
        self.parent.update_item(self, self.index)

class MyPushButton(QPushButton):
    """ For styling PushButton """
    def __init__(self, label):
        super().__init__(label)
        
        self.setStyleSheet(
            """
            QWidget {background-color: lightgray; border-radius: 5px; padding: 8px 8px;}
            QLabel {font-size: 18px;}
            """
        )
        

class BreadcrumbItem(QWidget):
    """Un élément du fil d'Ariane"""

    def __init__(self, title, index, parent=None, lateral=False):
        super().__init__(parent)
        self.title = title
        self.index = index
        self.active = False
        self.lateral = lateral

        # Layout horizontal pour l'élément
        layout = QHBoxLayout(self)

        # Étiquette pour le titre
        self.label = QLabel(title)
        self.label.setAlignment(Qt.AlignmentFlag.AlignCenter)
        self.label.setWordWrap(True)
        self.update_style()

        layout.addWidget(self.label)
        self.setLayout(layout)

        # Rendre l'élément cliquable
        self.setCursor(Qt.CursorShape.PointingHandCursor)

    def set_active(self, active):
        """Définit si cet élément est actif ou non"""
        self.active = active
        self.update_style()

    def set_width(self, width):
        self.setMinimumWidth(width)

    def update_style(self):
        """Met à jour le style en fonction de l'état actif"""
        if self.lateral:
            if self.active:
                self.setStyleSheet(
                    """
                    QLabel {
                        color: white;
                        background-color: #262F45;
                        font-size: 14px;
                        border-radius: 5px;
                        min-height: 30px;
                    }
                    """
                )
            else:
                self.setStyleSheet(
                    """
                    QWidget:hover {
                        background-color: #2397D4;
                        border-radius: 5px;
                        min-height: 30px;
                    }
                    QLabel {
                        color: white;
                        font-size: 14px;
                    }
                    """
                )

        else:
            if self.active:
                self.setStyleSheet(
                    """
                    QWidget {
                        background-color: #2397D4;
                        border-radius: 5px;
                        min-height: 40px;
                    }
                    QLabel {
                        color: white;
                        font-size: 12px;
                        padding: 2px 8px;
                    }
                    """
                )
            else:
                self.setStyleSheet(
                    """
                    QWidget:hover {
                        background-color: #2397D4;
                        border-radius: 5px;
                        min-height: 40px;
                    }
                    QLabel {
                        background-color: white;
                        border-radius: 5px;
                        color: #2c3e50;
                        font-size: 12px;
                        padding: 2px 8px;
                        margins: 5px;
                    }
                    """
                )

    def mousePressEvent(self, event):
        """Détecte le clic sur l'élément"""
        if event.button() == Qt.MouseButton.LeftButton:
            # Émettre un signal personnalisé pour indiquer que cet élément a été cliqué
            self.parent().item_clicked(self.index)

    def showEvent(self, event):
        self.update_style()


class Breadcrumb(QWidget):
    """Fil d'Ariane for navigation in pages or in application groups (lateral)"""

    def __init__(self, parent=None, lateral=False):
        super().__init__(parent)

        # Container for elements
        self.lateral = lateral
        self.container = self
        palette = QPalette()
        palette.setColor(
            QPalette.ColorRole.Window, QColor("#20FFFFFF" if lateral else "#262F45")
        )
        self.container.setPalette(palette)
        self.container.setAutoFillBackground(True)

        self.layout = (
            QVBoxLayout(self.container) if lateral else QHBoxLayout(self.container)
        )
        self.layout.setSpacing(5)
        self.layout.setContentsMargins(5, 0, 5, 0)

        # List for storing elements
        self.items = []

        # reference to slideshow
        self.slideshow = None

    def set_slideshow(self, slideshow):
        """Associe le fil d'Ariane à un diaporama"""
        self.slideshow = slideshow

    def add_item(self, title, index):
        """Ajoute un élément au fil d'Ariane"""
        item = BreadcrumbItem(title, index, self, lateral=self.lateral)
        self.layout.addWidget(item)
        self.items.append(item)
        if not self.lateral:
            width = int(DEFAULT_WIDTH / len(self.items))
            for item in self.items:
                item.set_width(width)

    def set_active_item(self, index):
        """Définit l'élément actif"""
        for i, item in enumerate(self.items):
            item.set_active(i == index)

    def item_clicked(self, index):
        """Appelé quand un élément est cliqué"""
        if self.slideshow:
            self.slideshow.goto_slide(index)


class SlideShowWidget(QStackedWidget):
    """Widget de diaporama avec animations de transition"""

    def __init__(self):
        super().__init__()

        self.current_index = 0
        self.next_index = 0
        self.in_transition = False
        self.animation_duration = 800

        self.setContentsMargins(0, 0, 0, 0)

        # Fil d'Ariane associé
        self.breadcrumb = None
        self.admin_rights = []

    def set_breadcrumb(self, breadcrumb):
        """Associe un fil d'Ariane au diaporama"""
        self.breadcrumb = breadcrumb
        self.breadcrumb.set_slideshow(self)

    def add_slide(self, slide, admin_rights=False):
        """Ajoute une diapositive au diaporama"""
        self.addWidget(slide)
        if self.breadcrumb:
            width = self.breadcrumb.add_item(slide.title, self.count() - 1)
            self.admin_rights.append(admin_rights)

    def next_slide(self):
        """Passe à la diapositive suivante avec animation"""
        if self.in_transition or self.count() <= 1:
            return

        self.next_index = (self.current_index + 1) % self.count()
        self._animate_horizontal_transition(True)  # True = at right
        self.admin_widget.show() if self.admin_rights[
            index
        ] else self.admin_widget.hide()

    def previous_slide(self):
        """Passe à la diapositive précédente avec animation"""
        if self.in_transition or self.count() <= 1:
            return

        self.next_index = (self.current_index - 1) % self.count()
        self._animate_horizontal_transition(False)  # False = at left
        self.admin_widget.show() if self.admin_rights[
            index
        ] else self.admin_widget.hide()

    def goto_slide(self, index):
        """Va directement à une diapositive spécifique"""
        if (
            self.in_transition
            or index == self.current_index
            or index < 0
            or index >= self.count()
        ):
            return

        self.next_index = index

        # Déterminer la direction de l'animation
        forward = self.next_index > self.current_index
        if self.next_index == 0 and self.current_index == self.count() - 1:
            forward = True
        elif self.next_index == self.count() - 1 and self.current_index == 0:
            forward = False

        self._animate_horizontal_transition(forward)
        self.admin_widget.show() if self.admin_rights[
            index
        ] else self.admin_widget.hide()

    def _animate_horizontal_transition(self, forward=True):
        """Anime la transition horizontale entre deux diapositives"""
        self.in_transition = True

        # Mettre à jour le fil d'Ariane
        if self.breadcrumb:
            self.breadcrumb.set_active_item(self.next_index)

        # Widget actuel
        current_widget = self.widget(self.current_index)

        # Widget suivant (à afficher)
        next_widget = self.widget(self.next_index)

        # S'assurer que le widget suivant est visible mais pas encore au premier plan
        next_widget.setGeometry(current_widget.geometry())
        next_widget.show()
        next_widget.raise_()

        # Positionner les widgets pour l'animation
        offset = self.width()

        # Position de départ du widget suivant (en dehors de l'écran)
        if forward:  # Glissement vers la gauche (la nouvelle diapo vient de droite)
            next_widget.move(offset, 0)
        else:  # Glissement vers la droite (la nouvelle diapo vient de gauche)
            next_widget.move(-offset, 0)

        # Animation pour le widget actuel
        self.current_anim = QPropertyAnimation(current_widget, b"pos")
        self.current_anim.setDuration(self.animation_duration)
        self.current_anim.setStartValue(current_widget.pos())
        if forward:  # Glissement vers la gauche
            self.current_anim.setEndValue(QPoint(-offset, 0))
        else:  # Glissement vers la droite
            self.current_anim.setEndValue(QPoint(offset, 0))
        self.current_anim.setEasingCurve(QEasingCurve.Type.OutCubic)

        # Animation pour le nouveau widget
        self.next_anim = QPropertyAnimation(next_widget, b"pos")
        self.next_anim.setDuration(self.animation_duration)
        self.next_anim.setStartValue(next_widget.pos())
        self.next_anim.setEndValue(QPoint(0, 0))
        self.next_anim.setEasingCurve(QEasingCurve.Type.OutCubic)

        # Connecter le signal de fin d'animation
        self.next_anim.finished.connect(self._finish_transition)

        # Démarrer les animations
        self.current_anim.start()
        self.next_anim.start()

    def _finish_transition(self):
        """Nettoie après la fin de l'animation"""
        # Mettre à jour l'indice courant
        self.current_index = self.next_index

        # Cacher tous les widgets sauf celui à l'indice courant
        for i in range(self.count()):
            if i != self.current_index:
                self.widget(i).hide()

        # Terminer la transition
        self.in_transition = False

    def set_admin_rights(self, admin_widget):
        # used to display note at bottom
        self.admin_widget = admin_widget


class SlideShowApp(QMainWindow):
    """Application principale de diaporama"""

    def __init__(self):
        super().__init__()
        #: the application title
        self.setWindowTitle( _("Welcome", "Welcome to Mageia"))
        self.setGeometry(100, 100, 100 + DEFAULT_WIDTH, 700)

        # central Widget
        central_widget = QWidget()
        main_layout = QGridLayout(central_widget)
        main_layout.setContentsMargins(0, 0, 0, 0)
        banner = QLabel()
        picture = self.createGradientBanner(self.width(), 120)
        banner.setPixmap(QPixmap.fromImage(picture))
        main_layout.addWidget(banner, 0, 0)

        # Créer le fil d'Ariane
        self.breadcrumb = Breadcrumb()
        main_layout.addWidget(self.breadcrumb, 1, 0)

        # Créer le diaporama
        self.slideshow = SlideShowWidget()
        self.slideshow.set_breadcrumb(self.breadcrumb)

        self.slideshow.add_slide(Welcome(self.username()))
        if self.username() != "live":
            self.slideshow.add_slide(Sources(), admin_rights=True)
            self.slideshow.add_slide(Updates(), admin_rights=True)
            self.slideshow.add_slide(Mcc(), admin_rights=True)
            self.slideshow.add_slide(
                InstallSoftware(self.username()), admin_rights=True
            )
            self.slideshow.add_slide(Applications())
            self.slideshow.add_slide(Configuration())
        else:
            # Live mode
            self.slideshow.add_slide(Live())
            self.slideshow.add_slide(Mcc())
            self.slideshow.add_slide(InstallSoftware(self.username()))
            # Install on HD
            self.slideshow.add_slide(Install())
        self.slideshow.add_slide(Links())

        # Mettre à jour le fil d'Ariane pour la première diapositive
        self.breadcrumb.set_active_item(0)

        # Ajouter au layout principal
        main_layout.addWidget(self.slideshow, 2, 0)

        # background color at bottom
        widget = QWidget()
        bottom_layout = QHBoxLayout()
        palette = QPalette()
        palette.setColor(QPalette.ColorRole.Window, QColor("#2397D4"))
        widget.setPalette(palette)
        widget.setAutoFillBackground(True)
        widget.setLayout(bottom_layout)
        widget.setContentsMargins(0, 0, 0, 0)
        self.admin_rights = QLabel(
            _("Sources", "(*) Administrator password is needed.")
        )
        bottom_layout.addWidget(self.admin_rights)
        self.slideshow.set_admin_rights(self.admin_rights)
        bottom_layout.addStretch(1)
        self.admin_rights.hide()
        self.cb_launch = QCheckBox(_("mw-ui", "Show this window at startup"))
        self.cb_launch.clicked.connect(self.toogle_start)
        bottom_layout.setAlignment(Qt.AlignmentFlag.AlignJustify)
        bottom_layout.addWidget(self.cb_launch)
        main_layout.addWidget(widget, 3, 0)

        self.setCentralWidget(central_widget)

        self.autostart = Autostart()
        self.cb_launch.setChecked(self.autostart.isEnabled())

    def username(self):
        user = pwd.getpwuid(os.getuid())[4]  # pw_gecos, i e the real name
        if user == "":
            user = pwd.getpwuid(os.getuid())[0]  # login
        return user

    def createGradientBanner(self, width, height):
        image = QImage(width, height, QImage.Format.Format_ARGB32)
        image.fill(QColorConstants.Transparent)

        painter = QPainter(image)
        logo = QPixmap("img/mageia-2013-black-alpha.png")
        gradient = QLinearGradient(0, 0, width, 0)
        gradient.setColorAt(0.0, QColorConstants.Svg.lightgray)
        gradient.setColorAt(1.0, QColorConstants.White)

        painter.fillRect(0, 0, width, height, gradient)
        painter.setCompositionMode(QPainter.CompositionMode.CompositionMode_SourceOver)
        painter.drawPixmap(
            QPoint((width - logo.width()) // 2, (height - logo.height()) // 2), logo
        )
        painter.end()

        return image

    def toogle_start(self):
        if self.cb_launch.isChecked():
            self.autostart.enable()
        else:
            self.autostart.disable()


if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = SlideShowApp()
    window.show()
    sys.exit(app.exec())