Skip to content

Commit 5b1cfa9

Browse files
committed
0.5.0
1 parent cd7c756 commit 5b1cfa9

File tree

16 files changed

+1399
-315
lines changed

16 files changed

+1399
-315
lines changed

data.db

0 Bytes
Binary file not shown.

src/gui/config.py

Lines changed: 557 additions & 157 deletions
Large diffs are not rendered by default.

src/gui/main.py

Lines changed: 68 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -383,30 +383,59 @@ class MessageButtonBar(QWidget):
383383
def __init__(self, parent):
384384
super().__init__(parent=parent)
385385
self.parent = parent
386-
self.mic_button = self.MicButton()
386+
self.mic_button = self.MicButton(self)
387387
self.enhance_button = TextEnhancerButton(self, self.parent, gen_block_folder_name='Enhance prompt')
388-
self.edit_button = self.EditButton()
388+
self.edit_button = self.EditButton(self)
389+
self.screenshot_button = self.ScreenshotButton(self)
390+
389391
self.layout = CVBoxLayout(self)
390392
h_layout = CHBoxLayout()
391393
h_layout.addWidget(self.mic_button)
392394
h_layout.addWidget(self.edit_button)
393395
self.layout.addLayout(h_layout)
394-
self.layout.addWidget(self.enhance_button)
396+
397+
h2_layout = CHBoxLayout()
398+
h2_layout.addWidget(self.enhance_button)
399+
h2_layout.addWidget(self.screenshot_button)
400+
self.layout.addLayout(h2_layout)
401+
395402
self.hide()
396403

397404
class EditButton(IconButton):
398-
def __init__(self):
399-
super().__init__(parent=None, icon_path=':/resources/icon-dots.png', size=20, opacity=0.75)
405+
def __init__(self, parent):
406+
super().__init__(parent=parent, icon_path=':/resources/icon-dots.png', size=20, opacity=0.75)
400407
self.setProperty("class", "send")
401408
self.clicked.connect(self.on_clicked)
402-
self.recording = False
403409

404410
def on_clicked(self):
405411
pass
406412

413+
class ScreenshotButton(IconButton):
414+
def __init__(self, parent):
415+
super().__init__(parent=parent, icon_path=':/resources/icon-screenshot.png', size=20, opacity=0.75)
416+
self.setProperty("class", "send")
417+
self.clicked.connect(self.on_clicked)
418+
419+
def on_clicked(self):
420+
# minimize app, take screenshot, maximize app
421+
main = find_main_widget(self)
422+
423+
try:
424+
import pyautogui
425+
pyautogui.screenshot() # check missing lib before minimizing
426+
main.showMinimized()
427+
screenshot = pyautogui.screenshot()
428+
main.showNormal()
429+
b64 = screenshot.tobytes()
430+
print(b64)
431+
except Exception as e:
432+
display_message(self, f'Error taking screenshot: {e}', 'Error', QMessageBox.Warning)
433+
finally:
434+
main.showNormal()
435+
407436
class MicButton(ToggleIconButton):
408-
def __init__(self):
409-
super().__init__(parent=None, icon_path=':/resources/icon-mic.png', color_when_checked='#6aab73', size=20, opacity=0.75)
437+
def __init__(self, parent):
438+
super().__init__(parent=parent, icon_path=':/resources/icon-mic.png', color_when_checked='#6aab73', size=20, opacity=0.75)
410439
self.setProperty("class", "send")
411440
self.recording = False
412441

@@ -458,40 +487,51 @@ def __init__(self, parent=None, color=None):
458487
elif not color.startswith('#'):
459488
color = '#ff6464'
460489

461-
# color = apply_alpha_to_hex(color, 0.8)
462490
self.setStyleSheet(f"""
463491
background-color: {color};
464492
border-radius: 10px;
465493
color: white;
466494
padding: 10px;
467495
""")
468496
self.setMaximumWidth(300)
469-
# self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
497+
outer_layout = QVBoxLayout(self)
498+
outer_layout.setContentsMargins(0, 0, 0, 0)
499+
outer_layout.setSpacing(0)
500+
501+
self.content = QWidget(self)
502+
content_layout = QVBoxLayout(self.content)
503+
content_layout.setContentsMargins(0, 0, 0, 0)
504+
content_layout.setSpacing(0)
470505

471-
self.layout = CVBoxLayout(self)
472506
self.label = QLabel()
473-
# set word wrap at 290px width
474-
# self.label.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
475-
# self.label.setMaximumWidth(290)
476-
# self.label.setWordWrap(True)
477-
self.layout.addWidget(self.label)
507+
self.label.setWordWrap(True)
508+
content_layout.addWidget(self.label)
509+
510+
outer_layout.addWidget(self.content)
511+
512+
self.content.setMinimumHeight(0)
478513

479514
self.timer = QTimer(self)
480515
self.timer.setSingleShot(True)
481516
self.timer.timeout.connect(self.hide_animation)
482517

483-
self.animation = QPropertyAnimation(self, b"maximumHeight")
518+
self.animation = QPropertyAnimation(self.content, b"minimumHeight")
484519
self.animation.setEasingCurve(QEasingCurve.InOutCubic)
485520
self.animation.finished.connect(self.on_animation_finished)
486521

487522
def show_message(self, message, duration=3000):
488523
self.label.setText(message)
489524
self.label.adjustSize()
525+
self.content.adjustSize()
490526
self.adjustSize()
491-
self.setMaximumHeight(0) # Start with zero height
492527

493-
# Animate showing
494-
target_height = self.sizeHint().height()
528+
QApplication.processEvents() # todo
529+
530+
self.content.setMinimumHeight(0)
531+
532+
target_height = self.content.sizeHint().height()
533+
534+
self.animation.stop()
495535
self.animation.setStartValue(0)
496536
self.animation.setEndValue(target_height)
497537
self.animation.setDuration(300)
@@ -500,15 +540,15 @@ def show_message(self, message, duration=3000):
500540
self.timer.start(duration)
501541

502542
def hide_animation(self):
503-
# Animate hiding
504-
current_height = self.height()
543+
current_height = self.content.minimumHeight()
544+
self.animation.stop()
505545
self.animation.setStartValue(current_height)
506546
self.animation.setEndValue(0)
507547
self.animation.setDuration(300)
508548
self.animation.start()
509549

510550
def on_animation_finished(self):
511-
if self.maximumHeight() == 0:
551+
if self.content.minimumHeight() == 0:
512552
self.hide()
513553
self.closed.emit(self)
514554

@@ -517,7 +557,7 @@ def enterEvent(self, event):
517557
event.accept()
518558

519559
def leaveEvent(self, event):
520-
self.timer.start(3000) # Reset timer when mouse leaves
560+
self.timer.start(3000)
521561
event.accept()
522562

523563

@@ -529,6 +569,7 @@ def __init__(self, parent):
529569
self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint | Qt.Tool)
530570
self.setAttribute(Qt.WA_TranslucentBackground)
531571
self.setAttribute(Qt.WA_ShowWithoutActivating) # Add this line
572+
self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred)
532573

533574
self.layout = CVBoxLayout(self)
534575
self.layout.setSpacing(4)
@@ -563,16 +604,8 @@ def remove_notification(self, notification):
563604
self.hide()
564605

565606
def update_position(self):
566-
# main_x, main_y = self.main.x(), self.main.y()
567607
self.move(self.main.x() + self.main.width() - self.width() - 4, self.main.y() + 50)
568-
# print(f'POSITION: main.x={self.main.x()}, main.width={self.main.width()}, self.width={self.width()}')
569-
# parent = self.parent()
570-
# if parent:
571-
# parent_geometry = parent.geometry()
572-
# self.adjustSize()
573-
# pos_x = parent_geometry.right() - self.width() - 20
574-
# pos_y = parent_geometry.top() + 20
575-
# self.move(pos_x, pos_y)
608+
576609

577610

578611
class MessageText(QTextEdit):
@@ -899,18 +932,6 @@ def __init__(self):
899932

900933
self.notification_manager.update_position()
901934

902-
def disp_msg(self, msg):
903-
self.notification_manager.show_notification(msg)
904-
905-
# @Slot(str, str)
906-
# def on_task_completed(self, task_id, result):
907-
# print(f"Task {task_id} completed with result: {result}")
908-
# # Update UI or perform any other actions
909-
# # def send_notification(self, message):
910-
# # notification = NotificationWidget(self)
911-
# # notification.show_message(message)
912-
# # self.notification_widgets.append(notification)
913-
914935
def pinned_pages(self): # todo?
915936
all_pinned_pages = {'Chat', 'Contexts', 'Agents', 'Settings'}
916937
# pinned_pages = self.system.config.dict.get('display.pinned_pages', []) # !! #
@@ -1047,6 +1068,8 @@ def sync_send_button_size(self):
10471068
self.message_text.button_bar.setFixedHeight(self.message_text.height())
10481069
self.message_text.button_bar.mic_button.setFixedHeight(int(self.message_text.height() / 2))
10491070
self.message_text.button_bar.enhance_button.setFixedHeight(int(self.message_text.height() / 2))
1071+
self.message_text.button_bar.edit_button.setFixedHeight(int(self.message_text.height() / 2))
1072+
self.message_text.button_bar.screenshot_button.setFixedHeight(int(self.message_text.height() / 2))
10501073

10511074
def is_bottom_corner(self):
10521075
screen_geo = QGuiApplication.primaryScreen().geometry() # get screen geometry

src/gui/pages/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def after_init(self):
7575
def sync_models(self):
7676
res = display_message_box(
7777
icon=QMessageBox.Question,
78-
text="This will reset your APIs and models to the latest version.\nAll model parameters will be reset\nAPI keys will be preserved\nAre you sure you want to continue?",
78+
text="This will reset your APIs and models to the latest version.\nThis might be up to date and you may need to add your models manually\nAll model parameters will be reset\nAPI keys will be preserved\nAre you sure you want to continue?",
7979
title="Reset APIs and models",
8080
buttons=QMessageBox.Yes | QMessageBox.No,
8181
)

src/gui/style.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ def get_stylesheet():
2626
# {'''border: 1px solid red;''' if is_dev_mode else ''}
2727
# {'border: 1px solid red;' if is_dev_mode else ''} border: 1px solid red;
2828
# {'''border: 1px solid red;''' if is_dev_mode else ''}
29+
# QWidget.conf:hover {{
30+
# border: 1px solid blue;
31+
# }}
2932
return f"""
3033
QWidget {{
3134
background-color: {PRIMARY_COLOR};

src/gui/widgets.py

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -784,8 +784,8 @@ class TextEnhancerButton(IconButton):
784784
enhancement_error_occurred = Signal(str)
785785

786786
def __init__(self, parent, widget, gen_block_folder_name):
787-
super().__init__(parent=widget, size=22, icon_path=':/resources/icon-wand.png', tooltip='Enhance the text using a system block.')
788-
self.setStyleSheet("background-color: transparent;")
787+
super().__init__(parent=parent, size=22, icon_path=':/resources/icon-wand.png', tooltip='Enhance the text using a system block.')
788+
self.setProperty("class", "send")
789789
self.widget = widget
790790

791791
self.gen_block_folder_name = gen_block_folder_name
@@ -1915,6 +1915,37 @@ def on_index_changed(self, index):
19151915
self.setCurrentIndex(self.findData('<NEW>') - 1)
19161916

19171917

1918+
class WorkspaceTypeComboBox(BaseComboBox):
1919+
def __init__(self, *args, **kwargs):
1920+
super().__init__(*args, **kwargs)
1921+
self.load()
1922+
# self.currentIndexChanged.connect(self.on_index_changed)
1923+
1924+
def load(self):
1925+
with block_signals(self):
1926+
self.clear()
1927+
roles = sql.get_results("SELECT name FROM workspace_types", return_type='list')
1928+
for role in roles:
1929+
self.addItem(role.title(), role)
1930+
# add a 'New Role' option
1931+
# self.addItem('< New >', '<NEW>')
1932+
1933+
# def on_index_changed(self, index):
1934+
# if self.itemData(index) == '<NEW>':
1935+
# new_role, ok = QInputDialog.getText(self, "New Type", "Enter the name for the new workspace type:")
1936+
# if ok and new_role:
1937+
# sql.execute("INSERT INTO roles (name) VALUES (?)", (new_role.lower(),))
1938+
#
1939+
# self.load()
1940+
#
1941+
# new_index = self.findText(new_role.title())
1942+
# if new_index != -1:
1943+
# self.setCurrentIndex(new_index)
1944+
# else:
1945+
# # If dialog was cancelled or empty input, revert to previous selection
1946+
# self.setCurrentIndex(self.findData('<NEW>') - 1)
1947+
1948+
19181949
class InputSourceComboBox(QWidget):
19191950
currentIndexChanged = Signal(int)
19201951
def __init__(self, parent):
@@ -2749,8 +2780,12 @@ def match_parameter(self, text, expression, format):
27492780
def clear_layout(layout, skip_count=0):
27502781
"""Clear all layouts and widgets from the given layout"""
27512782
while layout.count() > skip_count:
2752-
item = layout.takeAt(skip_count)
2783+
item = layout.itemAt(skip_count)
27532784
widget = item.widget()
2785+
if isinstance(widget, BreadcrumbWidget):
2786+
skip_count += 1
2787+
continue
2788+
item = layout.takeAt(skip_count)
27542789
if widget is not None:
27552790
widget.deleteLater()
27562791
else:

src/members/agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class Info_Fields(ConfigFields):
102102
def __init__(self, parent):
103103
super().__init__(parent=parent)
104104
self.conf_namespace = 'info'
105-
self.alignment = Qt.AlignHCenter
105+
self.field_alignment = Qt.AlignHCenter
106106
self.schema = [
107107
{
108108
'text': 'Avatar',

src/members/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ async def process_char(self, next_char):
551551
if not self.active_tag:
552552
if char == '<':
553553
self.tag_opened = True
554-
elif char == '>':
554+
elif char == '>' and self.tag_opened:
555555
self.tag_opened = False
556556
matched_role = self.match_tag(self.tag_name_buffer.lower())
557557
if matched_role:

src/members/user.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def __init__(self, parent):
3333
super().__init__(parent=parent)
3434
self.parent = parent
3535
self.conf_namespace = 'info'
36-
self.alignment = Qt.AlignHCenter
36+
self.field_alignment = Qt.AlignHCenter
3737
self.schema = [
3838
{
3939
'text': 'Avatar',

src/plugins/openinterpreter/modules/agent_plugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def __init__(self, parent):
221221
super().__init__(parent=parent)
222222
self.parent = parent
223223
self.conf_namespace = 'loop'
224-
self.alignment = Qt.AlignHCenter
224+
self.field_alignment = Qt.AlignHCenter
225225
self.schema = [
226226
{
227227
'text': 'Loop',
@@ -421,7 +421,7 @@ def __init__(self, parent):
421421
# super().__init__(parent=parent)
422422
# self.parent = parent
423423
# self.conf_namespace = 'loop'
424-
# self.alignment = Qt.AlignHCenter
424+
# self.field_alignment = Qt.AlignHCenter
425425
# self.schema = [
426426
# {
427427
# 'text': 'Loop',

src/system/workspaces.py

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)