Skip to content

Commit 3167603

Browse files
authored
fix: back to progress dialog
1 parent 462670f commit 3167603

2 files changed

Lines changed: 86 additions & 2 deletions

File tree

revengai/utils/periodic_check.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from threading import Timer
2+
import threading
23
from os.path import basename
34
from typing import Optional
45
from binaryninja import log_info, log_error, BinaryView
@@ -105,7 +106,7 @@ def start_ai_decompiler_checking(self, function_id: int, callback, editor: QPlai
105106
self._ai_decompiler_timer.timeout.connect(lambda: self._ai_decompiler_worker(function_id, name, callback, editor))
106107

107108
# Start the timer with 5 second intervals
108-
self._ai_decompiler_timer.start(5000) # 1000 ms = 1 second
109+
self._ai_decompiler_timer.start(30000) # 1000 ms = 1 second
109110

110111
log_info(f"RevEng.AI | Started AI decompiler periodic check for: {name}")
111112

revengai/utils/progress_dialog.py

Lines changed: 84 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,90 @@ def worker_thread():
123123

124124
if not res.get("status", False):
125125
log_info(f"RevEng.AI | AI Decompilation for function at 0x{function_id:x} failed")
126-
self.update_text_signal.emit(self._current_callback, f"AI Decompilation failed: {res.get('errors').get('message')}")
126+
self.update_text_signal.emit(self._current_callback, from PySide6.QtWidgets import QProgressDialog, QProgressBar, QPushButton
127+
from PySide6.QtCore import Qt
128+
129+
def create_progress_dialog(parent, title, message):
130+
progress = QProgressDialog(message, None, 0, 0, parent)
131+
progress.setWindowTitle(title)
132+
progress.setWindowModality(Qt.WindowModal)
133+
progress.setCancelButton(None)
134+
progress.setMinimumWidth(400)
135+
progress.setMinimumHeight(100)
136+
137+
progress_bar = progress.findChild(QProgressBar)
138+
if progress_bar:
139+
progress_bar.setMinimumWidth(250)
140+
progress_bar.setMinimumHeight(20)
141+
142+
progress.setStyleSheet("""
143+
QProgressBar {
144+
border: 1px solid #cccccc;
145+
border-radius: 4px;
146+
text-align: center;
147+
background-color: #f0f0f0;
148+
min-width: 250px;
149+
min-height: 20px;
150+
}
151+
QProgressBar::chunk {
152+
background-color: #007bff;
153+
border-radius: 3px;
154+
}
155+
""")
156+
157+
return progress
158+
159+
def create_cancellable_progress_dialog(parent, title, message, cancel_callback=None):
160+
"""Create a progress dialog with a cancel button that can stop threads"""
161+
progress = QProgressDialog(message, "Cancel", 0, 0, parent)
162+
progress.setWindowTitle(title)
163+
progress.setWindowModality(Qt.WindowModal)
164+
progress.setMinimumWidth(400)
165+
progress.setMinimumHeight(100)
166+
167+
# Style the cancel button
168+
cancel_button = progress.findChild(QPushButton)
169+
if cancel_button:
170+
cancel_button.setStyleSheet("""
171+
QPushButton {
172+
background-color: #dc3545;
173+
color: white;
174+
padding: 6px 12px;
175+
border-radius: 4px;
176+
border: none;
177+
min-width: 60px;
178+
}
179+
QPushButton:hover {
180+
background-color: #c82333;
181+
}
182+
QPushButton:pressed {
183+
background-color: #bd2130;
184+
}
185+
""")
186+
187+
cancel_button.clicked.connect(cancel_callback)
188+
189+
progress_bar = progress.findChild(QProgressBar)
190+
if progress_bar:
191+
progress_bar.setMinimumWidth(250)
192+
progress_bar.setMinimumHeight(20)
193+
194+
progress.setStyleSheet("""
195+
QProgressBar {
196+
border: 1px solid #cccccc;
197+
border-radius: 4px;
198+
text-align: center;
199+
background-color: #f0f0f0;
200+
min-width: 250px;
201+
min-height: 20px;
202+
}
203+
QProgressBar::chunk {
204+
background-color: #007bff;
205+
border-radius: 3px;
206+
}
207+
""")
208+
209+
return progress f"AI Decompilation failed: {res.get('errors').get('message')}")
127210
self.stop()
128211
return
129212

0 commit comments

Comments
 (0)