summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/ui.py61
1 files changed, 28 insertions, 33 deletions
diff --git a/src/ui.py b/src/ui.py
index a01ded2..82dab34 100644
--- a/src/ui.py
+++ b/src/ui.py
@@ -8,7 +8,6 @@ from PyQt6.QtWidgets import (
QMainWindow,
QWidget,
QStackedWidget,
- QLayout,
QVBoxLayout,
QHBoxLayout,
QGridLayout,
@@ -16,8 +15,6 @@ from PyQt6.QtWidgets import (
QLabel,
QScrollArea,
QMessageBox,
- QStyledItemDelegate,
- QListView,
QGraphicsOpacityEffect,
)
from PyQt6.QtCore import (
@@ -27,16 +24,11 @@ from PyQt6.QtCore import (
QEasingCurve,
QIODevice,
QPoint,
- QTimer,
- QSize,
- QObject,
- pyqtSlot,
pyqtSignal,
)
from PyQt6.QtGui import (
QColor,
QPalette,
- QFont,
QPixmap,
QKeyEvent,
QImage,
@@ -49,8 +41,6 @@ import webbrowser
import subprocess
from functools import partial
from helpers import (
- get_desktop_name,
- get_desktop_name2,
is_installed,
NetworkState,
ConfList,
@@ -190,6 +180,7 @@ class Commands():
self.command([cmd[1]])
self.restore_focus()
+
class SlidePage(QWidget, Commands):
"""Widget pour une page individuelle du diaporama"""
@@ -197,12 +188,12 @@ class SlidePage(QWidget, Commands):
super().__init__()
# Stocker le titre pour référence
- self.title = title
+ self.title = title
def paintEvent(self, event):
painter = QPainter(self)
painter.setRenderHint(QPainter.RenderHint.Antialiasing)
-
+
gradient = QLinearGradient(0, 0, 0, self.height())
gradient.setColorAt(0.0, QColor("#262F45"))
gradient.setColorAt(1.0, QColor("#2397D4"))
@@ -216,6 +207,7 @@ class SlidePage(QWidget, Commands):
# Forcer le repaint pour les gradients
self.update()
+
class Links(SlidePage):
"""Widget pour une page individuelle du diaporama"""
@@ -309,6 +301,7 @@ class Links(SlidePage):
# Posted by eyllanesc, modified by community. See post 'Timeline' for change history
# Retrieved 2026-02-11, License - CC BY-SA 4.0
+
class Clickable(QLabel):
clicked=pyqtSignal()
@@ -384,13 +377,13 @@ class Welcome(SlidePage):
self.setLayout(layout)
-
def toogle_start(self):
if self.cb_launch.isChecked():
self.autostart.enable()
else:
self.autostart.disable()
+
class Sources(SlidePage):
def __init__(self):
super().__init__(_("Sources", "Media sources"))
@@ -490,7 +483,7 @@ class Sources(SlidePage):
)
)
content_label.setWordWrap(True)
- content_label.setTextFormat(Qt.TextFormat.RichText)
+ content_label.setTextFormat(Qt.TextFormat.RichText)
content_label.setStyleSheet("font-size: 14px; color: white;")
layout.addWidget(content_label)
ns = NetworkState()
@@ -618,7 +611,7 @@ class Mcc(SlidePage):
_("Mcc", "System"),
_("Mcc", "Network Sharing"),
_("Mcc", "Local Disks"),
- _("Mcc","Security"),
+ _("Mcc", "Security"),
_("Mcc", "Boot"),
]
@@ -849,8 +842,8 @@ class AppListStack(QStackedWidget):
print(f"niveau 2 : j={j} {name}")
widget_page.update_item(widget_item, index)
return
-
-
+
+
class AppListPage(QScrollArea):
"""Page of applications lists for a group"""
@@ -911,11 +904,12 @@ class AppListPage(QScrollArea):
)
)
self.update()
-
+
def update_wide_item(self, index):
self.parent.update_wide_item(index, self.group)
+
class Configuration(SlidePage):
def __init__(self):
#: The button in the buttons bar
@@ -989,14 +983,14 @@ class Live(SlidePage):
content_label2.setStyleSheet("font-size: 14px; color: white; padding: 0px 60px")
layout.addWidget(content_label2)
-
+
button_layout = QHBoxLayout()
button_layout.addStretch(1)
doc_button = MyPushButton(_("Live", "Installer documentation"))
doc_button.clicked.connect(
partial(
self.weblink,
- #: the link to the local file can be adapted to your language if the documentation is translated
+ #: the link to the local file can be adapted to your language if the documentation is translated and packaged
_("Live", "file:///usr/share/doc/mageia/en/draklive/index.html"),
)
)
@@ -1050,7 +1044,8 @@ class GradientLegend(QWidget):
layout = QHBoxLayout()
label_widget = QLabel(label)
label_widget.setStyleSheet(
- f"font-size: 14px; color: white; font-weight: bold;")
+ "font-size: 14px; color: white; font-weight: bold;"
+ )
label_widget.setAlignment(Qt.AlignmentFlag.AlignCenter | Qt.AlignmentFlag.AlignVCenter)
self.setStyleSheet(
f"background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 {top_color.name()}, stop:1 {bottom_color.name()})")
@@ -1139,7 +1134,7 @@ class ApplistItem(QWidget, Commands):
)
layout.addWidget(repo_label)
self.setLayout(layout)
-
+
def installation(self, args):
self.install(args)
# Reload the app widget also in other tabs
@@ -1147,13 +1142,13 @@ class ApplistItem(QWidget, Commands):
for group in self.group.split(" "):
if group != self.parent.group:
self.parent.update_wide_item(self.index)
-
+
class MyPushButton(QPushButton):
""" For styling PushButton """
def __init__(self, label):
super().__init__(label)
-
+
self.setStyleSheet(
"""
QWidget {color: #262F45; background-color: lightgray; border-radius: 5px; padding: 8px 8px;}
@@ -1163,7 +1158,7 @@ class MyPushButton(QPushButton):
}
"""
)
-
+
class BreadcrumbItem(QWidget):
"""Un élément du fil d'Ariane"""
@@ -1228,7 +1223,6 @@ class BreadcrumbItem(QWidget):
"""
)
-
else:
if self.active:
self.setStyleSheet(
@@ -1343,6 +1337,7 @@ class HoverButton(QPushButton):
self.effect.setOpacity(1)
super().leaveEvent(event)
+
class SlideShowWidget(QStackedWidget):
"""Widget de diaporama avec animations de transition"""
@@ -1362,10 +1357,9 @@ class SlideShowWidget(QStackedWidget):
self.slides = []
self.i = 0
-
def resizeEvent(self, event):
"""Gère le redimensionnement du widget de slideshow"""
- self.i +=1
+ self.i += 1
for i in range(self.count()):
widget = self.widget(i)
if widget:
@@ -1489,6 +1483,7 @@ class SlideShowWidget(QStackedWidget):
# Terminer la transition
self.in_transition = False
+
class Banner(QLabel):
def __init__(self):
super().__init__()
@@ -1501,7 +1496,6 @@ class Banner(QLabel):
self.setAlignment(Qt.AlignmentFlag.AlignCenter)
# super().resizeEvent(event)
-
def createGradientBanner(self, width, height):
image = QImage(width, height, QImage.Format.Format_ARGB32)
image.fill(QColorConstants.Transparent)
@@ -1521,6 +1515,7 @@ class Banner(QLabel):
return image
+
class SlideShowApp(QMainWindow):
"""Application principale de diaporama"""
@@ -1530,7 +1525,7 @@ class SlideShowApp(QMainWindow):
self.setWindowTitle( _("Welcome", "Welcome to Mageia"))
self.setMinimumSize(DEFAULT_WIDTH, 520) # Taille minimale
self.setGeometry(100, 100, 100 + DEFAULT_WIDTH, 700)
-
+
# central Widget
central_widget = QWidget()
main_layout = QGridLayout(central_widget)
@@ -1564,7 +1559,7 @@ class SlideShowApp(QMainWindow):
# 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)
@@ -1579,7 +1574,7 @@ class SlideShowApp(QMainWindow):
if user == "":
user = pwd.getpwuid(os.getuid())[0] # login
return user
-
+
def mode_live(self):
return os.path.exists("/run/mgalive")
@@ -1592,7 +1587,7 @@ class SlideShowApp(QMainWindow):
self.slideshow.previous_slide()
else:
super().keyPressEvent(event)
-
+
if __name__ == "__main__":
app = QApplication(sys.argv)