Seregon/PkgToolBox

Toolbox for analyzing and editing pkg application files for psp,ps3, ps4 and ps5, includes the most useful functions you might need.

Python/57.3 KB/No license
GraphicUserInterface/widgets/info_tab.py
1"""
2Info tab widget for displaying PKG information
3"""
4from PyQt5.QtWidgets import (QVBoxLayout, QTreeWidget, QTreeWidgetItem,
5 QGroupBox, QLabel)
6from PyQt5.QtCore import Qt
7from .base_tab import BaseTab
8 
9class InfoTab(BaseTab):
10 """Tab for displaying PKG information"""
11
12 def setup_ui(self):
13 """Setup the info tab UI"""
14 # Main info group
15 info_group = QGroupBox("Package Information")
16 info_layout = QVBoxLayout()
17
18 # Tree widget for displaying info
19 self.info_tree = QTreeWidget()
20 self.info_tree.setHeaderLabels(["Property", "Value", "Description"])
21 self.info_tree.setAlternatingRowColors(True)
22 self.info_tree.setRootIsDecorated(False)
23
24 # Style the tree widget
25 self.info_tree.setStyleSheet("""
26 QTreeWidget {
27 border: 1px solid #bdc3c7;
28 border-radius: 6px;
29 background-color: white;
30 selection-background-color: #3498db;
31 }
32 QTreeWidget::item {
33 padding: 8px;
34 border-bottom: 1px solid #ecf0f1;
35 }
36 QTreeWidget::item:hover {
37 background-color: #f8f9fa;
38 }
39 QTreeWidget::item:selected {
40 background-color: #3498db;
41 color: white;
42 }
43 QHeaderView::section {
44 background-color: #34495e;
45 color: white;
46 padding: 10px;
47 border: none;
48 font-weight: bold;
49 }
50 """)
51
52 info_layout.addWidget(self.info_tree)
53 info_group.setLayout(info_layout)
54
55 # Add to main layout
56 self.layout.addWidget(info_group)
57
58 def update_info(self, info_dict):
59 """Update info display with package information"""
60 self.info_tree.clear()
61
62 # Dictionary of descriptions for each key
63 descriptions = {
64 "pkg_magic": "Magic number identifying the PKG file format",
65 "pkg_type": "Type of the PKG (e.g., 0x1 for PS4)",
66 "pkg_file_count": "Number of files contained in the PKG",
67 "pkg_entry_count": "Number of entries in the PKG table",
68 "pkg_sc_entry_count": "Number of entries in the SC table",
69 "pkg_entry_data_size": "Size of the entry data in bytes",
70 "pkg_body_size": "Size of the PKG body in bytes",
71 "pkg_content_id": "Unique identifier for the PKG content",
72 "pkg_content_type": "Type of content in the PKG",
73 "pkg_content_flags": "Flags describing the content",
74 "pkg_promote_size": "Size of promotional content",
75 "pkg_version_date": "Version date of the PKG",
76 "pkg_version": "Package version",
77 "pkg_revision": "PKG format revision",
78 "title_id": "Title ID",
79 "system_version": "Minimum required system version",
80 "app_version": "Application version",
81 "total_size": "Total package size",
82 "pkg_size": "Package size",
83 "install_directory": "Installation directory",
84 "content_id": "Content ID",
85 }
86
87 # Add information to tree widget
88 for key, value in info_dict.items():
89 item = QTreeWidgetItem(self.info_tree)
90 item.setText(0, str(key))
91 item.setText(1, str(value))
92 item.setText(2, descriptions.get(key, ""))
93
94 # Resize columns to fit content
95 self.info_tree.resizeColumnToContents(0)
96 self.info_tree.resizeColumnToContents(1)
97 self.info_tree.resizeColumnToContents(2)
98