Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Make the codebase more modular and easier to read #32

Merged
merged 33 commits into from
Nov 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
a046052
[VERY WIP] refactor: Seperate UI into sep modules
kleidis Oct 14, 2024
1730516
core: Remove i`mports.py` and switch back to per-module
kleidis Oct 21, 2024
2a7c481
core: Add lazy importing module
kleidis Oct 21, 2024
bb942b1
ui: Re-add per-module imports
kleidis Oct 21, 2024
7504c3d
[VERY WIP] refactor: Use lazy importing throughout the codebase
kleidis Oct 21, 2024
5c0b676
network: Store processed JSON data in a var
kleidis Oct 22, 2024
0b95aa4
Switch to `emulator_database` and....
kleidis Oct 22, 2024
311f6e7
instances: Add `DownloadWorker` instance
kleidis Oct 22, 2024
3a25b07
Use the new instances throughout main.py
kleidis Oct 22, 2024
c0cad26
refactor: Rename the old welcome page to `act page`
kleidis Oct 23, 2024
279b4d9
instances: Always return a new instance to reset the thread
kleidis Oct 23, 2024
e68ba8d
network: Refactor the QThread into a Object
kleidis Oct 23, 2024
b938615
ui: Improve the `qt_button_click` and `qt_index_switcher` functions
kleidis Oct 23, 2024
be87daa
ui: Update pages for previous commit
kleidis Oct 23, 2024
c306d10
main: Various updates needed from the past commits
kleidis Oct 23, 2024
8f114ca
network: Move code to network folder
kleidis Oct 23, 2024
660fa9c
network: Cleanup the code
kleidis Oct 23, 2024
bade598
main: Disable git tag fetching for now
kleidis Oct 23, 2024
55733e8
ui_header: Fetch the header logo online
kleidis Oct 23, 2024
71884e5
network: Update database URL to latest git
kleidis Oct 26, 2024
ade9d8d
main / ui: Don't switch index if no emulator is selected
kleidis Oct 26, 2024
bc4bb69
refactor: Move `disable_qt_buttons_if_installed` to ui
kleidis Oct 26, 2024
4965387
refactor: Cleanup calls to the registry fetcher
kleidis Oct 26, 2024
dc6b9f1
main: Fix weird path strings and cleanup `InstallPath`
kleidis Oct 26, 2024
7422ff4
refactor: Move release fetching to `network`
kleidis Oct 26, 2024
e708f59
refactor: Cleanup various UI pages
kleidis Oct 26, 2024
8b3b829
refactor: Small cleanup to `emulator_updater`
kleidis Oct 27, 2024
3dc780e
main: Refactor zip extract and move function
kleidis Oct 30, 2024
ca9d8a7
Always check for registry changes and create_reg on install finish
kleidis Nov 3, 2024
76e2fe8
Always replace files in `move_files`
kleidis Nov 3, 2024
657a34d
main: Cleanup and refactor `Prepare_Download` into 2 files
kleidis Nov 3, 2024
31996d9
refactor: Code cleanup
kleidis Nov 3, 2024
99bb326
Fix CI
kleidis Nov 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ jobs:
- name: Build
shell: bash
run: |
pyinstaller --clean --onefile --icon=icon.ico --add-data "icon.ico;." --windowed main.py
pyinstaller --clean --onefile --icon=icon.ico --windowed init_troppical.py
pyinstaller --clean --onefile --icon=icons/assets/troppical.ico --add-data "icons/assets/troppical.ico;." --windowed main.py
env:
GITHUB_TOKEN: ${{ secrets.BUILD }}

Expand Down
103 changes: 103 additions & 0 deletions init_instances.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Lazy initialization using properties
class inst:
_main = None #main.py
_online = None #network_functions.py
_download = None #network_functions.py
_ui = None #ui_main.py
_secondary_thread = None #ui_main.py
_header = None #header.py
_wel = None #welcome.py
_sel = None #selection_page.py
_act = None #act_page.py
_install = None #install_page.py
_bar = None #progress_bar.py
_finish = None #finish_page.py

@property
def main(self):
if self._main is None:
from main import Main # Import Main only when needed
self._main = Main()
return self._main

@property
def online(self):
if self._online is None:
from network.network_functions import Online # Import Online from network_functions
self._online = Online()
return self._online

@property
def download(self):
from network.network_functions import DownloadWorker
return DownloadWorker() # Always return a new instance to reset the thread

@property
def ui(self):
if self._ui is None:
from ui.ui_main import MainWindow # Import MainWindow only when needed
self._ui = MainWindow()
return self._ui

@property
def secondary_thread(self):
if self._secondary_thread is None:
from ui.ui_main import Worker # Import Worker only when needed
self._secondary_thread = Worker()
return self._secondary_thread

@property
def header(self):
if self._header is None:
from ui.header import Header # Import Header only when needed
self._header = Header()
return self._header

@property
def wel(self):
if self._wel is None:
from ui.welcome_page import WelcomePage # Import WelcomePage only when needed
self._wel = WelcomePage()
return self._wel

@property
def sel(self):
if self._sel is None:
from ui.selection_page import SelectionPage # Import SelectionPage only when needed
self._sel = SelectionPage()
return self._sel

@property
def act(self):
if self._act is None:
from ui.act_page import ActPage # Import WelcomePage only when needed
self._act = ActPage()
return self._act

@property
def install(self):
if self._install is None:
from ui.install_page import InstallPage # Import InstallPage only when needed
self._install = InstallPage()
return self._install

@property
def bar(self):
if self._bar is None:
from ui.progress_bar import ProgressBarPage # Import ProgressBarPage only when needed
self._bar = ProgressBarPage()
return self._bar

@property
def finish(self):
if self._finish is None:
from ui.finish_page import FinishPage # Import FinishPage only when needed
self._finish = FinishPage()
return self._finish

inst = inst()





70 changes: 0 additions & 70 deletions init_troppical.py

This file was deleted.

Loading
Loading