Skip to content

Commit

Permalink
Add a new gui popup API
Browse files Browse the repository at this point in the history
  • Loading branch information
mahaloz committed Sep 27, 2024
1 parent de997ea commit 0647570
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion libbs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "1.25.1"
__version__ = "1.26.0"


import logging
Expand Down
8 changes: 8 additions & 0 deletions libbs/api/decompiler_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,14 @@ def gui_ask_for_choice(self, question: str, choices: list, title="Plugin Questio
from libbs.ui.utils import gui_ask_for_choice
return gui_ask_for_choice(question, choices, title=title)

def gui_popup_text(self, text: str, title: str = "Plugin Message") -> bool:
"""
Opens a GUI dialog box that displays a message. If not overriden by the decompiler interface,
this will default to a Qt dialog box that is based on the decompilers Qt version.
"""
from libbs.ui.utils import gui_popup_text
return gui_popup_text(text, title=title)

#
# Override Mandatory API
#
Expand Down
15 changes: 14 additions & 1 deletion libbs/ui/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,23 @@

from .qt_objects import (
QDialog, QVBoxLayout, QProgressBar, QLabel, QPushButton, Qt, QThread, QApplication, Signal, QLineEdit,
QComboBox, QFontMetrics
QComboBox, QFontMetrics, QMessageBox
)


def gui_popup_text(text, title="Plugin Info") -> bool:
message_box = QMessageBox()
message_box.setIcon(QMessageBox.Information)
message_box.setWindowTitle(title)
message_box.setText(text)
message_box.setStandardButtons(QMessageBox.Ok)

if message_box.exec() == QMessageBox.Ok:
return True
else:
return False


def gui_ask_for_string(question, title="Plugin Question") -> str:
dialog = QDialog()
dialog.setWindowTitle(title)
Expand Down

0 comments on commit 0647570

Please sign in to comment.