forked from wasdwasd0105/7zip-pyside
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
62 lines (49 loc) · 1.98 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import sys
from PySide6.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QSplitter, QWidget, QLineEdit, QMessageBox
from PySide6.QtCore import Qt, QDir, QEvent, QSettings
from menu_bar import MenuBar
from tool_bar import ToolBar
from navigation_pane import NavigationContainer
from main_pane import MainPane
from SevenZHelperMacOS import get_app_version
class CustomApplication(QApplication):
def __init__(self, argv):
super().__init__(argv)
self.main_window = None
def event(self, event: QEvent) -> bool:
if event.type() == QEvent.Type.FileOpen:
file_path = event.file()
if self.main_window: # Just to be safe
self.main_window.main_pane.display_archive_contents(file_path)
return True
return super().event(event)
class SevenZipGUI(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle('7-Zip Archiver')
self.setGeometry(100, 100, 800, 600)
# Set up Menu Bar and Toolbar
self.menuBarInstance = MenuBar(self)
self.setMenuBar(self.menuBarInstance)
self.addToolBar(ToolBar())
# Set up Navigation Pane (Left) and Main Pane (Right)
self.nav_pane = NavigationContainer(self)
self.main_pane = MainPane()
self.nav_pane.nav_pane.set_main_pane(self.main_pane)
# Create a horizontal splitter for adjustable width
splitter = QSplitter(Qt.Orientation.Horizontal)
splitter.addWidget(self.nav_pane)
splitter.addWidget(self.main_pane)
splitter.setStretchFactor(0, 1) # Left panel
splitter.setStretchFactor(1, 2) # Right panel
layout = QVBoxLayout()
layout.addWidget(splitter)
container = QWidget()
container.setLayout(layout)
self.setCentralWidget(container)
self.show()
if __name__ == '__main__':
app = CustomApplication(sys.argv)
window = SevenZipGUI()
app.main_window = window
sys.exit(app.exec())