-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
68 lines (50 loc) · 2.28 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import glob
import os
import sys
from pathlib import Path
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QApplication
from qfluentwidgets import FluentIcon as FIF, MSFluentWindow
from qfluentwidgets import NavigationItemPosition
from src.config import cfg
from src.interfaces import HomeInterface, PlaylistInterface, SettingInterface, DownloadInterface
APP_LOGO = str(Path(__file__).parent / "src" / "assets" / "icons" / "logo.png")
class Window(MSFluentWindow):
def __init__(self):
super().__init__()
self._init_window()
self.download_dir = Path(__file__).parent / "src" / "assets" / "downloads"
if not os.path.exists(self.download_dir):
os.makedirs(self.download_dir)
self.home_interface = HomeInterface(self)
self.video_interface = DownloadInterface(self, 'video')
self.audio_interface = DownloadInterface(self, 'audio')
self.playlist_interface = PlaylistInterface(self)
self.settings_interface = SettingInterface(self)
self.settings_interface.mica_enable_changed.connect(self.setMicaEffectEnabled)
self.init_navigation()
def init_navigation(self):
self.addSubInterface(self.home_interface, FIF.HOME, 'Home')
self.addSubInterface(self.video_interface, FIF.VIDEO, 'Video')
self.addSubInterface(self.audio_interface, FIF.MUSIC, 'MP3')
self.addSubInterface(self.playlist_interface, FIF.MEDIA, 'Playlist')
self.addSubInterface(self.settings_interface, FIF.SETTING, 'Settings', position=NavigationItemPosition.BOTTOM)
def _init_window(self):
self.resize(1280, 720)
self.setWindowIcon(QIcon(APP_LOGO))
self.setWindowTitle('UltraFetch')
self.setMicaEffectEnabled(cfg.get(cfg.micaEnabled))
# Center window
desktop = QApplication.desktop().availableGeometry()
width, height = desktop.width(), desktop.height()
self.move(width // 2 - self.width() // 2, height // 2 - self.height() // 2)
def closeEvent(self, event):
files_to_remove = glob.glob(f'{self.download_dir}/*')
for file in files_to_remove:
os.remove(file)
event.accept()
if __name__ == '__main__':
app = QApplication(sys.argv)
window = Window()
window.show()
sys.exit(app.exec_())