Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 69365f4

Browse files
committedJan 17, 2025·
Reverting to commit 789fcf4
1 parent 7b64a28 commit 69365f4

File tree

9 files changed

+154
-93
lines changed

9 files changed

+154
-93
lines changed
 

‎.gitignore

+1-3
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,4 @@ 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/
170-
171-
settings.json
169+
#.idea/

‎app/__init__.py

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

@@ -12,41 +13,138 @@
1213
from PySide6.QtWidgets import QMainWindow
1314
from PySide6.QtWidgets import QWidget
1415
from PySide6.QtCore import QUrl
15-
1616
import sys
1717

18+
# class DownloadWorker(QObject):
1819

19-
class ApplicationContext:
20+
# finished = Signal()
21+
# error_occurred = Signal(str)
2022

21-
def __inject_theme(self):
22-
self.app.setStyle('Fusion')
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
2329

24-
def __load_about_dialog(self):
25-
self.dialog = QWidget()
26-
self.about = AboutWidget()
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()
2737

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

33-
def __setup_main_form(self):
34-
self.ui.setupUi(self.main_window)
39+
class ApplicationContext:
3540

36-
def __setup_about_dialog(self):
37-
self.about.setupUi(self.dialog)
41+
__main_widget :MainWidget
42+
__about_widget :AboutWidget
43+
__download_service :DownloadService
44+
__version_service :str
3845

39-
def __inject_signals(self):
40-
self.ui.WikiButton.clicked.connect(self.dialog.show())
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):
4151

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()
52+
self.__main_widget = main_widget
53+
self.__about_widget = about_widget
54+
self.__download_service = download_service
55+
56+
self.__set_up()
4857

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+
4963
def run(self):
50-
self.__inject_theme()
51-
self.main_window.show()
52-
sys.exit(self.app.exec())
64+
...
65+
66+
def start_download(self):
67+
...
68+
69+
70+
71+
72+
73+
74+
75+
76+
77+
78+
79+
80+
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())

‎app/app.py

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

3-
class DandilionApplication():
3+
4+
class DandilionApplication(object):
45
"""
56
DandilionApplication is the main entry point for the Dandilion application.
67

‎app/services/DownloadService.py

+4-31
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
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
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
105

116

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

5449
except DownloadError as e:
5550
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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"path": "C:\\Users\\simoa\\Downloads",
3+
"theme": "Fusion"
4+
}

‎app/settings/settings.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from pathlib import Path
2+
import json
3+
import os
4+
5+
6+
__DIRNAME__ = os.path.join(os.path.dirname(__file__), "settings.json")
7+
8+
9+
class Settings:
10+
def __init__(self):
11+
with open(__DIRNAME__) as file:
12+
self.config:dict = json.load(file)
13+
if self.config["path"] == None:
14+
self.config["path"] = str(Path.home() / "Downloads")
15+
with open(__DIRNAME__, "w") as file:
16+
json.dump(self.config, file, indent=4)

‎app/widgets/app.py

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

270270
# retranslateUi
271-
272-
273-

‎main.py

+2-28
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,7 @@
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-
221
import sys
23-
242
sys.dont_write_bytecode = True
25-
263
from app.app import DandilionApplication
274

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

0 commit comments

Comments
 (0)
Please sign in to comment.