|
| 1 | +import sys |
| 2 | +import os |
| 3 | +import webbrowser |
| 4 | +import subprocess |
| 5 | +from PySide6.QtWidgets import QApplication, QWidget, QLabel, QPushButton, QVBoxLayout, QHBoxLayout, QFrame |
| 6 | +from PySide6.QtGui import QPixmap, QFont |
| 7 | +from PySide6.QtCore import Qt |
| 8 | + |
| 9 | +class HackerOSWelcome(QWidget): |
| 10 | + def __init__(self): |
| 11 | + super().__init__() |
| 12 | + self.setWindowTitle("HackerOS Welcome") |
| 13 | + self.setGeometry(100, 100, 900, 650) |
| 14 | + self.setStyleSheet("background-color: #121212; color: white;") |
| 15 | + self.initUI() |
| 16 | + |
| 17 | + def initUI(self): |
| 18 | + main_layout = QVBoxLayout() |
| 19 | + top_layout = QHBoxLayout() |
| 20 | + |
| 21 | + # Logo |
| 22 | + self.logo_label = QLabel(self) |
| 23 | + pixmap = QPixmap("/usr/share/HackerOS/ICONS/HackerOS.png") |
| 24 | + self.logo_label.setPixmap(pixmap) |
| 25 | + self.logo_label.setFixedSize(120, 120) |
| 26 | + self.logo_label.setScaledContents(True) |
| 27 | + top_layout.addWidget(self.logo_label) |
| 28 | + |
| 29 | + # Title |
| 30 | + self.title_label = QLabel("Witaj w HackerOS!", self) |
| 31 | + self.title_label.setFont(QFont("Arial", 28, QFont.Bold)) |
| 32 | + self.title_label.setAlignment(Qt.AlignCenter) |
| 33 | + top_layout.addWidget(self.title_label) |
| 34 | + |
| 35 | + main_layout.addLayout(top_layout) |
| 36 | + |
| 37 | + self.subtitle_label = QLabel("Twój system do Gier i Etycznego Hakowania", self) |
| 38 | + self.subtitle_label.setFont(QFont("Arial", 18)) |
| 39 | + self.subtitle_label.setAlignment(Qt.AlignCenter) |
| 40 | + main_layout.addWidget(self.subtitle_label) |
| 41 | + |
| 42 | + # Separator |
| 43 | + separator = QFrame() |
| 44 | + separator.setFrameShape(QFrame.HLine) |
| 45 | + separator.setFrameShadow(QFrame.Sunken) |
| 46 | + separator.setStyleSheet("background-color: #888; height: 2px;") |
| 47 | + main_layout.addWidget(separator) |
| 48 | + |
| 49 | + # Buttons layout |
| 50 | + buttons_layout = QHBoxLayout() |
| 51 | + left_buttons = QVBoxLayout() |
| 52 | + right_buttons = QVBoxLayout() |
| 53 | + |
| 54 | + button_style = """ |
| 55 | + QPushButton { |
| 56 | + background-color: #1E1E1E; |
| 57 | + color: white; |
| 58 | + border: 2px solid #555; |
| 59 | + border-radius: 8px; |
| 60 | + padding: 10px; |
| 61 | + font-size: 14px; |
| 62 | + } |
| 63 | + QPushButton:hover { |
| 64 | + background-color: #333; |
| 65 | + border-color: #777; |
| 66 | + } |
| 67 | + QPushButton:pressed { |
| 68 | + background-color: #444; |
| 69 | + } |
| 70 | + """ |
| 71 | + |
| 72 | + # Left side buttons |
| 73 | + buttons_left = [ |
| 74 | + ("Sprawdź aktualizacje", self.checkUpdates), |
| 75 | + ("Uruchom narzędzia HackerOS", self.launchTools), |
| 76 | + ("Otwórz stronę HackerOS", lambda: webbrowser.open("https://hackeros-linux-system.github.io/HackerOS-Website/Home-page.html")), |
| 77 | + ("Otwórz X", lambda: webbrowser.open("https://x.com/hackeros_linux")), |
| 78 | + ("Otwórz dokumentację", self.openDocumentation), |
| 79 | + ("Uruchom Steam", self.launchSteam), |
| 80 | + ("Otwórz sklep z aplikacjami", self.openSoftware) |
| 81 | + ] |
| 82 | + for text, action in buttons_left: |
| 83 | + btn = QPushButton(text, self) |
| 84 | + btn.setStyleSheet(button_style) |
| 85 | + btn.clicked.connect(action) |
| 86 | + left_buttons.addWidget(btn) |
| 87 | + |
| 88 | + # Right side buttons |
| 89 | + buttons_right = [ |
| 90 | + ("Proton Updater", "/usr/share/HackerOS/Scripts/Bin/Proton-Updater.sh"), |
| 91 | + ("Switch to Hacker Mode", "/usr/share/HackerOS/Scripts/Bin/Switch_To_Hacker-Mode.sh"), |
| 92 | + ("HackerOS Cockpit", "/usr/share/HackerOS/Scripts/Bin/HackerOS-Cockpit.sh"), |
| 93 | + ("Update System", "/usr/share/HackerOS/Scripts/Bin/update_system.sh"), |
| 94 | + ("Check updates", "/usr/share/HackerOS/Scripts/Bin/check_updates_notify.sh"), |
| 95 | + ("Hacker Game", "love /usr/share/HackerOS/Scripts/Hacker-Games/hacker-game.love"), |
| 96 | + ("Starblaster", "/usr/share/HackerOS/Scripts/Hacker-Games/starblaster"), |
| 97 | + ("The Racer", "/usr/share/HackerOS/Scripts/Hacker-Games/The-Racer"), |
| 98 | + ("Hacker Launcher", "/usr/share/HackerOS/Scripts/HackerOS-Apps/Hacker_Launcher") |
| 99 | + ] |
| 100 | + for text, cmd in buttons_right: |
| 101 | + btn = QPushButton(text, self) |
| 102 | + btn.setStyleSheet(button_style) |
| 103 | + btn.clicked.connect(lambda _, c=cmd: self.run_command_with_feedback(c)) |
| 104 | + right_buttons.addWidget(btn) |
| 105 | + |
| 106 | + buttons_layout.addLayout(left_buttons) |
| 107 | + buttons_layout.addLayout(right_buttons) |
| 108 | + main_layout.addLayout(buttons_layout) |
| 109 | + self.setLayout(main_layout) |
| 110 | + |
| 111 | + def run_command_with_feedback(self, cmd): |
| 112 | + """Wspólna metoda do uruchamiania komend z feedbackiem.""" |
| 113 | + full_cmd = f"bash -c '{cmd}'" |
| 114 | + result = os.system(f"pkexec {full_cmd}") |
| 115 | + if result == 0: |
| 116 | + self.subtitle_label.setText(f"Uruchomiono: {cmd.split()[0]}.") |
| 117 | + else: |
| 118 | + self.subtitle_label.setText(f"Błąd podczas uruchamiania: {cmd.split()[0]}.") |
| 119 | + |
| 120 | + def checkUpdates(self): |
| 121 | + result = os.system("pkexec bash -c 'apt update && apt upgrade -y && flatpak update'") |
| 122 | + if result == 0: |
| 123 | + self.subtitle_label.setText("Sprawdzenie aktualizacji zakończone pomyślnie.") |
| 124 | + else: |
| 125 | + self.subtitle_label.setText("Błąd podczas sprawdzania aktualizacji.") |
| 126 | + |
| 127 | + def launchTools(self): |
| 128 | + result = os.system("pkexec bash /usr/share/HackerOS/Scripts/Bin/install-tools.sh") |
| 129 | + if result == 0: |
| 130 | + self.subtitle_label.setText("Uruchomiono narzędzia HackerOS pomyślnie.") |
| 131 | + else: |
| 132 | + self.subtitle_label.setText("Błąd podczas uruchamiania narzędzi HackerOS.") |
| 133 | + |
| 134 | + def launchSteam(self): |
| 135 | + try: |
| 136 | + subprocess.run(["flatpak", "run", "com.valvesoftware.Steam", "-gamepadui"], check=True) |
| 137 | + self.subtitle_label.setText("Steam został uruchomiony w trybie gamepad UI.") |
| 138 | + except FileNotFoundError: |
| 139 | + os.system("flatpak install com.valvesoftware.Steam") |
| 140 | + try: |
| 141 | + subprocess.run(["steam", "-gamepadui"], check=True) |
| 142 | + self.subtitle_label.setText("Steam zainstalowany i uruchomiony.") |
| 143 | + except subprocess.CalledProcessError: |
| 144 | + self.subtitle_label.setText("Błąd podczas uruchamiania Steam po instalacji.") |
| 145 | + except subprocess.CalledProcessError: |
| 146 | + self.subtitle_label.setText("Wystąpił błąd podczas uruchamiania Steam.") |
| 147 | + |
| 148 | + def openSoftware(self): |
| 149 | + result = os.system("gnome-software &") |
| 150 | + self.subtitle_label.setText("Uruchomiono Sklep z aplikacjami.") |
| 151 | + |
| 152 | + def openDocumentation(self): |
| 153 | + result = os.system("pkexec bash /usr/share/HackerOS/Scripts/Bin/HackerOS-Documentation.sh") |
| 154 | + if result == 0: |
| 155 | + self.subtitle_label.setText("Otworzono dokumentację HackerOS.") |
| 156 | + else: |
| 157 | + self.subtitle_label.setText("Błąd podczas otwierania dokumentacji.") |
| 158 | + |
| 159 | + |
| 160 | +if __name__ == '__main__': |
| 161 | + app = QApplication(sys.argv) |
| 162 | + window = HackerOSWelcome() |
| 163 | + window.show() |
| 164 | + sys.exit(app.exec()) |
0 commit comments