summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPapoteur <papoteur@mageia.org>2025-05-27 21:36:32 +0200
committerPapoteur <papoteur@mageia.org>2025-05-27 22:56:15 +0200
commiteb43969e128972984715b7a7f3ac2badbf0e6731 (patch)
treee45f1391134f5c96e9829764f2ffcfdabb8b0377 /src
parent139727aa644e99ae2d5cbc7b7dfbe26fdf960aac (diff)
downloadmageiawelcome-eb43969e128972984715b7a7f3ac2badbf0e6731.tar
mageiawelcome-eb43969e128972984715b7a7f3ac2badbf0e6731.tar.gz
mageiawelcome-eb43969e128972984715b7a7f3ac2badbf0e6731.tar.bz2
mageiawelcome-eb43969e128972984715b7a7f3ac2badbf0e6731.tar.xz
mageiawelcome-eb43969e128972984715b7a7f3ac2badbf0e6731.zip
Add commands3.0
and diverse
Diffstat (limited to 'src')
-rw-r--r--src/ui.py168
1 files changed, 114 insertions, 54 deletions
diff --git a/src/ui.py b/src/ui.py
index 1fe6a9b..2c92800 100644
--- a/src/ui.py
+++ b/src/ui.py
@@ -55,31 +55,12 @@ 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)
-
+class Commands():
def weblink(self, url):
webbrowser.open_new_tab(url)
def command(self, app):
+ print(f"Lancement de {app}")
if type(app) == list:
cmd = app
try:
@@ -134,26 +115,48 @@ class SlidePage(QWidget):
core32_updates = True
if repo == "tainted" and not (tainted and t_updates):
# repo tainted not enabled
- self.needed.emit(repo)
+ message = QMessageBox(
+ QMessageBox.Icon.Warning,
+ _("mw-ui", "Application installation"),
+ #: {} will be replaced with the 'Media sources' translation
+ _("mw-ui", "Tainted repositories are not enabled. See the '{}' tab.").format(_("Sources",_("Media sources"))),
+ )
+ message.exec()
return
if repo == "non-free" and not (nonfree and nf_updates):
# repo nonfree not enabled
- self.needed.emit(repo)
+ message = QMessageBox(
+ QMessageBox.Icon.Warning,
+ _("mw-ui", "Application installation"),
+ #: {} will be replaced with the 'Media sources' translation
+ _("mw-ui", "Nonfree repositories are not enabled. See the '{}' tab.").format(_("Sources",_("Media sources"))),
+ )
+ message.exec()
return
if repo == "steam" and not (
core32 and core32_updates and nonfree and nf_updates
):
- # repo not enabled
- self.needed.emit(repo)
+ # repo not enabled . See the '%1' tab
+ message = QMessageBox(
+ QMessageBox.Icon.Warning,
+ _("mw-ui", "Application installation"),
+ #: {} will be replaced with the 'Media sources' translation
+ _("mw-ui", "Steam needs that Nonfree and Core 32bit repositories are enabled. See the '{}' tab.").format(_("Sources",_("Media sources"))),
+ )
+ message.exec()
return
if repo == "" and not (core and updates):
# repo not enabled
- self.repo.emit()
+ message = QMessageBox(
+ QMessageBox.Icon.Warning,
+ _("mw-ui", "Application installation"),
+ #: {} will be replaced with the 'Media sources' translation
+ _("mw-ui", "Core repositories are not enabled. See the '{}' tab.").format(_("Sources",_("Media sources"))),
+ )
+ message.exec()
return
proc = subprocess.Popen(["/usr/bin/gurpmi", cmd[0]])
proc.wait()
- # Give the signal to reload the applist
- self.installed.emit()
def install_and_launch(self, app):
"""
@@ -169,6 +172,28 @@ class SlidePage(QWidget):
self.command([cmd[1]])
+class SlidePage(QWidget, Commands):
+ """Widget pour une page individuelle du diaporama"""
+
+ def __init__(self, title):
+ super().__init__()
+
+ # Stocker le titre pour référence
+ self.title = title
+
+ def paintEvent(self, event):
+ painter = QPainter(self)
+ gradient = QLinearGradient(0, 0, 0, self.height())
+ gradient.setColorAt(0.0, QColor("#262F45"))
+ gradient.setColorAt(1.0, QColor("#2397D4"))
+ painter.setBrush(gradient)
+ painter.setPen(Qt.PenStyle.NoPen)
+ painter.drawRect(self.rect())
+
+ def resizeEvent(self, event):
+ self.paintEvent(event)
+
+
class Links(SlidePage):
"""Widget pour une page individuelle du diaporama"""
@@ -228,8 +253,8 @@ class Links(SlidePage):
layout.setSpacing(30)
col = 1
- for title in ("Documentation", "Support", "Community"):
- button = QLabel(_("Links", title))
+ for title in (_("Links","Documentation"), _("Links", "Support"), _("Links", "Community")):
+ button = QLabel(title)
button.setAlignment(Qt.AlignmentFlag.AlignCenter)
button.setWordWrap(True)
button.setStyleSheet(
@@ -492,14 +517,14 @@ class Mcc(SlidePage):
layout.addWidget(title_label)
entries_list = [
- "Software Management",
- "Hardware",
- "Network and Internet",
- "System",
- "Network Sharing",
- "Local Disks",
- "Security",
- "Boot",
+ _("Mcc", "Software Management"),
+ _("Mcc", "Hardware"),
+ _("Mcc", "Network and Internet"),
+ _("Mcc", "System"),
+ _("Mcc", "Network Sharing"),
+ _("Mcc", "Local Disks"),
+ _("Mcc","Security"),
+ _("Mcc", "Boot"),
]
content_label = QLabel(
@@ -508,10 +533,10 @@ class Mcc(SlidePage):
"<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])
+ + "<BR>• ".join(entries_list)
)
content_label.setWordWrap(True)
- content_label.setStyleSheet("font-size: 14px; color: white;")
+ content_label.setStyleSheet("font-size: 14px; color: white; padding: 0px 60px")
layout.addWidget(content_label)
button_layout = QHBoxLayout()
@@ -561,7 +586,7 @@ class InstallSoftware(SlidePage):
)
)
content_label.setWordWrap(True)
- content_label.setStyleSheet("font-size: 14px; color: white;")
+ content_label.setStyleSheet("font-size: 14px; color: white; padding: 0px 60px")
layout.addWidget(content_label)
button_layout = QHBoxLayout()
@@ -600,7 +625,7 @@ class InstallSoftware(SlidePage):
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;")
+ content_label2.setStyleSheet("font-size: 14px; color: white; padding: 0px 60px")
layout.addWidget(content_label2)
button3_layout = QHBoxLayout()
@@ -700,10 +725,11 @@ class AppListPage(QWidget):
def __init__(self, group):
super().__init__()
- list_layout = QVBoxLayout()
+ self.list_layout = QVBoxLayout()
+ index = 0
for item in AppList:
if group in item["group"]:
- list_layout.addWidget(
+ self.list_layout.addWidget(
ApplistItem(
item["group"],
item["icon"],
@@ -712,11 +738,35 @@ class AppListPage(QWidget):
item["description"],
item["repo"],
item["command"],
+ index,
+ self,
)
)
- list_layout.addStretch(0)
- self.setLayout(list_layout)
-
+ index += 1
+ self.list_layout.addStretch(0)
+ self.setLayout(self.list_layout)
+
+ def update_item(self, widget, applist_index):
+ index = self.list_layout.indexOf(widget)
+ widget.deleteLater()
+ item = AppList[applist_index]
+ self.list_layout.insertWidget(
+ index,
+ ApplistItem(
+ item["group"],
+ item["icon"],
+ item["name"],
+ item["title"],
+ item["description"],
+ item["repo"],
+ item["command"],
+ index,
+ self,
+ )
+ )
+ self.update()
+
+
class Configuration(SlidePage):
def __init__(self):
@@ -731,7 +781,7 @@ class Configuration(SlidePage):
for config in cf.configuration:
content_label = QLabel(config)
content_label.setWordWrap(True)
- content_label.setStyleSheet("font-size: 14px; color: white;")
+ content_label.setStyleSheet("font-size: 14px; color: white; padding: 0px 60px")
layout.addWidget(content_label)
# About button
@@ -775,7 +825,7 @@ class Live(SlidePage):
)
)
content_label.setWordWrap(True)
- content_label.setStyleSheet("font-size: 14px; color: white;")
+ content_label.setStyleSheet("font-size: 14px; color: white; padding: 0px 60px")
layout.addWidget(content_label)
content_label2 = QLabel(
@@ -785,7 +835,7 @@ class Live(SlidePage):
)
)
content_label2.setWordWrap(True)
- content_label2.setStyleSheet("font-size: 14px; color: white;")
+ content_label2.setStyleSheet("font-size: 14px; color: white; padding: 0px 60px")
layout.addWidget(content_label2)
@@ -820,7 +870,7 @@ class Install(SlidePage):
)
)
content_label.setWordWrap(True)
- content_label.setStyleSheet("font-size: 14px; color: white;")
+ content_label.setStyleSheet("font-size: 14px; color: white; padding: 0px 60px")
layout.addWidget(content_label)
image = QPixmap("file:/usr/share/icons/draklive-install.png")
@@ -866,12 +916,14 @@ class GradientLegend(QWidget):
painter.drawRect(self.rect())
-class ApplistItem(QWidget):
+class ApplistItem(QWidget, Commands):
"""An element in application list"""
- def __init__(self, group, icon, name, title, description, repo, command):
+ def __init__(self, group, icon, name, title, description, repo, command, index, parent):
super().__init__()
+ self.index = index
+ self.parent = parent
layout = QHBoxLayout()
layout.setContentsMargins(2, 2, 2, 2)
image = QPixmap(icon)
@@ -897,6 +949,7 @@ class ApplistItem(QWidget):
if (not release) or (repo != inst_repo and inst_repo == ""):
# the application is not yet installed, we display an Install button
button = MyPushButton(_("mw-ui", "Install"))
+ button.clicked.connect(partial(self.installation, [name, repo]))
else:
if command == "":
# there is no command associated, we display it is installed
@@ -914,6 +967,7 @@ class ApplistItem(QWidget):
else:
# display a button for launching command associated
button = MyPushButton(_("mw-ui", "Launch"))
+ button.clicked.connect(partial(self.command, [command]))
button.setFixedWidth(QApplication.font().pointSize() * 10)
layout.addWidget(button)
# label for repository
@@ -936,8 +990,14 @@ class ApplistItem(QWidget):
)
layout.addWidget(repo_label)
self.setLayout(layout)
+
+ def installation(self, args):
+ self.install(args)
+ # Give the signal to reload the app widget
+ self.parent.update_item(self, self.index)
class MyPushButton(QPushButton):
+ """ For styling PushButton """
def __init__(self, label):
super().__init__(label)
@@ -1261,7 +1321,7 @@ class SlideShowApp(QMainWindow):
def __init__(self):
super().__init__()
#: the application title
- self.setWindowTitle(_("mw-ui", _("Welcome", "Welcome to Mageia")))
+ self.setWindowTitle( _("Welcome", "Welcome to Mageia"))
self.setGeometry(100, 100, 100 + DEFAULT_WIDTH, 700)
# central Widget