diff options
author | Papoteur <papoteur@mageia.org> | 2025-05-09 19:08:43 +0200 |
---|---|---|
committer | Papoteur <papoteur@mageia.org> | 2025-05-22 08:56:42 +0200 |
commit | efe82e845a66e6c8e9bab9124d3d0b10cb1fbd46 (patch) | |
tree | e45308db3c7c5005e71493426995bc91dcf53e1f | |
parent | cd790f7487ab3289ed967ecaac522dfbac1a3da8 (diff) | |
download | mageiawelcome-efe82e845a66e6c8e9bab9124d3d0b10cb1fbd46.tar mageiawelcome-efe82e845a66e6c8e9bab9124d3d0b10cb1fbd46.tar.gz mageiawelcome-efe82e845a66e6c8e9bab9124d3d0b10cb1fbd46.tar.bz2 mageiawelcome-efe82e845a66e6c8e9bab9124d3d0b10cb1fbd46.tar.xz mageiawelcome-efe82e845a66e6c8e9bab9124d3d0b10cb1fbd46.zip |
Port to Qt6 using QtWidgets
-rw-r--r-- | po/fr.po | 6 | ||||
-rw-r--r-- | qml/AppList.py | 59 | ||||
-rw-r--r-- | qml/AppList.qml | 59 | ||||
-rw-r--r-- | qml/Configuration.qml | 54 | ||||
-rw-r--r-- | qml/Install.qml | 37 | ||||
-rw-r--r-- | qml/InstallSoftware.qml | 75 | ||||
-rw-r--r-- | qml/Links.qml | 86 | ||||
-rw-r--r-- | qml/Live.qml | 48 | ||||
-rw-r--r-- | qml/MButton.qml | 21 | ||||
-rw-r--r-- | qml/Mcc.qml | 58 | ||||
-rw-r--r-- | qml/Sources.qml | 219 | ||||
-rw-r--r-- | qml/Updates.qml | 55 | ||||
-rw-r--r-- | qml/Version.qml | 2 | ||||
-rw-r--r-- | qml/Welcome.qml | 36 | ||||
-rw-r--r-- | qml/helpers.py | 164 | ||||
-rw-r--r-- | qml/mageiawelcome.py | 340 | ||||
-rw-r--r-- | qml/mw-ui.qml | 595 | ||||
-rw-r--r-- | qml/ui.py | 1360 |
18 files changed, 1611 insertions, 1663 deletions
@@ -631,8 +631,8 @@ msgid "" "survive until you reboot the system, unless you have added a persistence " "partition." msgstr "" -"Toute personnalisation du système , applications installées, seront " -"conservées jusqu'au prochain redémarrage, à moins que vous n'avez ajouté une " +"Toute personnalisation du système et applications installées seront " +"conservées jusqu'au prochain redémarrage, sauf si vous avez ajouté une " "partition persistante au support amovible." #. the link to the local file can be adapted to your language if the documentation is translated @@ -849,7 +849,7 @@ msgstr "(*) Nécessite le mot de passe Administrateur" #: qml/Updates.qml:6 msgctxt "Updates|" msgid "Update" -msgstr "Mettre à jour" +msgstr "Mises à jour" #: qml/Updates.qml:16 msgctxt "Updates|" diff --git a/qml/AppList.py b/qml/AppList.py new file mode 100644 index 0000000..8ccb99f --- /dev/null +++ b/qml/AppList.py @@ -0,0 +1,59 @@ +from PyQt6.QtWidgets import QApplication +_ = QApplication.translate + +AppList = [ + { "group": "audio featured", "description": _("AppList", "Various Audio Codecs"), "title": "Audio Codecs", "name": "task-codec-audio", "command": "", "repo": "", "icon": "img/codecs-audio.png"}, + { "group": "audio featured", "description": _("AppList", "Various Audio Codecs"), "title": "Audio Codecs", "name": "task-codec-audio", "command": "", "repo": "tainted", "icon": "img/codecs-audio.png"}, + { "group": "video featured", "description": _("AppList", "Various Video Codecs"), "title": "Video Codecs", "name": "task-codec-video", "command": "", "repo": "", "icon": "img/codecs-video.png"}, + { "group": "video featured", "description": _("AppList", "Various Video Codecs"), "title": "Video Codecs", "name": "task-codec-video", "command": "", "repo": "tainted", "icon": "img/codecs-video.png"}, + { "group": "games", "description": _("AppList", "Steam Client (This needs 32-bit repositories enabled (see Media Sources tab)"), "title": "Steam", "name": "steam", "command": "steam", "repo": "steam", "icon": "img/steam.png"}, + { "group": "games", "description": _("AppList", "3D Real Time Strategy"), "title": "Megaglest", "name": "megaglest", "command": "megaglest", "repo": "", "icon": "img/megaglest.png"}, + { "group": "games", "description": _("AppList", "Single/Multi-player first person shooter game"), "title": "Sauerbraten", "name": "sauerbraten", "command": "sauerbraten", "repo": "non-free", "icon": "img/sauerbraten.png"}, + { "group": "games", "description": _("AppList", "Classic 2d jump 'n run sidescroller with Tux "), "title": "Supertux", "name": "supertux", "command": "supertux2", "repo": "", "icon": "img/supertux.png"}, + { "group": "games", "description": _("AppList", "Kart racing game featuring Tux and friends"), "title": "SuperTuxKart", "name": "supertuxkart", "command": "supertuxkart", "repo": "", "icon": "img/supertuxkart.png"}, + { "group": "games", "description": _("AppList", "Postnuclear realtime strategy"), "title": "Warzone 2100", "name": "warzone2100", "command": "warzone2100", "repo": "", "icon": "img/warzone2100.png"}, + { "group": "games", "description": _("AppList", "Fantasy turn-based strategy game"), "title": "Battle for Wesnoth", "name": "wesnoth", "command": "wesnoth", "repo": "", "icon": "img/wesnoth.png"}, + { "group": "games", "description": _("AppList", "RTS Game of Ancient Warfare"), "title": "O A.D", "name": "0ad", "command": "0ad", "repo": "", "icon": "img/0ad.png"}, + { "group": "games", "description": _("AppList", "A collection of more than 1000 solitaire card games"), "title": "PySolFC", "name": "PySolFC", "command": "pysol", "repo": "", "icon": "img/pysol01.png"}, + { "group": "graphics", "description": _("AppList", "3d modeller/renderer"), "title": "Blender", "name": "blender", "command": "blender.nonsse", "repo": "", "icon": "img/blender.png"}, + { "group": "graphics", "description": _("AppList", "Painting program"), "title": "MyPaint", "name": "mypaint", "command": "mypaint", "repo": "", "icon": "img/mypaint.png"}, + { "group": "graphics", "description": _("AppList", "The GNU Image Manipulation Program"), "title": "GIMP", "name": "gimp", "command": "gimp", "repo": "", "icon": "img/gimp.png"}, + { "group": "graphics", "description": _("AppList", "Vector graphics editor"), "title": "Inkscape", "name": "inkscape", "command": "inkscape", "repo": "", "icon": "img/inkscape.png"}, + { "group": "graphics", "description": _("AppList", "Digital photo management application"), "title": "Digikam", "name": "digikam", "command": "digikam", "repo": "", "icon": "img/digikam.png"}, + { "group": "graphics", "description": _("AppList", "Virtual lighttable and darkroom for photographers"), "title": "Darktable", "name": "darktable", "command": "darktable", "repo": "", "icon": "img/darktable.png"}, + { "group": "internet", "description": _("AppList", "Multi-protocol instant messaging client"), "title": "Pidgin", "name": "pidgin", "command": "pidgin", "repo": "", "icon": "img/pidgin.png"}, + { "group": "internet", "description": _("AppList", "Full-featured graphical ftp/ftps/sftp client"), "title": "Filezilla", "name": "filezilla", "command": "filezilla", "repo": "", "icon": "img/filezilla.png"}, + { "group": "internet featured", "description": _("AppList", "Next-generation web browser"), "title": "Firefox", "name": "firefox", "command": "firefox", "repo": "", "icon": "img/firefox.png"}, + { "group": "internet featured", "description": _("AppList", "Lightweight but feature rich bittorrent client"), "title": "Qbittorrent", "name": "qbittorrent", "command": "qbittorrent", "repo": "", "icon": "img/qbittorrent.png"}, + { "group": "internet", "description": _("AppList", "Fast Webbrowser"), "title": "Chromium", "name": "chromium-browser", "command": "chromium-browser", "repo": "", "icon": "img/chromium.png"}, + { "group": "internet", "description": _("AppList", "E-mailnews and RSS client"), "title": "Thunderbird", "name": "thunderbird", "command": "thunderbird", "repo": "", "icon": "img/thunderbird.png"}, + { "group": "internet", "description": _("AppList", "Fast e-mail client"), "title": "Claws Mail", "name": "claws-mail", "command": "claws-mail", "repo": "", "icon": "img/claws-mail.png"}, + { "group": "video featured", "description": _("AppList", "Media Player"), "title": "Smplayer", "name": "smplayer", "command": "smplayer", "repo": "", "icon": "img/smplayer.png"}, + { "group": "video", "description": _("AppList", "A non-linear video editing application"), "title": "Kdenlive", "name": "kdenlive", "command": "kdenlive", "repo": "", "icon": "img/kdenlive.png"}, + { "group": "video featured", "description": _("AppList", "Multimedia player and streamer"), "title": "VLC", "name": "vlc", "command": "vlc", "repo": "", "icon": "img/vlc.png"}, + { "group": "video", "description": _("AppList", "For converting video to a selection of codecs"), "title": "Handbrake", "name": "handbrake", "command": "ghb", "repo": "tainted", "icon": "img/handbrake.png"}, + { "group": "video featured", "description": _("AppList", "Multimedia player and streamer"), "title": "VLC", "name": "vlc", "command": "vlc", "repo": "tainted", "icon": "img/vlc.png"}, + { "group": "video", "description": _("AppList", "Media Center"), "title": "Kodi", "name": "kodi", "command": "kodi", "repo": "", "icon": "img/kodi.png"}, + { "group": "audio", "description": _("AppList", "Audio Player similar to Winamp"), "title": "Qmmp", "name": "qmmp", "command": "qmmp", "repo": "", "icon": "img/qmmp.png"}, + { "group": "audio", "description": _("AppList", "Modern music player and library organizer"), "title": "Clementine", "name": "clementine", "command": "clementine", "repo": "", "icon": "img/clementine.png"}, + { "group": "audio", "description": _("AppList", "An audio file converterCD ripper and replay gain tool"), "title": "Soundkonverter", "name": "soundkonverter", "command": "soundkonverter", "repo": "", "icon": "img/soundkonverter.png"}, + { "group": "programming", "description": _("AppList", "Scientific Python Development Environment "), "title": "Spyder", "name": "spyder", "command": "spyder3", "repo": "", "icon": "img/spyder3.png"}, + { "group": "programming", "description": _("AppList", "Lightweight IDE for Qt"), "title": "Qt Creator", "name": "qt-creator", "command": "qtcreator", "repo": "", "icon": "img/qt-creator.png"}, + { "group": "programming", "description": _("AppList", "IDE for free pascal"), "title": "Lazarus", "name": "lazarus", "command": "lazarus", "repo": "", "icon": "img/lazarus.png"}, + { "group": "system", "description": _("AppList", "Sophisticated cd/dvd burning application"), "title": "K3b", "name": "k3b", "command": "k3b", "repo": "", "icon": "img/k3b.png"}, + { "group": "system", "description": _("AppList", "Write ISO images on USB device"), "title": "Isodumper", "name": "isodumper", "command": "isodumper", "repo": "", "icon": "img/isodumper.png"}, + { "group": "system", "description": _("AppList", "Partition editor"), "title": "GParted", "name": "gparted", "command": "gparted", "repo": "", "icon": "img/gparted.png"}, + { "group": "system featured", "description": _("AppList", "Extra community-made background images"), "title": "mageia-theme-extra", "name": "mageia-theme-extra", "command": "", "repo": "", "icon": "img/mageia-theme-extra.png"}, + { "group": "system", "description": _("AppList", "Clean junk to free disk space and maintain privacy "), "title": "BleachBit", "name": "bleachbit", "command": "bleachbit", "repo": "", "icon": "img/bleachbit.png"}, + { "group": "system", "description": _("AppList", "A printer administration tool"), "title": "System Config Printer", "name": "system-config-printer", "command": "system-config-printer", "repo": "", "icon": "img/system-config-printer.png"}, + { "group": "system", "description": _("AppList", "Virtualization software"), "title": _("AppList", "VirtualBox (only with 64-bit systems)"), "name": "virtualbox", "command": "VirtualBox", "repo": "", "icon": "img/virtualbox.png"}, + { "group": "office", "description": _("AppList", "LibreOffice Spreadsheet Application"), "title": "LibreOffice Calc", "name": "libreoffice-calc", "command": "oocalc", "repo": "", "icon": "img/libreoffice-calc.png"}, + { "group": "office", "description": _("AppList", "LibreOffice Word Processor Application"), "title": "LibreOffice Writer", "name": "libreoffice-writer", "command": "oowriter", "repo": "", "icon": "img/libreoffice-writer.png"}, + { "group": "office", "description": _("AppList", "KDE office suite"), "title": "Calligra", "name": "calligra", "command": "", "repo": "", "icon": "img/calligra.png"}, + { "group": "office", "description": _("AppList", "Lean and fastbut full-featured word processor"), "title": "AbiWord", "name": "abiword", "command": "abiword", "repo": "", "icon": "img/abiword.png"}, + { "group": "office", "description": _("AppList", "A full-featured spreadsheet for GNOME"), "title": "Gnumeric", "name": "gnumeric", "command": "gnumeric", "repo": "", "icon": "img/gnumeric.png"}, + { "group": "office", "description": _("AppList", "E-book converter and library management"), "title": "Calibre", "name": "calibre", "command": "calibre", "repo": "", "icon": "img/calibre.png"}, + { "group": "office", "description": _("AppList", "Desktop Publishing Program"), "title": "Scribus", "name": "scribus", "command": "scribus", "repo": "", "icon": "img/scribus.png"}, + { "group": "office", "description": _("AppList", "Free easy personal accounting for all"), "title": "HomeBank", "name": "homebank", "command": "homebank", "repo": "", "icon": "img/homebank.png"}, + { "group": "office", "description": _("AppList", "Personal Finance Management Tool"), "title": "Skrooge", "name": "skrooge", "command": "skrooge", "repo": "", "icon": "img/skrooge.png"}, +] diff --git a/qml/AppList.qml b/qml/AppList.qml deleted file mode 100644 index cd5945b..0000000 --- a/qml/AppList.qml +++ /dev/null @@ -1,59 +0,0 @@ -import QtQuick 2.2 -import QtQml.Models 2.1 - -ListModel { - ListElement { group: "audio featured";description: qsTr("Various Audio Codecs"); title: "Audio Codecs";name: "task-codec-audio";command: "";repo: "";icon: "img/codecs-audio.png";} - ListElement { group: "audio featured";description: qsTr("Various Audio Codecs"); title: "Audio Codecs";name: "task-codec-audio";command: "";repo: "tainted";icon: "img/codecs-audio.png";} - ListElement { group: "video featured";description: qsTr("Various Video Codecs"); title: "Video Codecs";name: "task-codec-video";command: "";repo: "";icon: "img/codecs-video.png";} - ListElement { group: "video featured";description: qsTr("Various Video Codecs"); title: "Video Codecs";name: "task-codec-video";command: "";repo: "tainted";icon: "img/codecs-video.png";} - ListElement { group: "games";description: qsTr("Steam Client (This needs 32-bit repositories enabled, see Media Sources tab)"); title: "Steam";name: "steam";command: "steam";repo: "steam";icon: "img/steam.png";} - ListElement { group: "games";description: qsTr("3D Real Time Strategy"); title: "Megaglest";name: "megaglest";command: "megaglest";repo: "";icon: "img/megaglest.png";} - ListElement { group: "games";description: qsTr("Single/Multi-player first person shooter game"); title: "Sauerbraten";name: "sauerbraten";command: "sauerbraten";repo: "non-free";icon: "img/sauerbraten.png";} - ListElement { group: "games";description: qsTr("Classic 2d jump 'n run sidescroller with Tux "); title: "Supertux";name: "supertux";command: "supertux2";repo: "";icon: "img/supertux.png";} - ListElement { group: "games";description: qsTr("Kart racing game featuring Tux and friends"); title: "SuperTuxKart";name: "supertuxkart";command: "supertuxkart";repo: "";icon: "img/supertuxkart.png";} - ListElement { group: "games";description: qsTr("Postnuclear realtime strategy"); title: "Warzone 2100";name: "warzone2100";command: "warzone2100";repo: "";icon: "img/warzone2100.png";} - ListElement { group: "games";description: qsTr("Fantasy turn-based strategy game"); title: "Battle for Wesnoth";name: "wesnoth";command: "wesnoth";repo: "";icon: "img/wesnoth.png";} - ListElement { group: "games";description: qsTr("RTS Game of Ancient Warfare"); title: "O A.D";name: "0ad";command: "0ad";repo: "";icon: "img/0ad.png";} - ListElement { group: "games";description: qsTr("A collection of more than 1000 solitaire card games"); title: "PySolFC";name: "PySolFC";command: "pysol";repo: "";icon: "img/pysol01.png";} - ListElement { group: "graphics";description: qsTr("3d modeller/renderer"); title: "Blender";name: "blender";command: "blender.nonsse";repo: "";icon: "img/blender.png";} - ListElement { group: "graphics";description: qsTr("Painting program"); title: "MyPaint";name: "mypaint";command: "mypaint";repo: "";icon: "img/mypaint.png";} - ListElement { group: "graphics";description: qsTr("The GNU Image Manipulation Program"); title: "GIMP";name: "gimp";command: "gimp";repo: "";icon: "img/gimp.png";} - ListElement { group: "graphics";description: qsTr("Vector graphics editor"); title: "Inkscape";name: "inkscape";command: "inkscape";repo: "";icon: "img/inkscape.png";} - ListElement { group: "graphics";description: qsTr("Digital photo management application"); title: "Digikam";name: "digikam";command: "digikam";repo: "";icon: "img/digikam.png";} - ListElement { group: "graphics";description: qsTr("Virtual lighttable and darkroom for photographers"); title: "Darktable";name: "darktable";command: "darktable";repo: "";icon: "img/darktable.png";} - ListElement { group: "internet";description: qsTr("Multi-protocol instant messaging client"); title: "Pidgin";name: "pidgin";command: "pidgin";repo: "";icon: "img/pidgin.png";} - ListElement { group: "internet";description: qsTr("Full-featured graphical ftp/ftps/sftp client"); title: "Filezilla";name: "filezilla";command: "filezilla";repo: "";icon: "img/filezilla.png";} - ListElement { group: "internet featured";description: qsTr("Next-generation web browser"); title: "Firefox";name: "firefox";command: "firefox";repo: "";icon: "img/firefox.png";} - ListElement { group: "internet featured";description: qsTr("Lightweight but feature rich bittorrent client"); title: "Qbittorrent";name: "qbittorrent";command: "qbittorrent";repo: "";icon: "img/qbittorrent.png";} - ListElement { group: "internet";description: qsTr("Fast Webbrowser"); title: "Chromium";name: "chromium-browser";command: "chromium-browser";repo: "";icon: "img/chromium.png";} - ListElement { group: "internet";description: qsTr("E-mail, news and RSS client"); title: "Thunderbird";name: "thunderbird";command: "thunderbird";repo: "";icon: "img/thunderbird.png";} - ListElement { group: "internet";description: qsTr("Fast e-mail client"); title: "Claws Mail";name: "claws-mail";command: "claws-mail";repo: "";icon: "img/claws-mail.png";} - ListElement { group: "video featured";description: qsTr("Media Player"); title: "Smplayer";name: "smplayer";command: "smplayer";repo: "";icon: "img/smplayer.png";} - ListElement { group: "video";description: qsTr("A non-linear video editing application"); title: "Kdenlive";name: "kdenlive";command: "kdenlive";repo: "";icon: "img/kdenlive.png";} - ListElement { group: "video featured";description: qsTr("Multimedia player and streamer"); title: "VLC";name: "vlc";command: "vlc";repo: "";icon: "img/vlc.png";} - ListElement { group: "video";description: qsTr("For converting video to a selection of codecs"); title: "Handbrake";name: "handbrake";command: "ghb";repo: "tainted";icon: "img/handbrake.png";} - ListElement { group: "video featured";description: qsTr("Multimedia player and streamer"); title: "VLC";name: "vlc";command: "vlc";repo: "tainted";icon: "img/vlc.png";} - ListElement { group: "video";description: qsTr("Media Center"); title: "Kodi";name: "kodi";command: "kodi";repo: "";icon: "img/kodi.png";} - ListElement { group: "audio";description: qsTr("Audio Player similar to Winamp"); title: "Qmmp";name: "qmmp";command: "qmmp";repo: "";icon: "img/qmmp.png";} - ListElement { group: "audio";description: qsTr("Modern music player and library organizer"); title: "Clementine";name: "clementine";command: "clementine";repo: "";icon: "img/clementine.png";} - ListElement { group: "audio";description: qsTr("An audio file converter, CD ripper and replay gain tool"); title: "Soundkonverter";name: "soundkonverter";command: "soundkonverter";repo: "";icon: "img/soundkonverter.png";} - ListElement { group: "programming";description: qsTr("Scientific Python Development Environment "); title: "Spyder";name: "spyder";command: "spyder3";repo: "";icon: "img/spyder3.png";} - ListElement { group: "programming";description: qsTr("Lightweight IDE for Qt"); title: "Qt Creator";name: "qt-creator";command: "qtcreator";repo: "";icon: "img/qt-creator.png";} - ListElement { group: "programming";description: qsTr("IDE for free pascal"); title: "Lazarus";name: "lazarus";command: "lazarus";repo: "";icon: "img/lazarus.png";} - ListElement { group: "system";description: qsTr("Sophisticated cd/dvd burning application"); title: "K3b";name: "k3b";command: "k3b";repo: "";icon: "img/k3b.png";} - ListElement { group: "system";description: qsTr("Write ISO images on USB device"); title: "Isodumper";name: "isodumper";command: "isodumper";repo: "";icon: "img/isodumper.png";} - ListElement { group: "system";description: qsTr("Partition editor"); title: "GParted";name: "gparted";command: "gparted";repo: "";icon: "img/gparted.png";} - ListElement { group: "system featured";description: qsTr("Extra community-made background images"); title: "mageia-theme-extra";name: "mageia-theme-extra";command: "";repo: "";icon: "img/mageia-theme-extra.png";} - ListElement { group: "system";description: qsTr("Clean junk to free disk space and maintain privacy "); title: "BleachBit";name: "bleachbit";command: "bleachbit";repo: "";icon: "img/bleachbit.png";} - ListElement { group: "system";description: qsTr("A printer administration tool"); title: "System Config Printer";name: "system-config-printer";command: "system-config-printer";repo: "";icon: "img/system-config-printer.png";} - ListElement { group: "system";description: qsTr("Virtualization software"); title: qsTr("VirtualBox (only with 64-bit systems)");name: "virtualbox";command: "VirtualBox";repo: "";icon: "img/virtualbox.png";} - ListElement { group: "office";description: qsTr("LibreOffice Spreadsheet Application"); title: "LibreOffice Calc";name: "libreoffice-calc";command: "oocalc";repo: "";icon: "img/libreoffice-calc.png";} - ListElement { group: "office";description: qsTr("LibreOffice Word Processor Application"); title: "LibreOffice Writer";name: "libreoffice-writer";command: "oowriter";repo: "";icon: "img/libreoffice-writer.png";} - ListElement { group: "office";description: qsTr("KDE office suite"); title: "Calligra";name: "calligra";command: "";repo: "";icon: "img/calligra.png";} - ListElement { group: "office";description: qsTr("Lean and fast, but full-featured word processor"); title: "AbiWord";name: "abiword";command: "abiword";repo: "";icon: "img/abiword.png";} - ListElement { group: "office";description: qsTr("A full-featured spreadsheet for GNOME"); title: "Gnumeric";name: "gnumeric";command: "gnumeric";repo: "";icon: "img/gnumeric.png";} - ListElement { group: "office";description: qsTr("E-book converter and library management"); title: "Calibre";name: "calibre";command: "calibre";repo: "";icon: "img/calibre.png";} - ListElement { group: "office";description: qsTr("Desktop Publishing Program"); title: "Scribus";name: "scribus";command: "scribus";repo: "";icon: "img/scribus.png";} - ListElement { group: "office";description: qsTr("Free easy personal accounting for all"); title: "HomeBank";name: "homebank";command: "homebank";repo: "";icon: "img/homebank.png";} - ListElement { group: "office";description: qsTr("Personal Finance Management Tool"); title: "Skrooge";name: "skrooge";command: "skrooge";repo: "";icon: "img/skrooge.png";} -} diff --git a/qml/Configuration.qml b/qml/Configuration.qml deleted file mode 100644 index b36f28d..0000000 --- a/qml/Configuration.qml +++ /dev/null @@ -1,54 +0,0 @@ -import QtQuick 2 -import QtQuick.Controls 1 -import QtQuick.Dialogs 1.1 - -// Configuration summary Page -Rectangle { - LayoutMirroring.enabled: (direction == "LTR" ? false : true) - LayoutMirroring.childrenInherit: true - Version {id:version} - property var title: qsTr("Your configuration") - width: view.width; height: view.height - Loader { sourceComponent: slidebackground ; - anchors.fill: parent} - - Column { - Rectangle{ - height: 50 - width:1 - color:"transparent" - } - ListView { - id: confList - width: view.width - height: view.height -150 - spacing: 3 - model: ConfList - delegate: Row { - width: view.width - Label { - text: name - leftPadding: 50 - rightPadding: 50 - textFormat: Text.RichText - color: "white" - } - } - } - MButton { - anchors.horizontalCenter: parent.horizontalCenter - objectName: "launch" - onMbuttonClicked: { about.open() } - buttonText: qsTr("About") - } - MessageDialog { - id: about - title: qsTr("About Mageiawelcome") - //: %1 will be replaced with the release number, %2 with author's names - text: qsTr("Release %1<br />Authors : %2").arg(version.version).arg("Daniel Napora, Papoteur, Antony Baker<br />") - //: replace with the list of translator's names - detailedText: qsTr("Translators: English is the source language") - standardButtons: StandardButton.Close - } - } -} diff --git a/qml/Install.qml b/qml/Install.qml deleted file mode 100644 index bd81596..0000000 --- a/qml/Install.qml +++ /dev/null @@ -1,37 +0,0 @@ -import QtQuick 2 -import QtQuick.Controls 1 - -Rectangle { - //: the button in buttons bar - property var title: qsTr("Install") - width: view.width; height: view.height - Loader { sourceComponent: slidebackground ; - anchors.fill: parent} - Column { - spacing: 10 - anchors.centerIn: parent - anchors.verticalCenter: parent.verticalCenter - - Label { - horizontalAlignment: TextInput.AlignHCenter - anchors.horizontalCenter: parent.horizontalCenter - text: qsTr("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."); - textFormat: Text.RichText - wrapMode: Text.WordWrap - color: "white" - width: view.width * 0.8 - } - - Image { - anchors.horizontalCenter: parent.horizontalCenter - source: "file:/usr/share/icons/draklive-install.png" - } - MButton { - anchors.horizontalCenter: parent.horizontalCenter - objectName: "launch" - onMbuttonClicked: { launch.command(["/usr/bin/draklive-install",])} - buttonText: qsTr("Launch installation") - } - - } -} diff --git a/qml/InstallSoftware.qml b/qml/InstallSoftware.qml deleted file mode 100644 index f7d964b..0000000 --- a/qml/InstallSoftware.qml +++ /dev/null @@ -1,75 +0,0 @@ -import QtQuick 2 -import QtQuick.Controls 1 - -// Install software page -Rectangle { - property var title: qsTr("Install software") - width: view.width; height: view.height - Loader { sourceComponent: slidebackground ; - anchors.fill: parent} - Column { - spacing: 10 - Label { - text: qsTr("Install and remove software") - width: slideshow.width - topPadding: 30; leftPadding: 20; - padding: 10 - font.bold: true - wrapMode: Text.WordWrap - color: "white" - } - Label { - text: qsTr("With Mageia, you will find the software in the media repositories. Mageia users simply access these media via one of the Software Managers."); - width: slideshow.width - padding: 20 - wrapMode: Text.WordWrap - textFormat: Text.RichText - color: "white" - } - MButton { - anchors.left: parent.left; anchors.leftMargin: 20; - width: slideshow.width * .35 - objectName: "launch" - onMbuttonClicked: { launch.command(["/usr/bin/rpmdrake",])} - buttonText: qsTr("RPMdrake")+" *" - } - MButton { - anchors.left: parent.left; anchors.leftMargin: 20; - width: slideshow.width * .35 - objectName: "launch" - onMbuttonClicked: { launch.install_and_launch(["dnfdragora","/usr/bin/dnfdragora"])} - buttonText: qsTr("Dnfdragora") - } - Label { - text: (user == 'live' ? "": qsTr("The next slide shows a small selection of popular applications - any of which may be installed at this point.<BR/>")); - width: slideshow.width - padding: 20 - wrapMode: Text.WordWrap - textFormat: Text.RichText - color: "white" - } - Label { - text: (user == 'live' ? qsTr("You can find a detailed list here:") : qsTr("You can find a more detailed list here:")); - width: slideshow.width - padding: 20 - wrapMode: Text.WordWrap - textFormat: Text.RichText - color: "white" - } - MButton { - anchors.left: parent.left; anchors.leftMargin: 20 - width: slideshow.width * .35 - objectName: "link" - //: Translate only if the link is to a specific page for your language - onMbuttonClicked: { link.weblink(qsTr("https://wiki.mageia.org/en/List_of_applications"))} - buttonText: qsTr("List of applications (wiki)") - } - } - Label { - anchors {top: parent.bottom; topMargin: 3; horizontalCenter: parent.left; horizontalCenterOffset: parent.width * .4 } - text: qsTr("(*) Administrator password is needed") - wrapMode: Text.WordWrap - font.italic: true - color: "white" - } -} diff --git a/qml/Links.qml b/qml/Links.qml deleted file mode 100644 index 770291b..0000000 --- a/qml/Links.qml +++ /dev/null @@ -1,86 +0,0 @@ -import QtQuick 2 -import QtQuick.Controls 1 -import QtQuick.Controls.Styles 1 - -// Links page -Rectangle { - property var title: qsTr("More information") - width: view.width; height: view.height - Loader { sourceComponent: slidebackground ; - anchors.fill: parent} - Column { - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - Grid { - columns: 3 - spacing: view.width * .03 - Label { - horizontalAlignment: TextInput.AlignHCenter - width: view.width * .2 - text: qsTr("Documentation") - wrapMode: Text.WordWrap - font.bold: true - color: "white" - } - Label { - horizontalAlignment: TextInput.AlignHCenter - width: view.width * .2 - text: qsTr("Support") - wrapMode: Text.WordWrap - font.bold: true - color: "white" - } - Label { - horizontalAlignment: TextInput.AlignHCenter - width: view.width * .2 - text: qsTr("Community") - wrapMode: Text.WordWrap - font.bold: true - color: "white" - } - Repeater{ - model: [{'name': qsTr("Release notes"), 'url': - //: Translate only if the link is to a specific page for your language - qsTr("https://wiki.mageia.org/en/Mageia_9_Release_Notes")}, - {'name': qsTr("Forums"),'url': - //: Translate only if the link is to a specific page for your language - qsTr("https://forums.mageia.org/en/")}, - {'name': qsTr("Community Center"),'url': "https://www.mageia.org/community/"}, - {'name': qsTr("Errata"), 'url': - //: Translate only if the link is to a specific page for your language - qsTr("https://wiki.mageia.org/en/Mageia_9_Errata")}, - {'name': qsTr("Wiki"), 'url': - //: Translate only if the link is to a specific page for your language - qsTr("https://wiki.mageia.org/en/Documentation")}, - {'name': qsTr("Contribute"),'url': "https://www.mageia.org/contribute/"}, - {'name': qsTr("Newcomers Howto"),'url': - //: Translate only if the link is to a specific page for your language - qsTr("https://wiki.mageia.org/en/Newcomers_start_here")}, - {'name': qsTr("Chat Room"), - //: Translate only if the link is to a specific page for your language - 'url': qsTr("ircs://irc.libera.chat:6697/#mageia")}, - {'name': qsTr("Donations"),'url': "https://www.mageia.org/donate/"}, - {'name': qsTr("Documentation"),'url': "https://www.mageia.org/doc/"}, - {'name': qsTr("Bugs tracker"),'url': "https://bugs.mageia.org/"}, - {'name': qsTr("Join us!"),'url': "https://identity.mageia.org/"}] - delegate: Button { - width: view.width * .2 - objectName: "link" - onClicked: { link.weblink(modelData.url)} - style: ButtonStyle { - label: Label { - text: modelData.name - horizontalAlignment: TextInput.AlignHCenter - color: "black" - width: parent.width - wrapMode: Text.WordWrap } - background: Rectangle { - color: "lightgrey" - radius: 5 - } - } - } - } - } - } - } diff --git a/qml/Live.qml b/qml/Live.qml deleted file mode 100644 index 987eccf..0000000 --- a/qml/Live.qml +++ /dev/null @@ -1,48 +0,0 @@ -import QtQuick 2 -import QtQuick.Controls 1 - -Rectangle { - property var title: qsTr("Live mode") - width: view.width; height: view.height - Loader { sourceComponent: slidebackground ; - anchors.fill: parent - } - Column { - anchors.centerIn: parent - spacing: 10 - - Label { - anchors.horizontalCenter: parent.horizontalCenter - horizontalAlignment: TextInput.AlignHCenter - text: qsTr("Live mode") - font.weight: Font.DemiBold - font.pixelSize: Qt.application.font.pixelSize * 1.5 - color: "white" - } - Label { - anchors.horizontalCenter: parent.horizontalCenter - horizontalAlignment: TextInput.AlignHCenter - width: slideshow.width - text:qsTr('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.') - wrapMode: Text.WordWrap;textFormat: Text.RichText - padding: 20 - color: "white" - } - Label { - anchors.horizontalCenter: parent.horizontalCenter - horizontalAlignment: TextInput.AlignHCenter - width: slideshow.width - text:qsTr("Any customization, including installation of additional software, will only survive until you reboot the system, unless you have added a persistence partition.") - wrapMode: Text.WordWrap;textFormat: Text.RichText - padding: 20 - color: "white" - } - MButton { - anchors.horizontalCenter: parent.horizontalCenter - objectName: "link" - //: the link to the local file can be adapted to your language if the documentation is translated - onMbuttonClicked: { link.weblink(qsTr("file:///usr/share/doc/mageia/en/draklive/index.html"))} - buttonText: qsTr("Installer documentation") - } - } -} diff --git a/qml/MButton.qml b/qml/MButton.qml deleted file mode 100644 index f7085e3..0000000 --- a/qml/MButton.qml +++ /dev/null @@ -1,21 +0,0 @@ -// MButton.qml -// Customized button -import QtQuick 2.0 -import QtGraphicalEffects 1 - -Rectangle { - id:mbutton - property alias buttonText: textItem.text - width: textItem.implicitWidth + 10 - height: textItem.implicitHeight + 10 - color: "lightgrey" - radius: 5 - signal mbuttonClicked - MouseArea { - anchors.fill: parent - onClicked: mbuttonClicked() - } - Text {id: textItem - anchors.centerIn: parent - } - } diff --git a/qml/Mcc.qml b/qml/Mcc.qml deleted file mode 100644 index 866287d..0000000 --- a/qml/Mcc.qml +++ /dev/null @@ -1,58 +0,0 @@ -import QtQuick 2 -import QtQuick.Controls 1 - -// MCC Page -Rectangle { - //: The button in the buttons bar, shortcut for Mageia Control Center - property var title: qsTr("MCC") - width: view.width; height: view.height - Loader { sourceComponent: slidebackground ; - anchors.fill: parent} - - Column { - x: 10; y: 30 - spacing: 10 - Label { - text: qsTr("<b>Mageia Control Center</b> (aka drakconf) is a set of tools to help you configure your system.") - width: view.width * 0.9 - padding: 10 - wrapMode: Text.WordWrap - textFormat: Text.RichText - color: "white" - } - Label { - padding: 5 - anchors.horizontalCenter: parent.horizontalCenter - text: "• " + qsTr("Software Management")+"\n• " - + qsTr("Hardware")+"\n• " - + qsTr("Network and Internet")+"\n• " - + qsTr("System")+"\n• " - + qsTr("Network Sharing")+"\n• " - + qsTr("Local Disks")+"\n• " - + qsTr("Security")+"\n• " - + qsTr("Boot"); - wrapMode: Text.WordWrap; - color: "white" - } - - MButton { - anchors.horizontalCenter: parent.horizontalCenter - objectName: "launch" - onMbuttonClicked: { launch.command(["drakconf",])} - buttonText: qsTr("Mageia Control Center")+" *" - } - MButton { - anchors.horizontalCenter: parent.horizontalCenter - objectName: "link" - onMbuttonClicked: { link.weblink("https://www.mageia.org/doc")} - buttonText: qsTr("MCC documentation") - } - } - Label { - anchors {top: parent.bottom; topMargin: 3; horizontalCenter: parent.left; horizontalCenterOffset: parent.width * .4 } - text: qsTr("(*) Administrator password is needed") - wrapMode: Text.WordWrap - font.italic: true - color: "white" - } -} diff --git a/qml/Sources.qml b/qml/Sources.qml deleted file mode 100644 index a43b6a4..0000000 --- a/qml/Sources.qml +++ /dev/null @@ -1,219 +0,0 @@ -import QtQuick 2 -import QtQuick.Controls 1 -import QtQuick.Layouts 1 -import QtQuick.Controls.Styles 1 -import QtGraphicalEffects 1 - -// Configure source page -Rectangle { - property var title: qsTr("Media sources") - width: view.width; height: view.height - Loader { sourceComponent: slidebackground ; - anchors.fill: parent} - Flickable { - width: view.width; height: view.height - contentWidth: gridRepo.width; contentHeight: gridRepo.height - clip: true - flickableDirection: Flickable.VerticalFlick - GridLayout { - id: gridRepo - columns: 2 - Label { - Layout.columnSpan: 2 - Layout.topMargin: 10 - Layout.leftMargin: 10 - text: qsTr("Configure software repositories"); font.bold: true; - color: "white" } - Label { - Layout.columnSpan: 2 - Layout.topMargin: 10 - Layout.leftMargin: 10 - text: qsTr("Mageia official repositories contain:"); - color: "white" } - Button {id: coreBg - Layout.margins: 5 - Layout.alignment: Qt.AlignTop - Layout.fillWidth: true - //height: Qt.application.font.pixelSize * 1.3 - style: ButtonStyle { - label: Label { - horizontalAlignment: TextInput.AlignHCenter - //: Should be as displayed in software manager, thus in general not translated - text: qsTr("core"); - font.bold: true; color: "black"; - } - background: Rectangle { - LinearGradient { - anchors.fill: parent - start: Qt.point(0, 0) - end: Qt.point(0, 20) - gradient: Gradient { - GradientStop { position: 0.0; color: "lightgreen" } - GradientStop { position: 1.0; color: "green" } - } - } - } - - } - } - Label { - text: qsTr("- the free-open-source packages"); - wrapMode: Text.WordWrap - Layout.maximumWidth: slideshow.width -20 - coreBg.width - color: "white" - } - Button { - Layout.margins: 5 - Layout.alignment: Qt.AlignTop - Layout.fillWidth: true - style: ButtonStyle { - label: Label { - horizontalAlignment: TextInput.AlignHCenter - //: Should be as displayed in software manager, thus in general not translated - text: qsTr("nonfree"); - font.bold: true; color: "white"; - } - background: Rectangle { - LinearGradient { - anchors.fill: parent - start: Qt.point(0, 0) - end: Qt.point(0, 20) - gradient: Gradient { - GradientStop { position: 0.0; color: "red" } - GradientStop { position: 1.0; color: "darkred" } - } - } - } - - } - } - Label { - width: parent.width - text: qsTr("- closed-source programs, e.g. Nvidia proprietary drivers, non-free drivers for some Wi-Fi cards, etc"); - Layout.maximumWidth: slideshow.width - 110 - wrapMode: Text.WordWrap - color: "white" - } - Button { - Layout.margins: 5 - Layout.alignment: Qt.AlignTop - Layout.fillWidth: true - style: ButtonStyle { - label: Label { - horizontalAlignment: TextInput.AlignHCenter - //: Should be as displayed in software manager, thus in general not translated - text: qsTr("tainted"); - font.bold: true; color: "white"; - } - background: Rectangle { - LinearGradient { - anchors.fill: parent - start: Qt.point(0, 0) - end: Qt.point(0, 20) - gradient: Gradient { - GradientStop { position: 0.0; color: "red" } - GradientStop { position: 1.0; color: "darkred" } - } - } - } - - } - } - Label { - text: qsTr("- 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. "); - wrapMode: Text.WordWrap - Layout.maximumWidth: slideshow.width -110 - color: "white" - } - Button { - Layout.margins: 5 - Layout.alignment: Qt.AlignTop - Layout.fillWidth: true - style: ButtonStyle { - label: Label { - horizontalAlignment: TextInput.AlignHCenter - //: Should be as displayed in software manager, thus in general not translated - text: qsTr("backports"); - font.bold: true; color: "black"; - } - background: Rectangle { - LinearGradient { - anchors.fill: parent - start: Qt.point(0, 0) - end: Qt.point(0, 20) - gradient: Gradient { - GradientStop { position: 0.0; color: "lightgray" } - GradientStop { position: 1.0; color: "darkgray" } - } - } - } - - } - } - Label { - text: qsTr("- include new versions of packages, and new packages, that do not meet the updates policy."); - wrapMode: Text.WordWrap - Layout.maximumWidth: slideshow.width -110 - color: "white" - } - Button { - Layout.margins: 5 - Layout.alignment: Qt.AlignTop - Layout.fillWidth: true - style: ButtonStyle { - label: Label { - horizontalAlignment: TextInput.AlignHCenter - text: qsTr("Note! "); - font.bold: true; color: "black"; - } - background: Rectangle { - color: "#e6c200"; - } - - } - } - Label { text: qsTr("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."); - wrapMode: Text.WordWrap - textFormat: Text.RichText - color: "white" - Layout.fillWidth: true - Layout.maximumWidth: slideshow.width - 110 - } - Label { text: qsTr("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 />"+ - qsTr("After you have checked and enabled the repositories you need, you can go to the next slide.") - wrapMode: Text.WordWrap - textFormat: Text.RichText - color: "white" - Layout.fillWidth: true - Layout.maximumWidth: slideshow.width - 10 - Layout.columnSpan: 2 - Layout.margins: 10 - } - MButton { - visible: networkstate.isOffLine() - Layout.columnSpan: 2 - Layout.alignment: Qt.AlignHCenter - objectName: "launch" - onMbuttonClicked: { launch.command(["/usr/bin/draknetcenter",])} - buttonText: qsTr("Configure network") - } - MButton { - Layout.columnSpan: 2 - Layout.alignment: Qt.AlignHCenter - objectName: "launch" - onMbuttonClicked: { launch.command(["/usr/bin/drakrpm-edit-media",])} - buttonText: qsTr("Edit software sources")+" *" - } - } - } - - Label { - anchors {top: parent.bottom; topMargin: 3; horizontalCenter: parent.left; horizontalCenterOffset: parent.width * .4 } - text: qsTr("(*) Administrator password is needed.") - Layout.maximumWidth: slideshow.width * .4 - font.italic: true - color: "white" - } - -} diff --git a/qml/Updates.qml b/qml/Updates.qml deleted file mode 100644 index fce4a22..0000000 --- a/qml/Updates.qml +++ /dev/null @@ -1,55 +0,0 @@ -import QtQuick 2 -import QtQuick.Controls 1 - -// Update page -Rectangle { - property var title: qsTr("Update") - LayoutMirroring.enabled: (direction == "LTR" ? false : true) - LayoutMirroring.childrenInherit: true - width: view.width; height: view.height - Loader { sourceComponent: slidebackground ; - anchors.fill: parent} - Column { - spacing: 10 - Row { - width: view.width - Label { text: qsTr("How Mageia manages updates"); font.bold: true; - padding: 40 - color: "white"} - } - Row { - width: view.width - Label { - width: view.width - padding: 40 - text: qsTr("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."); - wrapMode: Text.WordWrap - color: "white" - } - } - - MButton { - anchors.horizontalCenter: parent.horizontalCenter - objectName: "launch" - onMbuttonClicked: { launch.command(["drakrpm-update",])} - buttonText: qsTr("Check system updates")+" *" - } - MButton { - anchors.horizontalCenter: parent.horizontalCenter - objectName: "link" - //: (en) indicates that the content of the link is in English - onMbuttonClicked: { link.weblink("https://advisories.mageia.org/")} - buttonText: qsTr("Advisories of updates (en)") - } - - } - Label { - anchors {top: parent.bottom; topMargin: 3; horizontalCenter: parent.left; horizontalCenterOffset: parent.width * .4 } - text: qsTr("(*) User password is needed") - wrapMode: Text.WordWrap - font.italic: true - color: "white" - } -} diff --git a/qml/Version.qml b/qml/Version.qml deleted file mode 100644 index 715b458..0000000 --- a/qml/Version.qml +++ /dev/null @@ -1,2 +0,0 @@ -import QtQuick 2.0 -Item { property var version: '2.25';} diff --git a/qml/Welcome.qml b/qml/Welcome.qml deleted file mode 100644 index 6851b52..0000000 --- a/qml/Welcome.qml +++ /dev/null @@ -1,36 +0,0 @@ -import QtQuick 2 -import QtQuick.Controls 1 - - Rectangle { - //: the button in buttons bar - property var title: qsTr("Welcome") - width: view.width; height: view.height - Loader { sourceComponent: slidebackground ; - anchors.fill: parent} - Column { - anchors.centerIn: parent - anchors.verticalCenter: parent.verticalCenter - - Label { - //: the %1 will be replaced with the user name - anchors.horizontalCenter: parent.horizontalCenter - horizontalAlignment: TextInput.AlignHCenter - text: (user == 'live' ? qsTr("Welcome to Mageia") : qsTr("Welcome to Mageia, %1").arg(user)+'\n') - font.weight: Font.DemiBold - font.pixelSize: Qt.application.font.pixelSize * 1.5 - color: "white" - } - - Label { - horizontalAlignment: TextInput.AlignHCenter - anchors.horizontalCenter: parent.horizontalCenter - width: slideshow.width * .6 - text: (user == 'live' ? - qsTr("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> %1 </i> to go to the first step.").arg(qsTr("Live mode")) : - qsTr("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>%1</i> to go to the first step.").arg(qsTr("Media sources"))); - wrapMode: Text.WordWrap - textFormat: Text.RichText - color: "white" - } - } - } diff --git a/qml/helpers.py b/qml/helpers.py index 40d1ee8..7023011 100644 --- a/qml/helpers.py +++ b/qml/helpers.py @@ -2,6 +2,14 @@ import gettext import rpm +import os +import subprocess +from PyQt6.QtCore import Qt, QObject, pyqtSlot, QAbstractListModel, QModelIndex, QCoreApplication, pyqtSignal +from PyQt6.QtNetwork import QNetworkInformation +from PyQt6.QtWidgets import QStyledItemDelegate,QLabel +from xdg.DesktopEntry import DesktopEntry + +translate = QCoreApplication.translate def get_desktop_name(x): return { @@ -42,3 +50,159 @@ def is_installed(name): else: repo = '' return release != "", repo + + +class Launcher(QObject): + installed = pyqtSignal() + needed = pyqtSignal(str, arguments=["repo"]) + repo = pyqtSignal() + noprogram = pyqtSignal() + + def __init__(self): + QObject.__init__(self) + + +class Autostart(): + def __init__(self): + self.home = os.getenv("HOME") + self.desktop_file = os.path.join(self.home, ".config", "autostart", "mageiawelcome.desktop") + self.desktop_file_system = "/etc/xdg/autostart/mageiawelcome.desktop" + # self.conffile = self.home + "/.config/mageiawelcome/norun.flag" + + # @pyqtSlot(bool) + # def setRunAtLaunch(self, checked): + # print("Setting", checked) + # if checked: + # if os.path.exists(self.conffile): + # os.remove(self.conffile) + # else: + # os.makedirs(self.home + "/.config/mageiawelcome", exist_ok=True) + # with open(self.conffile, "w"): + # pass + # + # @pyqtSlot(result=bool) + # def startupcheck(self): + # return not os.path.exists(self.conffile) + + def disable(self): + print("Désactive") + if os.path.exists(self.desktop_file): + desktop = DesktopEntry(self.desktop_file) + else: + os.makedirs(os.path.dirname(self.desktop_file), exist_ok=True) + desktop = DesktopEntry(self.desktop_file_system) + desktop.set('Hidden', 'true') + + # Store modified file + desktop.write(filename=self.desktop_file) + + def enable(self): + # desktop in autostart is already installed in /etc we remove the local one to avoid to hide system one + print("Active") + if os.path.exists(self.desktop_file): + os.remove(self.desktop_file) + + def isEnabled(self): + if os.path.exists(self.desktop_file): + desktop = DesktopEntry(self.desktop_file) + return desktop.getHidden() + else: + return True + +class NetworkState(QObject): + def __init__(self): + QObject.__init__(self) + QNetworkInformation.load(QNetworkInformation.Feature.Reachability) + self.net = QNetworkInformation.instance() + + @pyqtSlot(result=bool) + def isOffLine(self): + # Search active network connections + # QNetworkInformation::Reachability::Online 4 Indicates that the system is connected to a network and able to access the Internet. + return not self.net.reachability() == 4 + + def reachability(self): + return self.net.reachability() + + def availableBackends(self): + return self.net.availableBackends() + + +class ConfList(): + + def __init__(self, ns, parent=None): + # Changing working directory + abspath = os.path.abspath(__file__) + dname = os.path.dirname(abspath) + os.chdir(dname) + self.net_state = ns + + # collect sys info + release = subprocess.getoutput("lsb_release -sd") + release = release[1:-1] + release_nb = subprocess.getoutput("lsb_release -sr") + release_nb = release_nb.strip() + kernel = subprocess.getoutput("uname -r") + if os.uname()[4] == ("x86_64", "aarch64"): + arch = "64-bit" + elif os.uname()[4] in ("i586", "i686", "armv7hl"): + arch = "32-bit" + else: + arch = os.uname()[4] + try: + desktop = get_desktop_name(os.path.basename(os.getenv("DESKTOP_SESSION"))) + except: + desktop = "Other" + + if desktop == "Other": + desktop = get_desktop_name2(os.getenv("XDG_CURRENT_DESKTOP")) + if desktop == "unknown": + desktop = os.getenv("XDG_CURRENT_DESKTOP") + self.screen_factor = 0.0 + if desktop == "Gnome Wayland": + import gi + + gi.require_version("Gdk", "3.0") + from gi.repository.Gdk import Display + + # pre-3.22, otherwise deprecated + # factor = Gdk.Screen.get_default().get_monitor_scale_factor(0) + self.screen_factor = Display.get_default().get_monitor(0).get_scale_factor() + + # Search active network connections + if self.net_state.reachability() == QNetworkInformation.Reachability.Online: + confs = self.net_state.availableBackends() + netconfs = ", ".join([conf for conf in confs]) + + self.configuration = [translate( + "ConfList", "<b>Congratulations!</b><BR />You are now running {}" + ).format(release), + translate("ConfList", "You are using linux kernel: {}").format( + kernel + ), + translate("ConfList", "Your system architecture is: {}").format( + arch + ), + translate( + "ConfList", "You are now using the Desktop: {}" + ).format(desktop), + translate("ConfList", "Your user id is: {}").format(os.getuid()), + ] + if self.net_state.reachability() == QNetworkInformation.Reachability.Online: + self.configuration.append( + translate("ConfList", "You are connected to a network through {}").format(netconfs) + ) + else: + self.configuration.append( + translate("ConfList", "You have no network connection") + ) + + def factor(self, app): + """ + Determine screen factor + Can be specific for Gnome Wayland + """ + if self.screen_factor == 0: + screen = app.primaryScreen() + self.screen_factor = screen.devicePixelRatio() + return self.screen_factor diff --git a/qml/mageiawelcome.py b/qml/mageiawelcome.py index f67f797..a6c7de7 100644 --- a/qml/mageiawelcome.py +++ b/qml/mageiawelcome.py @@ -1,296 +1,29 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -from PyQt5.QtGui import QGuiApplication, QIcon, QScreen -from PyQt5.QtQuick import QQuickView -from PyQt5.QtCore import ( +from PyQt6.QtGui import QIcon, QScreen +from PyQt6.QtCore import ( QUrl, QLocale, QTranslator, QLibraryInfo, QVariant, - QAbstractListModel, - QModelIndex, Qt, QObject, pyqtSlot, pyqtSignal, QCoreApplication, ) -from PyQt5.QtNetwork import QNetworkConfigurationManager, QNetworkConfiguration +from PyQt6.QtWidgets import QApplication import sys import os -import subprocess -from helpers import get_desktop_name, get_desktop_name2, is_installed -import pwd +from helpers import get_desktop_name, get_desktop_name2, is_installed, NetworkState, ConfList +from ui import SlideShowApp # Workaround for opengl lib selection from OpenGL import GL translate = QCoreApplication.translate -class Networkstate(QObject): - def __init__(self): - QObject.__init__(self) - - @pyqtSlot(result=bool) - def isOffLine(self): - # Search active network connections - net = QNetworkConfigurationManager() - return not net.isOnline() - - -class ConfList(QAbstractListModel): - NameRole = Qt.UserRole + 1 - - def __init__(self, parent=None): - super().__init__(parent) - # Changing working directory - abspath = os.path.abspath(__file__) - dname = os.path.dirname(abspath) - os.chdir(dname) - - # collect sys info - release = subprocess.getoutput("lsb_release -sd") - release = release[1:-1] - release_nb = subprocess.getoutput("lsb_release -sr") - release_nb = release_nb.strip() - kernel = subprocess.getoutput("uname -r") - if os.uname()[4] == ("x86_64", "aarch64"): - arch = "64-bit" - elif os.uname()[4] in ("i586", "i686", "armv7hl"): - arch = "32-bit" - else: - arch = os.uname()[4] - try: - desktop = get_desktop_name(os.path.basename(os.getenv("DESKTOP_SESSION"))) - except: - desktop = "Other" - - if desktop == "Other": - desktop = get_desktop_name2(os.getenv("XDG_CURRENT_DESKTOP")) - if desktop == "unknown": - desktop = os.getenv("XDG_CURRENT_DESKTOP") - self.screen_factor = 0.0 - if desktop == "Gnome Wayland": - import gi - - gi.require_version("Gdk", "3.0") - from gi.repository.Gdk import Display - - # pre-3.22, otherwise deprecated - # factor = Gdk.Screen.get_default().get_monitor_scale_factor(0) - self.screen_factor = Display.get_default().get_monitor(0).get_scale_factor() - - # Search active network connections - net = QNetworkConfigurationManager() - first = True - if net.isOnline(): - confs = net.allConfigurations(QNetworkConfiguration.Active) - for conf in confs: - if first: - netconfs = conf.name() - first = False - else: - netconfs += ", " + conf.name() - - self.configuration = [ - { - "name": translate( - "ConfList", "<b>Congratulations!</b><BR />You are now running {}" - ).format(release) - }, - { - "name": translate("ConfList", "You are using linux kernel: {}").format( - kernel - ) - }, - { - "name": translate("ConfList", "Your system architecture is: {}").format( - arch - ) - }, - { - "name": translate( - "ConfList", "You are now using the Desktop: {}" - ).format(desktop) - }, - {"name": translate("ConfList", "Your user id is: {}").format(os.getuid())}, - ] - if net.isOnline(): - self.configuration.append( - { - "name": translate( - "ConfList", "You are connected to a network through {}" - ).format(netconfs) - } - ) - else: - self.configuration.append( - {"name": translate("ConfList", "You have no network connection")} - ) - - def factor(self, app): - """ - Determine screen factor - Can be specific for Gnome Wayland - """ - if self.screen_factor == 0: - screen = app.primaryScreen() - self.screen_factor = screen.devicePixelRatio() - return self.screen_factor - - def data(self, index, role=Qt.DisplayRole): - row = index.row() - return self.configuration[row]["name"] - - def rowCount(self, parent=QModelIndex()): - return len(self.configuration) - - def roleNames(self): - return { - ConfList.NameRole: b"name", - } - - -class Callbrowser(QObject): - def __init__(self): - QObject.__init__(self) - - @pyqtSlot(str) - def weblink(self, link): - subprocess.Popen(["xdg-open", link]) - - -class Launcher(QObject): - installed = pyqtSignal() - needed = pyqtSignal(str, arguments=["repo"]) - repo = pyqtSignal() - noprogram = pyqtSignal() - - def __init__(self): - QObject.__init__(self) - - @pyqtSlot(QVariant) - def command(self, app): - if app.isArray(): - cmd = [] - for i in range(0, app.property("length").toInt()): - cmd.append(app.property(i).toString()) - self._command(cmd[0]) - - def _command(self, cmd): - try: - subprocess.Popen(cmd) - except: - print(f"Exception running {cmd}") - self.noprogram.emit() - return - - @pyqtSlot(QVariant) - def install(self, app): - if app.isArray(): - cmd = [] - # app should contain package, repository - for i in range(0, app.property("length").toInt()): - cmd.append(app.property(i).toString()) - 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 - self.needed.emit(repo) - return - if repo == "non-free" and not (nonfree and nf_updates): - # repo nonfree not enabled - self.needed.emit(repo) - return - if repo == "steam" and not ( - core32 and core32_updates and nonfree and nf_updates - ): - # repo not enabled - self.needed.emit(repo) - return - if repo == "" and not (core and updates): - # repo not enabled - self.repo.emit() - return - proc = subprocess.Popen(["/usr/bin/gurpmi", cmd[0]]) - proc.wait() - # Give the signal to reload the applist - self.installed.emit() - return - - @pyqtSlot(QVariant) - def install_and_launch(self, app): - """ - app should be an array with the package name to install and then the command to launch - """ - if app.isArray(): - cmd = [] - # app should contain package, repository - for i in range(0, app.property("length").toInt()): - cmd.append(app.property(i).toString()) - print(cmd) - 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 Norun(QObject): - def __init__(self): - QObject.__init__(self) - self.home = os.getenv("HOME") - self.conffile = self.home + "/.config/mageiawelcome/norun.flag" - - @pyqtSlot(bool) - def setRunAtLaunch(self, checked): - print("Setting", checked) - if checked: - if os.path.exists(self.conffile): - os.remove(self.conffile) - else: - os.makedirs(self.home + "/.config/mageiawelcome", exist_ok=True) - with open(self.conffile, "w"): - pass - - @pyqtSlot(result=bool) - def startupcheck(self): - return not os.path.exists(self.conffile) - - class Installable(QObject): def __init__(self): QObject.__init__(self) @@ -307,19 +40,14 @@ class Installable(QObject): return is_app_installed and repo == "" and inst_repo != "" -def username(): - user = pwd.getpwuid(os.getuid())[4] # pw_gecos, i e the real name - if user == "": - user = pwd.getpwuid(os.getuid())[0] # login - return user if __name__ == "__main__": - app = QGuiApplication(sys.argv) + app = QApplication(sys.argv) locale = QLocale.system().name() qtTranslator = QTranslator() if qtTranslator.load( - "qt_" + locale, QLibraryInfo.location(QLibraryInfo.TranslationsPath) + "qt_" + locale, QLibraryInfo.path(QLibraryInfo.LibraryPath.TranslationsPath) ): app.installTranslator(qtTranslator) appTranslator = QTranslator() @@ -329,48 +57,30 @@ if __name__ == "__main__": app.installTranslator(appTranslator) app.setOrganizationName("Mageia") app.setApplicationName("Mageiawelcome") - view = QQuickView() - view.setResizeMode(QQuickView.SizeRootObjectToView) - view.setTitle(app.translate("app", "Welcome to Mageia")) + direction = Qt.LayoutDirection.LeftToRight if translate("mw-ui", "LTR") == "LTR" else Qt.LayoutDirection.RightToLeft + app.setLayoutDirection(direction) app.setWindowIcon(QIcon("/usr/share/icons/hicolor/32x32/apps/mageiawelcome.png")) - cb = Callbrowser() - la = Launcher() - us = username() ins = Installable() - cl = ConfList() - nr = Norun() - ns = Networkstate() - sc = nr.startupcheck() + ns = NetworkState() + cl = ConfList(ns) + # sc = nr.startupcheck() factor = cl.factor(app) screen = app.primaryScreen() # if density is high, use at least factor 2 to scale the initial window. Considering high is more than 190 px/inches. - if screen.logicalDotsPerInch() > 190: - factor = max(2.0, factor) - defaultHeight = min(int(700 * factor), screen.availableGeometry().height()) - defaultWidth = min(int(1000 * factor), screen.availableGeometry().width()) - centerPoint = screen.availableGeometry().center() - view.setGeometry( - centerPoint.x() - defaultWidth // 2, - centerPoint.y() - defaultHeight // 2, - defaultWidth, - defaultHeight, - ) - view.rootContext().setContextProperty("link", cb) - view.rootContext().setContextProperty("launch", la) - view.rootContext().setContextProperty("user", us) - view.rootContext().setContextProperty("ConfList", cl) - view.rootContext().setContextProperty("pyinstallable", ins) - view.rootContext().setContextProperty("startupcheck", sc) - view.rootContext().setContextProperty("norun", nr) - view.rootContext().setContextProperty("networkstate", ns) + # if screen.logicalDotsPerInch() > 190: + # factor = max(2.0, factor) + # defaultHeight = min(int(700 * factor), screen.availableGeometry().height()) + # defaultWidth = min(int(1000 * factor), screen.availableGeometry().width()) + # centerPoint = screen.availableGeometry().center() + # view.setGeometry( + # centerPoint.x() - defaultWidth // 2, + # centerPoint.y() - defaultHeight // 2, + # defaultWidth, + # defaultHeight, + # ) current_path = os.path.abspath(os.path.dirname(__file__)) - qml_file = os.path.join(current_path, "mw-ui.qml") - view.setSource(QUrl.fromLocalFile(qml_file)) - if view.status() == QQuickView.Error: - for error in view.errors(): - print(error.description()) - sys.exit(-1) + view = SlideShowApp() view.show() - res = app.exec_() + res = app.exec() del view sys.exit(res) diff --git a/qml/mw-ui.qml b/qml/mw-ui.qml deleted file mode 100644 index ed6cecf..0000000 --- a/qml/mw-ui.qml +++ /dev/null @@ -1,595 +0,0 @@ -import QtQuick 2.0 - -import QtQml.Models 2.1 -import QtQuick.Layouts 1.3 -import QtQuick.Controls 1.4 -import QtQuick.Controls.Styles 1.4 -import QtGraphicalEffects 1 -import QtQuick.Window 2 -import Qt.labs.settings 1.0 -import QtQuick.Dialogs 1.1 - -Rectangle { - id: box - //width: 1000 * Screen.devicePixelRatio; height: 650 * Screen.devicePixelRatio - property alias view: view - - //: For Right to Left language, set this string to RTL, else keep it untranslated - property var direction: qsTr("LTR") - LayoutMirroring.enabled: (direction == "LTR" ? false : true) - // for tests - //LayoutMirroring.enabled: true - // TO-DO GridLayout RowLayout are not sensible to mirroring, change to other layout tools - LayoutMirroring.childrenInherit: true - - Settings { - property alias width: box.width - property alias height: box.height - } - Component { - id: slidebackground - LinearGradient { - start: Qt.point(0, 0) - end: Qt.point(0, box.height) - gradient: Gradient { - GradientStop { position: 1.0; color: "#2397D4" } - GradientStop { position: 0.0; color: "#262F45" } - } - } - } - Rectangle { - id: banner - opacity: 0.95 - layer.enabled: true - width: parent.width;height: 120 - LinearGradient { - anchors.fill: parent - start: Qt.point(0, 0) - end: Qt.point(0, 400) - gradient: Gradient { - GradientStop { position: 0.0; color: "lightgray" } - GradientStop { position: 1.0; color: "white" } - } - } - - Image { - anchors.fill: parent - anchors.bottomMargin: 10 - anchors.topMargin: 10 - source: "img/mageia-2013-black-alpha.png" - fillMode: Image.PreserveAspectFit - } - - } - - Rectangle { - id: slideshow - property Item displayItem: null - anchors {left: parent.left; top: buttonbox.bottom; bottom: parent.bottom; right: parent.right} - color: "#2397D4" - width: parent.width - - ObjectModel { - id: itemModel - - // Welcome page - Welcome {} - - // Configure source page - Sources {} - - // Update page - Updates {} - - // MCC Page - Mcc {} - - // Install software page - InstallSoftware {} - - // Applications page - function update_list(group) { - appListDM.items.remove(0,appListDM.count ); - var rowCount = appList.count; - for( var i = 0;i < rowCount;i++ ) - { - var entry = appList.get(i); - var pattern = new RegExp(group, "g"); - if(pattern.test(entry.group) && !pyinstallable.other(entry.name, entry.repo)) { - appListDM.items.insert(entry, "group"); - } - } - for(var child in applicationsListView.contentItem.children) { - if (applicationsListView.contentItem.children[child].naturalwidth > softListRect.installwidth ) { - softListRect.installwidth = applicationsListView.contentItem.children[child].naturalwidth - } - } - appListDM.filterOnGroup = "items"; - } - - Rectangle { - property var title: qsTr("Applications") - width: view.width; height: view.height - Loader { sourceComponent: slidebackground ; - anchors.fill: parent} - Column { - - Rectangle { - // warning banner - id: warning - width: view.width - height: warnText.height - color: "gold" - Label { - id: warnText - width: view.width - horizontalAlignment: TextInput.AlignHCenter - font.pixelSize: Qt.application.font.pixelSize * .9 - text: qsTr("Here is a small selection of popular applications - any of which may be installed or launched at this point.")+"<BR />"+qsTr("Ensure that you have enabled the <i>Media sources</i>.") - textFormat: Text.RichText - wrapMode: Text.WordWrap - color: "black" - font.weight: Font.DemiBold - } - } - Item { - width: row.width - height: 200 - Row { - id: row - // Under the warning - - // Software categories - - Component { //The hightlight - id: catHighlight - Rectangle { - width: categoriesList.width - height: Qt.application.font.pixelSize + 16 - color: "#262F45" - y: categoriesList.currentItem.y; - } - } - - ListView { - id:categoriesList - width: 190 - highlight: catHighlight - highlightFollowsCurrentItem: false - focus: true - model: [{'name': qsTr("Featured"), 'group': "featured"}, - {'name': qsTr("Games"),'group': "games"}, - {'name':qsTr("Internet"),'group': "internet"}, - {'name':qsTr("Video"),'group': "video"}, - {'name':qsTr("Audio"),'group': "audio"}, - {'name':qsTr("Office"),'group': "office"}, - {'name':qsTr("Graphics"),'group': "graphics"}, - {'name':qsTr("System"),'group': "system"}, - {'name':qsTr("Programming"),'group': "programming"}] - height: (Qt.application.font.pixelSize + 16) * 9 - delegate: Rectangle{ - property variant myGroup: modelData.group - width: parent.width - height: Qt.application.font.pixelSize + 16 - color:"#20FFFFFF" - Label {id: catLabel; - anchors.horizontalCenter: parent.horizontalCenter - text: modelData.name ; - padding: 7 - color: "white" - } - MouseArea { - anchors.centerIn: parent - width: parent.width - height: 25 - onClicked: { - categoriesList.currentIndex = index; - itemModel.update_list(modelData.group); - } - } - } - } - - Rectangle { - // Software list - id: softListRect - height: view.height - width: view.width - categoriesList.width - color: "transparent" - // the width of install and Launch button will be calculated then updated. We give here a minimal size - property real installwidth: Qt.application.font.pixelSize * 2 - - DelegateModel { - id: appListDM - model: AppList {id: appList} - groups: [ - DelegateModelGroup { - includeByDefault: false - name: "group" - } - ] - filterOnGroup: "group" - Component.onCompleted: { - var rowCount = appList.count; - items.remove(0,rowCount); - for( var i = 0;i < rowCount;i++ ) - { - var entry = appList.get(i); - var pattern = /featured/g; - if(pattern.test(entry.group) && !pyinstallable.other(entry.name, entry.repo) ) { - items.insert(entry, "group"); - } - } - // The lsit has to be painted first for buttons width evaluation - applicationsListView.forceLayout() - for(var child in applicationsListView.contentItem.children) { - if (applicationsListView.contentItem.children[child].naturalwidth > softListRect.installwidth ) { - softListRect.installwidth = applicationsListView.contentItem.children[child].naturalwidth - } - } - console.log("Screen: ", Screen.devicePixelRatio, Screen.pixelDensity) - } - delegate: Row { - spacing: 10 - property int naturalwidth : optButton.item.implicitWidth - Image { - source: icon - width: 32 - height: 32 - } - //CheckBox{ enabled: installable - //} - Column{ - Label { - text: title - font.weight: Font.DemiBold - color: "white" - } - Label { - text: description - font.italic: true - font.pixelSize: Qt.application.font.pixelSize * .9 - width: view.width - (190 + 44 +38 + softListRect.installwidth + tag.width ) - wrapMode: Text.WordWrap - color: "white" - } - } - - Loader { - id: optButton - Component { id: button; - Button { - width: softListRect.installwidth; - height: Qt.application.font.pixelSize * 1.3 - objectName: "launch" - onClicked: { - launch.install([name,repo,])} - style: ButtonStyle { - label: Label { - horizontalAlignment: TextInput.AlignHCenter - verticalAlignment: TextInput.AlignVCenter - text: qsTr("Install"); - font.pixelSize: Qt.application.font.pixelSize * .8 - color: "black" - } - } - } - } - Component { id: launcher; - Button { - width: softListRect.installwidth; - height: Qt.application.font.pixelSize * 1.3 - objectName: "launch" - onClicked: { - launch.command([command,])} - style: ButtonStyle { - label: Label { - horizontalAlignment: TextInput.AlignHCenter - verticalAlignment: TextInput.AlignVCenter - text: qsTr("Launch"); - font.pixelSize: Qt.application.font.pixelSize * .8 - color: "black" - } - } - } - } - Component { id: dummy;Label {text: qsTr("Installed") - padding: 2 - horizontalAlignment: TextInput.AlignHCenter - font.pixelSize: Qt.application.font.pixelSize * .8 - width: softListRect.installwidth - color: "white" - } - } - sourceComponent: ( pyinstallable.installable(name, repo)) ? button : (command === "" ? dummy : launcher) - } - - Loader { - id: tag - Component { - id: repotag - Rectangle { - color: "#FF4C4C" - radius: 3 - width: Qt.application.font.pixelSize * 3.5; height: Qt.application.font.pixelSize * 1.3 - Label { - anchors.centerIn: parent - text: repo - font.pixelSize: Qt.application.font.pixelSize * .8 - color: "white" - } - } - } - Component { id: dumm; - Label { - width: Qt.application.font.pixelSize * 3.5; - text: " "}} - sourceComponent: repo == "" ? dumm : repotag - } - } - } - Rectangle { - height: view.height-warning.height - width: view.width-200 - color: "transparent" - ListView { - id: applicationsListView - anchors.fill: parent - clip: true - model: appListDM - spacing: 5 - } - } - } - } - } - } - } - // Configuration summary Page - Configuration {} - - // Links page - Links {} - } - - - ObjectModel { - id: itemModelLive - - // Welcome page - Welcome {} - - // Live mode - Live {} - - // MCC Page - Mcc {} - - // Install software page - InstallSoftware {} - - // Install on HD - Install {} - - // Documentation links - Links {} - } - ListView { - id: view - z: 1 - anchors.rightMargin: 0 - anchors.leftMargin: 0 - anchors.topMargin: 0 - anchors { fill: parent; bottomMargin: startCB.implicitHeight +10 } - model: (user == 'live' ? itemModelLive : itemModel) - preferredHighlightBegin: 0; preferredHighlightEnd: view.width - highlightRangeMode: ListView.StrictlyEnforceRange - orientation: ListView.Horizontal - snapMode: ListView.SnapOneItem; flickDeceleration: 2000 - highlightFollowsCurrentItem: true - highlightMoveDuration: 800 - cacheBuffer: 200 - } - } - MouseArea { - id: nextMA - anchors {right: parent.right; verticalCenter: slideshow.verticalCenter } - width: 60 - height: 60 - hoverEnabled: true - onEntered: { rightArrow.state='Hovering'} - onExited: { rightArrow.state=''} - onClicked: {if (view.currentIndex < view.model.count - 1) - view.currentIndex = view.currentIndex + 1} - Rectangle { - id: rightArrow - anchors.fill: parent - color: "#80262F45" - visible: false - Text { - anchors.centerIn: parent - text: (direction == "LTR" ? ">" : "<") - font.pointSize: 30 - } - states: [ - State { - name: "Hovering" - PropertyChanges { - target: rightArrow - visible: view.currentIndex == view.model.count - 1 ? false : true - } - } - ] - } - } - MouseArea { - id: previousMA - anchors {left: parent.left; verticalCenter: slideshow.verticalCenter } - width: 60 - height: 60 - hoverEnabled: true - onEntered: { leftArrow.state='Hovering'} - onExited: { leftArrow.state=''} - onClicked: {if (view.currentIndex > 0) - view.currentIndex = view.currentIndex - 1} - Rectangle { - id: leftArrow - anchors.fill: parent - color: "#80262F45" - visible: false - Text { - anchors.centerIn: parent - text: (direction == "LTR" ? "<" : ">") - font.pointSize: 30 - } - states: [ - State { - name: "Hovering" - PropertyChanges { - target: leftArrow - visible: view.currentIndex == 0 ? false : true - } - } - ] - } - } - Rectangle { - id: buttonbox - width: banner.width; height: buttonRow.height - anchors { top: banner.bottom; } - color: "#262F45" - RowLayout { - id: buttonRow - - Rectangle { - Layout.preferredWidth: 8 - Layout.preferredHeight: buttonbox.height - color: buttonbox.color - } - - Repeater { - model: (user == 'live' ? itemModelLive.count : itemModel.count) - - Button { - Layout.fillHeight: true - - Layout.preferredWidth: (buttonbox.width - 8)/(user == 'live' ? itemModelLive.count : itemModel.count) - 9; - Layout.topMargin: 6 - Layout.bottomMargin: 6 - style: ButtonStyle { - background: Rectangle { - radius: 5 - color: view.currentIndex == index ? "#2397D4" : "white" - } - label: Label{ - text: (user == 'live' ? itemModelLive.get(index).title : itemModel.get(index).title) - font.pointSize: 9 - color: view.currentIndex == index ? "white" : "#262F45" - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - wrapMode : Text.WordWrap - } - } - onClicked: view.currentIndex = index - } - } - - Rectangle { - Layout.preferredWidth: 8 - Layout.preferredHeight: buttonbox.height - color: buttonbox.color - } - - } - } - Row { - anchors.right: box.right - anchors.bottom: box.bottom - anchors.margins: 6 - CheckBox { - id:startCB - text: qsTr("Show this window at startup") - checked: startupcheck - onClicked: norun.setRunAtLaunch(checked) - } - } - - MessageDialog { - id: no_tainted - icon: StandardIcon.Warning - title: qsTr("Application installation") - //: %1 will be replaced with the 'Media sources' translation - text: qsTr("Tainted repositories are not enabled. See the '%1' tab.").arg(qsTr("Media sources")) - standardButtons: StandardButton.Close - } - - MessageDialog { - id: no_core - icon: StandardIcon.Warning - title: qsTr("Application installation") - //: %1 will be replaced with the 'Media sources' translation - text: qsTr("Core repositories are not enabled. See the '%1' tab.").arg(qsTr("Media sources")) - standardButtons: StandardButton.Close - } - - MessageDialog { - id: no_nonfree - icon: StandardIcon.Warning - title: qsTr("Application installation") - //: %1 will be replaced with the 'Media sources' translation - text: qsTr("Nonfree repositories are not enabled. See the '%1' tab.").arg(qsTr("Media sources")) - standardButtons: StandardButton.Close - } - - MessageDialog { - id: no_program - icon: StandardIcon.Warning - title: qsTr("Launching command") - text: qsTr("This command is not installed") - standardButtons: StandardButton.Close - } - - MessageDialog { - id: no_steam - icon: StandardIcon.Warning - title: qsTr("Application installation") - //: %1 will be replaced with the 'Media sources' translation - text: qsTr("Steam needs that Nonfree and Core 32bit repositories are enabled. See the '%1' tab.").arg(qsTr("Media sources")) - standardButtons: StandardButton.Close - } - - Connections { - target: launch - function onInstalled() { - // get the signal to reload the applist - console.log("Reload applications list") - itemModel.update_list(categoriesList.currentItem.myGroup) - } - - function onRepo() { - // get the signal that core repo is not enabled - console.log("Core repository is not enabled") - no_core.visible = true - } - - function onNeeded(repo) { - // get the signal that tainted repo is not enabled - console.log("%1 is not enabled".arg(repo)) - if (repo == "non-free") { - no_nonfree.visible = true - } - if (repo == "tainted") { - no_tainted.visible = true - } - if (repo == "steam") { - no_steam.visible = true - } - } - - function onNoprogram() { - // get the signal that the command doesn't exist' - console.log("The program is not installed") - no_program.visible = true - } - } -} diff --git a/qml/ui.py b/qml/ui.py new file mode 100644 index 0000000..1ce7763 --- /dev/null +++ b/qml/ui.py @@ -0,0 +1,1360 @@ +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 SlidePage(QWidget): + """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) + + def weblink(self, url): + webbrowser.open_new_tab(url) + + def command(self, 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 + self.needed.emit(repo) + return + if repo == "non-free" and not (nonfree and nf_updates): + # repo nonfree not enabled + self.needed.emit(repo) + return + if repo == "steam" and not ( + core32 and core32_updates and nonfree and nf_updates + ): + # repo not enabled + self.needed.emit(repo) + return + if repo == "" and not (core and updates): + # repo not enabled + self.repo.emit() + return + proc = subprocess.Popen(["/usr/bin/gurpmi", cmd[0]]) + proc.wait() + # Give the signal to reload the applist + self.installed.emit() + + 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 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 ("Documentation", "Support", "Community"): + button = QLabel(_("Links", 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): + 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 = [ + "Software Management", + "Hardware", + "Network and Internet", + "System", + "Network Sharing", + "Local Disks", + "Security", + "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([_("Mcc", x) for x in entries_list]) + ) + content_label.setWordWrap(True) + content_label.setStyleSheet("font-size: 14px; color: white;") + 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, shortcut for Mageia Control Center + 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;") + layout.addWidget(content_label) + + button_layout = QHBoxLayout() + button_layout.addStretch(1) + 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) + 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;") + 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, shortcut for Mageia Control Center + 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 = [ + {"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__() + list_layout = QVBoxLayout() + for item in AppList: + if group in item["group"]: + list_layout.addWidget( + ApplistItem( + item["group"], + item["icon"], + item["name"], + item["title"], + item["description"], + item["repo"], + item["command"], + ) + ) + list_layout.addStretch(0) + self.setLayout(list_layout) + + +class Configuration(SlidePage): + def __init__(self): + # The button in the buttons bar, shortcut for Mageia Control Center + 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;") + 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, shortcut for Mageia Control Center + 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;") + 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;") + 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, shortcut for Mageia Control Center + 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;") + 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): + """An element in application list""" + + def __init__(self, group, icon, name, title, description, repo, command): + super().__init__() + + 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")) + 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.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) + +class MyPushButton(QPushButton): + 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; + } + """ + ) + else: + self.setStyleSheet( + """ + QWidget:hover { + background-color: #2397D4; + border-radius: 5px; + } + QLabel { + color: white; + font-size: 14px; + } + """ + ) + + else: + if self.active: + self.setStyleSheet( + """ + QWidget { + background-color: #2397D4; + border-radius: 5px; + } + QLabel { + color: white; + font-size: 12px; + padding: 2px 8px; + } + """ + ) + else: + self.setStyleSheet( + """ + QWidget:hover { + background-color: #2397D4; + border-radius: 5px; + } + 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) + + +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__() + self.setWindowTitle(_("mw-ui", _("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()) |