1
- from app .errors .URLEmptyException import URLEmptyException
2
- from app .services .DownloadService import DownloadService
3
- from app .settings .settings import Settings
4
- from app .widgets .about import Ui_About
5
- from app .widgets .app import Ui_Dandilion
6
- from PySide6 .QtGui import QDesktopServices
7
- from PySide6 .QtCore import QThread
8
- from PySide6 .QtCore import QObject
9
- from PySide6 .QtCore import Signal
10
- from PySide6 .QtWidgets import QApplication
11
- from PySide6 .QtWidgets import QMessageBox
12
- from PySide6 .QtWidgets import QMainWindow
13
- from PySide6 .QtWidgets import QWidget
14
- from PySide6 .QtCore import QUrl
1
+ from app .handlers .URLEmptyException import URLEmptyException
2
+ from app .services .DownloadService import DownloadService
3
+ from app .settings .settings import Settings
4
+ from app .widgets .about import AboutWidget
5
+ from app .widgets .app import MainWidget
6
+
7
+ from PySide6 .QtGui import QDesktopServices
8
+ from PySide6 .QtCore import QThread
9
+ from PySide6 .QtCore import QObject
10
+ from PySide6 .QtCore import Signal
11
+ from PySide6 .QtWidgets import QApplication
12
+ from PySide6 .QtWidgets import QMessageBox
13
+ from PySide6 .QtWidgets import QMainWindow
14
+ from PySide6 .QtWidgets import QWidget
15
+ from PySide6 .QtCore import QUrl
15
16
import sys
16
17
17
- class DownloadWorker (QObject ):
18
- finished = Signal ()
19
- error_occurred = Signal (str )
18
+ # class DownloadWorker(QObject):
20
19
21
- def __init__ (self , url , path , file_type , download_service ):
22
- super ().__init__ ()
23
- self .url = url
24
- self .path = path
25
- self .file_type = file_type
26
- self .download_service = download_service
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
29
+
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()
27
37
28
- def run (self ):
29
- try :
30
- self .download_service .download (self .url , self .path , self .file_type )
31
- except Exception as e :
32
- self .error_occurred .emit (str (e ))
33
- finally :
34
- self .finished .emit ()
35
-
36
- class Application :
37
- """
38
- The Application class initializes and sets up the main application, including
39
- the main window, about window, and settings window. It also manages the download
40
- service and its associated thread.
41
- """
42
- main_widget = Ui_Dandilion ()
43
- about_widget = Ui_About ()
44
- settings_config = Settings ()
45
- def __init__ (self ):
46
- """
47
- Initializes the Application class by setting up the QApplication, main window,
48
- about window, and settings window. It also configures the application style
49
- and sets up the UI components and services.
50
- """
51
- # Injecting
52
- self .app = QApplication (sys .argv )
53
- self .main_window = QMainWindow ()
54
- self .about_window = QWidget ()
55
- self .settings_window = QWidget ()
56
- self .app .setStyle (self .settings_config .config ['theme' ])
57
- # Setting Up
58
- self .main_widget .setupUi (self .main_window )
59
- self .about_widget .setupUi (self .about_window )
60
- self .main_window .setFixedSize (836 , 324 )
61
- self .about_window .setFixedSize (400 , 125 )
62
- # Services
63
- self .download_service = DownloadService (
64
- self .main_widget .DownloadProgressBar , self .main_widget .OutputAreaBox
65
- )
66
- self .download_thread = None # Initialize as None
67
- self .set_actions ()
68
38
39
+ class ApplicationContext :
40
+
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
+
69
66
def start_download (self ):
67
+ ...
68
+
69
+
70
+
71
+
72
+
70
73
71
- if self .main_widget .UrlEntry .text () == "" :
72
- self .show_error_message ("Empty URL Warning" , "Please provide a URL." )
73
- return
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
74
116
75
- self .main_widget .OutputAreaBox .insertPlainText ("Starting download...\n " )
117
+ # self.main_widget.OutputAreaBox.insertPlainText("Starting download...\n")
76
118
77
- url = self .main_widget .UrlEntry .text ()
78
- path = self .settings_config .config ['path' ]
79
- file_type = self .main_widget .TypeComboBox .currentText ()
119
+ # url = self.main_widget.UrlEntry.text()
120
+ # path = self.settings_config.config['path']
121
+ # file_type = self.main_widget.TypeComboBox.currentText()
80
122
81
- # Create and set up worker thread
82
- self .download_thread = QThread ()
83
- self .download_worker = DownloadWorker (url , path , file_type , self .download_service )
84
- self .download_worker .moveToThread (self .download_thread )
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)
85
127
86
- # Connect signals
87
- self .download_thread .started .connect (self .download_worker .run )
88
- self .download_worker .finished .connect (self .download_thread .quit )
89
- self .download_worker .finished .connect (self .download_worker .deleteLater )
90
- self .download_thread .finished .connect (self .download_thread .deleteLater )
91
- self .download_worker .error_occurred .connect (self .show_error_message )
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)
92
134
93
- # Start the thread
94
- self .download_thread .start ()
135
+ # # Start the thread
136
+ # self.download_thread.start()
95
137
96
- def show_error_message (self , title , message ):
97
- msg = QMessageBox ()
98
- msg .critical (self .main_window , title , message )
138
+ # def show_error_message(self, title, message):
139
+ # msg = QMessageBox()
140
+ # msg.critical(self.main_window, title, message)
99
141
100
- def set_actions (self ):
101
- url = QUrl ('https://github.com/Kyle-Myre' )
102
- self .main_widget .DownloadButton .clicked .connect (self .start_download )
103
- self .main_widget .WikiButton .clicked .connect (self .about_window .show )
104
- self .main_widget .GithubButton .clicked .connect (lambda : QDesktopServices .openUrl (url ))
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))
105
147
106
- def run (self ):
107
- self .main_window .show ()
108
- sys .exit (self .app .exec ())
148
+ # def run(self):
149
+ # self.main_window.show()
150
+ # sys.exit(self.app.exec())
0 commit comments