Skip to content

Conversation

LuLuKitty1998
Copy link
Contributor

Fix UI Bugs and Improve GUI

Description/Motivation/Screenshots

This patch addresses several UI bugs and crashes in the CEmu GUI, making it more stable and user-friendly. The changes include:
Fixing multiple crashes related to the GUI.
Enhancing the overall stability of the application.
Resolving bugs specific to the Windows platform.
These changes are required to improve the user experience by providing a more stable and reliable interface. The fixes ensure that users encounter fewer crashes and bugs, especially on Windows. By enhancing the stability and usability of CEmu, this patch contributes to a smoother and more enjoyable experience for users, encouraging more people to use and contribute to the project. Screenshots showcasing the improved GUI have been added to the README.md file for reference.

Checklist

[ ] My PR was done against the main branch, not dev.
[x] My code follows the code style of this project.
[ ] My change includes a change to the documentation, if required.

- Emptied default.qss to allow system dark and light modes to apply properly.
- Ensures compatibility with Cleanlooks theme in PyQt6.
- Added .idea/ to .gitignore to prevent JetBrains IDE configuration files from being tracked.
- Helps keep the repository clean and focused on source code.
- Corrected typos in the configuration file.
- Updated default width and height values for better display of the window.
…_.py

- Added exception handling to manage cases where syscall files do not exist for specific architectures (e.g., Generic).
- Display a PyQt6 QMessageBox with the exception message to inform the user.
- Added is_dark_mode function to check if the current palette is in dark mode.
- Uses QPalette to determine if the window color value is less than 128.
- Changed column width from 60 to 80 in RegisterWidget class.
- Improves the display of register names and values in the table.
- Increased column widths to 120 for better display in MemoryMappingWidget.
- Set fixed width of MemoryMapTableWidget to 350.
- Corrected typo in permission checkbox label from 'eXecute' to 'Execute'.
- Enhanced CommandWidget to show tooltips when hovering over QPushButtons.
- Tooltips provide additional context for each button's functionality.
- Wrapped self.setup() method in try-except to handle exceptions gracefully.
- Added QMessageBox to display error messages when setup fails.
- Removed unnecessary reassignment of self.codelines in reset method to prevent crashes.
- Modified next_instruction method to return Optional, returning None when no instructions remain instead of raising an exception.
- Increased fixed width of AssemblyView from 140 to 230 for better display.
- Removed background color stylesheet for better harmony in dark mode.
- Fixed bug in update_assembly_code_pane method to correctly handle line returns on Windows by using '\n' instead of os.linesep.
…highlighter.py

- Organized imports for better readability and maintenance.
- Removed unneeded return statements at the end of None type methods.
…arious bugs in cemu/ui/main.py

- Enhanced dock widget positions for better user experience in CEmuWindow class.
- Implemented StartInFullScreen with global settings stored in ini file.
- Changed default window width and height to 800x600 instead of 1600x800.
- Fixed bug in Architecture menu for proper switching between x86 AT&T and Intel syntax in different bits (16, 32, 64).
- Fixed bug in showShortcutPopup method with incorrect string format syntax.
- Fixed crash in EmulationRunner class method run when no instructions remain.
- Add various functions for ui dark mode in cemu/ui/utils.py
- Improve syntax highlighting for ui dark mode in cemu/ui/highlighter.py
- Added new screenshots for GUI
@hugsy
Copy link
Owner

hugsy commented Jul 29, 2024

Looks epic, thanks @LuLuKitty1998 !
It looks ok at a first glance, but give me a bit of time to review in more depth

@hugsy hugsy self-requested a review July 29, 2024 19:56
@hugsy hugsy added this to the 0.8 milestone Jul 29, 2024
Copy link
Owner

@hugsy hugsy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few minor things to change but really looks good
I tried to provide suggestions to make the changes easier.

Comment on lines 86 to 90
msgbox = QMessageBox()
msgbox.setIcon(QMessageBox.Icon.Critical)
msgbox.setWindowTitle("No Syscall File Error")
msgbox.setText(str(e))
msgbox.exec()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use cemu.ui.popup to make this a bit smaller

msgbox.setWindowTitle("No Syscall File Error")
msgbox.setText(str(e))
msgbox.exec()
pass
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pass
return {}

cemu/emulator.py Outdated
Comment on lines 516 to 520
msgbox = QMessageBox()
msgbox.setIcon(QMessageBox.Icon.Critical)
msgbox.setWindowTitle("Emulator setup error")
msgbox.setText(str(e))
msgbox.exec()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can use popup here too

@@ -16,12 +16,11 @@
)

import cemu.core
from build.lib.cemu.const import DEFAULT_CODE_VIEW_FONT, DEFAULT_CODE_VIEW_FONT_SIZE
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's build.lib here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think PyCharm IDE optimized imports by mistake :) instead of import from cemu.const imported from different directory

@@ -34,30 +33,22 @@


class CodeEdit(QTextEdit):
def __init__(self, parent):
def __init__(self, parent=None):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add type hints too?

Suggested change
def __init__(self, parent=None):
def __init__(self, parent: Optional[QtWidget] = None):

cemu/ui/utils.py Outdated
return palette.color(QPalette.ColorRole.Window).value() < 128


def brighten_color(hex_color: str, percent: float):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def brighten_color(hex_color: str, percent: float):
def brighten_color(hex_color: str, percent: float) -> str:

cemu/ui/utils.py Outdated
return f'{r:02x}{g:02x}{b:02x}'


def hex_to_rgb(hex_color: str):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def hex_to_rgb(hex_color: str):
def hex_to_rgb(hex_color: str) -> tuple[int, int, int]:

cemu/ui/utils.py Outdated
return tuple(int(hex_color[i:i + 2], 16) for i in (0, 2, 4))


def is_red(hex_color: str):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def is_red(hex_color: str):
def is_red(hex_color: str) -> bool:

cemu/ui/utils.py Outdated
return r > g and r > b


def is_green(hex_color: str):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def is_green(hex_color: str):
def is_green(hex_color: str) -> bool:

cemu/ui/utils.py Outdated
return g > r and g > b


def is_blue(hex_color: str):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def is_blue(hex_color: str):
def is_blue(hex_color: str) -> bool:

@hugsy hugsy mentioned this pull request Jul 29, 2024
3 tasks
@hugsy
Copy link
Owner

hugsy commented Jul 29, 2024

FWIW the packaging system has changed making CI fail. You can ignore the CI failures

@LuLuKitty1998 LuLuKitty1998 requested a review from hugsy July 30, 2024 00:00
@hugsy hugsy merged commit 4cad30a into hugsy:main Jul 30, 2024
@hugsy
Copy link
Owner

hugsy commented Jul 30, 2024

Awesome PR, merged!
Thanks!

@LuLuKitty1998 LuLuKitty1998 deleted the fix-ui-bugs branch July 30, 2024 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants