Skip to content

Commit 7b64a28

Browse files
author
Kyle-Myre
committed
Rolling Back
1 parent 026cf54 commit 7b64a28

File tree

9 files changed

+93
-154
lines changed

9 files changed

+93
-154
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,6 @@ cython_debug/
166166
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
167167
# and can be added to the global gitignore or merged into this file. For a more nuclear
168168
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
169-
#.idea/
169+
#.idea/
170+
171+
settings.json

app/__init__.py

+26-124
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from app.handlers.URLEmptyException import URLEmptyException
22
from app.services.DownloadService import DownloadService
3-
from app.settings.settings import Settings
43
from app.widgets.about import AboutWidget
54
from app.widgets.app import MainWidget
65

@@ -13,138 +12,41 @@
1312
from PySide6.QtWidgets import QMainWindow
1413
from PySide6.QtWidgets import QWidget
1514
from PySide6.QtCore import QUrl
16-
import sys
17-
18-
# class DownloadWorker(QObject):
19-
20-
# finished = Signal()
21-
# error_occurred = Signal(str)
22-
23-
# def __init__(self, url, path, file_type, download_service):
24-
# super().__init__()
25-
# self.url = url
26-
# self.path = path
27-
# self.file_type = file_type
28-
# self.download_service = download_service
2915

30-
# def run(self):
31-
# try:
32-
# self.download_service.download(self.url, self.path, self.file_type)
33-
# except Exception as e:
34-
# self.error_occurred.emit(str(e))
35-
# finally:
36-
# self.finished.emit()
16+
import sys
3717

3818

3919
class ApplicationContext:
4020

41-
__main_widget :MainWidget
42-
__about_widget :AboutWidget
43-
__download_service :DownloadService
44-
__version_service :str
45-
46-
@property
47-
def __app(self):
48-
return QApplication(sys.argv)
49-
50-
def __init__(self , main_widget:MainWidget,about_widget:AboutWidget,download_service:DownloadService):
51-
52-
self.__main_widget = main_widget
53-
self.__about_widget = about_widget
54-
self.__download_service = download_service
55-
56-
self.__set_up()
57-
58-
def __set_up(self):
59-
# self.__app.setStyle(self.__settings_config.config['theme']);
60-
self.__main_widget.setupUi(QMainWindow().setFixedSize(836, 324));
61-
self.__about_widget.setupUi(QWidget().setFixedSize(400, 125));
62-
63-
def run(self):
64-
...
65-
66-
def start_download(self):
67-
...
68-
69-
70-
71-
72-
73-
21+
def __inject_theme(self):
22+
self.app.setStyle('Fusion')
7423

24+
def __load_about_dialog(self):
25+
self.dialog = QWidget()
26+
self.about = AboutWidget()
7527

28+
def __load_main_form(self):
29+
self.app = QApplication([])
30+
self.main_window = QMainWindow()
31+
self.ui = MainWidget()
7632

33+
def __setup_main_form(self):
34+
self.ui.setupUi(self.main_window)
7735

36+
def __setup_about_dialog(self):
37+
self.about.setupUi(self.dialog)
7838

39+
def __inject_signals(self):
40+
self.ui.WikiButton.clicked.connect(self.dialog.show())
7941

42+
def __init__(self):
43+
self.__load_main_form()
44+
self.__load_about_dialog()
45+
self.__setup_about_dialog()
46+
self.__setup_main_form()
47+
self.__inject_signals()
8048

81-
82-
83-
84-
85-
def load_config(self):
86-
...
87-
88-
# """
89-
# Initializes the Application class by setting up the QApplication, main window,
90-
# about window, and settings window. It also configures the application style
91-
# and sets up the UI components and services.
92-
# """
93-
# # Injecting
94-
# self.app = QApplication(sys.argv)
95-
# self.main_window = QMainWindow()
96-
# self.about_window = QWidget()
97-
# self.settings_window = QWidget()
98-
# self.app.setStyle(self.settings_config.config['theme'])
99-
# # Setting Up
100-
# self.main_widget.setupUi(self.main_window)
101-
# self.about_widget.setupUi(self.about_window)
102-
# self.main_window.setFixedSize(836, 324)
103-
# self.about_window.setFixedSize(400, 125)
104-
# # Services
105-
# self.download_service = DownloadService(
106-
# self.main_widget.DownloadProgressBar, self.main_widget.OutputAreaBox
107-
# )
108-
# self.download_thread = None # Initialize as None
109-
# self.set_actions()
110-
111-
# def start_download(self):
112-
113-
# if self.main_widget.UrlEntry.text() == "":
114-
# self.show_error_message("Empty URL Warning", "Please provide a URL.")
115-
# return
116-
117-
# self.main_widget.OutputAreaBox.insertPlainText("Starting download...\n")
118-
119-
# url = self.main_widget.UrlEntry.text()
120-
# path = self.settings_config.config['path']
121-
# file_type = self.main_widget.TypeComboBox.currentText()
122-
123-
# # Create and set up worker thread
124-
# self.download_thread = QThread()
125-
# self.download_worker = DownloadWorker(url, path, file_type, self.download_service)
126-
# self.download_worker.moveToThread(self.download_thread)
127-
128-
# # Connect signals
129-
# self.download_thread.started.connect(self.download_worker.run)
130-
# self.download_worker.finished.connect(self.download_thread.quit)
131-
# self.download_worker.finished.connect(self.download_worker.deleteLater)
132-
# self.download_thread.finished.connect(self.download_thread.deleteLater)
133-
# self.download_worker.error_occurred.connect(self.show_error_message)
134-
135-
# # Start the thread
136-
# self.download_thread.start()
137-
138-
# def show_error_message(self, title, message):
139-
# msg = QMessageBox()
140-
# msg.critical(self.main_window, title, message)
141-
142-
# def set_actions(self):
143-
# url = QUrl('https://github.com/Kyle-Myre')
144-
# self.main_widget.DownloadButton.clicked.connect(self.start_download)
145-
# self.main_widget.WikiButton.clicked.connect(self.about_window.show)
146-
# self.main_widget.GithubButton.clicked.connect(lambda: QDesktopServices.openUrl(url))
147-
148-
# def run(self):
149-
# self.main_window.show()
150-
# sys.exit(self.app.exec())
49+
def run(self):
50+
self.__inject_theme()
51+
self.main_window.show()
52+
sys.exit(self.app.exec())

app/app.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
from app import ApplicationContext
1+
from app import ApplicationContext
22

3-
4-
class DandilionApplication(object):
3+
class DandilionApplication():
54
"""
65
DandilionApplication is the main entry point for the Dandilion application.
76

app/services/DownloadService.py

+31-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
from PySide6.QtWidgets import QProgressBar
2-
from PySide6.QtWidgets import QPlainTextEdit
3-
from yt_dlp.utils import DownloadError
4-
from yt_dlp import YoutubeDL
1+
from PySide6.QtWidgets import QProgressBar
2+
from PySide6.QtWidgets import QPlainTextEdit
3+
4+
from yt_dlp.utils import DownloadError
5+
from yt_dlp import YoutubeDL
6+
7+
from PySide6.QtCore import QThread
8+
from PySide6.QtCore import QObject
9+
from PySide6.QtCore import Signal
510

611

712
class DownloadService(object):
@@ -48,3 +53,25 @@ def download(self , url:str , path:str , type:str):
4853

4954
except DownloadError as e:
5055
return {"error": str(e)}
56+
57+
58+
class DownloadWorker(QObject):
59+
60+
finished = Signal()
61+
error_occurred = Signal(str)
62+
63+
def __init__(self, url, path, file_type, download_service):
64+
65+
super().__init__()
66+
self.url = url
67+
self.path = path
68+
self.file_type = file_type
69+
self.download_service = download_service
70+
71+
def run(self):
72+
try:
73+
self.download_service.download(self.url, self.path, self.file_type)
74+
except Exception as e:
75+
self.error_occurred.emit(str(e))
76+
finally:
77+
self.finished.emit()

app/settings/__init__.py

Whitespace-only changes.

app/settings/settings.json

-4
This file was deleted.

app/settings/settings.py

-16
This file was deleted.

app/widgets/app.py

+3
Original file line numberDiff line numberDiff line change
@@ -268,3 +268,6 @@ def retranslateUi(self, Dandilion):
268268
)
269269

270270
# retranslateUi
271+
272+
273+

main.py

+28-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,33 @@
1+
"""
2+
This script serves as the entry point for the DandilionApplication.
3+
4+
It disables the generation of `.pyc` bytecode files for cleaner project management
5+
and initializes and runs the application.
6+
7+
Modules:
8+
sys: Provides system-specific parameters and functions.
9+
app.app: Contains the definition of the `DandilionApplication` class,
10+
which encapsulates the functionality of the application.
11+
12+
Classes:
13+
DandilionApplication: The main application class imported from `app.app`.
14+
15+
Usage:
16+
Run this script directly to start the DandilionApplication.
17+
18+
Example:
19+
python main.py
20+
"""
21+
122
import sys
23+
224
sys.dont_write_bytecode = True
25+
326
from app.app import DandilionApplication
427

5-
28+
def main():
29+
app = DandilionApplication()
30+
app.run()
31+
632
if __name__ == "__main__":
7-
app = DandilionApplication()
33+
main()

0 commit comments

Comments
 (0)