-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgui_components.py
More file actions
337 lines (289 loc) · 11.3 KB
/
Copy pathgui_components.py
File metadata and controls
337 lines (289 loc) · 11.3 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
from PySide6.QtCore import Qt, QPropertyAnimation, Property, QEasingCurve, QPoint
from PySide6.QtGui import (QPainter, QLinearGradient, QBrush, QColor,
QPen, QRadialGradient, QPainterPath)
from PySide6.QtWidgets import (QFrame, QPushButton, QLabel, QVBoxLayout,
QHBoxLayout, QTextEdit, QLineEdit, QComboBox,
QGraphicsDropShadowEffect, QSizePolicy, QWidget,
QScrollArea)
# UI renk tanımlamaları
PRIMARY_COLOR = QColor(42, 42, 64) # Dark blue
SECONDARY_COLOR = QColor(72, 72, 108) # Medium blue
ACCENT_COLOR = QColor(114, 159, 207) # Light blue
GRADIENT_START = QColor(35, 35, 55) # Darker blue
GRADIENT_END = QColor(52, 52, 78) # Lighter blue
TEXT_COLOR = QColor(240, 240, 250) # Almost white
HIGHLIGHT_COLOR = QColor(72, 139, 220) # Bright blue
class GradientFrame(QFrame):
"""Frame with gradient background"""
def __init__(self, parent=None, start_color=GRADIENT_START, end_color=GRADIENT_END,
direction=Qt.Vertical):
super().__init__(parent)
self.start_color = start_color
self.end_color = end_color
self.direction = direction
def paintEvent(self, event):
painter = QPainter(self)
gradient = QLinearGradient()
if self.direction == Qt.Vertical:
gradient.setStart(0, 0)
gradient.setFinalStop(0, self.height())
else:
gradient.setStart(0, 0)
gradient.setFinalStop(self.width(), 0)
gradient.setColorAt(0, self.start_color)
gradient.setColorAt(1, self.end_color)
painter.fillRect(self.rect(), QBrush(gradient))
class RoundedFrame(QFrame):
"""Frame with rounded corners"""
def __init__(self, parent=None, radius=10, bg_color=PRIMARY_COLOR):
super().__init__(parent)
self.radius = radius
self.bg_color = bg_color
def paintEvent(self, event):
painter = QPainter(self)
painter.setRenderHint(QPainter.Antialiasing)
# Set background color
painter.setBrush(QBrush(self.bg_color))
# Set border
painter.setPen(Qt.NoPen)
# Draw rounded rectangle
painter.drawRoundedRect(self.rect(), self.radius, self.radius)
class AnimatedButton(QPushButton):
"""Button with hover and click animations"""
def __init__(self, text="", parent=None):
super().__init__(text, parent)
self.setStyleSheet("""
QPushButton {
background-color: #3C6E71;
color: white;
border: none;
border-radius: 5px;
padding: 8px 12px;
font-weight: bold;
}
QPushButton:hover {
background-color: #4D8C8F;
}
QPushButton:pressed {
background-color: #2A5254;
}
""")
# Add subtle shadow effect
shadow = QGraphicsDropShadowEffect(self)
shadow.setOffset(0, 2)
shadow.setBlurRadius(5)
shadow.setColor(QColor(0, 0, 0, 80))
self.setGraphicsEffect(shadow)
class InfoPanel(QFrame):
"""Information panel with title and content"""
def __init__(self, title, parent=None):
super().__init__(parent)
self.setObjectName("infoPanel")
self.setStyleSheet("""
#infoPanel {
background-color: rgba(52, 52, 78, 180);
border-radius: 8px;
border: 1px solid rgba(114, 159, 207, 120);
}
QLabel {
color: #E0E0E0;
}
""")
layout = QVBoxLayout(self)
# Title
title_label = QLabel(title)
title_label.setStyleSheet("""
font-size: 16px;
font-weight: bold;
color: #A0C8E5;
padding-bottom: 5px;
border-bottom: 1px solid rgba(114, 159, 207, 120);
""")
# Content
self.content = QLabel("Bekliyor...")
self.content.setAlignment(Qt.AlignTop | Qt.AlignLeft)
self.content.setWordWrap(True)
layout.addWidget(title_label)
layout.addWidget(self.content)
def update_content(self, text):
self.content.setText(text)
class ChatPanel(QFrame):
"""Chat panel with history and input"""
def __init__(self, parent=None):
super().__init__(parent)
self.setObjectName("chatPanel")
self.setStyleSheet("""
#chatPanel {
background-color: rgba(52, 52, 78, 180);
border-radius: 8px;
border: 1px solid rgba(114, 159, 207, 120);
}
""")
layout = QVBoxLayout(self)
# Chat history
self.chat_history = QTextEdit()
self.chat_history.setReadOnly(True)
self.chat_history.setStyleSheet("""
QTextEdit {
background-color: rgba(52, 52, 78, 180);
color: #E0E0E0;
border: none;
border-radius: 8px;
padding: 10px;
}
""")
# Chat input
input_layout = QHBoxLayout()
self.chat_input = QLineEdit()
self.chat_input.setPlaceholderText("Nesne hakkında soru sorun...")
self.chat_input.setStyleSheet("""
QLineEdit {
background-color: #3C6E71;
color: white;
border: none;
border-radius: 4px;
padding: 8px;
}
""")
send_button = AnimatedButton("Gönder")
input_layout.addWidget(self.chat_input)
input_layout.addWidget(send_button)
layout.addWidget(self.chat_history)
layout.addLayout(input_layout)
# Connect signals
self.chat_input.returnPressed.connect(self.on_send)
send_button.clicked.connect(self.on_send)
def on_send(self):
"""Handle send button click or enter press"""
text = self.chat_input.text().strip()
if text:
self.chat_history.append(f"<b>Siz:</b> {text}")
self.chat_input.clear()
# Emit signal for parent to handle
self.parent().on_chat_input(text)
class VideoPanel(QFrame):
"""Video display panel"""
def __init__(self, parent=None):
super().__init__(parent)
self.setObjectName("videoPanel")
self.setStyleSheet("""
#videoPanel {
background-color: rgba(52, 52, 78, 180);
border-radius: 8px;
border: 1px solid rgba(114, 159, 207, 120);
}
""")
layout = QVBoxLayout(self)
# Title
title = QLabel("Nesne Görselleştirme")
title.setStyleSheet("""
font-size: 16px;
font-weight: bold;
color: #A0C8E5;
padding-bottom: 5px;
border-bottom: 1px solid rgba(114, 159, 207, 120);
""")
title.setAlignment(Qt.AlignCenter)
# Video display
self.video_label = QLabel("Nesne tespit edildiğinde görselleştirme burada gösterilecek")
self.video_label.setAlignment(Qt.AlignCenter)
self.video_label.setStyleSheet("""
background-color: #2E2E2E;
color: #C9D6DF;
border-radius: 8px;
padding: 10px;
font-style: italic;
""")
self.video_label.setFixedSize(320, 240)
self.video_label.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
# 3D model button
self.load_model_button = AnimatedButton("3D Model Yükle")
self.load_model_button.setStyleSheet("""
QPushButton {
background-color: #3C6E71;
color: white;
border: none;
border-radius: 5px;
padding: 8px 12px;
font-weight: bold;
margin-top: 10px;
}
QPushButton:hover {
background-color: #4D8C8F;
}
QPushButton:disabled {
background-color: #2A5254;
color: #888888;
}
""")
self.load_model_button.setEnabled(False)
layout.addWidget(title)
layout.addWidget(self.video_label, 0, Qt.AlignCenter)
layout.addWidget(self.load_model_button, 0, Qt.AlignCenter)
def update_frame(self, pixmap):
"""Update video display with new frame"""
if pixmap:
self.video_label.setPixmap(pixmap)
def set_text(self, text):
"""Set text message in video display"""
self.video_label.setText(text)
def enable_model_button(self, enabled=True):
"""Enable/disable 3D model button"""
self.load_model_button.setEnabled(enabled)
class ControlPanel(QFrame):
"""Control panel with buttons and settings"""
def __init__(self, parent=None):
super().__init__(parent)
self.setObjectName("controlPanel")
self.setStyleSheet("""
#controlPanel {
background-color: rgba(52, 52, 78, 180);
border-radius: 8px;
border: 1px solid rgba(114, 159, 207, 120);
}
""")
layout = QVBoxLayout(self)
# Camera controls
camera_controls = QHBoxLayout()
self.screenshot_button = AnimatedButton("Ekran Görüntüsü")
self.record_button = AnimatedButton("Kayıt Başlat")
camera_controls.addWidget(self.screenshot_button)
camera_controls.addWidget(self.record_button)
# Model selection
model_layout = QHBoxLayout()
model_label = QLabel("YOLO Modeli:")
model_label.setStyleSheet("color: #E0E0E0;")
self.model_combo = QComboBox()
self.model_combo.setStyleSheet("""
QComboBox {
background-color: #3C6E71;
color: white;
border: none;
border-radius: 4px;
padding: 5px;
}
QComboBox::drop-down {
border: none;
}
QComboBox::down-arrow {
image: none;
}
""")
self.select_model_button = AnimatedButton("Model Seç")
model_layout.addWidget(model_label)
model_layout.addWidget(self.model_combo)
model_layout.addWidget(self.select_model_button)
layout.addLayout(camera_controls)
layout.addLayout(model_layout)
# Connect signals
self.screenshot_button.clicked.connect(self.parent().take_screenshot)
self.record_button.clicked.connect(self.parent().toggle_recording)
self.model_combo.currentTextChanged.connect(self.parent().on_model_changed)
self.select_model_button.clicked.connect(self.parent().select_yolo_model)
def update_record_button(self, is_recording):
"""Update record button text"""
self.record_button.setText("Kayıt Durdur" if is_recording else "Kayıt Başlat")
def set_models(self, models):
"""Set available models in combo box"""
self.model_combo.clear()
self.model_combo.addItems(models)