-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_window.py
More file actions
128 lines (100 loc) · 4.21 KB
/
Copy pathmain_window.py
File metadata and controls
128 lines (100 loc) · 4.21 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# main_window.py
# v1.0.0
from PySide6.QtWidgets import (
QMainWindow, QWidget, QVBoxLayout, QLabel, QStatusBar, QSplitter,
QHBoxLayout, QMessageBox
)
from PySide6.QtCore import Qt
from ui.components.address_bar import AddressBar
from ui.components.tree_view import TreeView
from ui.components.export_panel import ExportPanel
from ui.components.search_panel import SearchPanel
from ui.components.exclusion_panel import ExclusionPanel
from ui.components.menu_bar import MenuBar
from ui.components.about_dialog import AboutDialog
from ui.components.context_menu_actions import ContextMenuActions
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setup_ui()
def setup_ui(self):
self.setWindowTitle("File Tree Generator")
self.resize(900, 700)
# Menu bar
self.menu_bar = MenuBar(self)
self.setMenuBar(self.menu_bar)
# Central widget
central_widget = QWidget()
self.setCentralWidget(central_widget)
# Main layout - reduce spacing and margins
main_layout = QVBoxLayout(central_widget)
main_layout.setContentsMargins(10, 10, 10, 10)
main_layout.setSpacing(5)
# Directory path section
dir_section = QWidget()
dir_layout = QVBoxLayout(dir_section)
dir_layout.setContentsMargins(0, 0, 0, 0)
dir_layout.setSpacing(2)
dir_label = QLabel("Directory Path:")
self.address_bar = AddressBar()
dir_layout.addWidget(dir_label)
dir_layout.addWidget(self.address_bar)
# Splitter for main content
splitter = QSplitter(Qt.Horizontal)
# Left side: Tree view and search panel
left_widget = QWidget()
left_layout = QVBoxLayout(left_widget)
left_layout.setContentsMargins(0, 0, 0, 0)
left_layout.setSpacing(5)
self.search_panel = SearchPanel()
self.tree_view = TreeView()
left_layout.addWidget(self.search_panel)
left_layout.addWidget(self.tree_view)
# Right side: Exclusion panel
right_widget = QWidget()
right_layout = QVBoxLayout(right_widget)
right_layout.setContentsMargins(0, 0, 0, 0)
right_layout.setSpacing(5)
self.exclusion_panel = ExclusionPanel()
right_layout.addWidget(self.exclusion_panel)
right_layout.addStretch()
# Add panels to splitter
splitter.addWidget(left_widget)
splitter.addWidget(right_widget)
splitter.setStretchFactor(0, 3)
splitter.setStretchFactor(1, 1)
# Export panel
export_container = QWidget()
export_layout = QHBoxLayout(export_container)
export_layout.setContentsMargins(0, 0, 0, 0)
self.export_panel = ExportPanel()
export_layout.addWidget(self.export_panel)
# Status bar
self.status_bar = QStatusBar()
self.setStatusBar(self.status_bar)
# Add widgets to layout
main_layout.addWidget(dir_section)
main_layout.addWidget(splitter, 1)
main_layout.addWidget(export_container)
# Connect search signals
self.search_panel.search_requested.connect(self.tree_view.highlight_search_results)
self.search_panel.clear_requested.connect(self.tree_view.clear_search)
# Connect menu bar signals
self.menu_bar.about_requested.connect(self.show_about_dialog)
# Context menu actions handler
self.context_menu_actions = ContextMenuActions(
main_window=self,
menu_bar=self.menu_bar,
status_bar=self.status_bar
)
self.menu_bar.install_context_menu_requested.connect(self.context_menu_actions.on_install_context_menu)
self.menu_bar.uninstall_context_menu_requested.connect(self.context_menu_actions.on_uninstall_context_menu)
self.menu_bar.context_menu.aboutToShow.connect(self.context_menu_actions.update_context_menu_status)
# Initial status update
self.context_menu_actions.update_context_menu_status()
def set_status(self, message: str):
"""Set a message in the status bar"""
self.status_bar.showMessage(message)
def show_about_dialog(self):
about_dialog = AboutDialog(self)
about_dialog.exec()