Skip to content

Commit 1ca5545

Browse files
committed
Added start of web browser
1 parent 211a095 commit 1ca5545

10 files changed

Lines changed: 307 additions & 155 deletions

File tree

Directory.py

Whitespace-only changes.

MainWindow.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import sys
2+
3+
from PySide6.QtWidgets import QMainWindow, QApplication, QStackedWidget, QFrame, QPushButton
4+
5+
from config import save_config
6+
7+
8+
class MainWindow(QMainWindow):
9+
def __init__(self):
10+
super().__init__()
11+
12+
geometry = QApplication.primaryScreen().availableGeometry()
13+
14+
self.setGeometry(geometry.width() / 2 - 350, geometry.height() / 2 - 200, 700, 400)
15+
self.setWindowTitle("Youtube Downloader and more :)")
16+
17+
self.stack = QStackedWidget(self)
18+
self.stack.resize(self.width(), self.height())
19+
self.stack.show()
20+
21+
self.views = {}
22+
23+
self.home_view = Home(self.stack)
24+
self.views[self.home_view.name] = self.stack.count()
25+
self.stack.addWidget(self.home_view)
26+
27+
def add_view(self, view):
28+
self.views[view.name] = self.stack.count()
29+
self.stack.addWidget(view)
30+
self.home_view.add_view(view)
31+
32+
def change_view(self, view):
33+
self.stack.setCurrentIndex(self.views[view.name])
34+
35+
def home(self):
36+
self.change_view(self.home_view)
37+
38+
def closeEvent(self, event):
39+
save_config()
40+
event.accept()
41+
sys.exit(0)
42+
43+
44+
class Home(QFrame):
45+
46+
def __init__(self, parent):
47+
super().__init__()
48+
self.setObjectName('Home')
49+
self.name = 'home'
50+
self.setParent(parent)
51+
self.resize(parent.width(), parent.height())
52+
53+
def add_view(self, view):
54+
button = QPushButton(view.name)
55+
button.setParent(self)
56+
57+
def switch_view():
58+
self.parent().parent().change_view(view)
59+
60+
button.clicked.connect(switch_view)
61+
button.adjustSize()
62+
button.resize(button.width(), 35)
63+
button.move(int((self.width() - button.width()) / 2), 30 + (self.parent().count() - 2) * 45)
64+
button.show()
65+
66+
67+
class View(QFrame):
68+
def __init__(self, parent, name):
69+
super().__init__()
70+
self.setParent(parent)
71+
self.name = name
72+
73+
self.button = QPushButton('Home')
74+
self.button.setParent(self)
75+
self.button.clicked.connect(self.home)
76+
self.button.setGeometry(10, 10, 0, 0)
77+
self.button.adjustSize()
78+
self.button.show()
79+
80+
def home(self):
81+
self.parent().parent().home()

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@
22

33
## Still in development, it is working, but not perfect at all.
44
Do not hesitate to ask for features, make suggestions or pull requests. I may not answer you immediately, but it will still be useful for me and next users.
5+
6+
## Please Help
7+
8+
I am ultimately planning on putting a protection so you cannot download usupported urls.
9+
For the time, if you see any youtube url that is not working (for example `https://www.youtube.com`), please put a response to <a href='https://github.com/Laggrif/Youtube_Download/issues/1'>this issue</a> with the url and I will add them to the blacklist as soon as possible

Run.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import sys
2+
3+
from PySide6.QtWidgets import QApplication
4+
5+
from MainWindow import MainWindow, View
6+
from YTDL import YTDL
7+
8+
app = QApplication(sys.argv)
9+
10+
with open("style.qss", "r") as f:
11+
_style = f.read()
12+
app.setStyleSheet(_style)
13+
14+
window = MainWindow()
15+
window.show()
16+
17+
stack = window.stack
18+
19+
ytdl = YTDL(stack)
20+
window.add_view(ytdl)
21+
22+
Directory = View(stack, 'Directory')
23+
window.add_view(Directory)
24+
25+
sys.exit(app.exec())

0 commit comments

Comments
 (0)